Converting "units"
-
I'm curious about the "Convert unit for display" idea in the system. Is it somehow possible to define a custom conversion? For example I read a running pulse count and would like to see a weighted interval reading from it. The pieces in the system seem to be there, a running pulse total with the Delta rollup applied to it then multiplied by the weight would be exactly what I need. For reporting purposes it is easy enough to just export the Delta results and multiply by the weight directly in the Excel spreadsheet, especially if the pulse weight is a variable I can export into the report.
-
Hi psysak,
It is possible currently, but it would be a bit of a hack and may have unintended consequences. We have talked about adding support for unit definitions as a system setting, but it's never been a high priority.
Currently you would have to add unit labels / aliases from a scripting environment, like,
var newUnit = javax.measure.unit.Unit.ONE.times(15); //our new unit is fifteen quanta com.serotonin.m2m2.util.UnitUtil.addLabel(newUnit, "fift");
Which, after running, should let you use the unit 'fift' to indicate the source value should be divided by 15 for display. Some examples are in the class referenced:
The drawback is that your point will fail validation in a system that had not run this unit addition (like that system, every time it starts), which could cause problems I have not foreseen. So, try at your own risk! Edit: Although if you modify the class and place it as an override, it will load instead of the provided UnitUtil class. You could also try adding them in a set point handler on the system startup event. /edit
The proper way to do it would be to write the new units into that class, or for us to provide a hook that loads in your units when Mango is starting. But, as I said, this has not jostled to the front of the priority queue.
-
Woooow... I shall stick to my current META script way :)
Thanks!