MangoAutomation / ma-core-public

Mango Automation Core public code
Other
79 stars 50 forks source link

Support for additional/custom units #309

Open jeremyjhall opened 10 years ago

jeremyjhall commented 10 years ago

Many electrical measurement units like var, VA, kvar, VAh etc are not supported by javax.measure.unit.

It would be good if the user could enter and save custom unit definitions in the point properties (rather than the text renderer).

terrypacker commented 8 years ago

We need a way to be able to assign all types of units to a point. Either fix how we use JScience or replace it with something more flexible.

Puckfist commented 7 years ago

It is very easy to add units to UnitUtil.java if that's a sufficient solution

Puckfist commented 6 years ago

Crazy idea - what if we transparently (well, provide a warning and disable the convert units / integral units) treat the unit as a suffix if unkown?

Puckfist commented 6 years ago

Or, crazy idea, what if I furnish examples of adding these units from a set point handler script on the system startup event?

Puckfist commented 5 years ago

Or, crazy idea, what if we added an ability to add scripts for the postDatabase stage in initialization, where one could invoke the functions to add units in the unit util?

jazdw commented 5 years ago

Guys, the purpose of being able to choose units is for 2 reasons a) Being able to convert the data point value to a different unit for display. e.g. I log a value of litres per second and I wish to display the value on my dashboards as gallons per minute b) Being able to display the integral statistic with whichever unit you choose e.g. I log a value of litres per second and I wish to display the integral statistic as cubic metres

If you want to display some arbitrary unit, you can do so using the suffix option of the text renderer. Contrary to the original issue report, it is possible to represent any unit using Mango's unit input / javax.measure.unit. Adding custom units to javax.measure.unit is not necessary.

jazdw commented 5 years ago

Please read http://web.mit.edu/10.213/oldpages/f99/supp/readings/units/index.html

Puckfist commented 5 years ago

I think people are bothered by the extra / not immediately obvious nature of that. Also, that solution wouldn't be possible if one was going to use a range renderer (no suffix on that one, currently. Time renderer neither, but I'm not sure a time renderer would ever have a suffix)

Adding custom units to javax.measure.unit is not necessary.

We already do this for PSI, BTU, and THERM. How would I do BTUs ? I don't think I can enter a numeric constant in the units field, and it's a direct scaling of joules

Puckfist commented 5 years ago

Oh, my mistake, BTU would be entered J*1055.05585262

Just can't put the constants first.

terrypacker commented 5 years ago

Even if one can represent any unit using a formula it may not be desirable, some sites may have a common set of units they like to use which are complex to setup on a point. To make the user experience better during point creation we could provide a place in the new UI to combine the existing Units and assign them labels which can then be used when creating data points. This would imply we have a place to store these custom units and ensure they make it into the Unit cache on startup.

I fully understand this is not necessary and would only serve to improve the user experience.

snowwindwaverider commented 5 years ago

var is the reactive component of power and is of the same dimensions as VA, this is something you would use a custom suffix for.

I am not sure what is meant by VAR is of the same dimensions as VA. VAR is as you say reactive power, VA is apparent power.

VA should be entered into the unit input as V·A, if you don't want the dot, use a custom suffix.

The only place I have ever seen the unit of measure for apparent power written as V·A is in mango, but an extraneous · isn't going to bother me.

kvar should be entered into the unit input as kV·A, again use the custom suffix if you want to display it as kvar

This is incorrect. kVAR is reactive power, kVA is apparent power. Refer to https://www.omnicalculator.com/physics/power-factor

My original issue was I wastrying to use units MVAR and MVARh but mango kept changing them to MV*A and MVAh, Thanks for looking in to it!

jazdw commented 5 years ago

I am not sure what is meant by VAR is of the same dimensions as VA. VAR is as you say reactive power, VA is apparent power.

VA being apparent power and VAR being reactive are engineering conventions. They are both of the same physical dimension.

Link that I posted previously, MIT - "A dimension is a property that can be measured, such as length, time, mass, or temperature, or calculated by multiplying or dividing other dimensions"

Penn State - "A dimension is a measure of a physical variable"

See also page 140 (page 26 of the PDF) of the SI units brochure- https://www.bipm.org/utils/common/pdf/si-brochure/SI-Brochure-9-EN.pdf

In practice, with certain quantities, preference is given to the use of certain special unit names to facilitate the distinction between different quantities having the same dimension. When using this freedom, one may recall the process by which this quantity is defined. For example, the quantity torque is the cross product of a position vector and a force vector. The SI unit is newton metre. Even though torque has the same dimension as energy (SI unit joule), the joule is never used for expressing torque.

And the side note:

The International Electrotechnical Commission (IEC) has introduced the var (symbol: var) as a special name for the unit of reactive power. In terms of SI coherent units, the var is identical to the volt ampere.

The only place I have ever seen the unit of measure for apparent power written as V·A is in mango, but an extraneous · isn't going to bother me.

The dot is mathematics notation for a product. You will see this under section 2.3.4 Derived units of the above linked SI unit brochure.

This is incorrect. kVAR is reactive power, kVA is apparent power. Refer to https://www.omnicalculator.com/physics/power-factor

It is not incorrect. This is how you should enter it. I am not disputing the engineering notation, I am saying that for both reactive and apparent power you would enter kV·A in the unit field as they are of the exact same physical dimension, to distinguish them when you display them, use a text renderer suffix.

My original issue was I wastrying to use units MVAR and MVARh but mango kept changing them to MV*A and MVAh, Thanks for looking in to it!

Correct Mango will simplify / modify units, and I agree this can be confusing for our users. The solution is to use text renderer suffixes.