Forum Home › Forums › Understanding the Software › Using Formulas › How to use EveryPeriod Function?
Tagged: EveryPeriod Function
- This topic has 5 replies, 2 voices, and was last updated 1 year, 10 months ago by
CCKOH.
-
AuthorPosts
-
March 1, 2024 at 7:42 am #14098
CCKOH
ParticipantHi Mikhail,
I’m need to execute My Function () at a time interval specific by the user (thru input channel 140). Understand that Rapid SCADA have a Timer function
EveryPeriod(Func<CnlData> getDataFunc, long period, long execSpan)Please advise me how to use this funtion to achieve my Task.
In addition, I’m notice that under EverySec(Func<CnlData> getDataFunc), EveryPeriod function is calling
EveryPeriod(getDataFunc, TimeSpan.TicksPerSecond, TimeSpan.TicksPerMillisecond * 500);
Why TimeSpan.TicksPerMilisecond need multiply by 500? Or actually what is the «execSpan» meaning?
I’m sorry if my question look silly as my programming skills are very very basic.
Thank you.March 1, 2024 at 12:15 pm #14104
MikhailModeratorHi,
EveryPeriod is defined as protected. You can change it to public and try using it directly. The period argument would be taken from a channel value, for example.
The execSpan parameter provides a flexible period when getDataFunc can be executed. Note that EveryPeriod is called many times a second by the Server engine, and you don’t know the particular moment when it is called.March 1, 2024 at 12:17 pm #14105
MikhailModeratorProbably, it’s better to create your own function that uses the EveryPeriod method.
execSpan can be equal to period / 10March 1, 2024 at 4:47 pm #14108CCKOH
ParticipantHi Mikhail,
Thank for the explanation.
If I’m need to execute my function “Compute()” every 5 second define by user thru channel 140 for example, can I’m write the formula as EveryPeriod (Compute(), Val(140), Val(140)/10) at the channel of output formula column?
I’m still confusing why we still need execSpan argument? As we already define function Compute() only can be execute when the time specific (5s in this example) elapsed. Really hope you can help elaborate more on it.
March 4, 2024 at 11:54 am #14124
MikhailModeratorHi,
Add a function like that:public CnlData Every5Sec(Func
getDataFunc) { return EveryPeriod(getDataFunc, TimeSpan.TicksPerSecond * 5, TimeSpan.TicksPerMillisecond * 500 * 5); } > I’m still confusing why we still need execSpan argument?
It is needed to avoid unnecessary calls of getDataFunc.March 4, 2024 at 4:40 pm #14132CCKOH
ParticipantHi Mikhail,
Thank for the function example and the explanation.
-
AuthorPosts
- You must be logged in to reply to this topic.