upm  1.6.0
Sensor/Actuator repository for libmraa (v1.9.0)
e50hx.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <map>
28 
29 #include "bacnetmstp.hpp"
30 #include "bacnetutil.hpp"
31 
32 namespace upm {
33 
85  class E50HX : public BACNETUTIL {
86  public:
87 
88  // Supported Analog Value Objects. These are readable and writable.
89  typedef enum : uint32_t {
90  AV_Config = 1, // always returns 0 on read
91  AV_System_Type = 2,
92  AV_CT_Ratio_Primary = 3,
93  AV_CT_Ratio_Secondary = 4,
94  AV_PT_Ratio = 5,
95  AV_System_Voltage = 6,
96  AV_Display_Units = 7,
97  AV_Phase_Loss_Voltage_Threshold = 8,
98  AV_Phase_Loss_Imbalance_Threshold = 9,
99  AV_Subintervals = 10,
100  AV_Subinterval_Length = 11
101  } ANALOG_VALUES_T;
102 
103  // Supported Analog Input Objects. These are read only.
104  typedef enum : uint32_t {
105  AI_Energy = 1,
106  AI_kW_Total = 2,
107  AI_kVAR_Total = 3,
108  AI_kVA_Total = 4,
109  AI_PF_Total = 5,
110  AI_Volts_LL_Avg = 6,
111  AI_Volts_LN_Avg = 7,
112  AI_Current_Avg = 8,
113  AI_kW_A = 9,
114  AI_kW_B = 10,
115  AI_kW_C = 11,
116  AI_PF_A = 12,
117  AI_PF_B = 13,
118  AI_PF_C = 14,
119  AI_Volts_AB = 15,
120  AI_Volts_BC = 16,
121  AI_Volts_AC = 17,
122  AI_Volts_AN = 18,
123  AI_Volts_BN = 19,
124  AI_Volts_CN = 20,
125  AI_Current_A = 21,
126  AI_Current_B = 22,
127  AI_Current_C = 23,
128  // AI24 is reserved
129  AI_Frequency = 25,
130  AI_kVAh = 26, // units = kVAh, not kWH
131  AI_kVARh = 27, // units = kVAh, not kWH
132  AI_kVA_A = 28,
133  AI_kVA_B = 29,
134  AI_kVA_C = 30,
135  AI_kVAR_A = 31,
136  AI_kVAR_B = 32,
137  AI_kVAR_C = 33,
138  AI_KW_Present_Demand = 34,
139  AI_KVAR_Present_Demand = 35,
140  AI_KWA_Present_Demand = 36,
141  AI_KW_Max_Demand = 37,
142  AI_KVAR_Max_Demand = 38,
143  AI_KVA_Max_Demand = 39,
144  AI_Pulse_Count_1 = 40, // H2 & H5
145  // AI41 is reserved on H2 variant
146  AI_Pulse_Count_2 = 41, // only on H5 variant
147  AI_KWH_A = 42,
148  AI_KWH_B = 43,
149  AI_KWH_C = 44,
150  AI_Max_Power = 45, // theoretical max power
151  // AI46 reserved
152  AI_Energy_Resets = 47,
153  // AI48 and AI49 reserved
154  AI_Power_Up_Count = 50,
155  AI_Output_Config = 51, // H2 = 11, H5 = 10
156  AI_Alarm_Bitmap = 52
157  } ANALOG_INPUTS_T;
158 
159  // Alarm bits (AI52)
160  typedef enum : uint16_t {
161  ALARM_Volts_Error_A = 0x0001,
162  ALARM_Volts_Error_B = 0x0002,
163  ALARM_Volts_Error_C = 0x0004,
164 
165  ALARM_Current_Error_A = 0x0008,
166  ALARM_Current_Error_B = 0x0010,
167  ALARM_Current_Error_C = 0x0020,
168 
169  ALARM_Frequency_Error = 0x0040,
170 
171  ALARM_Reserved_0 = 0x0080, // reserved
172 
173  ALARM_Phase_Loss_A = 0x0100,
174  ALARM_Phase_Loss_B = 0x0200,
175  ALARM_Phase_Loss_C = 0x0400,
176 
177  ALARM_Power_Factor_A = 0x0800,
178  ALARM_Power_Factor_B = 0x1000,
179  ALARM_Power_Factor_C = 0x2000,
180 
181  ALARM_RTC_RESET = 0x4000 // H5 only
182  } ALARM_BITS_T;
183 
184  // valid config values to write to AV1
185  typedef enum {
186  CFG_CLR_ENERGY_ACCUM = 30078, // clear energy accumulators
187  CFG_NEW_DSI = 21211, // begin new demand subinterval
188  CFG_RESET_MAX_TO_PRESENT = 21212, // reset max vals to present vals
189  CFG_CLEAR_PULSE_COUNTERS = 16498 // clear the pulse counters
190  } CFG_VALUES_T;
191 
192  // system type configuration
193  typedef enum {
194  SYSTYPE_SINGLE_PHASE_AN = 10,
195  SYSTYPE_SINGLE_PHASE_AB = 11,
196  SYSTYPE_SPLIT_PHASE_ABN = 12,
197  SYSTYPE_3PHASE_ABC = 31,
198  SYSTYPE_3PHASE_ABCN = 40
199  } SYSTEM_TYPES_T;
200 
201  // CT input ratio
202  typedef enum {
203  CT_RATIO_SECONDARY_1 = 1, // CT's w/ 1v outputs
204  CT_RATIO_SECONDARY_3 = 3 // CT's w/ 0.3v outputs
205  } CT_SECONDARY_T;
206 
207  // LCD display units
208  typedef enum {
209  DISP_UNITS_IEC = 0, // IEC display units
210  DISP_UNITS_IEEE = 1 // IEEE display units
211  } DISP_UNITS_T;
212 
225  E50HX(uint32_t targetDeviceObjectID);
226 
230  ~E50HX();
231 
240  void writeConfig(CFG_VALUES_T config);
241 
248  void writeSystemType(SYSTEM_TYPES_T systype);
249 
256  void writeCTRatioPrimary(float ctRatio);
257 
264  void writeCTRatioSecondary(CT_SECONDARY_T ctRatio);
265 
272  void writePTRatio(float ptRatio);
273 
280  void writeSystemVoltage(float sysVolts);
281 
288  void writeDisplayUnits(DISP_UNITS_T dispUnits);
289 
296  void writePhaseLossVT(float phaseLoss);
297 
304  void writePhaseLossIT(float phaseLoss);
305 
316  uint16_t getAlarmBits();
317 
318  protected:
319  private:
320  };
321 }
void writePTRatio(float ptRatio)
Definition: e50hx.cxx:82
void writeCTRatioPrimary(float ctRatio)
Definition: e50hx.cxx:66
UPM API for the Veris E50HX Energy Meter.
Definition: e50hx.hpp:85
~E50HX()
Definition: e50hx.cxx:47
void writePhaseLossIT(float phaseLoss)
Definition: e50hx.cxx:120
void writeConfig(CFG_VALUES_T config)
Definition: e50hx.cxx:56
C++ API for the kxtj3 driver.
Definition: a110x.hpp:29
void writeDisplayUnits(DISP_UNITS_T dispUnits)
Definition: e50hx.cxx:104
uint16_t getAlarmBits()
Definition: e50hx.cxx:51
UPM Utility API for BACnet.
Definition: bacnetutil.hpp:50
void writeSystemType(SYSTEM_TYPES_T systype)
Definition: e50hx.cxx:61
void writeSystemVoltage(float sysVolts)
Definition: e50hx.cxx:93
E50HX(uint32_t targetDeviceObjectID)
Definition: e50hx.cxx:38
void writePhaseLossVT(float phaseLoss)
Definition: e50hx.cxx:109
void writeCTRatioSecondary(CT_SECONDARY_T ctRatio)
Definition: e50hx.cxx:77