What would blank a Global Variable?

Guys,

NR 2.2.2

I have a routine that controls my Battery Charge and Discharge rates.

It performs various calculations on my Power usage and Solar output and then makes decisions about where to charge the battery from.

It relies and updates a number of global variables.

My Global variables are backed by Storage - running on a Virtual Machine on Ubuntu.

Today i got a message that my system was doing some weird stuff and when i looked a number of my key global variables that are used as the inputs to this function had been blanked - these variables are part of an object (as below)

image

In this instance the DesiredRate for each of the 3 inverters was not there i.e. the actual Property and its value had disappeared.

I am trying to work out how this could happen.

If my Change node to set this property had an invalid value ( for instance String instead of Number) would this completely remove the Property ?

I am going through all my code at the moment but believe the only way i write to these 3 properties is through Change Nodes i.e. no Function nodes

Any other idea what could remove a property in this fashion ?

NR has not been restarted, nor has the Virtual Machine.

There is plenty of disk space free

Craig

I just did a test and it looks like global don’t care what the input is. I.e. you don’t define a global variables type so you could set it to a number then a string and the string value would be the result.

However you are storing an object. Is it possible that somewhere in your code you are changing the object by deleting that part of it?

I agree. Unless you are changing the file that stores the data using some odd direct method (unlikely), there are only a few ways to make changes and they all come from a flow.

One thing I often do if I'm using an object variable is to add updated and updatedBy properties and make sure that anything that updates it updates these two. The updatedBy is a string and typically is something like tabName/nodeName. I use the same kind of thing with complex MQTT updates as well.

1 Like

Thanks guys - at least i am not going mad - will have to dig through the code.

The idea of UpdatedBy etc is a good one - but these object are essentially realtime - they get updated every 3 seconds so not sure that will catch much in this respect.

@zenofmud - thanks for doing the test Paul at least it confirms for me it is a code ssue somewhere.

I have placed a catch node on each of the function nodes now where the problem appears to have come from and then fed that out to a function node that dumps the Global object and then have Flogger log it to disk for me so if(when) it happens again i should get closer to a solution

Craig

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.