Octave Edge Action JavaScript - changing "dh://util/counter/value" odd behaviour

Hi

Ideally I’d have liked a volatile system key, value store - maybe using something like Datahub.write(path,data, 0) but I couldn’t see a way to implement this within an edge action event handler .

I guess that a virtual resource is the method I should use and reorder the implementation so that event handler returns sets the data.

Looking a bit further into this I think it’s likely that virtual resources created from an edge action are volatile. No sure if creating /virtual/config (non-volatile) entries from a edge action is possible.

Anyway - I came across some odd behaviour when I was attempting to use the system counter function as a state machine by setting it’s value on exit from the event handler

image

function(event) {
	var gauge =      [0x01, 0x0B, 0x00, 0x00,   50 ];

	var arrayToCheck = gauge;

	console.log(event);
	console.log(event.value);

	if(event.value > 5)
	{
		return {
			"dh://usp/write": [{"data": arrayToCheck}],
			"dh://util/counter/value": [0]
		}
	}
	else
	{
		return {
			"dh://usp/write": [{"data": arrayToCheck}]
		}
	}
}

However the console produces this

image

But the GUI shows this

image

Any ideas what is happening?

Thanks in advance

John

Hi John,
Can you include your device id so I can investigate a bit further?

Hi David

Thanks

d5db0157f43cdca9ed7dfd2f9

Kind regards

John

Hi,

Also stuck on a problem trying to change /util/counter/value as well. Not meaning to hijack the thread, but I think it may be similar in nature.

I have an edge action monitoring an observation on /util/counter/value. The EA processes my business rules and then like in John’s example above, once it reaches a condition, I have dh://util/counter/value": [0] in the return statement which is meant to “reset” the value.

No matter what we do in the EA, the counter value retains its current number and won’t take the new value. To further troubleshoot, we also sent a basic command stream event, such as:

{  
    "elems": {
        "util/counter/value": 0
    },
    //everything else
}

Interestingly, the command stream event temporarily sets the counter value to 0, but within the next util/counter/period iteration, the value again resumes its prior number.

Not sure what is going on, could be something simple we are overlooking. However, this is a key part of our data flow algorithm which isn’t working as intended.

Device ID: d5ef21ee0533debf349c063b8. Thanks!

a resource is either an input or an output, the util/counter/value is an input, so it’s not writable.

As today I don’t thin you can reset the counter, it on our list of improvements.

Hi Julien

If the counter is an input only - why does the GUI indicate the value 0? - but the edge device (as expected) reads the correct count value

Thanks

John

Hi John,

the UI will show the current counter value:

  • if in developer mode (with a 1 minute refresh rate)
  • or if the counter is directly reported by an Observation

The counter is handled by the lower level hardware, it starts at 0 at device boot and cannot be reset programatically