Continuing a calcuation after restart ?

Forum Home Forums Understanding the Software Using Formulas Continuing a calcuation after restart ?

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #7772
    zzz
    Participant

    Hi MikHail,

    There is such a case, in which, we need to keep the accumulated value of a group of channels. Each channel’s value increase to the target value K then reset to 0.

    We created a object and a function for this case, the object keep track of the last values and timestamps of each channel and calculate the deltas of each channel then add the deltas to the total sum.

    The missing part, is when server is restarted, the object used to hold calculation data is recreated, the accumulated total is reset. Is there any way to make the accumulated total survive a server restart?
    e.g. a function to retrieve the last value of the current channel (latest in history, before restart) ?

    (Not writing/reading it into/from a text file…, since the formula seems to have has no way to determine if the server is about to shutdown, and value has to be saved constantly which make it not a saleable solution.)

    #7786
    Mikhail
    Moderator

    Hi,

    To save and load values you can store them into input channels. Current values of input channels are loaded on start.
    Otherwise, it’s better to develop a Server module and store values in a file.

    #7796
    zzz
    Participant

    You mean things can be easily fixed if I do sth like this in the calculated-real channel “AccumulatedSum” ?

    
    Func AccCalculate()
    {
    ....
    if(AccCaclulatorObj.last_sum = float.NaN) AccCaclulatorObj.last_sum=CnlVal();
    ....
    }
    

    Should I use ChlVal() or Val()?

    #7797
    Mikhail
    Moderator

    You could create a property like

    double MyVar
    {
      get
      {
        return Val(101);
      }
      set
      {
        SetVal(101, value);
      }
    }

    Where 101 is the input channel number. Channel of the calculated real type. Note: I didn’t tested it.

    #7802
    zzz
    Participant

    Sorry wrong question.
    So is Val() or ChlVal or both get reloaded on restart ?

    #7804
    Mikhail
    Moderator

    CnlVal contains value that is received from controller.
    Val() is a function that retrieves current channel value. Channel values are loaded on start.

    #7808
    zzz
    Participant

    Got it, thank you.

    #7895
    athes
    Participant

    Hi Mikhail,

    I need again your kind help.
    I have the same issue. I didn’t get you how to store the values to survive restart.

    I have at least 30 calculated minute values.
    One example: https://drive.google.com/file/d/1_XMJvwn8yaApgV3lr1lA9NkmWRFj0-Mm/view?usp=drivesdk

    In this example I want to keep Val(1311) after restart.

    What exactly should I do if I want to keep the calculated values?

    #7899
    Mikhail
    Moderator

    Hi,

    Check the following:
    1. Stop the server service.
    2. Open current data and check value of the channel 1311. Use Administrator to view raw data. Does it correct?
    3. Start server. Check value of the channel 1311 again. What is the value and status?
    4. If it was reset, publish ScadaServer.log.

    Provide some screenshots.

    • This reply was modified 3 years, 2 months ago by Mikhail.
    #7903
    athes
    Participant

    Hi,

    1. Done
    2. Done. Value correct (25089)
    3. Done. Value correct (25089, status: 1)

    I have no issue if only the RapidScada server/communicator got restarted.
    I have issue if the whole raspberry got restarted (OS restart) –> If I restart my raspberry, the value will be 0 instead of continuing from the last valid value.

    My – not so elegant – workaround: I have a daily copy of the current.dat file, and after reboot I stop the server, overwrite the new current.dat with the old saved one, then my counters continue from the right value.

    #7904
    athes
    Participant

    Sorry for the confusion, I see it is not exactly the same question as the original in this thread.

    #7909
    Mikhail
    Moderator

    If you use RAM disk for current data on Raspberry, it will not be saved on hardware reboot. If you write scripts for your solution, it would be good.

    #7912
    athes
    Participant

    RAM disk was the issue. I’ve set up a script to back up the current.dat in every 3 hours and an other to copy back after @restart. Working fine.
    Thanks for your kind support!

    #7914
    manjey73
    Participant

    On Raspberry, I used formulas to save and read channel data to a file. Since the values fall into RAM (tmpfs)

    #7915
    athes
    Participant

    I’ve just added to crontab this:

    5 0/3 * * * cp /opt/scada/ArchiveDAT/Cur/current.dat /opt/scada/ArchiveDAT/
    @reboot cp /opt/scada/ArchiveDAT/current.dat /opt/scada/ArchiveDAT/Cur/

    I have this entry in my fstab as per installation guide, so current.dat is on tmpfs / ramdrive:
    tmpfs /opt/scada/ArchiveDAT/Cur tmpfs defaults,noatime,size=10m 0 0

    What exactly do you mean on “I used formulas to save and read channel data to a file”? Did you remove the tmpfs and write current.dat to SD card?

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