View Single Post
  #1  
Old 07-08-2003, 10:42 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Creating a Vizard Sensor Plugin

If you want to connect to a hardware device within your Vizard script you need to use a Sensor Plugin. Vizard already comes with Sensor Plugins for popular hardware devices, but you can easily make one for your own hardware device. You must know C/C++ programming in order to create one. Here are the basic steps:

Step 1:

Download sensor.zip to your computer and unzip it.

Step 2:

Open the project files. If you don't have Visual Studio then create a Win32 DLL project and add the files main.cxx and sensors.h to it. Fill in the functions outlined in main.cxx. When you compile your program make sure the extension for your dll is .dls. Put your new plugin in the [VIZARD_PATH]/plug-ins directory, where [VIZARD_PATH] is the location of your Vizard installation.

Step 3:

To use the plugin within you Vizard script it would look something like this, assuming the name of your plugin is mysensor.dls:

Code:
import viz

viz.go()

mysensor = viz.add('mysensor.dls')
When you want to reset your sensor you would perform the following command:

Code:
mysensor.reset()
When you want to retrieve data from your sensor you would perform the following command:

Code:
data = mysensor.get()
If you would like to send a command to your sensor then performing the following command:

Code:
mysensor.command(1,'some string',1.2,3.4,5.6)

That's it, you should now have your own working Sensor Plugin for Vizard. If you would like to share your plugin with other users then read the post Sharing Files on SourceForge.

Have fun!
Reply With Quote