Search in sources :

Example 21 with ModelProperty

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

the class SpecWithCondition 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);
    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 }));
    addFunctionblockProperty("button", buttonModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 22 with ModelProperty

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

the class SpecWithConditionedRules method createFBSpec.

@Override
protected void createFBSpec() {
    FunctionblockModel doorState = 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("homeconnect");
    digitalInputStateProperty.addStereotype(Stereotype.createWithConditionalXpath("data.key == 'DoorState'", "data/value"));
    doorState.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    FunctionblockModel operationState = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
    ModelProperty digitalInputStateProperty1 = new ModelProperty();
    digitalInputStateProperty1.setMandatory(true);
    digitalInputStateProperty1.setName("sensor_value");
    digitalInputStateProperty1.setType(PrimitiveType.STRING);
    digitalInputStateProperty1.setTargetPlatformKey("homeconnect");
    digitalInputStateProperty1.addStereotype(Stereotype.createWithConditionalXpath("data.key == 'OperationState'", "data/value"));
    operationState.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty1 }));
    addFunctionblockProperty("doorState", doorState);
    addFunctionblockProperty("operationState", operationState);
}
Also used : FunctionblockModel(org.eclipse.vorto.repository.api.content.FunctionblockModel) ModelProperty(org.eclipse.vorto.repository.api.content.ModelProperty)

Example 23 with ModelProperty

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

Aggregations

ModelProperty (org.eclipse.vorto.repository.api.content.ModelProperty)23 FunctionblockModel (org.eclipse.vorto.repository.api.content.FunctionblockModel)18 Infomodel (org.eclipse.vorto.repository.api.content.Infomodel)4 Stereotype (org.eclipse.vorto.repository.api.content.Stereotype)3 ArrayList (java.util.ArrayList)2 MappingRule (org.eclipse.vorto.core.api.model.mapping.MappingRule)2 ReferenceTarget (org.eclipse.vorto.core.api.model.mapping.ReferenceTarget)2 StereoTypeTarget (org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)2 ModelId (org.eclipse.vorto.repository.api.ModelId)2 EntityModel (org.eclipse.vorto.repository.api.content.EntityModel)2 FunctionblockData (org.eclipse.vorto.service.mapping.normalized.FunctionblockData)2 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 JXPathContext (org.apache.commons.jxpath.JXPathContext)1 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)1 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)1 BooleanPropertyAttribute (org.eclipse.vorto.core.api.model.datatype.BooleanPropertyAttribute)1 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)1