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

CDP Studio

Software development tool for distributed control systems

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Protocols - ExternalControl I/O
  • Additional ExternalControlBroker Setup Guides
  • 4.10.7

SMTP Setup Guide Troubleshooting ExternalControl I/O Request Setup

Additional ExternalControlBroker Setup Guides

Additional ExternalControlBroker Setup Guides

Below are 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)

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 with:

  • 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 into it for the query result
  • Set ResponseTranslator to JSONTranslator
  • For test setup simplicity, set TLSAllowVerificationErrors property to AllowAnyCertificate.
  • 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 ResponseSignalChannel 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)
  • Set TLSAllowVerificationErrors property to AllowAnyCertificate.

Note: Never set AllowAnyCertificate in production setups! You should always download REST server CA certificate and set its file name in TLSCaCertFile property.

Log signal values to some text file at 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 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:0:50 DS:signal2: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: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 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 that example, like this:
    • Add HTTPRequest with URL="https://api.twilio.com/2010-04-01/Accounts/XXX/Messages.json", Method=POST
    • Set UserPwd="XXX:TTT" (userid:authtoken)
    • Set AuthMethod="Basic"
    • Add 2 uint64_t RequestSignalChannels named To and From and set with phone numbers required

      Note: No plus signs need 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
    • For test setup simplicity, set TLSAllowVerificationErrors property to AllowAnyCertificate.

      Note: Never set AllowAnyCertificate in production setups! You should always download REST server CA certificate and set its file name in TLSCaCertFile property.

SMTP Setup Guide Troubleshooting ExternalControl I/O Request Setup

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

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

Follow CDP

    © Copyright 2021 CDP Technologies. Privacy and cookie policy.

    Return to top