06-04-2018, 04:33 PM
Dean, is there a way to identify which field triggered an event, that has multiple triggers configured from different fields, configured to trigger when one or more are true?
Triggered event w/ multiple triggers
|
06-04-2018, 04:33 PM
Dean, is there a way to identify which field triggered an event, that has multiple triggers configured from different fields, configured to trigger when one or more are true?
Read the docs, just to be able to claim that I did :-)
In the TrigEvent Action Target list there is Code: IsFldChangeEvFor(fldname)   which seems to do what I need, but in my action editor cannot find it? CQC version 5.2.11 the 8 "Get*something" targets listed in the docs are there, but the 7 "Is*something" are missing
06-04-2018, 05:29 PM
You would still want to do a basic filter of course, to prevent every single trigger from running the action. So try to limit it as much as possible with a filter. Then use the TrigEvent target to get information about the trigger. What kind is it? Is is just a generic field change type that you have configured on some fields? If so, there is a 'GetFldChangeInfo' command that will get information about a field change type trigger. It'll give you the field name and the value that caused the trigger.
Dean Roddey
Explorans limites defectum
06-04-2018, 05:31 PM
That command is a conditional. It only makes sense to call in an If or If/Else block. So it doesn't show up under the Cmd button. Hit the If button.
Dean Roddey
Explorans limites defectum
06-04-2018, 05:40 PM
06-04-2018, 05:52 PM
If all of the triggers are field change triggers, and you can't filter it down any more than that, at least use the IsFldChange() filter so it only gets kicked off for field change triggers and not all of the standard ones. If the ones you care about are from one (or maybe two) devices, add one or two IsFromSource filters to limit it further to field changes from those devices.
Dean Roddey
Explorans limites defectum (06-04-2018, 05:29 PM)Dean Roddey Wrote: You would still want to do a basic filter of course, to prevent every single trigger from running the action. So try to limit it as much as possible with a filter. Then use the TrigEvent target to get information about the trigger. What kind is it? Is is just a generic field change type that you have configured on some fields? If so, there is a 'GetFldChangeInfo' command that will get information about a field change type trigger. It'll give you the field name and the value that caused the trigger. You must have been reading my mind... I am trying to synchronize 2 fields with each other. Both can change, thus trigger. Having separate actions results in many read/writes, such as field1 triggers, its value converted to field2 and written, in return field2 triggers a change and compares value, since the conversion and rounding will not exactly equal, thus write back to field1... With IsFldChangeEventFor  I can separate and identify what triggered and write the other, but the trigger storm still happening. Any strategy how to do this? Trying to sync 2 different volume fields, that are of different scales Device1Z1.Volume  0-50 Device2Z1.Volume 0-100 Trying to make sure that volumes are the same on both, both can change individually. I also have an issue, where if I keep pushing the volume up/down on one devices, the other is overwhelmed and disconnects, probably due to the storm of triggers and writes.
06-04-2018, 06:31 PM
Set two different IsFldChangeFor triggers, one for the first field and one for the second, so that you know you only get invoked for those two fields.
But you are going to have a problem with the circularity issue. Most likely you will have to use a global variable to remember the last value you calculated for each field (and then wrote out.) When you see a new value, see if it is within one in either direction of the previously written value. I so, don't do anything. That way you won't get hit with rounding issues. So first check if the global variable exists. If not, create it with a value out of the range for that field. The calculate the new value, store it to the global variable and write to the field. When you see another change, create values one above and one below the new value and see if the new value falls within that range. If so, do nothing.
Dean Roddey
Explorans limites defectum
06-04-2018, 07:09 PM
Thanks, I was trying to make something similar you described above.
Any ideas on how to limit writes per second? What I had worked just fine, until one leaned on the volume up or down button. After about 2-3 seconds, the driver is overwhelmed... It is a serial port that is on the Global Cache ip2serial gizmo, and modified driver to connect to socket.
06-04-2018, 09:30 PM
There wouldn't be a very easy way to do that. Well, you could but you'd always risk missing the last few or so. Just create a time variable and use it to calculate how long since you last wrote to each field. There are action commands to get now and calculate the offset between now and the previous time stamp. Just ignore any that come in until that time has expired. But any that come in during that last chunk will get ignored. There's no easily way to know that they've stopped and do a last write.
That sort of thing would require some more elaborate mechanism. There are a number of things of this sort that really need for a 'Rules Engine' type capability that supports standard rules like this one, or PID algorithms and that sort of thing. You can do it with an event monitor, but that means writing some CML. Event monitors aren't really much used. Actually I don't know if anyone has ever used one since I created them.
Dean Roddey
Explorans limites defectum |
« Next Oldest | Next Newest »
|