enums.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. # SPDX-License-Identifier: Apache-2.0
  2. # Copyright 2020 Contributors to OpenLEADR
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. """
  13. A collection of useful enumerations that you can use to construct or
  14. interpret OpenADR messages. Can also be useful during testing.
  15. """
  16. from openleadr import objects
  17. class Enum(type):
  18. def __getitem__(self, item):
  19. return getattr(self, item)
  20. @property
  21. def members(self):
  22. return sorted([item for item in list(set(dir(self)) - set(dir(Enum)))
  23. if not item.startswith("_")])
  24. @property
  25. def values(self):
  26. return [self[item] for item in self.members]
  27. class EVENT_STATUS(metaclass=Enum):
  28. NONE = "none"
  29. FAR = "far"
  30. NEAR = "near"
  31. ACTIVE = "active"
  32. COMPLETED = "completed"
  33. CANCELLED = "cancelled"
  34. class SIGNAL_TYPE(metaclass=Enum):
  35. DELTA = "delta"
  36. LEVEL = "level"
  37. MULTIPLIER = "multiplier"
  38. PRICE = "price"
  39. PRICE_MULTIPLIER = "priceMultiplier"
  40. PRICE_RELATIVE = "priceRelative"
  41. SETPOINT = "setpoint"
  42. X_LOAD_CONTROL_CAPACITY = "x-loadControlCapacity"
  43. X_LOAD_CONTROL_LEVEL_OFFSET = "x-loadControlLevelOffset"
  44. X_LOAD_CONTROL_PERCENT_OFFSET = "x-loadControlPorcentOffset"
  45. X_LOAD_CONTROL_SETPOINT = "x-loadControlSetpoint"
  46. class SIGNAL_NAME(metaclass=Enum):
  47. SIMPLE = "SIMPLE"
  48. simple = "simple"
  49. ELECTRICITY_PRICE = "ELECTRICITY_PRICE"
  50. ENERGY_PRICE = "ENERGY_PRICE"
  51. DEMAND_CHARGE = "DEMAND_CHARGE"
  52. BID_PRICE = "BID_PRICE"
  53. BID_LOAD = "BID_LOAD"
  54. BID_ENERGY = "BID_ENERGY"
  55. CHARGE_STATE = "CHARGE_STATE"
  56. LOAD_DISPATCH = "LOAD_DISPATCH"
  57. LOAD_CONTROL = "LOAD_CONTROL"
  58. class SI_SCALE_CODE(metaclass=Enum):
  59. p = "p"
  60. n = "n"
  61. micro = "micro"
  62. m = "m"
  63. c = "c"
  64. d = "d"
  65. k = "k"
  66. M = "M"
  67. G = "G"
  68. T = "T"
  69. none = "none"
  70. class OPT(metaclass=Enum):
  71. OPT_IN = "optIn"
  72. OPT_OUT = "optOut"
  73. class OPT_REASON(metaclass=Enum):
  74. ECONOMIC = "economic"
  75. EMERGENCY = "emergency"
  76. MUST_RUN = "mustRun"
  77. NOT_PARTICIPATING = "notParticipating"
  78. OUTAGE_RUN_STATUS = "outageRunStatus"
  79. OVERRIDE_STATUS = "overrideStatus"
  80. PARTICIPATING = "participating"
  81. X_SCHEDULE = "x-schedule"
  82. class READING_TYPE(metaclass=Enum):
  83. DIRECT_READ = "Direct Read"
  84. NET = "Net"
  85. ALLOCATED = "Allocated"
  86. ESTIMATED = "Estimated"
  87. SUMMED = "Summed"
  88. DERIVED = "Derived"
  89. MEAN = "Mean"
  90. PEAK = "Peak"
  91. HYBRID = "Hybrid"
  92. CONTRACT = "Contract"
  93. PROJECTED = "Projected"
  94. X_RMS = "x-RMS"
  95. X_NOT_APPLICABLE = "x-notApplicable"
  96. class REPORT_TYPE(metaclass=Enum):
  97. READING = "reading"
  98. USAGE = "usage"
  99. DEMAND = "demand"
  100. SET_POINT = "setPoint"
  101. DELTA_USAGE = "deltaUsage"
  102. DELTA_SET_POINT = "deltaSetPoint"
  103. DELTA_DEMAND = "deltaDemand"
  104. BASELINE = "baseline"
  105. DEVIATION = "deviation"
  106. AVG_USAGE = "avgUsage"
  107. AVG_DEMAND = "avgDemand"
  108. OPERATING_STATE = "operatingState"
  109. UP_REGULATION_CAPACITY_AVAILABLE = "upRegulationCapacityAvailable"
  110. DOWN_REGULATION_CAPACITY_AVAILABLE = "downRegulationCapacityAvailable"
  111. REGULATION_SETPOINT = "regulationSetpoint"
  112. STORED_ENERGY = "storedEnergy"
  113. TARGET_ENERGY_STORAGE = "targetEnergyStorage"
  114. AVAILABLE_ENERGY_STORAGE = "availableEnergyStorage"
  115. PRICE = "price"
  116. LEVEL = "level"
  117. POWER_FACTOR = "powerFactor"
  118. PERCENT_USAGE = "percentUsage"
  119. PERCENT_DEMAND = "percentDemand"
  120. X_RESOURCE_STATUS = "x-resourceStatus"
  121. class REPORT_NAME(metaclass=Enum):
  122. METADATA_HISTORY_USAGE = "METADATA_HISTORY_USAGE"
  123. HISTORY_USAGE = "HISTORY_USAGE"
  124. METADATA_HISTORY_GREENBUTTON = "METADATA_HISTORY_GREENBUTTON"
  125. HISTORY_GREENBUTTON = "HISTORY_GREENBUTTON"
  126. METADATA_TELEMETRY_USAGE = "METADATA_TELEMETRY_USAGE"
  127. TELEMETRY_USAGE = "TELEMETRY_USAGE"
  128. METADATA_TELEMETRY_STATUS = "METADATA_TELEMETRY_STATUS"
  129. TELEMETRY_STATUS = "TELEMETRY_STATUS"
  130. class STATUS_CODES(metaclass=Enum):
  131. OUT_OF_SEQUENCE = 450
  132. NOT_ALLOWED = 451
  133. INVALID_ID = 452
  134. NOT_RECOGNIZED = 453
  135. INVALID_DATA = 454
  136. COMPLIANCE_ERROR = 459
  137. SIGNAL_NOT_SUPPORTED = 460
  138. REPORT_NOT_SUPPORTED = 461
  139. TARGET_MISMATCH = 462
  140. NOT_REGISTERED_OR_AUTHORIZED = 463
  141. DEPLOYMENT_ERROR_OTHER = 469
  142. class SECURITY_LEVEL:
  143. STANDARD = 'STANDARD'
  144. HIGH = 'HIGH'
  145. _CURRENCIES = ("AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM",
  146. "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL",
  147. "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW",
  148. "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK",
  149. "DJF", "DKK", "DOP", "DZD", "EEK", "EGP", "ERN", "ETB", "EUR", "FJD",
  150. "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GWP", "GYD",
  151. "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR",
  152. "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW",
  153. "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL",
  154. "LYD", "MAD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO",
  155. "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO",
  156. "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN",
  157. "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG",
  158. "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "STD", "SVC", "SYP", "SZL",
  159. "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH",
  160. "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV",
  161. "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR",
  162. "XFU", "XOF", "XPD", "XPF", "XPF", "XPF", "XPT", "XTS", "XXX", "YER",
  163. "ZAR", "ZMK", "ZWL")
  164. _ACCEPTABLE_UNITS = {'currency': _CURRENCIES,
  165. 'currencyPerKW': _CURRENCIES,
  166. 'currencyPerKWh': _CURRENCIES,
  167. 'currencyPerTherm': _CURRENCIES,
  168. 'current': ('A',),
  169. 'energyApparent': ('VAh',),
  170. 'energyReactive': ('VArh',),
  171. 'energyReal': ('Wh',),
  172. 'frequency': ('Hz',),
  173. 'powerApparent': ('VA',),
  174. 'powerReactive': ('VAr',),
  175. 'powerReal': ('W',),
  176. 'pulseCount': ('count',),
  177. 'temperature': ('celsius', 'fahrenheit'),
  178. 'therm': ('thm',),
  179. 'voltage': ('V',)}
  180. _MEASUREMENT_DESCRIPTIONS = {'currency': 'Currency',
  181. 'currencyPerKW': 'CurrencyPerKW',
  182. 'currencyPerKWh': 'CurrencyPerKWh',
  183. 'currencyPerTherm': 'CurrencyPerTherm',
  184. 'energyApparent': 'ApparentEnergy',
  185. 'energyReactive': 'ReactiveEnergy',
  186. 'energyReal': 'RealEnergy',
  187. 'frequency': 'Frequency',
  188. 'powerApparent': 'ApparentPower',
  189. 'powerReactive': 'ReactivePower',
  190. 'powerReal': 'RealPower',
  191. 'pulseCount': 'pulse count',
  192. 'temperature': 'temperature',
  193. 'therm': 'Therm',
  194. 'voltage': 'Voltage'}
  195. class MEASUREMENTS(metaclass=Enum):
  196. VOLTAGE = objects.Measurement(name='voltage',
  197. description=_MEASUREMENT_DESCRIPTIONS['voltage'],
  198. unit=_ACCEPTABLE_UNITS['voltage'][0],
  199. acceptable_units=_ACCEPTABLE_UNITS['voltage'],
  200. scale='none')
  201. ENERGY_REAL = objects.Measurement(name='energyReal',
  202. description=_MEASUREMENT_DESCRIPTIONS['energyReal'],
  203. unit=_ACCEPTABLE_UNITS['energyReal'][0],
  204. acceptable_units=_ACCEPTABLE_UNITS['energyReal'],
  205. scale='none')
  206. REAL_ENERGY = objects.Measurement(name='energyReal',
  207. description=_MEASUREMENT_DESCRIPTIONS['energyReal'],
  208. unit=_ACCEPTABLE_UNITS['energyReal'][0],
  209. acceptable_units=_ACCEPTABLE_UNITS['energyReal'],
  210. scale='none')
  211. ACTIVE_ENERGY = objects.Measurement(name='energyReal',
  212. description=_MEASUREMENT_DESCRIPTIONS['energyReal'],
  213. unit=_ACCEPTABLE_UNITS['energyReal'][0],
  214. acceptable_units=_ACCEPTABLE_UNITS['energyReal'],
  215. scale='none')
  216. ENERGY_REACTIVE = objects.Measurement(name='energyReactive',
  217. description=_MEASUREMENT_DESCRIPTIONS['energyReactive'],
  218. unit=_ACCEPTABLE_UNITS['energyReactive'][0],
  219. acceptable_units=_ACCEPTABLE_UNITS['energyReactive'],
  220. scale='none')
  221. REACTIVE_ENERGY = objects.Measurement(name='energyReactive',
  222. description=_MEASUREMENT_DESCRIPTIONS['energyReactive'],
  223. unit=_ACCEPTABLE_UNITS['energyReactive'][0],
  224. acceptable_units=_ACCEPTABLE_UNITS['energyReactive'],
  225. scale='none')
  226. ENERGY_APPARENT = objects.Measurement(name='energyApparent',
  227. description=_MEASUREMENT_DESCRIPTIONS['energyApparent'],
  228. unit=_ACCEPTABLE_UNITS['energyApparent'][0],
  229. acceptable_units=_ACCEPTABLE_UNITS['energyApparent'],
  230. scale='none')
  231. APPARENT_ENERGY = objects.Measurement(name='energyApparent',
  232. description=_MEASUREMENT_DESCRIPTIONS['energyApparent'],
  233. unit=_ACCEPTABLE_UNITS['energyApparent'][0],
  234. acceptable_units=_ACCEPTABLE_UNITS['energyApparent'],
  235. scale='none')
  236. ACTIVE_POWER = objects.Measurement(name='powerReal',
  237. description=_MEASUREMENT_DESCRIPTIONS['powerReal'],
  238. unit=_ACCEPTABLE_UNITS['powerReal'][0],
  239. acceptable_units=_ACCEPTABLE_UNITS['powerReal'],
  240. scale='none',
  241. power_attributes=objects.PowerAttributes(hertz=50,
  242. voltage=230,
  243. ac=True))
  244. REAL_POWER = objects.Measurement(name='powerReal',
  245. description=_MEASUREMENT_DESCRIPTIONS['powerReal'],
  246. unit=_ACCEPTABLE_UNITS['powerReal'][0],
  247. acceptable_units=_ACCEPTABLE_UNITS['powerReal'],
  248. scale='none',
  249. power_attributes=objects.PowerAttributes(hertz=50,
  250. voltage=230,
  251. ac=True))
  252. POWER_REAL = objects.Measurement(name='powerReal',
  253. description=_MEASUREMENT_DESCRIPTIONS['powerReal'],
  254. unit=_ACCEPTABLE_UNITS['powerReal'][0],
  255. acceptable_units=_ACCEPTABLE_UNITS['powerReal'],
  256. scale='none',
  257. power_attributes=objects.PowerAttributes(hertz=50,
  258. voltage=230,
  259. ac=True))
  260. REACTIVE_POWER = objects.Measurement(name='powerReactive',
  261. description=_MEASUREMENT_DESCRIPTIONS['powerReactive'],
  262. unit=_ACCEPTABLE_UNITS['powerReactive'][0],
  263. acceptable_units=_ACCEPTABLE_UNITS['powerReactive'],
  264. scale='none',
  265. power_attributes=objects.PowerAttributes(hertz=50,
  266. voltage=230,
  267. ac=True))
  268. POWER_REACTIVE = objects.Measurement(name='powerReactive',
  269. description=_MEASUREMENT_DESCRIPTIONS['powerReactive'],
  270. unit=_ACCEPTABLE_UNITS['powerReactive'][0],
  271. acceptable_units=_ACCEPTABLE_UNITS['powerReactive'],
  272. scale='none',
  273. power_attributes=objects.PowerAttributes(hertz=50,
  274. voltage=230,
  275. ac=True))
  276. APPARENT_POWER = objects.Measurement(name='powerApparent',
  277. description=_MEASUREMENT_DESCRIPTIONS['powerApparent'],
  278. unit=_ACCEPTABLE_UNITS['powerApparent'][0],
  279. acceptable_units=_ACCEPTABLE_UNITS['powerApparent'],
  280. scale='none',
  281. power_attributes=objects.PowerAttributes(hertz=50,
  282. voltage=230,
  283. ac=True))
  284. POWER_APPARENT = objects.Measurement(name='powerApparent',
  285. description=_MEASUREMENT_DESCRIPTIONS['powerApparent'],
  286. unit=_ACCEPTABLE_UNITS['powerApparent'][0],
  287. acceptable_units=_ACCEPTABLE_UNITS['powerApparent'],
  288. scale='none',
  289. power_attributes=objects.PowerAttributes(hertz=50,
  290. voltage=230,
  291. ac=True))
  292. FREQUENCY = objects.Measurement(name='frequency',
  293. description=_MEASUREMENT_DESCRIPTIONS['frequency'],
  294. unit=_ACCEPTABLE_UNITS['frequency'][0],
  295. acceptable_units=_ACCEPTABLE_UNITS['frequency'],
  296. scale='none')
  297. PULSE_COUNT = objects.Measurement(name='pulseCount',
  298. description=_MEASUREMENT_DESCRIPTIONS['pulseCount'],
  299. unit=_ACCEPTABLE_UNITS['pulseCount'][0],
  300. acceptable_units=_ACCEPTABLE_UNITS['pulseCount'],
  301. scale='none')
  302. TEMPERATURE = objects.Measurement(name='temperature',
  303. description=_MEASUREMENT_DESCRIPTIONS['temperature'],
  304. unit=_ACCEPTABLE_UNITS['temperature'][0],
  305. acceptable_units=_ACCEPTABLE_UNITS['temperature'],
  306. scale='none')
  307. THERM = objects.Measurement(name='therm',
  308. description=_MEASUREMENT_DESCRIPTIONS['therm'],
  309. unit=_ACCEPTABLE_UNITS['therm'][0],
  310. acceptable_units=_ACCEPTABLE_UNITS['therm'],
  311. scale='none')
  312. CURRENCY = objects.Measurement(name='currency',
  313. description=_MEASUREMENT_DESCRIPTIONS['currency'],
  314. unit=_CURRENCIES[0],
  315. acceptable_units=_CURRENCIES,
  316. scale='none')
  317. CURRENCY_PER_KW = objects.Measurement(name='currencyPerKW',
  318. description=_MEASUREMENT_DESCRIPTIONS['currencyPerKW'],
  319. unit=_CURRENCIES[0],
  320. acceptable_units=_CURRENCIES,
  321. scale='none')
  322. CURRENCY_PER_KWH = objects.Measurement(name='currencyPerKWh',
  323. description=_MEASUREMENT_DESCRIPTIONS['currencyPerKWh'],
  324. unit=_CURRENCIES[0],
  325. acceptable_units=_CURRENCIES,
  326. scale='none')
  327. CURRENCY_PER_THERM = objects.Measurement(name='currencyPerTherm',
  328. description=_MEASUREMENT_DESCRIPTIONS['currencyPerTherm'],
  329. unit=_CURRENCIES[0],
  330. acceptable_units=_CURRENCIES,
  331. scale='none')