This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

save the value of a variable in the LM
#1
Hi,

I would like to know how I can save the value of a variable inside the memory of the LM, but that this value will never be erased.
the idea is that I keep the value of a meter variable one month (for example March), the next month (for example April) I create another variable and I keep the value of that month in that variable. Then I take the value of the first variable and I make a difference between the first and the second variable. this to make a comparison of consumption.

I've been looking for a similar example but I have not found anything.

thank you Big Grin
Reply
#2
Hi
Just use trend and counter and all this will be done for you automatically
BR
------------------------------
Ctrl+F5
Reply
#3
Hello,
Thank you, but I do not know if you have an example of how to use the trend and the accountant is honestly new to this
I would really apreciate it
Reply
#4
Hi
How do you want to display the data? If via trend then in there you have ready solution to compare the same trend with different period. If you want the value itself then fetch the data via this. http://openrb.com/docs/trends-new.htm
------------------------------
Ctrl+F5
Reply
#5
Hi.
I have tried with the trends but it does not give me the desired result.
Is there another way to carry out this process without the tendencies?
that is, for example with the storage library, save in a position X of the LM the value of the month and that the next month be stored in a position Y of the LM without affecting the previous value.
With the above, can data be stored for more than 2 years?
thank you
Reply
#6
You can use storage for any kind of data. For example you can store a Lua table there, where each table key is year-month pair:
Code:
key = os.date('%Y-%m') -- YYYY-MM format
value = 123 -- current value

values = storage.get('values', {})
values[ key ] = value
storage.set('values', values)
Reply
#7
good day.

Thank you very much, the code was very helpful.
Now I would like to know how I can do so that the data in the table are global.
since I try to read them in another script but it gives me null values
Reply
#8
All storage is available in every script. If you have null this is what the storage contain then.
------------------------------
Ctrl+F5
Reply
#9
good day.

Thank you very much, now I would like to know if there is a way to eliminate what is stored inside the storage code, since until now I do it through the storage application that the LogicMachine store has.
Another thing, I've noticed that as I store the information with storage, this increases:

https://drive.google.com/open?id=1gVOgmC...8TxbsAuhYd

I looked and I realized that memory is increasing according to what is saved with storage, but I do not understand why in "disk" is increasing, which function meets "disk" and there is a way to clean that part since sometimes it reaches 85% and the LogicMachine becomes very slow.
Reply
#10
Code:
storage.delete(key)
Storage is saved in redis database which is saved every half an hour to Disk which is the SPI flash.
------------------------------
Ctrl+F5
Reply


Forum Jump: