Search in sources :

Example 11 with FunctionblockModel

use of org.eclipse.vorto.repository.api.content.FunctionblockModel 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);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 12 with FunctionblockModel

use of org.eclipse.vorto.repository.api.content.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"), 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;
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 13 with FunctionblockModel

use of org.eclipse.vorto.repository.api.content.FunctionblockModel 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);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 14 with FunctionblockModel

use of org.eclipse.vorto.repository.api.content.FunctionblockModel 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);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 15 with FunctionblockModel

use of org.eclipse.vorto.repository.api.content.FunctionblockModel in project vorto by eclipse.

the class SpecWithTypeConversion 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.STRING);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("type:convertDouble(/@lng[1])"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    addFunctionblockProperty("button", buttonModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Aggregations

FunctionblockModel (org.eclipse.vorto.repository.api.content.FunctionblockModel)21 ModelProperty (org.eclipse.vorto.repository.api.content.ModelProperty)18 Test (org.junit.Test)4 Infomodel (org.eclipse.vorto.repository.api.content.Infomodel)2 Stereotype (org.eclipse.vorto.repository.api.content.Stereotype)2 ArrayList (java.util.ArrayList)1 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)1 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)1 ModelId (org.eclipse.vorto.repository.api.ModelId)1 EntityModel (org.eclipse.vorto.repository.api.content.EntityModel)1 JavascriptFunctions (org.eclipse.vorto.service.mapping.internal.converter.JavascriptFunctions)1 DefaultMappingSpecification (org.eclipse.vorto.service.mapping.internal.spec.DefaultMappingSpecification)1 FunctionblockData (org.eclipse.vorto.service.mapping.normalized.FunctionblockData)1