Tracking state in formula, a bad idea ?

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

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #8637
    Avatarzzz
    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
    MikhailMikhail
    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
    Avatarzzz
    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
    MikhailMikhail
    Moderator

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

    #8727
    Avatarzzz
    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
    Avatarzzz
    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 11 hours, 18 minutes ago by Avatarzzz.
    #8746
    MikhailMikhail
    Moderator

    Hi,

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

    Which line numbers of the source code do you mean?

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