100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Add and update to standard assettypes
Don29e107d25940
diff --git a/model/src/main/java/org/openremote/model/asset/impl/BuildingAsset.java b/model/src/main/java/org/openremote/model/asset/impl/BuildingAsset.javaindex d7461cfee..6eb07a812 100644--- a/model/src/main/java/org/openremote/model/asset/impl/BuildingAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/BuildingAsset.java@@ -32,11 +32,16 @@ import java.util.Collection;import java.util.Date;import java.util.Optional;+import static org.openremote.model.Constants.*;+@Entitypublic class BuildingAsset extends CityAsset {public static final AttributeDescriptor<String> STREET = new AttributeDescriptor<>("street", ValueType.TEXT);public static final AttributeDescriptor<String> POSTAL_CODE = new AttributeDescriptor<>("postalCode", ValueType.TEXT);+ public static final AttributeDescriptor<Integer> AREA = new AttributeDescriptor<>("area", ValueType.POSITIVE_INTEGER)+ .withUnits(UNITS_METRE, UNITS_SQUARED);+ public static final AttributeDescriptor<String> COUNTRY = CityAsset.COUNTRY.withOptional(true);public static final AssetDescriptor<BuildingAsset> DESCRIPTOR = new AssetDescriptor<>("office-building", "4b5966", BuildingAsset.class);@@ -55,6 +60,10 @@ public class BuildingAsset extends CityAsset {return getAttributes().getValue(STREET);}+ public Optional<Integer> getArea() {+ return getAttributes().getValue(AREA);+ }+public Optional<String> getPostalCode() {return getAttributes().getValue(POSTAL_CODE);}diff --git a/model/src/main/java/org/openremote/model/asset/impl/CityAsset.java b/model/src/main/java/org/openremote/model/asset/impl/CityAsset.javaindex 9304fec63..ccb5a9dc9 100644--- a/model/src/main/java/org/openremote/model/asset/impl/CityAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/CityAsset.java@@ -30,8 +30,10 @@ import java.util.Optional;@Entitypublic class CityAsset extends Asset<CityAsset> {- public static final AttributeDescriptor<String> CITY = new AttributeDescriptor<>("city", ValueType.TEXT);+ public static final AttributeDescriptor<String> REGION = new AttributeDescriptor<>("region", ValueType.TEXT);public static final AttributeDescriptor<String> COUNTRY = new AttributeDescriptor<>("country", ValueType.TEXT);+ public static final AttributeDescriptor<String> CITY = new AttributeDescriptor<>("city", ValueType.TEXT)+ .withOptional(true);public static final AssetDescriptor<CityAsset> DESCRIPTOR = new AssetDescriptor<>("city", null, CityAsset.class);@@ -50,6 +52,10 @@ public class CityAsset extends Asset<CityAsset> {return getAttributes().getValue(CITY);}+ public Optional<String> getRegion() {+ return getAttributes().getValue(REGION);+ }+public Optional<String> getCountry() {return getAttributes().getValue(COUNTRY);}diff --git a/model/src/main/java/org/openremote/model/asset/impl/DoorSensorAsset.java b/model/src/main/java/org/openremote/model/asset/impl/DoorSensorAsset.javanew file mode 100644index 000000000..b812309d9--- /dev/null+++ b/model/src/main/java/org/openremote/model/asset/impl/DoorSensorAsset.java@@ -0,0 +1,60 @@+/*+ * Copyright 2020, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.asset.impl;++import org.openremote.model.asset.Asset;+import org.openremote.model.asset.AssetDescriptor;+import org.openremote.model.attribute.MetaItem;+import org.openremote.model.value.AttributeDescriptor;+import org.openremote.model.value.MetaItemType;+import org.openremote.model.value.ValueType;++import javax.persistence.Entity;+import java.util.Optional;++@Entity+public class DoorSensorAsset extends Asset<DoorSensorAsset> {++ public static final AttributeDescriptor<Boolean> OPEN = new AttributeDescriptor<>("open", ValueType.BOOLEAN,+ new MetaItem<>(MetaItemType.READ_ONLY));+ public static final AttributeDescriptor<Boolean> LOCKED = new AttributeDescriptor<>("locked", ValueType.BOOLEAN,+ new MetaItem<>(MetaItemType.READ_ONLY));++ public static final AssetDescriptor<DoorSensorAsset> DESCRIPTOR = new AssetDescriptor<>("door", "ae2eb6", DoorSensorAsset.class);++ /**+ * For use by hydrators (i.e. JPA/Jackson)+ */+ DoorSensorAsset() {+ this(null);+ }++ public DoorSensorAsset(String name) {+ super(name);+ }++ public Optional<Boolean> getOpen() {+ return getAttributes().getValue(OPEN);+ }++ public Optional<Boolean> getLocked() {+ return getAttributes().getValue(LOCKED);+ }+}diff --git a/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.javaindex db7bd6940..e86e68387 100644--- a/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/ElectricityProducerWindAsset.java@@ -38,6 +38,8 @@ public class ElectricityProducerWindAsset extends ElectricityProducerAsset {public static final AttributeDescriptor<Double> WIND_SPEED_REFERENCE = new AttributeDescriptor<>("windSpeedReference", ValueType.POSITIVE_NUMBER).withUnits(UNITS_METRE, UNITS_PER, UNITS_SECOND);+ public static final AttributeDescriptor<Double> WIND_SPEED_MIN = new AttributeDescriptor<>("windSpeedMin", ValueType.POSITIVE_NUMBER+ ).withUnits(UNITS_METRE, UNITS_PER, UNITS_SECOND);public static final AssetDescriptor<ElectricityProducerWindAsset> DESCRIPTOR = new AssetDescriptor<>("wind-turbine", "4B87EA", ElectricityProducerWindAsset.class);@@ -52,6 +54,10 @@ public class ElectricityProducerWindAsset extends ElectricityProducerAsset {return getAttributes().getValue(WIND_SPEED_REFERENCE);}+ public Optional<Double> getWindSpeedMin() {+ return getAttributes().getValue(WIND_SPEED_MIN);+ }+@Overridepublic ElectricityProducerWindAsset setPower(Double value) {super.setPower(value);diff --git a/model/src/main/java/org/openremote/model/asset/impl/PlugAsset.java b/model/src/main/java/org/openremote/model/asset/impl/PlugAsset.javaindex e66c59254..08d9459dd 100644--- a/model/src/main/java/org/openremote/model/asset/impl/PlugAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/PlugAsset.java@@ -34,7 +34,7 @@ public class PlugAsset extends Asset<PlugAsset> {public static final AttributeDescriptor<Boolean> ON_OFF = new AttributeDescriptor<>("onOff", ValueType.BOOLEAN).withFormat(ValueFormat.BOOLEAN_ON_OFF());- public static final AssetDescriptor<PlugAsset> DESCRIPTOR = new AssetDescriptor<>("plug", "e6688a", PlugAsset.class);+ public static final AssetDescriptor<PlugAsset> DESCRIPTOR = new AssetDescriptor<>("power-socket-eu", "e6688a", PlugAsset.class);/*** For use by hydrators (i.e. JPA/Jackson)diff --git a/model/src/main/java/org/openremote/model/asset/impl/PresenceSensorAsset.java b/model/src/main/java/org/openremote/model/asset/impl/PresenceSensorAsset.javanew file mode 100644index 000000000..807c63956--- /dev/null+++ b/model/src/main/java/org/openremote/model/asset/impl/PresenceSensorAsset.java@@ -0,0 +1,54 @@+/*+ * Copyright 2020, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.asset.impl;++import org.openremote.model.asset.Asset;+import org.openremote.model.asset.AssetDescriptor;+import org.openremote.model.attribute.MetaItem;+import org.openremote.model.value.AttributeDescriptor;+import org.openremote.model.value.MetaItemType;+import org.openremote.model.value.ValueType;++import javax.persistence.Entity;+import java.util.Optional;++@Entity+public class PresenceSensorAsset extends Asset<PresenceSensorAsset> {++ public static final AttributeDescriptor<Boolean> PRESENCE = new AttributeDescriptor<>("presence", ValueType.BOOLEAN,+ new MetaItem<>(MetaItemType.READ_ONLY));++ public static final AssetDescriptor<PresenceSensorAsset> DESCRIPTOR = new AssetDescriptor<>("eye-circle", "5a20cc", PresenceSensorAsset.class);++ /**+ * For use by hydrators (i.e. JPA/Jackson)+ */+ PresenceSensorAsset() {+ this(null);+ }++ public PresenceSensorAsset(String name) {+ super(name);+ }++ public Optional<Boolean> getPresence() {+ return getAttributes().getValue(PRESENCE);+ }+}diff --git a/model/src/main/java/org/openremote/model/asset/impl/RoomAsset.java b/model/src/main/java/org/openremote/model/asset/impl/RoomAsset.javaindex 7b39be7d9..70c89ca89 100644--- a/model/src/main/java/org/openremote/model/asset/impl/RoomAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/RoomAsset.java@@ -21,12 +21,21 @@ package org.openremote.model.asset.impl;import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetDescriptor;+import org.openremote.model.value.AttributeDescriptor;+import org.openremote.model.value.ValueType;import javax.persistence.Entity;+import java.util.Optional;++import static org.openremote.model.Constants.*;@Entitypublic class RoomAsset extends Asset<RoomAsset> {+ public static final AttributeDescriptor<Integer> AREA = new AttributeDescriptor<>("area", ValueType.POSITIVE_INTEGER)+ .withUnits(UNITS_METRE, UNITS_SQUARED);+ public static final AttributeDescriptor<Integer> ROOM_NUMBER = new AttributeDescriptor<>("roomNumber", ValueType.POSITIVE_INTEGER);+public static final AssetDescriptor<RoomAsset> DESCRIPTOR = new AssetDescriptor<>("door", "2eaaa2", RoomAsset.class);/**@@ -36,6 +45,14 @@ public class RoomAsset extends Asset<RoomAsset> {this(null);}+ public Optional<Integer> getArea() {+ return getAttributes().getValue(AREA);+ }++ public Optional<Integer> getRoomNumber() {+ return getAttributes().getValue(ROOM_NUMBER);+ }+public RoomAsset(String name) {super(name);}diff --git a/model/src/main/java/org/openremote/model/asset/impl/ShipAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ShipAsset.javaindex e3358a236..475e49090 100644--- a/model/src/main/java/org/openremote/model/asset/impl/ShipAsset.java+++ b/model/src/main/java/org/openremote/model/asset/impl/ShipAsset.java@@ -21,7 +21,9 @@ package org.openremote.model.asset.impl;import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetDescriptor;+import org.openremote.model.attribute.MetaItem;import org.openremote.model.value.AttributeDescriptor;+import org.openremote.model.value.MetaItemType;import org.openremote.model.value.ValueType;import javax.persistence.Entity;@@ -33,8 +35,10 @@ import static org.openremote.model.Constants.UNITS_METRE;@Entitypublic class ShipAsset extends Asset<ShipAsset> {- public static final AttributeDescriptor<Integer> MSSI_NUMBER = new AttributeDescriptor<>("mSSINumber", ValueType.POSITIVE_INTEGER);- public static final AttributeDescriptor<Integer> IMO_NUMBER = new AttributeDescriptor<>("iMONumber", ValueType.POSITIVE_INTEGER);+ public static final AttributeDescriptor<Integer> MSSI_NUMBER = new AttributeDescriptor<>("mSSINumber", ValueType.POSITIVE_INTEGER,+ new MetaItem<>(MetaItemType.LABEL, "MSSI number"));+ public static final AttributeDescriptor<Integer> IMO_NUMBER = new AttributeDescriptor<>("iMONumber", ValueType.POSITIVE_INTEGER,+ new MetaItem<>(MetaItemType.LABEL, "IMO number"));public static final AttributeDescriptor<Integer> DIRECTION = new AttributeDescriptor<>("direction", ValueType.DIRECTION);public static final AttributeDescriptor<Integer> LENGTH = new AttributeDescriptor<>("length", ValueType.POSITIVE_INTEGER).withUnits(UNITS_METRE);diff --git a/model/src/main/java/org/openremote/model/asset/impl/ThermostatAsset.java b/model/src/main/java/org/openremote/model/asset/impl/ThermostatAsset.javanew file mode 100644index 000000000..def827234--- /dev/null+++ b/model/src/main/java/org/openremote/model/asset/impl/ThermostatAsset.java@@ -0,0 +1,69 @@+/*+ * Copyright 2020, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.asset.impl;++import org.openremote.model.asset.Asset;+import org.openremote.model.asset.AssetDescriptor;+import org.openremote.model.attribute.MetaItem;+import org.openremote.model.value.AttributeDescriptor;+import org.openremote.model.value.MetaItemType;+import org.openremote.model.value.ValueFormat;+import org.openremote.model.value.ValueType;++import javax.persistence.Entity;+import java.util.Optional;++import static org.openremote.model.Constants.UNITS_CELSIUS;++@Entity+public class ThermostatAsset extends Asset<ThermostatAsset> {++ public static final AttributeDescriptor<Double> TEMPERATURE_SETPOINT = new AttributeDescriptor<>("temperatureSetpoint", ValueType.NUMBER)+ .withUnits(UNITS_CELSIUS).withFormat(ValueFormat.NUMBER_1_DP());+ public static final AttributeDescriptor<Double> TEMPERATURE = new AttributeDescriptor<>("temperature", ValueType.NUMBER,+ new MetaItem<>(MetaItemType.READ_ONLY))+ .withUnits(UNITS_CELSIUS).withFormat(ValueFormat.NUMBER_1_DP());+ public static final AttributeDescriptor<Boolean> COOLING = new AttributeDescriptor<>("cooling", ValueType.BOOLEAN);++ public static final AssetDescriptor<ThermostatAsset> DESCRIPTOR = new AssetDescriptor<>("thermostat", "f5b324", ThermostatAsset.class);++ /**+ * For use by hydrators (i.e. JPA/Jackson)+ */+ ThermostatAsset() {+ this(null);+ }++ public ThermostatAsset(String name) {+ super(name);+ }++ public Optional<Double> getTemperatureSetpoint() {+ return getAttributes().getValue(TEMPERATURE_SETPOINT);+ }++ public Optional<Double> getTemperature() {+ return getAttributes().getValue(TEMPERATURE);+ }++ public Optional<Boolean> getCooling() {+ return getAttributes().getValue(COOLING);+ }+}diff --git a/model/src/main/java/org/openremote/model/asset/impl/VentilationAsset.java b/model/src/main/java/org/openremote/model/asset/impl/VentilationAsset.javanew file mode 100644index 000000000..2e51ea0d8--- /dev/null+++ b/model/src/main/java/org/openremote/model/asset/impl/VentilationAsset.java@@ -0,0 +1,61 @@+/*+ * Copyright 2020, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.asset.impl;++import org.openremote.model.asset.Asset;+import org.openremote.model.asset.AssetDescriptor;+import org.openremote.model.attribute.MetaItem;+import org.openremote.model.value.*;++import javax.persistence.Entity;+import java.util.Optional;++import static org.openremote.model.Constants.*;++@Entity+public class VentilationAsset extends Asset<VentilationAsset> {++ public static final AttributeDescriptor<Integer> FAN_SPEED = new AttributeDescriptor<>("fanSpeed", ValueType.POSITIVE_INTEGER)+ .withUnits(UNITS_PERCENTAGE).withConstraints(new ValueConstraint.Min(0), new ValueConstraint.Max(100));+ public static final AttributeDescriptor<Double> FLOW = new AttributeDescriptor<>("flow", ValueType.NUMBER,+ new MetaItem<>(MetaItemType.READ_ONLY))+ .withUnits(UNITS_METRE, UNITS_CUBED, UNITS_PER, UNITS_HOUR);++ public static final AssetDescriptor<VentilationAsset> DESCRIPTOR = new AssetDescriptor<>("fan", "0b99c3", VentilationAsset.class);++ /**+ * For use by hydrators (i.e. JPA/Jackson)+ */+ VentilationAsset() {+ this(null);+ }++ public VentilationAsset(String name) {+ super(name);+ }++ public Optional<Double> getFlow() {+ return getAttributes().getValue(FLOW);+ }++ public Optional<Integer> getFanSpeed() {+ return getAttributes().getValue(FAN_SPEED);+ }+}