Forum Home › Forums › Understanding the Software › Using Formulas › Tracking state in formula, a bad idea ?
- This topic has 9 replies, 2 voices, and was last updated 3 years, 6 months ago by zzz.
-
AuthorPosts
-
April 5, 2021 at 7:17 am #8637zzzParticipant
Hi Mik,
I have a few places doing state tracking (track multiple channel value **trends** to calculate final state) in formula, e.g. setting Cnl1 to cnl1_proxy(Val) where cnl1_proxy = f(x){state_process(x); return x;}. My assumption was each polled data point is processed by formula in sequence once and only once.
Recently I was planning to move all the formula stuff to a plugin. When inspecting the code in MainLogic, I noticed that there are many places calling InCnl.CalCnlData() directly or indirectly via CalcCnlData(inCnl, oldCnlData, ref newCnlData) and CalcDRCnls(), some on condition
I have difficulty in reading the non-english comments. I wonder if my prev assumptions still true ? Are the data of each channel gurenteed to be processed by the same formula instance in sequence and only once?
If possible could you explain what those channel type mean ?
CnlTypes.TS, CnlTypes.TI, CnlTypes…DR…. Bing translator’s tv signal, telemetering didn’t help at all.Thank you.
April 6, 2021 at 1:36 pm #8650MikhailModeratorHi,
I have difficulty in reading the non-english comments.
We will update all comments to English.
Are the data of each channel gurenteed to be processed by the same formula instance in sequence and only once?
This is true for input channels of the Real and Discrete types.
Channels of calculated types are calculated permanently in cycle.
If possible could you explain what those channel type mean ?
It is written in the Channel types table when you open any project in Administrator.
April 9, 2021 at 4:16 am #8684zzzParticipantDo you mean all
Calculate
types are calcuated once per cycle in sequence as listed inInputChannel
table after allReal/Discrete
channels have been processed ?April 9, 2021 at 1:18 pm #8698April 14, 2021 at 3:19 am #8727zzzParticipantHi Mik,
Thanks for the link, so from the linked part,
formulas could be called 1 ~ 3 times for the same data point,
based on if they are hour/minite sharp, correct ?lock (curSrez) { // установка недостоверности неактивных каналов SetUnreliable(events); // вычисление дорасчётных каналов if (calcDR) { CalcDRCnls(drCnls, curSrez, events); } // вычисление минутных каналов if (calcMinDR) { CalcDRCnls(drmCnls, curSrez, events); calcMinDT = CalcNextTime(nowDT, 60); curSrezMod = true; } // вычисление часовых каналов if (calcHrDR) { CalcDRCnls(drhCnls, curSrez, events); calcHrDT = CalcNextTime(nowDT, 3600); curSrezMod = true; } }
Regards
April 14, 2021 at 5:51 am #8728zzzParticipantHi Mik,
I followed along the calls. I wonder why CalcDRCnls() has to be called after average calculation? (The
changed
line in the following diagram.)https://pasteboard.co/JXfl6zB.png
- This reply was modified 3 years, 7 months ago by zzz.
April 14, 2021 at 1:55 pm #8746MikhailModeratorHi,
I wonder why CalcDRCnls() has to be called after average calculation?
Which line numbers of the source code do you mean?
April 15, 2021 at 7:22 am #8754zzzParticipantApril 15, 2021 at 11:33 am #8759MikhailModeratorHi,
// вычисление дорасчётных каналов, если добавленый срез изменился if (changed) CalcDRCnls(drCnls, newSrez, null);
It’s important because historical slice (snapshot, “srez”) can be changed because of averaging.
Anyway, in v6 we will remove averaging from the core logic and move it to separate formulas or module.
May 14, 2021 at 2:58 am #8951zzzParticipantThat’s great, the extra calls made the result of caculated channel not what it supposed to be.
I used to be hunting a filter problem. this simple filter retains last valid value on error, until N consective errors.
The behavior does not work as designed sometimes, N has to be increased to larger number to mainten the calculated delay, while all stations on bus have been configred to do intervaled sampling without retry.
-
AuthorPosts
- You must be logged in to reply to this topic.