Additional ExternalControlBroker Setup Guides
Additional ExternalControlBroker Setup Guides
Below are a few more examples of different usage scenarios of ExternalControlBroker requests in CDP Studio, the independent automation software for open PC-based real-time distributed control systems. These examples are described briefly to give you ideas on how ExternalControlBroker requests can be used and configured.
Regularly Check Network Or Sensor Bus Connectivity And Run Command On Failure
For that use the following guidelines:
- Create LocalCommandRun named TestPING with TriggerOnTimeout=300 (for every 5 minutes) to run CommandLine="ping [LINUX:-c:][WINDOWS:-n:] 3 ipaddress"
- Create another LocalCommandRun with TriggerRouting="App.Comp.TestPING.LastReturnCode" so the command will be launched when App.Comp.TestPING.LastReturnCode changes from 0 (ping OK) to 1 (ping fails) to run some actions (fe. remote device reset)
Log Signal Values to Some Text File Every 30 Minutes
For that use the following guidelines:
- Create LocalCommandRun with CommandLine="[LINUX:cat:][WINDOWS:more:] >> signal-log.txt"
- Optionally, set WorkingDirectory to point to the folder you want the log file to be created into
- Add RequestSignalChannel with Routing to your actual signal to log
- Set TriggerOnChange=false, TriggerOnTimeout=1800
Get Initial Configuration Values From JSON Configuration File on System Startup
For that use the following guidelines:
- Add FILERequest with URL="configuration.json", Method=GET
- Add ResponseChannels with names that match JSON tag names in your configuration file
- Set ResponseTranslator to JSONTranslator
Get UPS Status From Linux (f.e. Using UPSC Service)
For that use the following guidelines:
- Add LocalCommandRun with CommandLine="upsc myups ups.status 2>/dev/null"
- Add ResponseSignalChannel<short> named UPSStatus for UPS status
- Add three ValueMap<short> for ups.status output to be translated into signal short value, for example:
- StreamValue="OL" -> ChannelValue=0 (for UPS on-line status)
- StreamValue="OB" -> ChannelValue=1 (for UPS on-battery status)
- StreamValue="LB" -> ChannelValue=-1 (for UPS low-battery status)
- add some actions based on this UPSStatus signal changing (f.e. by triggering alarm using AlarmOperator)
Start Some Background Task Always at CDP Application Start, That Is Closed Automatically on Application Stop
For that use the following guidelines:
- Add LocalCommandRun with required background task set in CommandLine
- Set ResponseWaitTimeout=0
Create Signal Database Using RRD (Round Robin Database)
For that use the following guidelines:
- Create LocalCommandRun with CommandLine like
rrdtool create signals.rrd --step 300 DS:signal1:GAUGE:600:-50:50 DS:signal2:GAUGE:600:-50:50 RRA:MAX:0.5:1:288
for creating the database on CDP start (the command does nothing if the database already exists)
- Create another LocalCommandRun with CommandLine
rrdtool update signals.rrd N:%d:%d
for updating 2 values into the database from the 2 ReguestSignalChannels added and routed from the signals you need to log
- Optionally, for regular graph image (re)generation to be invoked by CDP, add another LocalComandRun with CommandLine like
rrdtool graph output.png -w 400 -h 120 -a PNG --start -604800 --end now DEF:signal1=signals.rrd:signal1:MAX DEF:signal2=signals.rrd:signal2:MAX LINE1:signal1#ff0000:"Signal 1" LINE1:signal2#0000ff:"Signal 2"
and set TriggerOnTimout to the graph update frequency needed
Note: Consult RRDTool manual for further information how to set up and use RRD databases and graphs.
Send Alarm Notifications to Mobile Device
You can send alarm notifications to the mobile device using some appropriate service provider, for example Pushover, like that:
- Create free (or paid) account on Pushover to get the User Key and the Application API Token/Key from it
- Create a notification HTTPRequest, like this:
- Add an HTTPRequest having URL="https://api.pushover.net/1/messages.json" and Method=POST
- Add 3 RequestSignalChannel<string> channels named user, token and message. Set user channel value to be User Key and token channel value to be Application API Token/Key
- Add a WWWURLEncodeTranslator<ostream> to form key-value pairs for POST request from these channels
- Configure also the message channel value, either to be static/same message all the time or by routing its value from some other component of the system
- Configure appropriate HTTPRequest send triggering (for example using TriggerOnRouting set on some alarm signal)
- On every HTTPRequest triggered the notification with the message will be sent to the mobile device
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.