How to implement metadata?
-
I have a Data point from a MODBUS device that I read on a periodic basis.
The raw data from the device must be run through a calculation in order to display in the graphical view widget.I was trying the Metadata data point and was not able to get it to work.
my calculation is simple in javascript:
var my = (p1-640)/16.0;
return my;does not seem to work, meaning the graphical widget does not update.
What am I missing, is there an example similar to this?
-
Hi tcontrada,
i would have written that as
return (p1.value - 640)/16.0;
the "my" would probably be aliasing the variable name for the point to refer to itself, and one should call for the .value property of the context point.
I do not know what you mean, "does not seem to work, meaning the graphical widget does not update." but I suspect the problem is the same. Check it on the data point details page if you are making a custom dashboard, just so one can more easily know where things are going wrong.
-
I see, working now....Thanks!
-
No problem! Just so you know, these calculations could probably be performed in the modbus point locator, which would probably be more efficient. It's value*multiplier + additive, so
(value-640)/16 --> value*.0.0625 - 40 would be equivalent, so multiplier=0.0625 additive=-40 but there can be benefits to using a Meta point, if you're wanting to keep the raw values around too for some reason.
-
OK, cool, I will try that as well...Thanks!