Support for the Rulbus Device Library (DLL)
[User Manual]

Defining the Modules

In the Rulbus Device Library (RDL) DLL, Rulbus device objects are handled a bit differently from the devices in the Rulbus Device Class Library (RDCL).

Reasons for this are:

To meet these requirements, the Rulbus device objects are created from a description in a configuration file and are accessed via a handle (number).

Here is a small Rulbus device configuration file.

# rulbus-small.conf - example rulbus device configuration file.

rack "top"
{
    address = 0

    rb8509_adc12 "adc"
    rb8510_dac12 "dac-ch0" { address = 0xD0 }
    rb8510_dac12 "dac-ch1" { address = 0xD2; bipolar = false; volt_per_bit = 1.25m }
}

rack "bottom"
{
   address = 1

   // still empty
}

And here is a longer configuration file.

The configuration file defines racks that contain modules (cards). Besides card declarations, a rack declaration usually contains an address specification (See secondary address).

Card Declarations

The card declarations specify the type of the card and the name by which it is referenced from the program. All card types can specify the address property and several card types can specify other properties, like bipolar for card type rb8510_dac12. The available properties and their default values are given in the section Default configuration in the Rulbus Device Library Reference manual for the various card types.

Note 1. The Rulbus Interface cannot be specified in the Rulbus device configuration file. The rationale behind this is, that the Rulbus Interface is related to the computer, whereas the items in the Rulbus device configuration file are related to the application. When a PC is replaced by another one, the application and the Rulbus device configuration file should move to the new computer, but not the Rulbus Interface specification.

Note 2. Because of the way DLLs use memory, the following applies:

Which Configuration File

The path of the configuration file to read is determined as follows:

  1. contents of environment variable RULBUS_CONFIG_FILE, or
  2. file .\rulbus.conf (current directory), or
  3. file C:\etc\rulbus.conf

You can set the environment variable RULBUS_CONFIG_FILE in a command shell temporarily as follows (see also Setrulbus Utility):

Device List

To make it possible to access Rulbus device objects that live in the Rulbus Device Library DLL from an application, a handle (number) is used in application software to refer to the actual device object.

The handle--device object relation is maintained by a list: TheRulbusDeviceList. An application obtains the handle to a device by opening the device by its name as given in the Rulbus configuration file.

The Rulbus device objects are accessed via the list in such a way, that they are protected from simultaneous access from different threads or processes (see RulbusDeviceProxy).

Example

The following code excerpts give an example of how DLL interface functions would use the classes from the Rulbus Device Class Library (RDCL).

// DLL

using namespace Rulbus;

int open_card( const char* name )
{
   return TheRulbusDeviceList::instance().open( name );
}

void close_card( handle )
{
   TheRulbusDeviceList::instance().close( handle );
}

int setVoltage( int handle, double voltage )
{
   to_rb8510( TheRulbusDeviceList::instance().get( handle ) ).setVoltage( voltage );
}

Functions open_card(), close_card() and setVoltage() are functions that are exported by the DLL.

// application

int main()
{
   int handle = open_card( "dac-ch0" );

   setVoltage( handle, 1.25 );

   close_card( handle );
}

It is assumed that the Rulbus devices are created and put on the list when the DLL is loaded (see RulbusDeviceFactory).

previous top next


Generated on Tue Oct 12 14:12:01 2004 for Rulbus Device Class Library for Microsoft Windows by doxygen 1.3.4