Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

How to Restore Variable-Data from file on CPU or CRD


Aung Htet Nov 12, 2017 05:06 AM

Dear All ,

I would like to know which program line to use to restore Data form file written on CPU or CRD after datalogger restarts.

The Point is that sometimes my datalogger battery run out on swapping the batteries so the datalogger and program restarts.

So I have to manually put the Datum data to reach the current reading.

I would like to do is to write a dataum data to file on CPU or CRD and when the battery out or program or the datalogger restarts, I would like to read that data from CPU or CRD and restore to respective Variable under one click of Boolean Button.

Thanks,

Aung Htet


AMK Nov 12, 2017 08:57 PM

Would the 'PreserveVariables' function be appropriate for this use case?


jra Nov 13, 2017 03:44 PM

Also, take a look at retrieving data from a DataTable. 

https://www.campbellsci.com/blog/programmatically-access-stored-data-values


Aung Htet Nov 13, 2017 05:02 PM

Dear jra,

Thanks it's worked.

By the way, how would I make the data table record only one time under boolean control ? 

Regards,

Aung Htet


Aung Htet Nov 13, 2017 05:04 PM

Dear AMK,

Thanks for your advise. 

Could you be a little more specific ? 

So that I can make a replica.

Regards,

Aung Htet


bradleyh Nov 13, 2017 07:44 PM

Here is what I've done to preserve current data across datalogger restarts.

Sub getPreviousValues
  'get the record that was written last so we can calculate new values
  Calfile (lastRecord(),3,"CPU:lastRecord",1)
EndSub

lastRecord() would be an array where I write the data that I want saved to the CPU for later retrieval.

Sub copyDataToLastRecordArray
  lastRecord(1) = data1
  lastRecord(2) = data2
  lastRecord(3) = data3
EndSub

 At the end of your program before you call your tables you can write the values you want to be saved to the file on the CPU.

'copy current data to the array to save to the lastRecord file
Call copyDataToLastRecordArray

'write data to the lastRecord file
Calfile (lastRecord(),3,"CPU:lastRecord",0)

 I would have a check at the start of the program that knows if values have been initialized yet and calls the getPreviousValues subroutine if necessary.  Then you would just need to write the array back to the variables to restore them.

data1 = lastRecord(1)
data2 = lastRecord(2)
data3 = lastRecord(3)

 


Aung Htet Nov 14, 2017 03:32 AM

Dear Bradleyh,

I will try it . 

Regards,

Aung Htet

Log in or register to post/reply in the forum.