Legrand / Raritan / Server Technology Xerus™ JSON-RPC API
Loading...
Searching...
No Matches
GatewaySensorManager.idl
1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright 2022 Raritan Inc. All rights reserved.
4 */
5
6#ifndef __PERIPHERAL_GATEWAY_SENSOR_MANAGER_IDL__
7#define __PERIPHERAL_GATEWAY_SENSOR_MANAGER_IDL__
8
9#include <Sensor.idl>
10#include <NumericSensor.idl>
11#include <Event.idl>
12#include <ModbusCfg.idl>
13
14/**
15 * Peripheral Devices
16 */
17module peripheral {
18
19 /** Gateway Sensor Configuration Interface */
21
22 /*
23 To define a gateway sensor the following steps are required:
24
25 1) Create a [Numeric|State|Switch]SensorClass with a unique
26 *classId* and metadata.
27 This specification can be used for one or more gateway sensors.
28
29 2) Create a Remote[ModbusRTU|ModbusTCP|...]Device with a unique
30 *deviceId* and all information required to connect a remote
31 device that provides access to sensors and actuators to be associated
32 to one or more gateway sensors.
33
34 3) Create a ValueEncoding, e.g. ModbusValueEncoding[Bit|8|16|32|64],
35 with a unique *encodingId* and all information needed to correctly
36 interpret a received byte sequence.
37
38 Besides word width, masking and encoding (bool/int/uint/float) there
39 is also the possibility to define rules that interpret error codes and
40 special values.
41
42 A rule consists of a recognition feature (e.g. InterpretationRuleRAW,
43 InterpretationRuleIEEE754INF) and an interpretation (e.g. IGNORE,
44 NUMERIC_INVALID).
45
46 This specification can be used for one or more gateway sensors.
47
48 4) Create a [Modbus|...]Sensor, with references to configurations described
49 above: *classId*, *deviceId* and *encodingId*. The unique *sensorId* will be
50 generated if not set. Additionaly, [Modbus|...]Sensor has information necessary
51 to address the sensor on the referenced RemoteDevice.
52
53 5) Store all created classes using setConfiguration()
54
55
56 Example A) PMMC-1000
57
58 1) Create NumericSensorClass with
59 classId = "Temperature"
60 metaData = {
61 type = { NUMERIC, TEMPERATURE, DEGREE_CELSIUS },
62 decdigits = 1,
63 range = { -55, +85 },
64 accuracy = 0.1,
65 resolution = 0.1,
66 tolerance = 0,
67 noiseThreshold = -55,
68 thresholdCaps = { true, true, true, true }
69 }
70 defaultThresholds = {
71 upperCriticalActive = true,
72 upperCritical = 44.0,
73 upperWarningActive = true,
74 upperWarning = 37.0,
75 lowerWarningActive = true,
76 lowerWarning = 1.0,
77 lowerCriticalActive = true,
78 lowerCritical = -11,
79 assertionTimeout = 3,
80 deassertionHysteresis = 2.0F
81 }
82 preferCommonThresholds = false
83
84 2) Create RemoteModbusRTUDevice with
85 deviceId = "PMMC"
86 busInterface = "REMOTE-HUB-1"
87 busSettings = {38400, NONE, 8, 1}
88 unitId = 247;
89 detectionIdentifiers = [ { VENDOR_NAME, "Raritan" },
90 { PRODUCT_CODE, "iPDU" }
91 { REVISION, "3\\.6.*"}
92 ]
93
94 3) Create ModbusValueEncoding32 with
95 encodingId = "IEEE754_32"
96 endianness = MODBUS_BIG_ENDIAN
97 type = IEEE754
98 interpretationRules = [
99 InterpretationRuleIEEE754NAN {
100 interpretation = INVALID
101 }
102 ]
103
104 4) Create ModbusSensor with
105 classId = "Temperature"
106 deviceId = "PMMC"
107 encodingId = "IEEE754_32"
108 function = HOLDING_REGISTER;
109 regAddr = 0x812
110 defaultName = "Room temperature"
111
112
113 Example B) Current sensor and check product code in INPUT_REGISTER 0
114
115 1) Create NumericSensorClass with
116 classId = "Current"
117 metaData = {
118 type = { NUMERIC, CURRENT, AMPERE },
119 decdigits = 2,
120 range = { 0, 100 },
121 accuracy = 0.01,
122 resolution = 0.01,
123 tolerance = 0,
124 noiseThreshold = 0.01,
125 thresholdCaps = { true, true, true, true }
126 }
127
128 2) Create RemoteModbusRTUDevice with
129 deviceId = "GW"
130 busInterface = "USB-2"
131 busSettings = {9600, NONE, 8, 1}
132 unitId = 1;
133
134 3) Create ModbusValueEncoding32 with
135 encodingId = "IEEE754_32_MIXED_LE"
136 endianness = MODBUS_LITTLE_ENDIAN
137 type = IEEE754
138 interpretationRules = [
139 InterpretationRuleRAW {
140 value = 0x00800000 # FLT_MIN
141 interpretation = IGNORE
142 ignoreTimeout = 60 # unavailable after 60 seconds
143 },
144 InterpretationRuleRAW {
145 value = 0x7f7fffff # FLT_MAX
146 interpretation = UNAVAILABLE
147 }
148 ]
149
150 Create ModbusValueEncoding16 with
151 encodingId = "GW_PRODUCT_UINT_16"
152 type = UINT
153 interpretationRules = [
154 InterpretationRuleRAW {
155 value = 1200 # product code
156 invertCondition = true
157 interpretation = REJECT_DEVICE # device detection failed
158 },
159 ]
160
161 4) Create ModbusSensor with
162 classId = "Current"
163 deviceId = "GW"
164 encodingId = "IEEE754_32_MIXED_LE"
165 function = INPUT_REGISTER;
166 regAddr = 0xD
167 defaultName = "AC Current ch2"
168
169 Create ModbusSensor with
170 classId = "" # used for device detection only
171 deviceId = "GW"
172 encodingId = "GW_PRODUCT_UINT_16"
173 function = INPUT_REGISTER;
174 regAddr = 0
175
176
177 Example C) Energy Meter
178
179 1) Create NumericSensorClass with
180 classId = "Energy"
181 metaData = {
182 type = { NUMERIC, POWER, WATT },
183 decdigits = 1,
184 range = { 0, 9999999 },
185 accuracy = 0.1,
186 resolution = 0.1,
187 tolerance = 0,
188 noiseThreshold = 0,
189 thresholdCaps = { }
190 }
191
192 2) Create RemoteModbusRTUDevice with
193 deviceId = "EX4"
194 busInterface = "REMOTE-HUB-1"
195 busSettings = {9600, NONE, 8, 1}
196 unitId = 4;
197
198 3) Create ModbusValueEncoding32 with
199 encodingId = "UINT_24_MIXED_LE"
200 endianness = MODBUS_LITTLE_ENDIAN
201 mask = "0x00FFFFFF"
202 type = UINT
203 scalingFactor = 10.0;
204
205 4) Create ModbusSensor with
206 classId = "Energy"
207 deviceId = "EX4"
208 encodingId = "UINT_24_MIXED_LE"
209 function = HOLDING_REGISTER;
210 regAddr = 0
211 defaultName = "Energy Meter"
212 */
213
214
215 /* ======================= SENSOR CLASSES ========================= */
216
217 /**
218 * @brief Specification of sensor class that stores sensor properties
219 *
220 * Before an instance of Sensor can be created,
221 * an instance of SensorClass must be present.
222 * The Sensor locates the corresponding SensorClass
223 * using the sensor class id `classId`.
224 */
225 valueobject SensorClass {
226 string classId; ///< sensor class id
227 };
228
229 /**
230 * @brief Sensor class that stores numeric sensor properties
231 */
232 valueobject NumericSensorClass extends SensorClass {
233 /**
234 * numeric sensor type, ranges, etc.
235 */
237
238 /**
239 * threshold values may be used initially and as default threshold values,
240 * depending on the value of the preferCommonThresholds field
241 */
243
244 boolean preferCommonThresholds; ///< if true, use common default thresholds if available, otherwise use the value of the defaultThresholds field
245 };
246
247 /**
248 * @brief Sensor class that stores state sensor properties
249 */
250 valueobject StateSensorClass extends SensorClass {
251 sensors.Sensor.TypeSpec type; ///< state sensor type
252 };
253
254 /**
255 * @brief Sensor class that switch properties
256 */
257 valueobject SwitchSensorClass extends StateSensorClass { };
258
259
260 /* ======================= REMOTE DEVICES ========================= */
261
262 /**
263 * @brief Specification of a remote device that provides access to sensors
264 *
265 * It contains all the information required to connect a remote
266 * device that provides access to sensors and actuators to be connected
267 * to one or more gateway sensors.
268 *
269 * Before an instance of Sensor can be created, an instance
270 * of RemoteDevice must be present. The Sensor locates the
271 * corresponding RemoteDevice using the remote device id `deviceId`.
272 */
273 valueobject RemoteDevice {
274 string deviceId; ///< remote device id
275 boolean disabled; ///< prevents usage of all sensor specifications which reference this device
276 string name; ///< human readable remote device name
277 int timeoutMs; ///< communication access timeout, 0 = default
278 int retry; ///< communication retry count, 0 = default
279 };
280
281 constant int MODBUS_VENDOR_NAME = 0;
282 constant int MODBUS_PRODUCT_CODE = 1;
283 constant int MODBUS_REVISION = 2;
284 constant int MODBUS_VENDOR_URL = 3;
285 constant int MODBUS_PRODUCT_NAME = 4;
286 constant int MODBUS_MODEL_NAME = 5;
287 constant int MODBUS_APP_NAME = 6;
288
289 valueobject RemoteModbusDevice extends RemoteDevice {
290 map<int, string> detectionIdentifiers; ///< list of expected device identifiers
291 int unitId; ///< modbus server address
292 /** @brief list of unsupported modbus function codes (FC)
293 *
294 * This information is used to select a supported way for communication,
295 * if more than one way is available. If there is no flexibility, the list is ignored.
296 * Therefore, some entries may have no effect.
297 *
298 * Examples:
299 * - FC 43 (Read Device Identification) is used without regard to this list,
300 * as there is no alternative way if detectionIdentifiers is to be used
301 * - FC 22 (Masked Register Write) is only used if the support is known,
302 * otherwise FC 03 + FC 06 (or FC 16 if not known as unsupported) will be used
303 */
305 };
306
308 /**
309 * @brief rs485 interface used for modbus communication
310 *
311 * Supported values:
312 *
313 * (1) with SRC-080X, the REMOTE HUB interfaces are supported, possible values are:
314 * - "REMOTE-HUB-1" or "sensorhub0-rs485" (deprecated) mean port "REMOTE HUB 1"
315 * - "REMOTE-HUB-2" or "sensorhub1-rs485" (deprecated) mean port "REMOTE HUB 2"
316 *
317 * (2) with Raritan Modbus/RS-485 dongle "USB-MOD-DONGLE", possible values are:
318 * - "USB<topo>": where <topo> contains the USB port number and possibly the topology of USB hubs
319 * - "USB-2" means dongle connected to PDU USB port "USB A 2"
320 * - "USB-1-2-3" means dongle is connected to a first USB hub at port 3,
321 * and the first USB hub is connected to a second USB hub at port 2,
322 * and the second USB hub is connected to PDU USB port "USB A 1"
323 * - "<serial>": where <serial> is the serial number of USB dongle, according to the label
324 */
326 ModbusCfg.SerialSettings busSettings; ///< interface settings
327 int interframeDelayDeciChars; ///< (== 0) -> default, (< 0) -> no delay, (> 0) -> e.g. 35 means 3.5 chars
328 };
329
331 string ipAddress; ///< modbus device ip address
332 int tcpPort; ///< modbus tcp port
333 };
334
335 valueobject RemoteSnmpDevice extends RemoteDevice {
336 string host; ///< host
337 };
338
340 string community; ///< community string for v1/v2c
341 };
342
343 enumeration SnmpSecurityLevel {
344 NO_AUTH_NO_PRIV, ///< no authentication, no privacy
345 AUTH_NO_PRIV, ///< authentication, no privacy
346 AUTH_PRIV ///< authentication, privacy
347 };
348
349 enumeration SnmpAuthProtocol {
350 MD5, ///< MD5
351 SHA1, ///< SHA-1
352 SHA224, ///< SHA-224
353 SHA256, ///< SHA-256
354 SHA384, ///< SHA-384
355 SHA512 ///< SHA-512
356 };
357
358 enumeration SnmpPrivProtocol {
359 DES, ///< DES
360 AES128, ///< AES-128
361 AES192, ///< AES-192
362 AES256, ///< AES-256
363 AES192_3DES, ///< AES-192 with key extension (3DES)
364 AES256_3DES ///< AES-256 with key extension (3DES)
365 };
366
368 string user; ///< security user name
369 SnmpSecurityLevel level; ///< security level (noAuthNoPriv|authNoPriv|authPriv)
370 SnmpAuthProtocol authProtocol; ///< authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
371 string authPassphrase; ///< authentication protocol passphrase
372 SnmpPrivProtocol privacyProtocol; ///< privacy protocol (DES|AES|AES-192|AES-256)
373 string privacyPassphrase; ///< privacy protocol pass phrase
374 };
375
376 /* ======================= VALUE ENCODING ========================= */
377
378 /**
379 * interpretation of binary values
380 */
381 enumeration EncodingType {
382 BOOL, ///< boolean
383 INT, ///< signed integer of a size specified in ValueEncoding as two's complement
384 UINT, ///< unsigned integer of a size specified in ValueEncoding
385 IEEE754, ///< IEEE 754 floating point of a size specified in ValueEncoding
386 INT_ONES_COMPLEMENT, ///< integer as one's complement
387 INT_SIGN_MAGNITUDE, ///< signed integer with sign in MSB
388 INT_10K, ///< signed integer stored as 'modulo 10000' (int16[0] + 10000 * int16[1] + 10000^2 * int16[2] ...), the int16 parts are stores as two's complement
389 UINT_10K, ///< unsigned integer stored as 'modulo 10000' (uint16[0] + 10000 * uint16[1] + 10000^2 * uint16[2] ...)
390 INT_BCD, ///< signed integer as BCD, 10th complement
391 INT_SIGN_MAGNITUDE_BCD, ///< signed integer as BCD, with sign in MSB
392 UINT_BCD, ///< unsigned integer as BCD
393 INT_PACKED_BCD, ///< signed integer as packed BCD, 10th complement
394 INT_SIGN_MAGNITUDE_PACKED_BCD, ///< signed integer as packed BCD, with sign in MSB
395 UINT_PACKED_BCD ///< unsigned integer as packed BCD
396 };
397
398 /**
399 * @brief Here you define how certain read values are to be interpreted
400 *
401 * The rules leading to *_IGNORE and *_UNAVAILABLE are applied to numeric values and states.
402 *
403 * IGNORE can be time-limited using ignoreTimeout, see InterpretationRule. After the time has expired,
404 * the value is set to unavailable.
405 *
406 * NUMERIC_INVALID only affects NumericSensors. As DEFAULT for numeric sensors (if
407 * no rule is matched, or if DEFAULT is matched) the value is converted to a floating point
408 * number according to type specification.
409 *
410 * STATE_ON and STATE_OFF affect only StateSensors. If no such rule is specified, the state
411 * becomes true if the read value is integral and not 0. If STATE_ON or STATE_OFF are present in
412 * the rules, then the state is set to true or false only if a STATE_* rule matches. Otherwise
413 * (DEFAULT) the state becomes unavailable.
414
415 * REJECT_SENSOR means: do not accept this reading in any way. The sensor is treated as
416 * non-existent.
417 *
418 * REJECT_DEVICE means: do not accept this reading in any way. Instead, this is a clear
419 * indication that the device is defective, or it is a wrong device. All sensors that belong
420 * to this device are treated as non-existent.
421 * REJECT_DEVICE can be used in this way to detect devices. The sensor defined for this purpose
422 * does not have to be imported as gateway sensor (see Sensor.classId = "").
423 *
424 * Default on read access for
425 * - received modbus exceptions is REJECT_SENSOR
426 * - on modbus errors (SystemError or ModbusSystemError) is REJECT_DEVICE
427 * - on value decoding/conversion is normal numeric/state decoding
428 *
429 * Default on write access (actuator switch) for
430 * - all modbus exceptions and errors is UNAVAILABLE
431 */
432 enumeration Interpretation {
433 DEFAULT, ///< default behaviour as without rule, see above
434 REJECT_DEVICE, ///< read only: device is treated as non-existent
435 REJECT_SENSOR, ///< read only: sensor is treated as non-existent
436 IGNORE, ///< read: ignore (use previous value) and retry write: ignore error and retry
437 UNAVAILABLE, ///< read: treat as unavailable (both state and numeric value) write: give up, do not retry
438 NUMERIC_INVALID, ///< read only: treat as invalid numeric value
439 STATE_ON, ///< read: treat as state ON write: use for reversed rule to handle requested ON
440 STATE_OFF ///< read: treat as state OFF write: use for reversed rule to handle requested OFF
441 };
442
443 enumeration AccessType {
444 ACCESS_READ_WRITE, ///< use rule for both read and write access
445 ACCESS_READ, ///< use rule for read access only
446 ACCESS_WRITE ///< use rule for write access only
447 };
448
449 /**
450 * InterpretationRule defines a rule that is applied to a reading, resulting in an Interpretation.
451 * A list of InterpretationRule is applied in the given order, and stopped after the first match.
452 * If no rule applies, the interpretation is Interpretation.DEFAULT.
453 **/
454 valueobject InterpretationRule {
455 Interpretation interpretation; ///< how to interpret the applied rule
456 int ignoreTimeout; ///< if > 0, ignoring stops after this timeout (seconds), and state changes to unavailable
457 AccessType accessType; ///< use rule for read and/or write access
458 };
459
461 boolean invertCondition; ///< negate rule condition
462 };
463
464 /** InterpretationRuleModbusException is applied to modbus read exceptions
465 */
467 vector<int> exceptions; ///< list of modbus exception codes
468 };
469
470 /** InterpretationRuleModbusSystemError is applied to standard system errors returned
471 * from libmodbus
472 */
474 vector<int> errnos; ///< list of system error codes
475 };
476
477 /** InterpretationRuleModbusSpecificError is applied to specific errors from libmodbus
478 */
480 vector<ModbusCfg.SpecificModbusErrors> errors; ///< list of specific libmodbus error codes
481 };
482
483 /** InterpretationRuleRAW is applied after swap, but before masking (because it has it's own mask)
484 */
486 string value; ///< compare to value (unsigned 64-bit value as string, decimal or hexadecimal)
487 string mask; ///< mask before compare (unsigned 64-bit value as string, decimal or hexadecimal; "" or "0" = not masked, the same as "0xFFFFFFFFFFFFFFFF")
488 };
489
490 /** InterpretationRuleRangeRAW is applied after swap, but before masking (because it has it's own mask)
491 */
493 string min; ///< minimum accepted value (unsigned 64-bit value as string, decimal or hexadecimal)
494 string max; ///< maximum accepted value (unsigned 64-bit value as string, decimal or hexadecimal)
495 string mask; ///< mask before compare (unsigned 64-bit value as string, decimal or hexadecimal; "" or "0" = not masked, the same as "0xFFFFFFFFFFFFFFFF")
496 };
497
498 /** InterpretationRuleEnum is applied to a reading and maps the values to the given Interpretation
499 */
501 vector<string> enumValues; ///< signed or unsigned 64-bit values as strings, decimal or hexadecimal 64-bit numbers
502 };
503
504 /** InterpretationRuleIEEE* are applied after value is wapped, masked and interpreted as float / double
505 */
508
510
511 /**
512 * @brief Specification of value encoding
513 *
514 * Before an instance of Sensor can be created,
515 * an instance of ValueEncoding must be present.
516 * The Sensor locates the corresponding ValueEncoding
517 * using the sensor class id `encodingId`.
518 */
519 valueobject ValueEncoding {
520 string encodingId; ///< encoding type id
521 EncodingType type; ///< value coding type
522 boolean invertState; ///< invert when interpreting as state
523 vector<InterpretationRule> interpretationRules; ///< error/value interpretation rules
524 int minAccessInterval; ///< minimum time interval between two read accesses in seconds
525 };
526
528 float scalingFactor; ///< multiply with when interpreting as numeric value
529 float offset; ///< add value after applying scalingFactor
530 };
531
532 valueobject ModbusValueEncodingBit extends ValueEncoding {};
533
535 /**
536 * 16-bit modbus words should be transferred in big-endian byte order.
537 * For modbus devices that do not comply with this, byteSwap = true must
538 * be set. Another application is to use byteSwap to address a single byte in
539 * a 16-bit modbus word in case 8-bit values are requested (ModbusValueEncoding8).
540 */
541 boolean byteSwap;
542 /**
543 * 64-bit unsigned raw mask value as decimal or hexadecimal string, applied before interpreting
544 * ("" or "0" = not masked, the same as "0xFFFFFFFFFFFFFFFF")
545 */
546 string mask;
547 /**
548 * The least significant bit of the read word used in numerical interpretation.
549 * If `start` is greater than 0, then one or more least significant bits remain unused.
550 * 0 is the default value. For integer values a `start > 0` has mostly the same effect as
551 * using a `mask = ~(2^start-1)` and a `scalingFactor = 1/2^start`.
552 */
553 int start;
554 /**
555 * Word width in bits used in numerical interpretation.
556 * If `width` is smaller than the read word width, then the most significant bits remain unused.
557 * 0 is the default value.
558 * Example: 24 bit signed integer:
559 * `ModbusValueEncoding32` with `start = 0` and `width = 24` and 'type = INT`
560 * (Only for unsigned integer the use of `mask` would be sufficient.)
561 */
562 int width;
563 };
564
566
567 enumeration ModbusEndianness {
568 MODBUS_BIG_ENDIAN, ///< use big endian modbus word order (default is big endian)
569 MODBUS_LITTLE_ENDIAN ///< use little endian modbus word order
570 };
571
573 /**
574 * Modbus 16-bit-words should be transmitted in big endian order. For modbus
575 * devices that do not comply with this, endianness must be set to LITTLE_ENDIAN.
576 */
578 };
579
581
583
584
585 /* ======================= SENSORS ========================= */
586
587 /**
588 * Specification of a Sensor
589 */
590 valueobject Sensor {
591 /**
592 * Unique sensor id, is automatically generated if not set
593 */
594 string sensorId;
595
596 /**
597 * Set disabled = true prevents any usage of the specification
598 */
599 boolean disabled;
600
601 /**
602 * @brief remote device id
603 *
604 * deviceId is used to locate the corresponding RemoteDevice that
605 * provides the physical sensor
606 */
607 string deviceId;
608
609 /**
610 * @brief sensor class id
611 *
612 * classId is used to locate the corresponding SensorClass.
613 * classId = "" prevents the sensor specification from being used
614 * for an imported gateway sensor. The sensor value is read anyway, and a read
615 * error or a interpretation as Interpretation.REJECT_DEVICE
616 * prevents the successful detection of the device
617 */
618 string classId;
619
620 /**
621 * @brief sensor encoding id
622 *
623 * classId is used to locate the corresponding ValueEncoding
624 */
626
627 /**
628 * @brief sensor name
629 *
630 * defaultName is used as default sensor slot name
631 */
633
634 /**
635 * @brief sensor description
636 *
637 * defaultDescription is used as default sensor slot description
638 */
640
641 /**
642 * @brief sensor location X coordinate
643 *
644 * defaultLocationX is used as default sensor slot location X coordinate
645 */
647
648 /**
649 * @brief sensor location Y coordinate
650 *
651 * defaultLocationY is used as default sensor slot location Y coordinate
652 */
654
655 /**
656 * @brief sensor location Z coordinate
657 *
658 * defaultLocationZ is used as default sensor slot location Z coordinate
659 */
661 };
662
663 valueobject ModbusSensor extends Sensor {
664 ModbusCfg.ModbusFunction function; ///< Modbus function to be used
665 int regAddr; ///< Modbus server register address
666 };
667
668 valueobject SnmpSensor extends Sensor {
669 string oid; ///< sensor oid
670 };
671
672 /* ======================= FULL CONFIGURATION ========================= */
673
675 boolean disabled; ///< prevents usage of all sensor specifications defined in this package
676 string name; ///< package name
677 vector<SensorClass> classes;
678 vector<RemoteDevice> devices;
679 vector<ValueEncoding> encodings;
680 vector<Sensor> sensors;
681 };
682
683 /**
684 * @brief Get all defined gateway sensors and required objects from config
685 *
686 * Read all Sensor Classes, Remote Devices, Value Encodings and Sensors
687 * at once to ensure that the overall configuration is consistent
688 *
689 * @return all defined gateway sensor feature configuration objects
690 */
691 map<string, ConfigurationPackage> getConfiguration();
692
693 constant int ERR_CONFIG_INCONSISTENT = 1;
694 constant int ERR_CONFIG_STORAGE_FAILED = 2;
695
696 /**
697 * @brief Replace defined gateway sensor and/or other configuration objects in config
698 *
699 * Write all Sensor Classes, Remote Devices, Value Encodings and Sensors
700 * at once to ensure that the overall configuration is consistent at every
701 * moment.
702 *
703 * The uniqueness of all IDs and the availability of all referenced elements are
704 * checked before the configuration is applied. Otherwise setConfiguration() returns
705 * with an error.
706 *
707 * @param cfg all defined gateway sensor feature configuration objects
708 * @return 0 if OK
709 * @return ERR_CONFIG_INCONSISTENT if consistency check has failed (e.g. non-unique identifiers)
710 * @return ERR_CONFIG_STORAGE_FAILED if configuration cannot be stored
711 */
712 int setConfiguration(in map<string, ConfigurationPackage> cfg);
713
714 /** Event: The gateway sensor feature configuration has changed */
715 valueobject ConfigurationChangedEvent extends idl.Event {
716 map<string, ConfigurationPackage> configuration; ///< the current gateway sensor feature configuration
717 };
718
719
720 /* ======================= FEEDBACK ========================= */
721
722 /**
723 * @brief Feedback from gateway sensor configuration usage
724 *
725 * There is no knowledge of Feedback required to configure gateway sensors.
726 * The following is only needed for special tools that monitor the usage
727 * of the configurations above.
728 */
729 structure FeedbackObject {
730 enumeration FeedbackState {
732 INTENTIONALLY_UNUSED,
733 FAILED_PRECONDITIONS_UNUSED,
734 FAILED,
735 GOOD
736 };
737
738 string key; ///< empty or free defined value name
739 string value; ///< message or value
740 FeedbackState stateTansitionTo; ///< this FeedbackObject changes state, if not UNSPECIFIED
741 };
742
743 valueobject Feedback {
744 FeedbackObject.FeedbackState currentState; ///< Device or sensor state
745 vector<FeedbackObject> infos;
746 };
747
748 valueobject DeviceFeedback extends Feedback {
749 string packageId; ///< the configuration package id
750 string deviceId; ///< the same id as in RemoteDevice
751 };
752
753 valueobject SensorFeedback extends Feedback {
754 string packageId; ///< the configuration package id
755 string deviceId; ///< the same id as in RemoteDevice
756 string sensorId; ///< the same id as in Sensor
757 };
758
759 /**
760 * Get feedback from gateway sensor configuration usage
761 *
762 * @return Result: the full feedback
763 */
764 vector<Feedback> getFeedback();
765
766 /** Event: The configuration usage feedback has changed */
767 valueobject FeedbackChangedEvent extends idl.Event {
768 vector<Feedback> feedback; ///< the latest configuration usage feedback
769 };
770 };
771}
772
773#endif /* __PERIPHERAL_GATEWAY_SENSOR_MANAGER_IDL__ */
Gateway Sensor Configuration Interface.
@ MODBUS_BIG_ENDIAN
use big endian modbus word order (default is big endian)
@ AES192_3DES
AES-192 with key extension (3DES)
map< string, ConfigurationPackage > getConfiguration()
Get all defined gateway sensors and required objects from config.
int setConfiguration(in map< string, ConfigurationPackage > cfg)
Replace defined gateway sensor and/or other configuration objects in config.
EncodingType
interpretation of binary values
@ INT_10K
signed integer stored as 'modulo 10000' (int16[0] + 10000 * int16[1] + 10000^2 * int16[2] ....
@ INT_SIGN_MAGNITUDE_BCD
signed integer as BCD, with sign in MSB
@ IEEE754
IEEE 754 floating point of a size specified in ValueEncoding.
@ UINT_10K
unsigned integer stored as 'modulo 10000' (uint16[0] + 10000 * uint16[1] + 10000^2 * uint16[2] ....
@ INT_SIGN_MAGNITUDE
signed integer with sign in MSB
@ INT_PACKED_BCD
signed integer as packed BCD, 10th complement
@ INT_BCD
signed integer as BCD, 10th complement
@ INT_SIGN_MAGNITUDE_PACKED_BCD
signed integer as packed BCD, with sign in MSB
@ INT_ONES_COMPLEMENT
integer as one's complement
@ INT
signed integer of a size specified in ValueEncoding as two's complement
@ UINT
unsigned integer of a size specified in ValueEncoding
@ ACCESS_READ_WRITE
use rule for both read and write access
@ ACCESS_READ
use rule for read access only
@ AUTH_NO_PRIV
authentication, no privacy
@ NO_AUTH_NO_PRIV
no authentication, no privacy
Interpretation
Here you define how certain read values are to be interpreted.
@ DEFAULT
default behaviour as without rule, see above
@ UNAVAILABLE
read: treat as unavailable (both state and numeric value) write: give up, do not retry
@ IGNORE
read: ignore (use previous value) and retry write: ignore error and retry
@ REJECT_SENSOR
read only: sensor is treated as non-existent
@ NUMERIC_INVALID
read only: treat as invalid numeric value
@ STATE_ON
read: treat as state ON write: use for reversed rule to handle requested ON
@ REJECT_DEVICE
read only: device is treated as non-existent
vector< Feedback > getFeedback()
Get feedback from gateway sensor configuration usage.
A sensor with numeric readings.
Sensor interface
Definition Sensor.idl:15
Basic IDL definitions.
Definition Event.idl:10
Peripheral Devices.
@ UNSPECIFIED
device type is unknown
Common base for all events.
Definition Event.idl:13
Event: The gateway sensor feature configuration has changed.
map< string, ConfigurationPackage > configuration
the current gateway sensor feature configuration
boolean disabled
prevents usage of all sensor specifications defined in this package
Event: The configuration usage feedback has changed.
vector< Feedback > feedback
the latest configuration usage feedback
Feedback from gateway sensor configuration usage.
FeedbackState stateTansitionTo
this FeedbackObject changes state, if not UNSPECIFIED
FeedbackObject::FeedbackState currentState
Device or sensor state.
InterpretationRuleEnum is applied to a reading and maps the values to the given Interpretation.
vector< string > enumValues
signed or unsigned 64-bit values as strings, decimal or hexadecimal 64-bit numbers
InterpretationRuleIEEE* are applied after value is wapped, masked and interpreted as float / double.
InterpretationRuleModbusException is applied to modbus read exceptions.
InterpretationRuleModbusSpecificError is applied to specific errors from libmodbus.
vector< ModbusCfg::SpecificModbusErrors > errors
list of specific libmodbus error codes
InterpretationRuleModbusSystemError is applied to standard system errors returned from libmodbus.
InterpretationRuleRAW is applied after swap, but before masking (because it has it's own mask)
string value
compare to value (unsigned 64-bit value as string, decimal or hexadecimal)
string mask
mask before compare (unsigned 64-bit value as string, decimal or hexadecimal; "" or "0" = not masked,...
InterpretationRuleRangeRAW is applied after swap, but before masking (because it has it's own mask)
string max
maximum accepted value (unsigned 64-bit value as string, decimal or hexadecimal)
string mask
mask before compare (unsigned 64-bit value as string, decimal or hexadecimal; "" or "0" = not masked,...
string min
minimum accepted value (unsigned 64-bit value as string, decimal or hexadecimal)
InterpretationRule defines a rule that is applied to a reading, resulting in an Interpretation.
AccessType accessType
use rule for read and/or write access
Interpretation interpretation
how to interpret the applied rule
int ignoreTimeout
if > 0, ignoring stops after this timeout (seconds), and state changes to unavailable
ModbusEndianness endianness
Modbus 16-bit-words should be transmitted in big endian order.
int width
Word width in bits used in numerical interpretation.
int start
The least significant bit of the read word used in numerical interpretation.
boolean byteSwap
16-bit modbus words should be transferred in big-endian byte order.
string mask
64-bit unsigned raw mask value as decimal or hexadecimal string, applied before interpreting ("" or "...
Sensor class that stores numeric sensor properties.
sensors::NumericSensor Thresholds defaultThresholds
threshold values may be used initially and as default threshold values, depending on the value of the...
sensors::NumericSensor MetaData metadata
numeric sensor type, ranges, etc.
boolean preferCommonThresholds
if true, use common default thresholds if available, otherwise use the value of the defaultThresholds...
float scalingFactor
multiply with when interpreting as numeric value
float offset
add value after applying scalingFactor
Specification of a remote device that provides access to sensors.
int timeoutMs
communication access timeout, 0 = default
string name
human readable remote device name
int retry
communication retry count, 0 = default
boolean disabled
prevents usage of all sensor specifications which reference this device
vector< byte > unsupportedFunctionCodes
list of unsupported modbus function codes (FC)
map< int, string > detectionIdentifiers
list of expected device identifiers
ModbusCfg::SerialSettings busSettings
interface settings
string busInterface
rs485 interface used for modbus communication
int interframeDelayDeciChars
(== 0) -> default, (< 0) -> no delay, (> 0) -> e.g. 35 means 3.5 chars
SnmpPrivProtocol privacyProtocol
privacy protocol (DES|AES|AES-192|AES-256)
SnmpSecurityLevel level
security level (noAuthNoPriv|authNoPriv|authPriv)
SnmpAuthProtocol authProtocol
authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
string authPassphrase
authentication protocol passphrase
Specification of sensor class that stores sensor properties.
boolean disabled
Set disabled = true prevents any usage of the specification.
string defaultLocationZ
sensor location Z coordinate
string sensorId
Unique sensor id, is automatically generated if not set.
string defaultLocationY
sensor location Y coordinate
string defaultLocationX
sensor location X coordinate
Sensor class that stores state sensor properties.
sensors::Sensor TypeSpec type
state sensor type
int minAccessInterval
minimum time interval between two read accesses in seconds
boolean invertState
invert when interpreting as state
vector< InterpretationRule > interpretationRules
error/value interpretation rules
Numeric sensor metadata.
Numeric sensor thresholds.
Complete sensor type specification.
Definition Sensor.idl:177