j123b567 / scpi-parser

Open Source SCPI device library
BSD 2-Clause "Simplified" License
463 stars 194 forks source link

fixed typo FAGRENHEIT should be FAHRENHEIT #86

Closed jeras closed 7 years ago

jeras commented 7 years ago

For now I have only this typo fix.

I will work on SCPI for about 2 months so I will probably have more fixes.

For example angle units for degrees and radians have the same multiplication factor 1 now, which I think makes the conversion between the two wrong.

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling 21f09e1cdeff8cf11d3cde4a76fd82467201472d on RedPitaya:master into on j123b567:master.

j123b567 commented 7 years ago

Thank you for the fix.

This is on purpose. Multiplier is just for SI prefixes and similar multipliers not for conversion to different units.

Unit is not "angle" but base unit of the scale, so "degrees", "radians", .... If the unit name will be "angel", everybody will be confused, if it is in radians or degrees or so.

Same for length. Base unit is "meter", but I will not convert it to inches or back, because it is different unit. If the unit name will be "length" nobody will know, if it is in meters, inches, feets, or so. So I will never accept unit naming like that.

If you need conversion functions, you can introduce completely new API to translate from different units and I will be happy to incorporate it to this library.

e.g.

scpi_result_t SCPI_NumberConvert(scpi_t * context, scpi_number_t * value, scpi_unit_t target_unit);

you can later call

SCPI_NumberConvert(context, &someAngelValue, SCPI_UNIT_DEGREE) == SCPI_RES_OK
SCPI_NumberConvert(context, &someTemperatureValue, SCPI_UNIT_FAHRENHEIT) == SCPI_RES_OK

SCPI_NumberConvert(context, &someLengthValue, SCPI_UNIT_FAHRENHEIT) == SCPI_RES_ERR