Forum Home › Forums › Understanding the Software › Using Formulas › Continuing a calcuation after restart ?
Tagged: continuious calcuation, server restart
- This topic has 18 replies, 4 voices, and was last updated 3 years, 3 months ago by manjey73.
-
AuthorPosts
-
December 20, 2020 at 8:03 am #7772zzzParticipant
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.)
December 21, 2020 at 12:42 pm #7786MikhailModeratorHi,
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.December 22, 2020 at 10:58 am #7796zzzParticipantYou 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()?
December 22, 2020 at 12:58 pm #7797MikhailModeratorYou 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.
December 23, 2020 at 6:22 am #7802zzzParticipantSorry wrong question.
So is Val() or ChlVal or both get reloaded on restart ?December 23, 2020 at 1:35 pm #7804MikhailModeratorCnlVal contains value that is received from controller.
Val() is a function that retrieves current channel value. Channel values are loaded on start.December 24, 2020 at 1:40 am #7808zzzParticipantGot it, thank you.
December 30, 2020 at 12:34 pm #7895athesParticipantHi 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=drivesdkIn this example I want to keep Val(1311) after restart.
What exactly should I do if I want to keep the calculated values?
December 31, 2020 at 10:21 am #7899MikhailModeratorHi,
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, 3 months ago by Mikhail.
December 31, 2020 at 11:01 am #7903athesParticipantHi,
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.
December 31, 2020 at 11:03 am #7904athesParticipantSorry for the confusion, I see it is not exactly the same question as the original in this thread.
January 2, 2021 at 9:58 am #7909MikhailModeratorIf 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.
January 2, 2021 at 11:11 am #7912athesParticipantRAM 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!January 2, 2021 at 1:44 pm #7914manjey73ParticipantOn Raspberry, I used formulas to save and read channel data to a file. Since the values fall into RAM (tmpfs)
January 2, 2021 at 2:11 pm #7915athesParticipantI’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 0What 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?
-
AuthorPosts
- You must be logged in to reply to this topic.