Tracking state in formula, a bad idea ?

Forum Home Forums Understanding the Software Using Formulas Tracking state in formula, a bad idea ?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #8637
    zzz
    Participant

    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.

    #8650
    Mikhail
    Moderator

    Hi,

    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.

    #8684
    zzz
    Participant

    Do you mean all Calculate types are calcuated once per cycle in sequence as listed in InputChannel table after all Real/Discrete channels have been processed ?

    #8698
    Mikhail
    Moderator

    You should check the code by yourself. Here is a link.

    #8727
    zzz
    Participant

    Hi 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

    #8728
    zzz
    Participant

    Hi 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 2 years, 11 months ago by zzz.
    #8746
    Mikhail
    Moderator

    Hi,

    I wonder why CalcDRCnls() has to be called after average calculation?

    Which line numbers of the source code do you mean?

    #8754
    zzz
    Participant
    #8759
    Mikhail
    Moderator

    Hi,

                    // вычисление дорасчётных каналов, если добавленый срез изменился
                    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.

    #8951
    zzz
    Participant

    That’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.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.