|
| 1 | +// This file is part of arduino aws-sitewise-integration. |
| 2 | +// |
| 3 | +// Copyright 2024 ARDUINO SA (http://www.arduino.cc/) |
| 4 | +// |
| 5 | +// This software is released under the Mozilla Public License Version 2.0, |
| 6 | +// which covers the main part of aws-sitewise-integration. |
| 7 | +// The terms of this license can be found at: |
| 8 | +// https://www.mozilla.org/media/MPL/2.0/index.815ca599c9df.txt |
| 9 | +// |
| 10 | +// You can be released from the requirements of the above licenses by purchasing |
| 11 | +// a commercial license. Buying such a license is mandatory if you want to |
| 12 | +// modify or otherwise use the software for commercial activities involving the |
| 13 | +// Arduino software without disclosing the source code of your own applications. |
| 14 | +// To purchase a commercial license, send an email to [email protected]. |
| 15 | + |
| 16 | +package iot |
| 17 | + |
| 18 | +type Type string |
| 19 | + |
| 20 | +const ( |
| 21 | + Analog Type = "ANALOG" |
| 22 | + CharString Type = "CHARSTRING" |
| 23 | + Float Type = "FLOAT" |
| 24 | + Int Type = "INT" |
| 25 | + LenghtC Type = "LENGHT_C" |
| 26 | + LenghtI Type = "LENGHT_I" |
| 27 | + LenghtM Type = "LENGHT_M" |
| 28 | + Percentage Type = "PERCENTAGE" |
| 29 | + Status Type = "STATUS" |
| 30 | + TemperatureC Type = "TEMPERATURE_C" |
| 31 | + TemperatureF Type = "TEMPERATURE_F" |
| 32 | + Meter Type = "METER" |
| 33 | + Kilogram Type = "KILOGRAM" |
| 34 | + Gram Type = "GRAM" |
| 35 | + Second Type = "SECOND" |
| 36 | + Ampere Type = "AMPERE" |
| 37 | + Kelvin Type = "KELVIN" |
| 38 | + Candela Type = "CANDELA" |
| 39 | + Mole Type = "MOLE" |
| 40 | + Hertz Type = "HERTZ" |
| 41 | + Radian Type = "RADIAN" |
| 42 | + Steradian Type = "STERADIAN" |
| 43 | + Newton Type = "NEWTON" |
| 44 | + Pascal Type = "PASCAL" |
| 45 | + Joule Type = "JOULE" |
| 46 | + Watt Type = "WATT" |
| 47 | + Coulomb Type = "COULOMB" |
| 48 | + Volt Type = "VOLT" |
| 49 | + Farad Type = "FARAD" |
| 50 | + Ohm Type = "OHM" |
| 51 | + Siemens Type = "SIEMENS" |
| 52 | + Weber Type = "WEBER" |
| 53 | + Tesla Type = "TESLA" |
| 54 | + Henry Type = "HENRY" |
| 55 | + DegreesCelsius Type = "DEGREES_CELSIUS" |
| 56 | + Lumen Type = "LUMEN" |
| 57 | + Lux Type = "LUX" |
| 58 | + Becquerel Type = "BECQUEREL" |
| 59 | + Gray Type = "GRAY" |
| 60 | + Sievert Type = "SIEVERT" |
| 61 | + Katal Type = "KATAL" |
| 62 | + SquareMeter Type = "SQUARE_METER" |
| 63 | + CubicMeter Type = "CUBIC_METER" |
| 64 | + Liter Type = "LITER" |
| 65 | + MeterPerSecond Type = "METER_PER_SECOND" |
| 66 | + MeterPerSquareSecond Type = "METER_PER_SQUARE_SECOND" |
| 67 | + CubicMeterPerSecond Type = "CUBIC_METER_PER_SECOND" |
| 68 | + LiterPerSecond Type = "LITER_PER_SECOND" |
| 69 | + WattPerSquareMeter Type = "WATT_PER_SQUARE_METER" |
| 70 | + CandelaPerSquareMeter Type = "CANDELA_PER_SQUARE_METER" |
| 71 | + Bit Type = "BIT" |
| 72 | + BitPerSecond Type = "BIT_PER_SECOND" |
| 73 | + DegreesLatitude Type = "DEGREES_LATITUDE" |
| 74 | + DegreesLongitude Type = "DEGREES_LONGITUDE" |
| 75 | + PhValue Type = "PH_VALUE" |
| 76 | + Decibel Type = "DECIBEL" |
| 77 | + Decibel1w Type = "DECIBEL_1W" |
| 78 | + Bel Type = "BEL" |
| 79 | + Count Type = "COUNT" |
| 80 | + RatioDiv Type = "RATIO_DIV" |
| 81 | + RatioMod Type = "RATIO_MOD" |
| 82 | + PercentageRelativeHumidity Type = "PERCENTAGE_RELATIVE_HUMIDITY" |
| 83 | + PercentageBatteryLevel Type = "PERCENTAGE_BATTERY_LEVEL" |
| 84 | + SecondsBatteryLevel Type = "SECONDS_BATTERY_LEVEL" |
| 85 | + EventRateSecond Type = "EVENT_RATE_SECOND" |
| 86 | + EventRateMinute Type = "EVENT_RATE_MINUTE" |
| 87 | + HeartRate Type = "HEART_RATE" |
| 88 | + HeartBeats Type = "HEART_BEATS" |
| 89 | + SiemensPerMeter Type = "SIEMENS_PER_METER" |
| 90 | + // Complex properties |
| 91 | + Location Type = "LOCATION" |
| 92 | + ColorHSB Type = "COLOR_HSB" |
| 93 | + ColorRGB Type = "COLOR_RGB" |
| 94 | + GenericComplexProperty = "GENERIC_COMPLEX_PROPERTY" |
| 95 | + Schedule Type = "SCHEDULE" |
| 96 | + // Alexa Properties |
| 97 | + HomeColoredLight = "HOME_COLORED_LIGHT" |
| 98 | + HomeDimmedLight = "HOME_DIMMED_LIGHT" |
| 99 | + HomeLight Type = "HOME_LIGHT" |
| 100 | + HomeContactSensor = "HOME_CONTACT_SENSOR" |
| 101 | + HomeMotionSensor = "HOME_MOTION_SENSOR" |
| 102 | + HomeSmartPlugType = "HOME_SMART_PLUG" |
| 103 | + HomeTemperature = "HOME_TEMPERATURE" |
| 104 | + HomeTemperatureC = "HOME_TEMPERATURE_C" |
| 105 | + HomeTemperatureF = "HOME_TEMPERATURE_F" |
| 106 | + HomeSwitch Type = "HOME_SWITCH" |
| 107 | + HomeTelevision = "HOME_TELEVISION" |
| 108 | + // New Types based on dimensions |
| 109 | + Energy Type = "ENERGY" |
| 110 | + Force Type = "FORCE" |
| 111 | + Temperature Type = "TEMPERATURE" |
| 112 | + Power Type = "POWER" |
| 113 | + ElectricCurrent Type = "ELECTRIC_CURRENT" |
| 114 | + ElectricPotential = "ELECTRIC_POTENTIAL" |
| 115 | + ElectricalResistance = "ELECTRICAL_RESISTANCE" |
| 116 | + Capacitance Type = "CAPACITANCE" |
| 117 | + Time Type = "TIME" |
| 118 | + Frequency Type = "FREQUENCY" |
| 119 | + DataRate Type = "DATA_RATE" |
| 120 | + Acceleration Type = "ACCELERATION" |
| 121 | + Area Type = "AREA" |
| 122 | + Length Type = "LENGTH" |
| 123 | + Velocity Type = "VELOCITY" |
| 124 | + Mass Type = "MASS" |
| 125 | + Volume Type = "VOLUME" |
| 126 | + FlowRate Type = "FLOW_RATE" |
| 127 | + Angle Type = "ANGLE" |
| 128 | + Illuminance Type = "ILLUMINANCE" |
| 129 | + LuminousFlux Type = "LUMINOUS_FLUX" |
| 130 | + Luminance Type = "LUMINANCE" |
| 131 | + LuminousIntensity = "LUMINOUS_INTENSITY" |
| 132 | + LogarithmicQuantity = "LOGARITHMIC_QUANTITY" |
| 133 | + Pressure Type = "PRESSURE" |
| 134 | + InformationContent = "INFORMATION_CONTENT" |
| 135 | +) |
| 136 | + |
| 137 | +var floatPropertyTypes = []Type{ |
| 138 | + Analog, |
| 139 | + Float, |
| 140 | + LenghtC, |
| 141 | + LenghtI, |
| 142 | + LenghtM, |
| 143 | + Percentage, |
| 144 | + TemperatureC, |
| 145 | + TemperatureF, |
| 146 | + Meter, |
| 147 | + Kilogram, |
| 148 | + Gram, |
| 149 | + Second, |
| 150 | + Ampere, |
| 151 | + Kelvin, |
| 152 | + Candela, |
| 153 | + Mole, |
| 154 | + Hertz, |
| 155 | + Radian, |
| 156 | + Steradian, |
| 157 | + Newton, |
| 158 | + Pascal, |
| 159 | + Joule, |
| 160 | + Watt, |
| 161 | + Coulomb, |
| 162 | + Volt, |
| 163 | + Farad, |
| 164 | + Ohm, |
| 165 | + Siemens, |
| 166 | + Weber, |
| 167 | + Tesla, |
| 168 | + Henry, |
| 169 | + DegreesCelsius, |
| 170 | + Lumen, |
| 171 | + Lux, |
| 172 | + Becquerel, |
| 173 | + Gray, |
| 174 | + Sievert, |
| 175 | + Katal, |
| 176 | + SquareMeter, |
| 177 | + CubicMeter, |
| 178 | + Liter, |
| 179 | + MeterPerSecond, |
| 180 | + MeterPerSquareSecond, |
| 181 | + CubicMeterPerSecond, |
| 182 | + LiterPerSecond, |
| 183 | + WattPerSquareMeter, |
| 184 | + CandelaPerSquareMeter, |
| 185 | + Bit, |
| 186 | + BitPerSecond, |
| 187 | + DegreesLatitude, |
| 188 | + DegreesLongitude, |
| 189 | + PhValue, |
| 190 | + Decibel, |
| 191 | + Decibel1w, |
| 192 | + Bel, |
| 193 | + RatioDiv, |
| 194 | + RatioMod, |
| 195 | + PercentageRelativeHumidity, |
| 196 | + PercentageBatteryLevel, |
| 197 | + SecondsBatteryLevel, |
| 198 | + EventRateSecond, |
| 199 | + EventRateMinute, |
| 200 | + HeartRate, |
| 201 | + HeartBeats, |
| 202 | + SiemensPerMeter, |
| 203 | + HomeTemperature, |
| 204 | + HomeTemperatureC, |
| 205 | + HomeTemperatureF, |
| 206 | + Energy, |
| 207 | + Force, |
| 208 | + Temperature, |
| 209 | + Power, |
| 210 | + ElectricCurrent, |
| 211 | + ElectricPotential, |
| 212 | + ElectricalResistance, |
| 213 | + Capacitance, |
| 214 | + Frequency, |
| 215 | + DataRate, |
| 216 | + Acceleration, |
| 217 | + Area, |
| 218 | + Length, |
| 219 | + Velocity, |
| 220 | + Mass, |
| 221 | + Volume, |
| 222 | + FlowRate, |
| 223 | + Angle, |
| 224 | + Illuminance, |
| 225 | + LuminousFlux, |
| 226 | + Luminance, |
| 227 | + LuminousIntensity, |
| 228 | + LogarithmicQuantity, |
| 229 | + Pressure, |
| 230 | +} |
| 231 | + |
| 232 | +var intPropertyTypes = []Type{ |
| 233 | + Int, |
| 234 | + Count, |
| 235 | + Time, |
| 236 | + InformationContent, |
| 237 | +} |
| 238 | + |
| 239 | +var booleanPropertyTypes = []Type{ |
| 240 | + Status, |
| 241 | + HomeLight, |
| 242 | + HomeSwitch, |
| 243 | + HomeContactSensor, |
| 244 | + HomeMotionSensor, |
| 245 | +} |
| 246 | + |
| 247 | +func IsPropertyFloat(pType string) bool { |
| 248 | + for _, tpy := range floatPropertyTypes { |
| 249 | + if pType == string(tpy) { |
| 250 | + return true |
| 251 | + } |
| 252 | + } |
| 253 | + return false |
| 254 | +} |
| 255 | + |
| 256 | +func IsPropertyInt(pType string) bool { |
| 257 | + for _, tpy := range intPropertyTypes { |
| 258 | + if pType == string(tpy) { |
| 259 | + return true |
| 260 | + } |
| 261 | + } |
| 262 | + return false |
| 263 | +} |
| 264 | + |
| 265 | +func IsPropertyNumberType(pType string) bool { |
| 266 | + return IsPropertyFloat(pType) || IsPropertyInt(pType) |
| 267 | +} |
| 268 | + |
| 269 | +func IsPropertyString(pType string) bool { |
| 270 | + return pType == "CHARSTRING" |
| 271 | +} |
| 272 | + |
| 273 | +func IsPropertyLocation(pType string) bool { |
| 274 | + return Type(pType) == Location |
| 275 | +} |
| 276 | + |
| 277 | +func IsPropertyBool(pType string) bool { |
| 278 | + for _, tpy := range booleanPropertyTypes { |
| 279 | + if pType == string(tpy) { |
| 280 | + return true |
| 281 | + } |
| 282 | + } |
| 283 | + return false |
| 284 | +} |
0 commit comments