Search in sources :

Example 51 with FunctionblockModel

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

the class SpecWithConditionFunction method createModel.

@Override
protected void createModel() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    buttonModel.setTargetPlatformKey("iotbutton");
    buttonModel.addStereotype(Stereotype.createCondition("not empty(array[0])"));
    ModelProperty digitalInputStateProperty = new ModelProperty();
    digitalInputStateProperty.setMandatory(true);
    digitalInputStateProperty.setName("sensor_value");
    digitalInputStateProperty.setType(PrimitiveType.FLOAT);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("array[1]"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 52 with FunctionblockModel

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

the class SpecWithConditionalProperties 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.FLOAT);
    ModelProperty digitalInputStateProperty2 = new ModelProperty();
    digitalInputStateProperty2.setMandatory(true);
    digitalInputStateProperty2.setName("sensor_value2");
    digitalInputStateProperty2.setType(PrimitiveType.FLOAT);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithConditionalXpath("count == 0", "/count"));
    digitalInputStateProperty2.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty2.addStereotype(Stereotype.createWithConditionalXpath("count > 1", "/count"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty, digitalInputStateProperty2 }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 53 with FunctionblockModel

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

the class SpecWithConfiguration2 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.createWithXpath("/e"));
    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 54 with FunctionblockModel

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

the class SpecWithNestedEnum method createModel.

@Override
protected void createModel() {
    EnumModel unitEnum = EnumModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Enum:1.0.0")).literal("Celcius", null).literal("Fahrenheit", null).build();
    FunctionblockModel temperatureModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.Builder("value", PrimitiveType.FLOAT).withXPathStereotype("/temperature", "iotbutton").build()).statusProperty(ModelProperty.Builder("unit", unitEnum.getId()).withXPathStereotype("'Celcius'", "iotbutton").build()).build();
    infomodel.getFunctionblocks().add(ModelProperty.Builder("outdoorTemperature", temperatureModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) EnumModel(org.eclipse.vorto.model.EnumModel)

Example 55 with FunctionblockModel

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

the class SpecWithTwoFunctionblocksWithNestedEntity method createModel.

@Override
protected void createModel() {
    EntityModel sensorValueEntity = EntityModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:SensorValue:1.0.0")).property(ModelProperty.Builder("value", PrimitiveType.FLOAT).withXPathStereotype("/temperature", "iotbutton").build()).build();
    FunctionblockModel temperatureModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.Builder("value", sensorValueEntity).build()).build();
    infomodel.getFunctionblocks().add(ModelProperty.Builder("outdoorTemperature", temperatureModel).build());
    EntityModel sensorValueEntity2 = EntityModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:SensorValue:1.0.0")).property(ModelProperty.Builder("value", PrimitiveType.FLOAT).withXPathStereotype("/humidity", "iotbutton").build()).build();
    FunctionblockModel humidityModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Humidity:1.0.0")).statusProperty(ModelProperty.Builder("value", sensorValueEntity2).build()).build();
    infomodel.getFunctionblocks().add(ModelProperty.Builder("humidity", humidityModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) EntityModel(org.eclipse.vorto.model.EntityModel)

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