use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class SpecWithConfigMapping method createButtonFb.
private FunctionblockModel createButtonFb() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("digital_input_state");
digitalInputStateProperty.setType(PrimitiveType.BOOLEAN);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("boolean:toBoolean(\"true\")"));
ModelProperty digitalInputCount = new ModelProperty();
digitalInputCount.setMandatory(true);
digitalInputCount.setName("digital_input_count");
digitalInputCount.setType(PrimitiveType.INT);
digitalInputCount.setTargetPlatformKey("iotbutton");
digitalInputCount.addStereotype(Stereotype.createWithXpath("button:convertClickType(clickType)"));
buttonModel.setConfigurationProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty, digitalInputCount }));
return buttonModel;
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class SpecWithConfigMapping method createModel.
@Override
protected void createModel() {
FunctionblockModel buttonModel = createButtonFb();
infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
FunctionblockModel voltageModel = createVoltageFb();
infomodel.getFunctionblocks().add(ModelProperty.Builder("voltage", voltageModel).build());
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class SpecWithCustomFunction method createVoltageFb.
private FunctionblockModel createVoltageFb() {
FunctionblockModel voltageModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:Voltage:1.0.0"));
ModelProperty sensorValueProperty = new ModelProperty();
sensorValueProperty.setMandatory(true);
sensorValueProperty.setName("sensor_value");
sensorValueProperty.setType(PrimitiveType.FLOAT);
sensorValueProperty.setTargetPlatformKey("iotbutton");
sensorValueProperty.addStereotype(Stereotype.createWithXpath("number:toFloat(string:substring(batteryVoltage,0,string:length(batteryVoltage)-2))"));
ModelProperty sensorUnitsProperty = new ModelProperty();
sensorUnitsProperty.setMandatory(false);
sensorUnitsProperty.setName("sensor_units");
sensorUnitsProperty.setType(PrimitiveType.STRING);
sensorUnitsProperty.setTargetPlatformKey("iotbutton");
sensorUnitsProperty.addStereotype(Stereotype.createWithXpath("string:substring(batteryVoltage,string:length(batteryVoltage)-2)"));
voltageModel.setStatusProperties(Arrays.asList(new ModelProperty[] { sensorValueProperty, sensorUnitsProperty }));
return voltageModel;
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class SpecWithMultipleParams method createModel.
@Override
protected void createModel() {
FunctionblockModel buttonModel = createButtonFb();
infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class SpecGattConverter method createModel.
@Override
protected void createModel() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("sensor_value");
digitalInputStateProperty.setType(PrimitiveType.STRING);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("button:convertSensorValue(vorto_conversion1:byteArrayToInt(characteristics[@uuid='23-D1-13-EF-5F-78-23-15-DE-EF-12-12-0D-F0-00-00']/data, 3, 0, 0, 3))"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Aggregations