Need an "On Change and/or Rate" Trigger for FactorySQL

Hi,

I have moved from RSSQL to FactorySQL and the project size which is being shifted has around 5000 groups.

I have many groups in my project which have triggers configured for execution. these groups are for event monitoring and the triggers can sometimes be complex and involve Action Items. Now my problem is that, if I only rely on the trigger say on Change, during a downtime of FactorySQL or a switch over from Master to Backup or if the Database was down, the trigger can be lost and consequently that event is lost also.

I have to use Stored Procedure groups here and to make the group trigger on the actual event as well as every 30 seconds to see, if the trigger condition is true and the event has indeed been logged, I add an “or” condition into the Trigger Action item using the Date and Time functions. The result is that if the group did not execute due to the Tag change, the 30 second timer will execute it.

The under lying stored procedure checks if the event was supposed to be started or ended and has it indeed been started or ended. This does add come additional DB calls but is necessary.

Now what I am noticing is that the execution of the same group is not sequencial i.e. FactorySQL is not waiting for the Stored procedure execution to complete before calling it again…this happens when the Trigger value based on Timer was executed on 58th second and the trigger again came at 59th second. Again, its just my observation on it.

due to this, I am having problems like duplicate insertion of events and incorrect event starts and ends.

My problem is that I cannot simply rely on a PLC based trigger and have to monitor the groups in between also to ensure that data has been logged. The way I am doing it, when the 2 triggers come very close by, the stored procedure which is not a simple insert/update and takes some time, screws up.

What I want is to program the redundant part of my trigger such that, it pulsates every 30 seconds but if the PLC trigger has come, then skip one cycle. I would like if it can be done using FactorySQL functions instead of a timer in PLC. I am suing FactorySQL 4.2.12 in redundancy mode.

Also if there is anyway to ensure 1 by 1 execution of a stored procedure in Sql Server 2000 Enterprise edition, that should solve it also.

On another note, is there a section of the Inductive Automation Website, where I can get relase notes and version releases for the softwares, I am anxiously waiting for Ignition to have store and forward for Stored Procedure Groups, We have already purchased it with 1 yr support but cannot upgrade to it, till that feature comes in.

Are these two different trigger conditions currently checked by two groups? I just want to make sure, because I think that’s the only way that the stored procedure would be called twice. If all of the trigger logic was in one group, it should wait until the call is complete before executing again.

So, if it is 2 groups, the trick would be to find a way to check everything in one group. There are two functions, “StoreVariable” and “GetVariable” that might be useful, but it is important to realize that these “variable” are global- so you’ll need to use a different name per group. Using these functions, you could probably track the last execution, and then check both the trigger condition and that time condition, getting it down to a “0” or “1” which is the actual trigger for the group.

If it’s NOT 2 separate groups right now, let me know- I really think it should wait for the stored procedure to complete, but I can look into it more.

Regards,

Also, I forgot to answer your last question: The update notes are currently posted to this thread. We do not currently have a timeline on the website, though I can tell you that the stored procedure/store and forward update will be in 7.2, which will be released soon (by the end of the year).

Regards,

thanks for your reply, No the concurrent execution are occuring in the same group, please note that the sored procedure logic can take upto 2-3 seconds to complete and if the group is trigger twice within the same duration, i think, it was called before last execution completed. I understand it is wierd to even think that this is happening this way but its been my observation with the stored Procedure groups.

Could you tell me, how I can store Last Execution Time of a group into a variable, I could then use datediff with Now(), inside the trigger to ensure that the period between consecutive group executions is not less than say 5 seconds. A small example to use Last Execution Time in a variable would be great.

Again my purpose is to enusre repeated call to ensure that event data is logged, the udnerlying stored procedure has the following logic:-

If Trigger is High & Event Start is not logged in the DB
then Log Start Event Data
else If Trigger is Low & Event End is not logged in the DB
then Log End Event Data

This simply ensure that if DB conenction was down and the trigger of event failed to log, then the Trigger part ( “|| Second(Now())>=30”) will ensure the logging of the event.

Hi,

To store the last execution, you could just have a trigger action item that was at the bottom of the list which was:

StoreVariable("group1_lastrun",now())

To get it back and check the difference, you could do the following:

DateDiff(GetVariable("group1_lastrun",ToDate("2000-01-01")),now(),"sec")

That will return the number of seconds between the last run, and now, with a default way in the past if it’s the first time the group has run.

Hope this helps,