Skip to content

Commit

Permalink
New configuration assets
Browse files Browse the repository at this point in the history
  • Loading branch information
pankalog committed Dec 24, 2023
1 parent f909b2e commit 2ba164c
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.openremote.model.custom;

import jakarta.persistence.Entity;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetDescriptor;
import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.AttributeDescriptor;
import org.openremote.model.value.ValueType;

@Entity
public class TeltonikaConfigurationAsset extends Asset<TeltonikaConfigurationAsset> {
public static final AttributeDescriptor<String[]> WHITELIST = new AttributeDescriptor<>("deviceIMEIWhitelist", ValueType.TEXT.asArray()).withOptional(true);
public static final AttributeDescriptor<Boolean> ENABLED = new AttributeDescriptor<>("Enabled", ValueType.BOOLEAN);
public static final AttributeDescriptor<Boolean> CHECK_FOR_IMEI = new AttributeDescriptor<>("CheckForValidIMEI", ValueType.BOOLEAN);

public static final AssetDescriptor<TeltonikaConfigurationAsset> DESCRIPTOR = new AssetDescriptor<>("gear", null, TeltonikaConfigurationAsset.class);

protected TeltonikaConfigurationAsset(){

}

public TeltonikaConfigurationAsset(String name){
super(name);
super.setLocation(new GeoJSONPoint(0,0,0));
super.setNotes("");
}

public TeltonikaConfigurationAsset setWhitelist(String[] whitelist) {
getAttributes().getOrCreate(WHITELIST).setValue(whitelist);
return this;
}
public TeltonikaConfigurationAsset setEnabled(boolean enabled) {
getAttributes().getOrCreate(ENABLED).setValue(enabled);
return this;
}

public TeltonikaConfigurationAsset setCheckForImei(boolean enabled) {
getAttributes().getOrCreate(CHECK_FOR_IMEI).setValue(enabled);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.openremote.model.custom;

import jakarta.persistence.Entity;
import net.fortuna.ical4j.model.property.Geo;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetDescriptor;
import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.teltonika.TeltonikaParameter;
import org.openremote.model.value.AttributeDescriptor;
import org.openremote.model.value.ValueType;

@Entity
public class TeltonikaModelConfigurationAsset extends Asset<TeltonikaModelConfigurationAsset> {
public static final AttributeDescriptor<String> MODEL_NUMBER = new AttributeDescriptor<>("modelNumber", ValueType.TEXT);
public static final AttributeDescriptor<TeltonikaParameter[]> PARAMETER_DATA = new AttributeDescriptor<>("TeltonikaParameterData", CustomValueTypes.TELTONIKA_PARAMETER.asArray());
public static final AssetDescriptor<TeltonikaModelConfigurationAsset> DESCRIPTOR = new AssetDescriptor<>("switch", null, TeltonikaModelConfigurationAsset.class);

protected TeltonikaModelConfigurationAsset(){}

public TeltonikaModelConfigurationAsset(String name){
super(name);
super.setLocation(new GeoJSONPoint(0,0,0));
super.setNotes("");
}

public TeltonikaModelConfigurationAsset setModelNumber(String name) {
getAttributes().getOrCreate(MODEL_NUMBER).setValue(name);
return this;
}

public TeltonikaModelConfigurationAsset setParameterData(TeltonikaParameter[] data) {
getAttributes().getOrCreate(PARAMETER_DATA).setValue(data);
return this;
}
}

0 comments on commit 2ba164c

Please sign in to comment.