Device Driver Model

Index | Measurement Control Cycles | Measurement System Wizard

Device drivers are software components that control particular measurement instruments. To be used with Measurement System Wizard tool, device driver must support special programming interfaces - IDMDevice and IDMDeviceEvents. Although these interfaces may be exposed to the hosting HTML document by custom ActiveX controls, typically they are created at runtime by special Dynamic HTML (DHTML) elements, so-called Scriptlet controls.

In fact, Scriptlet control is a HTML page that you can use as a control in any application that supports controls. The scriptlet is a complete Web-ready *.htm file, but unlike usual frames, it includes information that allows you to work with it as a control - you can get and set its properties, call its methods, and so on. Scriptlet container is defined as follows:

<object id="Device0" type="text/x-scriptlet" width="100%">
   <param name="url" value="keithley2182advanced.htm">

As soon as script procedures embedded into HTML page assigned to URL parameter are properly declared, you can invoke them by standard <object>.<member> notation:

sub InitializeDevices
end sub

IDMDevice and IDMDeviceEvents interface members

property InternalTrigger
Measurement instrument drivers can support two modes: automatic or manual trigger. Usually this property reflects appropriate device mode. It controls how device driver will respond to the Trigger command (see below).

property Text
This property can be assigned to send command to the device. Standard scan control commands are "SCANSTEPUP" and "SCANSTEPDOWN". Commutator states or other device control commands have no fixed format.

When you read this property, typically measurement readout value (or another information) is returned. For multichannel devices, several numbers in string should be separated by spaces.

property IsActive
You read this property to determine whether device is connected and working (inactive device must block all hardware operations). Typically you will set IsActive property to open or close device port connection.

property Port
Hardware port number (if required). Port is COM port number, HPIB bus address or something like this. You should initialize port before set IsActive=true.

method Trigger
Triggers measurement cycle. Notice: if InternalTrigger=true, Trigger method must immediately invoke OnData event! Otherwise, it must trigger hardware so that OnData event fired as soon as device actually return the readout.

method Clear
Initializes device (typically with HPIB interface).

method LoadConfig
This method should be internally invoked from window_onload if HTML page is NOT loaded into scriptlet. Typically device driver has two modes: if loaded as regular HTML page, it should display configuration controls and allow users to configure hardware. When loaded into scriptlet control, this method invoked externally to read previously saved configuration information.

Notice: if your device may have several instances, you should use port number to select appropriate configuration for each port, and reload configuration when port number is changed.

method SaveConfig
This method should be internally invoked from window_onunload (if this page is NOT loaded into scriptlet container) to remember device settings.

Notice: if your device may have several instances, you should use port number to save different configuration for each port.

event OnData
This event has no parameters. It is used to obtain data from the device asynchronously. Keep in mind that typical delays between Trigger call and the moment when instrument has finished operations may be in the second range, while your application must remain interactive for all that time.

How to use HTML Wizard to create device drivers?

With HTML Wizard tool in the Script Editor, you can easily create device driver template or even ready-to-use device driver! Click Help|Wizards|HTML Wizard menu item, then select HTML Device Driver in the application type combo box. You will be prompted to enter driver details as shown at the screenshot:

HTML Wizard - device driver details

Driver ID is a unique identifier used to store driver configuration in the Windows registry. Driver panel height must be sufficient to display all UI controls you plan to use (both these parameters may be changed later).

WARNING: Although DMRegistry object used for registry access was made as safe as possible, incorrect operation with Windows registry may cause serious problems that may require you to reinstall your operating system! You can use INI files to store configuration information instead of registry keys.

If you check "Run Data Acquisition Wizard" as shown at the screenshot, this wizard will be launched when you click OK button. With Data Acquisition Wizard tool, you can quickly create working device driver for measurement instrument with RS-232 interface. Otherwise HTML Wizard will generate device driver template and place it into the Script Editor.