Technical information
Programming - Advanced Topics
116
RMS Enterprise - NetLinx Programmer’s Guide
This event subscription and event notification callback method indicates when the RMS client connection state changes:
#DEFINE INCLUDE_RMS_EVENT_CLIENT_STATE_CHANGE_CALLBACK
DEFINE_FUNCTION RmsEventClientStateChanged(CHAR oldState[],
CHAR newState[])
{
}
Proxy Custom Commands Through RMS
The RMS NetLinx virtual device interface supports a special command syntax for NetLinx programmers to implement their own
custom messaging. The vdvRms device is already defined in all RMS asset monitoring modules and the main program. If you find
a need to be able to send custom messages throughout the system, you can do this using the RMS command proxy syntax.
Basically, any Send Command that starts with the '@' character is considered a proxy command, and the RMS virtual device will
relay this command back out on the virtual device interface.
// PROXY CUSTOM COMMAND THRU RMS VIRUTAL DEVICE
SEND_COMMAND vdvRMS, '@MYCUSTOMHEADER-MyCustomField1,MyCustomField2'
The RmsApi.axi Include File also contains a wrapper function to facilitate these custom commands. If using this function, there is
no need to include the '@' starting character, the function will automatically affix this to the start of the header command.
// PROXY CUSTOM COMMAND THRU RMS VIRUTAL DEVICE
RmsProxyCustomCommand ('MYCUSTOMHEADER','MyCustomData');
This custom command can then be intercepted/received by any DATA_EVENT listener of the vdvRMS virtual device.
// LISTEN FOR CUSTOM PROXIED MESSAGE ON THE RMS VIRUTAL DEVICE
DATA_EVENT[vdvRMS]
{
COMMAND:
{
STACK_VAR CHAR rmsHeader[RMS_MAX_HDR_LEN];
IF(LEFT_STRING(rmsHeader,1) == '@')
{
// IMPLEMENT CUSTOM MESSAGE HANDLER HERE
}
}
}
Custom proxy command handling is also supported by the RMS Event Notification system implemented in the
RmsEventListener.axi Include File.
Include the following compiler directive to subscribe for the event notification callback and implement the callback method to
handle the custom command:
// SUBSCRIBE TO CUSTOM USER PROXY COMMANDS
#DEFINE INCLUDE_RMS_EVENT_CUSTOM_COMMAND_CALLBACK
// CALLBACK METHOD FOR USER PROXY COMMANDS
DEFINE_FUNCTION RmsEventCustomCommand(CHAR header[], CHAR data[])
{
// IMPLEMENT CUSTOM MESSAGE HANDLING LOGIC HERE
}