Search in sources :

Example 1 with ModelProperty

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

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

Example 2 with ModelProperty

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

the class SpecWithConstraintConfigMapping 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);
    Constraint constraint = new Constraint(ConstraintType.MAX, "5000");
    sensorValueProperty.setConstraints(Arrays.asList(constraint));
    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) Constraint(org.eclipse.vorto.model.Constraint) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 3 with ModelProperty

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

the class SpecWithMaliciousFunction 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("digital_input_count");
    digitalInputCount.setType(PrimitiveType.INT);
    digitalInputCount.setTargetPlatformKey("iotbutton");
    digitalInputCount.addStereotype(Stereotype.createWithXpath("button:convert(clickType)"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputCount }));
    return buttonModel;
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 4 with ModelProperty

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

the class SpecWithArrayPayload 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.STRING);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("array[1]/clickType"));
    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 5 with ModelProperty

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

the class SpecWithConditionedRules method createModel.

@Override
protected void createModel() {
    FunctionblockModel doorState = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    doorState.addStereotype(Stereotype.createCondition("data.key == 'DoorState'"));
    ModelProperty digitalInputStateProperty = new ModelProperty();
    digitalInputStateProperty.setMandatory(true);
    digitalInputStateProperty.setName("sensor_value");
    digitalInputStateProperty.setType(PrimitiveType.STRING);
    digitalInputStateProperty.setTargetPlatformKey("homeconnect");
    digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("data/value"));
    doorState.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
    FunctionblockModel operationState = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    operationState.addStereotype(Stereotype.createCondition("data.key == 'OperationState'"));
    ModelProperty digitalInputStateProperty1 = new ModelProperty();
    digitalInputStateProperty1.setMandatory(true);
    digitalInputStateProperty1.setName("sensor_value");
    digitalInputStateProperty1.setType(PrimitiveType.STRING);
    digitalInputStateProperty1.setTargetPlatformKey("homeconnect");
    digitalInputStateProperty1.addStereotype(Stereotype.createWithXpath("data/value"));
    operationState.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty1 }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("doorState", doorState).build());
    infomodel.getFunctionblocks().add(ModelProperty.Builder("operationState", operationState).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Aggregations

ModelProperty (org.eclipse.vorto.model.ModelProperty)39 FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)30 Property (org.eclipse.vorto.core.api.model.datatype.Property)5 EntityModel (org.eclipse.vorto.model.EntityModel)5 Infomodel (org.eclipse.vorto.model.Infomodel)5 ModelId (org.eclipse.vorto.core.api.model.model.ModelId)4 Constraint (org.eclipse.vorto.model.Constraint)4 EnumModel (org.eclipse.vorto.model.EnumModel)4 ModelEvent (org.eclipse.vorto.model.ModelEvent)3 ModelId (org.eclipse.vorto.model.ModelId)3 Operation (org.eclipse.vorto.model.Operation)3 Stereotype (org.eclipse.vorto.model.Stereotype)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)2 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)2 EntityBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.EntityBuilder)2 EventBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.EventBuilder)2