Daqconnect Button For Remote Control


tigerlibin

Recommended Posts

Hi,

 

In my application, I had already done to use a button to stop my motor in DAQFactory when it is clicked. Now, I would like to control that button remotely using DAQConnect. I can now use DAQConnect to monitor my variable. Can any one help how can I control my button in DAQFactory by using DAQConnect.

 

Thanks in advance!

 

Ben

Link to comment
Share on other sites

This is described in the DAQConnect help under "Using -> Control Capability" and then in the specific section on DAQFactory, "Remote Connectors -> DAQFactory".  To make it easy, here it is again:

 

IMPORTANT NOTE: the architecture of our system keeps your SCADA system secure by having data push out the SCADA system so that the SCADA system can remain securely behind firewalls.  Once you add control capability, you are opening up the SCADA system to possible hackers, though the only things they'd have access to are things you have control capability enabled for.  For this reason, you should only enable control capability on items where random settings will not cause any injury or property damage.  This can be done reasonably effectively by adding constraints in the SCADA system and of course the proper hardware safety systems.  However, when designing a system with control capability, you should always assume that someone with malicious intent may get access and send random values to your keys.  Our system is secure, however, the weakest link is you, your users and your passwords.  Even the most secure password can be compromised by a key capture device on a public terminal, or a virus on your system.  The best defense is to assume the worse and keep the mission critical items on local control only.

In addition to viewing data arriving from your data sources, you can send commands back to the data source to control outputs, acknowledge alarms, or whatever else you may setup.  The capabilities are largely determined by the data source itself.  The application sends this commands with a simple line of script, typically placed in the Click event of a control:

system.sendCommand("dataSource.key","value")

 

dataSource.key is the name of the parameter / command you want to send to the data source.  The dataSource portion should be the name of the data source to receive the command.  The key is any name.  It could be a tag name if you are controlling an output tag, or it could be the name of an alarm to acknowledge, or anything else.  Our application doesn't do anything with it other than pass it to the data source, so its up to the data source to interpret the key.

value is the value to go along with the command.  So, it could be the value to set the output channel to, or anything else.

NOTE: the dataSource.key pair MUST always be in quotes.   The value can be in quotes, or if you are just sending a number, it can also be without quotes.  For advanced users, you can of course use string variables instead of these string constants.

 

DAQFactory:

DAQConnect can also send commands back to your DAQFactory application.  To ensure that the commands are processed the way YOU want them to be, there is no automatic command processing.  Instead, when a command comes in from DAQConnect, the system event "OnDCSet" is triggered, passing in the two values from DAQConnect: the key and the value.

To allow a remote user of DAQConnect to change values in your DAQFactory installation:

1) in DAQConnect, you will use the system.sendCommand() function (or other possible output functions) in an Click or other event.  These functions will take a key and a value.  The key is a string and often contains the name of the connector with a dot after it, such as "MyConnector.MyKey". The value can either be a string or number, and may be part of the function.  Please review the DAQConnect help for more information.

2) in DAQFactory, create a Sequence called "OnDCSet".  This sequence will be run whenever a new command comes in from DAQConnect.  Commands from DAQConnect only come in when DAQFactory sends data to DAQConnect.  So, if your channels are updating every 60 seconds, you can only possibly get commands from DAQConnect every 60 seconds. In these situations, you might consider using a Test channel or similar to ping the server more rapidly.

3) When the sequence is called, two local variables are created: "key" and "val".  What these mean is largely up to your design.  If, for example, you were directly controlling a digital output, "key" might be the name of a channel, and val either 0 or 1.  In this case, you might use this script:

if (key == "mydigout")

mydigout = val

endif

If you wanted to do more channels, you'd just repeat, or use a switch/case instead.

Now some important details:

key is always lowercase, no matter how you specify it in DAQConnect, and will NOT include the data source name.  This is stripped by DAQConnect.
val is a string, but will automatically get converted to a number when setting numeric output channels.  For other uses, you may need to use strtodouble() to convert it to a number
in the above example we did no constraining or safety checks.  Unless the output being controlled doesn't connect to anything dangerous, you should always do a safety check or ensure proper safeties are in place in hardware.  Remember that the output could be controlled remotely, and you should assume it could change at any time, even if you think you are the only one with access.
here's an example of a constrained output:

 

private nVal = strtodouble(val) // convert to a number

if (key == "myout")

if ((nVal > 20) && (nVal < 40))

   myout = nVal

endif

endif

 

Note that we converted the string "val" to a numeric "nVal" before doing comparisons.  > and < and other operators will work on strings, but work in a different way ("2" is actually > "10" for example, even though 2 < 10)

the OnDCSet event should run fast.  Do not put loops or delay()'s in this sequence.  If you need to do a loop or delay, do it in another sequence started with beginseq()
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.