Search in sources :

Example 56 with FunctionblockModel

use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.

the class SpecWithConfiguration method createModel.

@Override
protected void createModel() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    ModelProperty buttonEnableProperty = new ModelProperty();
    buttonEnableProperty.setMandatory(true);
    buttonEnableProperty.setName("enable");
    buttonEnableProperty.setType(PrimitiveType.BOOLEAN);
    buttonEnableProperty.setTargetPlatformKey("iotbutton");
    buttonEnableProperty.addStereotype(Stereotype.createTarget());
    buttonModel.setConfigurationProperties(Arrays.asList(new ModelProperty[] { buttonEnableProperty }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 57 with FunctionblockModel

use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.

the class SpecWithConfigMapping 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.setConfigurationProperties(Arrays.asList(new ModelProperty[] { sensorValueProperty, sensorUnitsProperty }));
    return voltageModel;
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 58 with FunctionblockModel

use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.

the class SpecWithCustomFunction 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());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel)

Example 59 with FunctionblockModel

use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.

the class SpecWithCustomFunction 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.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty, digitalInputCount }));
    return buttonModel;
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 60 with FunctionblockModel

use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.

the class SpecWithMultipleParams method createButtonFb.

private FunctionblockModel createButtonFb() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    ModelProperty digitalInputCount = new ModelProperty();
    digitalInputCount.setMandatory(true);
    digitalInputCount.setName("flag");
    digitalInputCount.setType(PrimitiveType.STRING);
    digitalInputCount.setTargetPlatformKey("iotbutton");
    digitalInputCount.addStereotype(Stereotype.createWithXpath("button:convertArray(/data,/header)"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputCount }));
    return buttonModel;
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Aggregations

FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)61 ModelProperty (org.eclipse.vorto.model.ModelProperty)32 Infomodel (org.eclipse.vorto.model.Infomodel)17 Test (org.junit.Test)17 FunctionblockValue (org.eclipse.vorto.model.runtime.FunctionblockValue)6 EntityModel (org.eclipse.vorto.model.EntityModel)5 EnumModel (org.eclipse.vorto.model.EnumModel)5 ArrayList (java.util.ArrayList)3 DictionaryPropertyType (org.eclipse.vorto.core.api.model.datatype.DictionaryPropertyType)3 Property (org.eclipse.vorto.core.api.model.datatype.Property)3 DictionaryType (org.eclipse.vorto.model.DictionaryType)3 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)3 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)2 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)2 InformationModelBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.InformationModelBuilder)2 PrimitivePropertyType (org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType)2 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)2 MappingException (org.eclipse.vorto.mapping.engine.MappingException)2 Constraint (org.eclipse.vorto.model.Constraint)2 ModelContent (org.eclipse.vorto.model.ModelContent)2