Custom Display Unit
-
Hello All,
I am using the following modules:
Mango Core: 3.6.0
Mango API: 3.6.0
Mango UI: 3.6.1
Platform: Centos 7.4.1708
Java Version: 1.8.0_161
Browser: Chrome 75.0.3770.100 (Official Build) (64-bit)With the new data source UI I was glad to see the tick box for Custom Display Unit as some of our data is not in the standard SI units. So I ticked the box as shown in the screenshot.
However if I put our non standard unit value in the either the Unit or the Display Unit (or both) I get an exception error or validation error and cannot save the data point. The help page for the point properties does not mention the Custom Display Unit as an option.
Is this working yet? It would be nice to be able to enter engineering units that are not in the accepted lists.
Cheers
Brian
-
Hi Brian,
Without both units being in the library's set of units, it cannot know how to perform the unit conversion. The analog text render provides the ability to override the unit with a suffix to display instead. You can use the suffix even if you convert it to another unit, although I'm not sure why one would do so.
As far as defining new units, I have answered that question here:
https://forum.infiniteautomation.com/topic/2382/custom-point-unitsThe git issue is here:
https://github.com/infiniteautomation/ma-core-public/issues/309There isn't a good way to hack up a solution. The proper solution currently would be to write a ModuleElementDefinition with a preInitialize method that added units to com.serotonin.m2m2.util.UnitUtil, https://github.com/infiniteautomation/ma-core-public/blob/0c45aa13c3974904ce9bfad1dcec7cd7f7cfffa4/Core/src/com/serotonin/m2m2/util/UnitUtil.java
One could add that that class file into an existing module's jar if one didn't want to deal with the other components of a module, but one would have to remember to do that at update (also one would have to update their module with each minor release version, 3.5 to 3.6 for instance, if one wrote a module).
The reason a hack like adding them via an event handler on the Mango startup event is that it would generate exceptions when deserializing points, which would happen before the startup event was raised.
Edit: Formerly "Convert unit for display"
-
Hello Phil,
Thank you for the reply. I will follow up on your suggestions.
In Mango 2, I was able to use any set of text as the engineering units for the DGLUX displays.
I was hoping that the addition of the custom units in Mango UI 3.6.1 would similarly allow the use of any text.
We only need these engineering units for display and logging, They will not be used for conversions since we write the script in the Meta Data points to convert anything we require converted.
Unfortunately the Analog Text Renderer in MangoUI 3.6.1 does not add the suffix to the gauge data displays.Cheers
Brian
-
@BG firstly, what unit are you trying to display?
@bg said in Custom Display Unit:
Unfortunately the Analog Text Renderer in MangoUI 3.6.1 does not add the suffix to the gauge data displays.
I just tested it and it does? Did you refresh the page?
-
Hello Jared,
At the time I did refresh and waited for the data point to update naturally. The text did not appear.
However. I just went back to the display to verify before replying and the text has appeared now.Thank you. The text renderer is all I need for these data points.
cheers
Brian
-
P.S.
The help file for the text rendering suggest that symbols from the HTML entities could be used. I can't seem to get those to work. I only ever get the text for the entity showing up on the gauge. Such as ° shows up as
I don't want to use the deg symbol but was trying for different symbols as an experiment.
Cheers
Brian
-
You could paste the symbol into the suffix field.
That note in the help should be removed, thanks for bringing it to our attention. It will not process HTML, as that is a code injection vector. Old versions of Mango enable one to encode HTML into all sorts of places in the old UI, which is generally bad, but for security reasons the old UI had all that audited and prevented throughout the 3.4 core series.
-
OK Thank you for the quick response Phil.
Cheers
Brian