• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

Blog

Collection of small examples of ExternalControl IO server

external_control_io_server

The External Control IO server has very powerful and flexible functionality. Here are some examples; Check connectivity and run commands on failure, get weather forecast, log to text file, get JSON values, get UPS status, run background tasks, create RRD and send SMS.

Regularily check network or sensor bus connectivity and run command on failure

To do this use the following guidelines:

  • Create LocalCommandRun named TestPING with TriggerOnTimeout=300 (for every 5 minutes) to run CommandLine=”ping -c 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)

Get weather information (temperature forecast)

You can get, for example, todays forecast for minimum, maximum and average temperatures for Oslo from MetaWeather free REST service into signals as follows:

  • Create HTTPRequest named CityIdQuery with URL=”https://www.metaweather.com/api/location /search/?query=oslo”, Method=GET 
  • Add 1 ResponseChannelGroup named 0 (for marking JSON result array)
  • Add 1 unsigned ResponseSignalChannel named woeid for the query result
  • Set ResponseTranslator to JSONTranslator
  • Create another HTTPRequest named WeatherQuery with URL=”https://www.metaweather.com /api/location/%d/”, Method=GET
  • Add 1 unsigned RequestSignalChannel and set Routing=”App.Comp.CityIdQuery.0.woeid”
  • Add 3 double ResponseSignalChannels named MinTemp, MaxTemp, AvgTemp for the result to be parsed into
  • Set ResponseTranslator to RegexTranslator with Pattern=””min_temp”:(.*),”max_temp”: (.*),”the_temp”:(.*)”. Note that sometimes it is easier to parse JSON with RegexTranslator (than JSONTranslator plus setting up corresponding JSON result channel tree)

​Log signal values to some text file at every 30 minutes

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

Use 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)​

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

Use the following guidelines:

  • Add LocalCommandRun with required background task set in CommandLine
  • Set ResponseWaitTimeout=0

​Create signal database using RRD (Round Robin Database)

Use the following guidelines:

  • Create LocalCommandRun with CommandLine like
    rrdtool create signals.rrd –step 300 DS:signal1:GAUGE:600:0:50 DS:signal1:GAUGE:600:0:50 RRA:MAX:0.5:1:288
    for creating database on CDP start (command does nothing if the database already exists)
  • Create another LocalCommandRun with CommandLine
    rrdtool update signals.rrd N:%d:%d 
    for updating values in database and also add corresponding ReguestSignalChannels 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:temp1: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 out alarm SMS-s 

You can send out SMS-s using some SMS gateway service, for example Twilio, like that:  

  • Create free (or paid) account on Twilio to get API access keys  
  • Then, go to address https://www.twilio.com/console/sms/getting-started/build and test you can send SMS from Twilio web interface  
  • From that web interface you can also find curl SMS sending command example, like that:  
    curl ‘https://api.twilio.com/2010-04-01/Accounts/userid/Messages.json’ -X POST \ 
    –data-urlencode ‘To=+555555555’ \  
    –data-urlencode ‘From=+555666666’ \  
    –data-urlencode ‘Body=0’ \  
    -u userid:authtoken 

You can easily create HTTPRequest based on this example:  

  • Add HTTPRequest with URL=”https://api.twilio.com/2010-04-01/Accounts /XXX/Messages.json”, Method=POST  
  • Set UserPwd=”XXX:TTT”  
  • Set AuthMethod=”Basic”  
  • Add 2 uint64_t RequestSignalChannels named To and From and set which phone numbers are required  
    Note: No plus signs needs to be at the beginning (f.e. instead of +55 5555555 you set signal value to 555555555)  
  • Add body RequestSignalChannel named Body and set Routing to the actual signal you want to be sent out  
  • Optionally set some ValueMap to map specific signal values to some strings in Body
Technical

Get CDP Studio

Download and get started with CDP Studio today.
All our plans includes a free 30 day trial.

Try CDP Studio now

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top