use of org.eclipse.vorto.model.ModelProperty 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());
}
use of org.eclipse.vorto.model.ModelProperty 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());
}
use of org.eclipse.vorto.model.ModelProperty 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());
}
use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.
the class ValidationTest method createModel.
private FunctionblockModel createModel(PrimitiveType type) {
FunctionblockModel fbModel = new FunctionblockModel(ModelId.fromPrettyFormat("default:TestFB:1.0.0"));
List<ModelProperty> properties = new ArrayList<>();
properties.add(ModelProperty.createPrimitiveProperty("prop", true, type));
fbModel.setStatusProperties(properties);
return fbModel;
}
use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.
the class InfomodelValue method validate.
@Override
public ValidationReport validate() {
ValidationReport report = new ValidationReport();
for (ModelProperty fbProperty : meta.getFunctionblocks()) {
if (fbProperty.isMandatory() && !functionblocks.containsKey(fbProperty.getName())) {
report.addItem(fbProperty, "Mandatory property is missing!");
} else {
FunctionblockValue fbData = functionblocks.get(fbProperty.getName());
if (fbData != null) {
ValidationReport fbReport = fbData.validate();
report.addReport(fbReport);
}
}
}
return report;
}
Aggregations