use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class SpecWithConditionFunction method createFBSpec.
@Override
protected void createFBSpec() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("sensor_value");
digitalInputStateProperty.setType(PrimitiveType.FLOAT);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithConditionalXpath("(base64:decodeString(data))[0] == 104", "string:toString(base64:decodeString(data),'utf8')"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
addFunctionblockProperty("button", buttonModel);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class SpecWithConditionXpath method createFBSpec.
@Override
protected void createFBSpec() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("sensor_value");
digitalInputStateProperty.setType(PrimitiveType.FLOAT);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithConditionalXpath("xpath:eval('data[@id = 100]/value',this) == 'x'", "100"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
addFunctionblockProperty("button", buttonModel);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty 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"), ModelType.Functionblock);
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.repository.api.content.ModelProperty in project vorto by eclipse.
the class SpecWithSameFunctionblock method createFBSpec.
@Override
protected void createFBSpec() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("sensor_value");
digitalInputStateProperty.setType(PrimitiveType.DATETIME);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("/@btnvalue1"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
addFunctionblockProperty("btn1", buttonModel);
FunctionblockModel buttonModel2 = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty2 = new ModelProperty();
digitalInputStateProperty2.setMandatory(true);
digitalInputStateProperty2.setName("sensor_value");
digitalInputStateProperty2.setType(PrimitiveType.DATETIME);
digitalInputStateProperty2.setTargetPlatformKey("iotbutton");
digitalInputStateProperty2.addStereotype(Stereotype.createWithXpath("/@btnvalue2"));
buttonModel2.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty2 }));
addFunctionblockProperty("btn2", buttonModel2);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class SpecWithTimestamp method createFBSpec.
@Override
protected void createFBSpec() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("sensor_value");
digitalInputStateProperty.setType(PrimitiveType.DATETIME);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("date:format(time)"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
addFunctionblockProperty("button", buttonModel);
}
Aggregations