-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
34 deletions.
There are no files selected for viewing
74 changes: 41 additions & 33 deletions
74
sensor-data-bridge/src/main/java/nl/bertriksikken/pm/ESensorItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,70 @@ | ||
package nl.bertriksikken.pm; | ||
|
||
import java.util.Locale; | ||
|
||
public enum ESensorItem { | ||
PM10("Particulate matter PM10 (aka P1)", "ug/m3", 0), | ||
PM2_5("Particulate matter PM2.5 (aka P2)", "ug/m3", 0), | ||
PM4_0("Particulate matter PM4 (aka P4)", "ug/m3", 0), | ||
PM1_0("Particulate matter PM1.0 (aka P0)", "ug/m3", 0), | ||
|
||
PM10("Particulate matter PM10 (aka P1), in ug/m3", 0), | ||
PM2_5("Particulate matter PM2.5 (aka P2), in ug/m3", 0), | ||
PM4_0("Particulate matter PM4 (aka P4), in ug/m3", 0), | ||
PM1_0("Particulate matter PM1.0 (aka P0), in ug/m3", 0), | ||
|
||
PM10_N("Particulate matter PM10, in #/cm3", 0), | ||
PM4_0_N("Particulate matter PM4, in #/cm3", 0), | ||
PM2_5_N("Particulate matter PM2.5, in #/cm3", 0), | ||
PM1_0_N("Particulate matter PM1.0, in #/cm3", 0), | ||
PM0_5_N("Particulate matter PM0.5, in #/cm3", 0), | ||
PM10_N("Particulate matter PM10", "#/cm3", 0), | ||
PM4_0_N("Particulate matter PM4", "#/cm3", 0), | ||
PM2_5_N("Particulate matter PM2.5", "#/cm3", 0), | ||
PM1_0_N("Particulate matter PM1.0", "#/cm3", 0), | ||
PM0_5_N("Particulate matter PM0.5", "#/cm3", 0), | ||
|
||
PM_TPS("Typical particle size, in um"), | ||
PM_TPS("Typical particle size", "um"), | ||
|
||
HUMIDITY("Relative humidity, in percent", 0, 100), | ||
TEMPERATURE("Temperature, in degrees Celcius", -100, 100), | ||
PRESSURE("Atmospheric pressure, in Pa", 0, 1E6), | ||
HUMIDITY("Relative humidity", "%", 0, 100), | ||
TEMPERATURE("Temperature", "degC", -100, 100), | ||
PRESSURE("Atmospheric pressure", "Pa", 0, 1E6), | ||
|
||
POS_LAT("Latitude in degrees", -90, 90), | ||
POS_LON("Longitude in degrees", -180, 180), | ||
POS_ALT("Altitude in meters"), | ||
POS_LAT("Latitude", "deg", -90, 90), | ||
POS_LON("Longitude", "deg", -180, 180), | ||
POS_ALT("Altitude", "m"), | ||
|
||
NOISE_LA_EQ("Noise avg (dBA)", 0, 200), | ||
NOISE_LA_MIN("Noise min (dBA)", 0, 200), | ||
NOISE_LA_MAX("Noise max (dBA)", 0, 200), | ||
NOISE_LA_EQ("Noise avg", "dBA", 0, 200), | ||
NOISE_LA_MIN("Noise min", "dBA", 0, 200), | ||
NOISE_LA_MAX("Noise max", "dBA", 0, 200), | ||
|
||
NO2("NO2 concentration (unit?)", 0), | ||
RADIATION("Radiation (unit?)", 0), | ||
NO2("NO2 concentration", "?", 0), | ||
RADIATION("Radiation", "?", 0), | ||
|
||
LORA_SF("Spreading factor", 6, 12), | ||
LORA_SNR("Signal-to-noise ratio"), | ||
LORA_RSSI("Signal strength, in dBm"); | ||
LORA_SF("Spreading factor", "", 6, 12), | ||
LORA_SNR("Signal-to-noise ratio", "dB"), | ||
LORA_RSSI("Signal strength", "dBm"); | ||
|
||
private String description; | ||
private String unit; | ||
private double minValue; | ||
private double maxValue; | ||
private String description; | ||
|
||
private ESensorItem(String description, double minValue, double maxValue) { | ||
private ESensorItem(String description, String unit, double minValue, double maxValue) { | ||
this.description = description; | ||
this.unit = unit; | ||
this.minValue = minValue; | ||
this.maxValue = maxValue; | ||
} | ||
|
||
private ESensorItem(String description, double minValue) { | ||
this(description, minValue, Double.POSITIVE_INFINITY); | ||
private ESensorItem(String description, String unit, double minValue) { | ||
this(description, unit, minValue, Double.POSITIVE_INFINITY); | ||
} | ||
|
||
private ESensorItem(String description) { | ||
this(description, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); | ||
private ESensorItem(String description, String unit) { | ||
this(description, unit, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
@Override | ||
public String toString() { | ||
return String.format(Locale.ROOT, "%s (%s)", description, unit); | ||
} | ||
|
||
public boolean inRange(Double value) { | ||
return Double.isFinite(value) && (value >= minValue) && (value <= maxValue); | ||
} | ||
|
||
public String format(Number value) { | ||
return String.format(Locale.ROOT, "%s=%s%s", name(), value, unit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters