ActiveX Interface
COM Registration
The EpicsCAServer.exe and EpicsCAClient.exe programs are "AxtiveX Automation Servers". They are self-registering when run with the "-RegServer" option. The supplied register.bat files do this for Win98, NT, Win2000.To check the registration,
- run the "regedit" program. Under HKEY_CLASSES_ROOT you should find "EpicsCAServer.ProcessVariable" and "EpicsCAClient.ProcessVariable".
- Check e.g. the "EpicsCAServer.ProcessVariable/CLSID", it looks like "{5F190F33-E77D-11D2-8F1D-00105AC8D47C}".
- Browse to HKEY_CLASSES_ROOT/CLSID/{5F190F33-E77D-11D2-8F1D-00105AC8D47C}. Under there, you should find an entry for "LocalServer32" that points to the location of the executable EpicsCAServer.exe.
Usage
The syntax varies, but most Win32 programming languages have some means of connecting to an ActiveX automation server by name.
In Visual Basic, you useSet PV = CreateObject("EpicsCAServer.ProcessVariable")As a result, the Win32 operating system will locate the ActiveX Automation Server for this object ("COM Class") by looking at the registry, very similar to what's described in the previous section. Win32 will run that application and create a ProcessVariable in there.
This example, where the string for the object name is passed, is called late binding.
Alternatively, many languages allow you to create a "Reference" to the EpicsCAServer.ProcessVariable. You can then directly call "New" on this type, the compiled code will use the CLSID and directly access methods and properties vai their numerical codes/offsets instead of querying by name.
LabVIEW has an "Automation Open" VI. When clicking on this, you can select the EpicsCAServer/Client ProcessVariable. After wiring the result to the invoke or property nodes, you can select the method to invoke or property to change.
For Visual Basic, you can view the methods and properties on the Object Browser after establishing a reference.
Read the ActiveX section of the manual for your program to learn more.EpicsCAServer.ProcessVariable
You should use your programming tools' object browser to see what methods and properties are actually accessible. In general, the result should be similar to this:
- String name
You have to set this to define the name of the PV to serve.- SetValue(Variant new_value)
You have to call this at least once to define the value
and type of the PV.
Now the PV should be visible to CA clients.- String enum_string(Long index)
If you set enumeration strings 0...N, those will be visible to clients, i.e. they can choose to display a value of "1" by showing the enum_string[1]. This is useful for boolean types (set strings 0 and 1) or status values ("Idle", "Running", "Stuck").- SetEnumValue(Long new_value)
If you set enumeration strings, you might prefer this to the SetValue call. Difference: SetEnumValue will generate an error message if new_value is outside of 0..N, the range of available enum_strings.- Double deadband
Clients that subscribe to this PV will only be notified when the value changes beyond the deadband value. Per default, deadband is zero, so all changes are sent to clients.- String units, Long precision, Double low_warning, Double high_warning, ...
You can set those to define the usual PV properties that clients might use to display the PV.- Event Changed(Variant value_received)
When a CA client writes to the PV, EpicsCAServer will send this ActiveX event to your program.
It is your responsibility to catch the event, check the value and if you like it, call SetValue.
Example: You control a device with positions 0..10 and serve this as "XYPosition". When someone writes "2" to "XYPosition", you move to 2 and call SetValue(2). If, on the other hand, someone writes "11", you will move to 10 and call SetValue(10) because the device can't go further. Alternatively, you might do nothing at all because of the faulty input. It's up to you.EpicsCAClient.ProcessVariable
Again, check your programming tools' object browser.
- String name
You have to set this. EpicsCAClient will now try to connect to the PV.- Long is_connected
0 if not connected, 1 if connected. The value's properties are undefined if the PV is not connected.- Variant Value
Most recent value of the PV.- String units, ...
Other properties of the PV. The list of available properties might grow with further releases of this software.- Event NewValue(Long is_connected, Variant value)
Since CA is a network protocol, you have to wait for the initial connection. After that, the connection to the PV might go away and come up again. And you might not want to poll for new values but prefer to get notification whenever the value changes.
This ActiveX event does all that: It is emitted with is_connected=1 whenever the connection comes up or a new value arrives. When the connection goes away, is_connected is 0 and the value is invalid.