AMU Library 3.0
C/C++ library for communicating with AMU (Aerospace Measurement Unit) devices
Loading...
Searching...
No Matches
units.c
Go to the documentation of this file.
1/*-
2 * Copyright (c) 2012-2013 Jan Breuer,
3 *
4 * All Rights Reserved
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
36
37#include <string.h>
38#include "parser.h"
39#include "units.h"
40#include "utils_private.h"
41#include "utils.h"
42#include "error.h"
43#include "lexer_private.h"
44
45
46/*
47 * multipliers IEEE 488.2-1992 tab 7-2
48 * 1E18 EX
49 * 1E15 PE
50 * 1E12 T
51 * 1E9 G
52 * 1E6 MA (use M for OHM and HZ)
53 * 1E3 K
54 * 1E-3 M (disaalowed for OHM and HZ)
55 * 1E-6 U
56 * 1E-9 N
57 * 1E-12 P
58 * 1E-15 F
59 * 1E-18 A
60 */
61
62/*
63 * units definition IEEE 488.2-1992 tab 7-1
64 */
65const scpi_unit_def_t scpi_units_def[] = {
66#if USE_UNITS_PARTICLES
67 /* Absorbet dose */
68 {/* name */ "GY", /* unit */ SCPI_UNIT_GRAY, /* mult */ 1},
69
70 /* Activity of radionuclide */
71 {/* name */ "BQ", /* unit */ SCPI_UNIT_BECQUEREL, /* mult */ 1},
72
73 /* Amount of substance */
74 {/* name */ "MOL", /* unit */ SCPI_UNIT_MOLE, /* mult */ 1},
75
76 /* Dose equivalent */
77 {/* name */ "NSV", /* unit */ SCPI_UNIT_SIEVERT, /* mult */ 1e-9},
78 {/* name */ "USV", /* unit */ SCPI_UNIT_SIEVERT, /* mult */ 1e-6},
79 {/* name */ "MSV", /* unit */ SCPI_UNIT_SIEVERT, /* mult */ 1e-3},
80 {/* name */ "SV", /* unit */ SCPI_UNIT_SIEVERT, /* mult */ 1},
81 {/* name */ "KSV", /* unit */ SCPI_UNIT_SIEVERT, /* mult */ 1e3},
82 {/* name */ "MASV", /* unit */ SCPI_UNIT_SIEVERT, /* mult */ 1e6},
83
84 /* Energy */
85 {/* name */ "EV", /* unit */ SCPI_UNIT_ELECTRONVOLT, /* mult */ 1},
86 {/* name */ "KEV", /* unit */ SCPI_UNIT_ELECTRONVOLT, /* mult */ 1e3},
87 {/* name */ "MAEV", /* unit */ SCPI_UNIT_ELECTRONVOLT, /* mult */ 1e6},
88 {/* name */ "GEV", /* unit */ SCPI_UNIT_ELECTRONVOLT, /* mult */ 1e9},
89 {/* name */ "TEV", /* unit */ SCPI_UNIT_ELECTRONVOLT, /* mult */ 1e12},
90
91 /* Mass */
92 {/* name */ "U", /* unit */ SCPI_UNIT_ATOMIC_MASS, /* mult */ 1},
93#endif /* USE_UNITS_PARTICLES */
94
95#if USE_UNITS_ANGLE
96 /* Angle */
97 {/* name */ "DEG", /* unit */ SCPI_UNIT_DEGREE, /* mult */ 1},
98 {/* name */ "GON", /* unit */ SCPI_UNIT_GRADE, /* mult */ 1},
99 {/* name */ "MNT", /* unit */ SCPI_UNIT_DEGREE, /* mult */ 1. / 60.},
100 {/* name */ "RAD", /* unit */ SCPI_UNIT_RADIAN, /* mult */ 1},
101 {/* name */ "SEC", /* unit */ SCPI_UNIT_DEGREE, /* mult */ 1. / 3600.},
102 {/* name */ "REV", /* unit */ SCPI_UNIT_REVOLUTION, /* mult */ 1},
103 {/* name */ "RS", /* unit */ SCPI_UNIT_STERADIAN, /* mult */ 1},
104#endif /* USE_UNITS_ANGLE */
105
106#if USE_UNITS_ELECTRIC
107 /* Electric - capacitance */
108 {/* name */ "PF", /* unit */ SCPI_UNIT_FARAD, /* mult */ 1e-12},
109 {/* name */ "NF", /* unit */ SCPI_UNIT_FARAD, /* mult */ 1e-9},
110 {/* name */ "UF", /* unit */ SCPI_UNIT_FARAD, /* mult */ 1e-6},
111 {/* name */ "MF", /* unit */ SCPI_UNIT_FARAD, /* mult */ 1e-3},
112 {/* name */ "F", /* unit */ SCPI_UNIT_FARAD, /* mult */ 1},
113
114 /* Electric - current */
115 {/* name */ "UA", /* unit */ SCPI_UNIT_AMPER, /* mult */ 1e-6},
116 {/* name */ "MA", /* unit */ SCPI_UNIT_AMPER, /* mult */ 1e-3},
117 {/* name */ "A", /* unit */ SCPI_UNIT_AMPER, /* mult */ 1},
118 {/* name */ "KA", /* unit */ SCPI_UNIT_AMPER, /* mult */ 1e3},
119
120 /* Electric - potential */
121 {/* name */ "UV", /* unit */ SCPI_UNIT_VOLT, /* mult */ 1e-6},
122 {/* name */ "MV", /* unit */ SCPI_UNIT_VOLT, /* mult */ 1e-3},
123 {/* name */ "V", /* unit */ SCPI_UNIT_VOLT, /* mult */ 1},
124 {/* name */ "KV", /* unit */ SCPI_UNIT_VOLT, /* mult */ 1e3},
125
126 /* Electric - resistance */
127 {/* name */ "OHM", /* unit */ SCPI_UNIT_OHM, /* mult */ 1},
128 {/* name */ "KOHM", /* unit */ SCPI_UNIT_OHM, /* mult */ 1e3},
129 {/* name */ "MOHM", /* unit */ SCPI_UNIT_OHM, /* mult */ 1e6},
130
131 /* Inductance */
132 {/* name */ "UH", /* unit */ SCPI_UNIT_HENRY, /* mult */ 1e-6},
133 {/* name */ "MH", /* unit */ SCPI_UNIT_HENRY, /* mult */ 1e-3},
134 {/* name */ "H", /* unit */ SCPI_UNIT_HENRY, /* mult */ 1},
135#endif /* USE_UNITS_ELECTRIC */
136
137#if USE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE
138 /* Electric - charge */
139 {/* name */ "C", /* unit */ SCPI_UNIT_COULOMB, /* mult */ 1},
140
141 /* Electric - conductance */
142 {/* name */ "USIE", /* unit */ SCPI_UNIT_SIEMENS, /* mult */ 1e-6},
143 {/* name */ "MSIE", /* unit */ SCPI_UNIT_SIEMENS, /* mult */ 1e-3},
144 {/* name */ "SIE", /* unit */ SCPI_UNIT_SIEMENS, /* mult */ 1},
145#endif /* USE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE */
146
147#if USE_UNITS_ENERGY_FORCE_MASS
148 /* Energy */
149 {/* name */ "J", /* unit */ SCPI_UNIT_JOULE, /* mult */ 1},
150 {/* name */ "KJ", /* unit */ SCPI_UNIT_JOULE, /* mult */ 1e3},
151 {/* name */ "MAJ", /* unit */ SCPI_UNIT_JOULE, /* mult */ 1e6},
152
153 /* Force */
154 {/* name */ "N", /* unit */ SCPI_UNIT_NEWTON, /* mult */ 1},
155 {/* name */ "KN", /* unit */ SCPI_UNIT_NEWTON, /* mult */ 1e3},
156
157 /* Pressure */
158 {/* name */ "ATM", /* unit */ SCPI_UNIT_ATMOSPHERE, /* mult */ 1},
159 {/* name */ "INHG", /* unit */ SCPI_UNIT_INCH_OF_MERCURY, /* mult */ 1},
160 {/* name */ "MMHG", /* unit */ SCPI_UNIT_MM_OF_MERCURY, /* mult */ 1},
161
162 {/* name */ "TORR", /* unit */ SCPI_UNIT_TORT, /* mult */ 1},
163 {/* name */ "BAR", /* unit */ SCPI_UNIT_BAR, /* mult */ 1},
164
165 {/* name */ "PAL", /* unit */ SCPI_UNIT_PASCAL, /* mult */ 1},
166 {/* name */ "KPAL", /* unit */ SCPI_UNIT_PASCAL, /* mult */ 1e3},
167 {/* name */ "MAPAL", /* unit */ SCPI_UNIT_PASCAL, /* mult */ 1e6},
168
169 /* Viscosity kinematic */
170 {/* name */ "ST", /* unit */ SCPI_UNIT_STROKES, /* mult */ 1},
171
172 /* Viscosity dynamic */
173 {/* name */ "P", /* unit */ SCPI_UNIT_POISE, /* mult */ 1},
174
175 /* Viscosity dynamic */
176 {/* name */ "L", /* unit */ SCPI_UNIT_LITER, /* mult */ 1},
177
178 /* Mass */
179 {/* name */ "MG", /* unit */ SCPI_UNIT_KILOGRAM, /* mult */ 1e-6},
180 {/* name */ "G", /* unit */ SCPI_UNIT_KILOGRAM, /* mult */ 1e-3},
181 {/* name */ "KG", /* unit */ SCPI_UNIT_KILOGRAM, /* mult */ 1},
182 {/* name */ "TNE", /* unit */ SCPI_UNIT_KILOGRAM, /* mult */ 1000},
183#endif /* USE_UNITS_ENERGY_FORCE_MASS */
184
185#if USE_UNITS_FREQUENCY
186 /* Frequency */
187 {/* name */ "HZ", /* unit */ SCPI_UNIT_HERTZ, /* mult */ 1},
188 {/* name */ "KHZ", /* unit */ SCPI_UNIT_HERTZ, /* mult */ 1e3},
189 {/* name */ "MHZ", /* unit */ SCPI_UNIT_HERTZ, /* mult */ 1e6},
190 {/* name */ "GHZ", /* unit */ SCPI_UNIT_HERTZ, /* mult */ 1e9},
191#endif /* USE_UNITS_FREQUENCY */
192
193#if USE_UNITS_DISTANCE
194 /* Length */
195 {/* name */ "ASU", /* unit */ SCPI_UNIT_ASTRONOMIC_UNIT, /* mult */ 1},
196 {/* name */ "PRS", /* unit */ SCPI_UNIT_PARSEC, /* mult */ 1},
197#if USE_UNITS_IMPERIAL
198 {/* name */ "IN", /* unit */ SCPI_UNIT_INCH, /* mult */ 1},
199 {/* name */ "FT", /* unit */ SCPI_UNIT_FOOT, /* mult */ 1},
200 {/* name */ "MI", /* unit */ SCPI_UNIT_MILE, /* mult */ 1},
201 {/* name */ "NAMI", /* unit */ SCPI_UNIT_NAUTICAL_MILE, /* mult */ 1},
202#endif /* USE_UNITS_IMPERIAL */
203
204 {/* name */ "NM", /* unit */ SCPI_UNIT_METER, /* mult */ 1e-9},
205 {/* name */ "UM", /* unit */ SCPI_UNIT_METER, /* mult */ 1e-6},
206 {/* name */ "MM", /* unit */ SCPI_UNIT_METER, /* mult */ 1e-3},
207 {/* name */ "M", /* unit */ SCPI_UNIT_METER, /* mult */ 1},
208 {/* name */ "KM", /* unit */ SCPI_UNIT_METER, /* mult */ 1e3},
209#endif /* USE_UNITS_DISTANCE */
210
211#if USE_UNITS_LIGHT
212 /* Illuminance */
213 {/* name */ "LX", /* unit */ SCPI_UNIT_LUX, /* mult */ 1},
214
215 /* Luminous flux */
216 {/* name */ "LM", /* unit */ SCPI_UNIT_LUMEN, /* mult */ 1},
217
218 /* Luminous intensity */
219 {/* name */ "CD", /* unit */ SCPI_UNIT_CANDELA, /* mult */ 1},
220#endif /* USE_UNITS_LIGHT */
221
222#if USE_UNITS_MAGNETIC
223 /* Magnetic flux */
224 {/* name */ "WB", /* unit */ SCPI_UNIT_WEBER, /* mult */ 1},
225
226 /* Magnetic induction */
227 {/* name */ "NT", /* unit */ SCPI_UNIT_TESLA, /* mult */ 1e-9},
228 {/* name */ "UT", /* unit */ SCPI_UNIT_TESLA, /* mult */ 1e-6},
229 {/* name */ "MT", /* unit */ SCPI_UNIT_TESLA, /* mult */ 1e-3},
230 {/* name */ "T", /* unit */ SCPI_UNIT_TESLA, /* mult */ 1},
231#endif /* USE_UNITS_MAGNETIC */
232
233#if USE_UNITS_POWER
234 /* Power */
235 {/* name */ "W", /* unit */ SCPI_UNIT_WATT, /* mult */ 1},
236 {/* name */ "DBM", /* unit */ SCPI_UNIT_DBM, /* mult */ 1},
237 {/* name */ "DBMW", /* unit */ SCPI_UNIT_DBM, /* mult */ 1},
238#endif /* USE_UNITS_POWER */
239
240#if USE_UNITS_RATIO
241 /* Ratio */
242 {/* name */ "DB", /* unit */ SCPI_UNIT_DECIBEL, /* mult */ 1},
243 {/* name */ "PCT", /* unit */ SCPI_UNIT_UNITLESS, /* mult */ 1e-2},
244 {/* name */ "PPM", /* unit */ SCPI_UNIT_UNITLESS, /* mult */ 1e-6},
245#endif /* USE_UNITS_RATIO */
246
247#if USE_UNITS_TEMPERATURE
248 /* Temperature */
249 {/* name */ "CEL", /* unit */ SCPI_UNIT_CELSIUS, /* mult */ 1},
250#if USE_UNITS_IMPERIAL
251 {/* name */ "FAR", /* unit */ SCPI_UNIT_FAGRENHEIT, /* mult */ 1},
252#endif /* USE_UNITS_IMPERIAL */
253 {/* name */ "K", /* unit */ SCPI_UNIT_KELVIN, /* mult */ 1},
254#endif /* USE_UNITS_TEMPERATURE */
255
256#if USE_UNITS_TIME
257 /* Time */
258 {/* name */ "PS", /* unit */ SCPI_UNIT_SECOND, /* mult */ 1e-12},
259 {/* name */ "NS", /* unit */ SCPI_UNIT_SECOND, /* mult */ 1e-9},
260 {/* name */ "US", /* unit */ SCPI_UNIT_SECOND, /* mult */ 1e-6},
261 {/* name */ "MS", /* unit */ SCPI_UNIT_SECOND, /* mult */ 1e-3},
262 {/* name */ "S", /* unit */ SCPI_UNIT_SECOND, /* mult */ 1},
263 {/* name */ "MIN", /* unit */ SCPI_UNIT_SECOND, /* mult */ 60},
264 {/* name */ "HR", /* unit */ SCPI_UNIT_SECOND, /* mult */ 3600},
265 {/* name */ "D", /* unit */ SCPI_UNIT_DAY, /* mult */ 1},
266 {/* name */ "ANN", /* unit */ SCPI_UNIT_YEAR, /* mult */ 1},
267#endif /* USE_UNITS_TIME */
268
270};
271
272/*
273 * Special number values definition
274 */
275const scpi_choice_def_t scpi_special_numbers_def[] = {
276 {/* name */ "MINimum", /* type */ SCPI_NUM_MIN},
277 {/* name */ "MAXimum", /* type */ SCPI_NUM_MAX},
278 {/* name */ "DEFault", /* type */ SCPI_NUM_DEF},
279 {/* name */ "UP", /* type */ SCPI_NUM_UP},
280 {/* name */ "DOWN", /* type */ SCPI_NUM_DOWN},
281 {/* name */ "NAN", /* type */ SCPI_NUM_NAN},
282 {/* name */ "INFinity", /* type */ SCPI_NUM_INF},
283 {/* name */ "NINF", /* type */ SCPI_NUM_NINF},
284 {/* name */ "AUTO", /* type */ SCPI_NUM_AUTO},
286};
287
295static const scpi_unit_def_t * translateUnit(const scpi_unit_def_t * units, const char * unit, size_t len) {
296 int i;
297
298 if (units == NULL) {
299 return NULL;
300 }
301
302 for (i = 0; units[i].name != NULL; i++) {
303 if (compareStr(unit, len, units[i].name, strlen(units[i].name))) {
304 return &units[i];
305 }
306 }
307
308 return NULL;
309}
310
317static const char * translateUnitInverse(const scpi_unit_def_t * units, const scpi_unit_t unit) {
318 int i;
319
320 if (units == NULL) {
321 return NULL;
322 }
323
324 for (i = 0; units[i].name != NULL; i++) {
325 if ((units[i].unit == unit) && (units[i].mult == 1)) {
326 return units[i].name;
327 }
328 }
329
330 return NULL;
331}
332
341static scpi_bool_t transformNumber(scpi_t * context, const char * unit, size_t len, scpi_number_t * value) {
342 size_t s;
343 const scpi_unit_def_t * unitDef;
344 s = skipWhitespace(unit, len);
345
346 if (s == len) {
347 value->unit = SCPI_UNIT_NONE;
348 return TRUE;
349 }
350
351 unitDef = translateUnit(context->units, unit + s, len - s);
352
353 if (unitDef == NULL) {
355 return FALSE;
356 }
357
358 value->content.value *= unitDef->mult;
359 value->unit = unitDef->unit;
360
361 return TRUE;
362}
363
371scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory) {
372 scpi_token_t token;
373 lex_state_t state;
374 scpi_parameter_t param;
375 scpi_bool_t result;
376 int32_t tag;
377
378 if (!value) {
380 return FALSE;
381 }
382
383 result = SCPI_Parameter(context, &param, mandatory);
384
385 if (!result) {
386 return result;
387 }
388
389 state.buffer = param.ptr;
390 state.pos = state.buffer;
391 state.len = param.len;
392
393 switch (param.type) {
400 value->unit = SCPI_UNIT_NONE;
401 value->special = FALSE;
402 result = TRUE;
403 break;
404 default:
405 break;
406 }
407
408 switch (param.type) {
412 value->base = 10;
413 break;
415 value->base = 2;
416 break;
418 value->base = 16;
419 break;
421 value->base = 8;
422 break;
423 default:
424 break;
425 }
426
427 switch (param.type) {
429 SCPI_ParamToDouble(context, &param, &(value->content.value));
430 break;
432 SCPI_ParamToDouble(context, &param, &(value->content.value));
433 break;
435 SCPI_ParamToDouble(context, &param, &(value->content.value));
436 break;
438 SCPI_ParamToDouble(context, &param, &(value->content.value));
439 break;
441 scpiLex_DecimalNumericProgramData(&state, &token);
442 scpiLex_WhiteSpace(&state, &token);
443 scpiLex_SuffixProgramData(&state, &token);
444
445 SCPI_ParamToDouble(context, &param, &(value->content.value));
446
447 result = transformNumber(context, token.ptr, token.len, value);
448 break;
450 scpiLex_WhiteSpace(&state, &token);
451 scpiLex_CharacterProgramData(&state, &token);
452
453 /* convert string to special number type */
454 result = SCPI_ParamToChoice(context, &token, special, &tag);
455
456 value->special = TRUE;
457 value->content.tag = tag;
458
459 break;
460 default:
461 result = FALSE;
462 }
463
464 return result;
465}
466
475size_t SCPI_NumberToStr(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, char * str, size_t len) {
476 const char * type;
477 const char * unit;
478 size_t result;
479
480 if (!value || !str || len==0) {
481 return 0;
482 }
483
484 if (value->special) {
485 if (SCPI_ChoiceToName(special, value->content.tag, &type)) {
486 strncpy(str, type, len);
487 result = SCPIDEFINE_strnlen(str, len - 1);
488 str[result] = '\0';
489 return result;
490 } else {
491 str[0] = '\0';
492 return 0;
493 }
494 }
495
496 result = SCPI_DoubleToStr(value->content.value, str, len);
497
498 if (result + 1 < len) {
499 unit = translateUnitInverse(context->units, value->unit);
500
501 if (unit) {
502 strncat(str, " ", len - result);
503 if (result + 2 < len) {
504 strncat(str, unit, len - result - 1);
505 }
506 result = strlen(str);
507 }
508 }
509
510 return result;
511}
#define SCPIDEFINE_strnlen(s, l)
Definition config.h:174
void SCPI_ErrorPush(scpi_t *context, int16_t err)
Definition error.c:202
@ SCPI_ERROR_SYSTEM_ERROR
Definition error.h:193
@ SCPI_ERROR_INVALID_SUFFIX
Definition error.h:193
int scpiLex_DecimalNumericProgramData(lex_state_t *state, scpi_token_t *token)
Definition lexer.c:508
int scpiLex_SuffixProgramData(lex_state_t *state, scpi_token_t *token)
Definition lexer.c:533
int scpiLex_CharacterProgramData(lex_state_t *state, scpi_token_t *token)
Definition lexer.c:451
int scpiLex_WhiteSpace(lex_state_t *state, scpi_token_t *token)
Definition lexer.c:330
scpi_bool_t SCPI_ChoiceToName(const scpi_choice_def_t *options, int32_t tag, const char **text)
Definition parser.c:1349
scpi_bool_t SCPI_ParamToChoice(scpi_t *context, scpi_parameter_t *parameter, const scpi_choice_def_t *options, int32_t *value)
Definition parser.c:1314
scpi_bool_t SCPI_ParamToDouble(scpi_t *context, scpi_parameter_t *parameter, double *value)
Definition parser.c:999
scpi_bool_t SCPI_Parameter(scpi_t *context, scpi_parameter_t *parameter, scpi_bool_t mandatory)
Definition parser.c:774
bool scpi_bool_t
Definition types.h:67
enum _scpi_unit_t scpi_unit_t
Definition types.h:292
#define SCPI_CHOICE_LIST_END
Definition types.h:320
@ SCPI_UNIT_YEAR
Definition types.h:287
@ SCPI_UNIT_CANDELA
Definition types.h:269
@ SCPI_UNIT_UNITLESS
Definition types.h:283
@ SCPI_UNIT_COULOMB
Definition types.h:255
@ SCPI_UNIT_BECQUEREL
Definition types.h:246
@ SCPI_UNIT_NEWTON
Definition types.h:259
@ SCPI_UNIT_FARAD
Definition types.h:254
@ SCPI_UNIT_INCH_OF_MERCURY
Definition types.h:277
@ SCPI_UNIT_HERTZ
Definition types.h:241
@ SCPI_UNIT_ATMOSPHERE
Definition types.h:276
@ SCPI_UNIT_FAGRENHEIT
Definition types.h:284
@ SCPI_UNIT_JOULE
Definition types.h:258
@ SCPI_UNIT_ATOMIC_MASS
Definition types.h:272
@ SCPI_UNIT_MILE
Definition types.h:266
@ SCPI_UNIT_STERADIAN
Definition types.h:252
@ SCPI_UNIT_TORT
Definition types.h:280
@ SCPI_UNIT_DBM
Definition types.h:275
@ SCPI_UNIT_FOOT
Definition types.h:264
@ SCPI_UNIT_BAR
Definition types.h:281
@ SCPI_UNIT_DECIBEL
Definition types.h:282
@ SCPI_UNIT_SIEVERT
Definition types.h:253
@ SCPI_UNIT_KELVIN
Definition types.h:285
@ SCPI_UNIT_GRAY
Definition types.h:245
@ SCPI_UNIT_RADIAN
Definition types.h:250
@ SCPI_UNIT_CELSIUS
Definition types.h:242
@ SCPI_UNIT_INCH
Definition types.h:263
@ SCPI_UNIT_OHM
Definition types.h:240
@ SCPI_UNIT_REVOLUTION
Definition types.h:251
@ SCPI_UNIT_LUX
Definition types.h:260
@ SCPI_UNIT_NAUTICAL_MILE
Definition types.h:267
@ SCPI_UNIT_ASTRONOMIC_UNIT
Definition types.h:262
@ SCPI_UNIT_MOLE
Definition types.h:247
@ SCPI_UNIT_DEGREE
Definition types.h:248
@ SCPI_UNIT_VOLT
Definition types.h:238
@ SCPI_UNIT_DAY
Definition types.h:286
@ SCPI_UNIT_POISE
Definition types.h:289
@ SCPI_UNIT_HENRY
Definition types.h:261
@ SCPI_UNIT_SIEMENS
Definition types.h:256
@ SCPI_UNIT_KILOGRAM
Definition types.h:273
@ SCPI_UNIT_GRADE
Definition types.h:249
@ SCPI_UNIT_TESLA
Definition types.h:271
@ SCPI_UNIT_ELECTRONVOLT
Definition types.h:257
@ SCPI_UNIT_AMPER
Definition types.h:239
@ SCPI_UNIT_LUMEN
Definition types.h:268
@ SCPI_UNIT_SECOND
Definition types.h:243
@ SCPI_UNIT_PARSEC
Definition types.h:265
@ SCPI_UNIT_MM_OF_MERCURY
Definition types.h:278
@ SCPI_UNIT_WEBER
Definition types.h:270
@ SCPI_UNIT_WATT
Definition types.h:274
@ SCPI_UNIT_PASCAL
Definition types.h:279
@ SCPI_UNIT_LITER
Definition types.h:290
@ SCPI_UNIT_STROKES
Definition types.h:288
@ SCPI_UNIT_METER
Definition types.h:244
@ SCPI_UNIT_NONE
Definition types.h:237
#define TRUE
Definition types.h:63
#define FALSE
Definition types.h:60
#define SCPI_UNITS_LIST_END
Definition types.h:299
@ SCPI_NUM_NINF
Definition types.h:311
@ SCPI_NUM_INF
Definition types.h:310
@ SCPI_NUM_MIN
Definition types.h:304
@ SCPI_NUM_DEF
Definition types.h:306
@ SCPI_NUM_NAN
Definition types.h:309
@ SCPI_NUM_UP
Definition types.h:307
@ SCPI_NUM_DOWN
Definition types.h:308
@ SCPI_NUM_AUTO
Definition types.h:312
@ SCPI_NUM_MAX
Definition types.h:305
@ SCPI_TOKEN_PROGRAM_MNEMONIC
Definition types.h:156
@ SCPI_TOKEN_BINNUM
Definition types.h:155
@ SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX
Definition types.h:158
@ SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA
Definition types.h:157
@ SCPI_TOKEN_OCTNUM
Definition types.h:154
@ SCPI_TOKEN_HEXNUM
Definition types.h:153
scpi_token_t scpi_parameter_t
Definition types.h:362
static scpi_bool_t transformNumber(scpi_t *context, const char *unit, size_t len, scpi_number_t *value)
Definition units.c:341
const scpi_choice_def_t scpi_special_numbers_def[]
Definition units.c:275
scpi_bool_t SCPI_ParamNumber(scpi_t *context, const scpi_choice_def_t *special, scpi_number_t *value, scpi_bool_t mandatory)
Definition units.c:371
static const char * translateUnitInverse(const scpi_unit_def_t *units, const scpi_unit_t unit)
Definition units.c:317
size_t SCPI_NumberToStr(scpi_t *context, const scpi_choice_def_t *special, scpi_number_t *value, char *str, size_t len)
Definition units.c:475
static const scpi_unit_def_t * translateUnit(const scpi_unit_def_t *units, const char *unit, size_t len)
Definition units.c:295
const scpi_unit_def_t scpi_units_def[]
Definition units.c:65
size_t skipWhitespace(const char *cmd, size_t len)
Definition utils.c:410
size_t SCPI_DoubleToStr(double val, char *str, size_t len)
Definition utils.c:263
scpi_bool_t compareStr(const char *str1, size_t len1, const char *str2, size_t len2)
Definition utils.c:348
Conversion routines and string manipulation routines.