use of org.eclipse.vorto.model.Infomodel in project vorto by eclipse.
the class DefaultPayloadMappingService method getOrCreateSpecification.
@Override
public IMappingSpecification getOrCreateSpecification(ModelId modelId) {
ModelContent modelContent = getModelContent(modelId, createTargetPlatformKey(modelId));
Infomodel infomodel = (Infomodel) modelContent.getModels().get(modelContent.getRoot());
MappingSpecification specification = new MappingSpecification();
specification.setInfoModel(infomodel);
addReferencesRecursive(infomodel, infomodel.getTargetPlatformKey());
return specification;
}
use of org.eclipse.vorto.model.Infomodel in project vorto by eclipse.
the class TwinPayloadFactoryTest method testCreateRequestSingleMultipleFbProperties.
@Test
public void testCreateRequestSingleMultipleFbProperties() {
FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("indoorTemperature", fbm).build()).withProperty(ModelProperty.Builder("outdoorTemperature", fbm).build()).build();
FunctionblockValue indoorTemperature = new FunctionblockValue(fbm);
indoorTemperature.withStatusProperty("value", 20.2);
FunctionblockValue outdoorTemperature = new FunctionblockValue(fbm);
outdoorTemperature.withStatusProperty("value", 9.2);
InfomodelValue infomodelValue = new InfomodelValue(infomodel);
infomodelValue.withFunctionblock("indoorTemperature", indoorTemperature);
infomodelValue.withFunctionblock("outdoorTemperature", outdoorTemperature);
System.out.println(gson.toJson(TwinPayloadFactory.toShadowUpdateRequest(infomodelValue)));
}
use of org.eclipse.vorto.model.Infomodel in project vorto by eclipse.
the class TwinPayloadFactoryTest method testCreateRequestSingleMultipleFbProperties.
@Test
public void testCreateRequestSingleMultipleFbProperties() {
FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("indoorTemperature", fbm).build()).withProperty(ModelProperty.Builder("outdoorTemperature", fbm).build()).build();
FunctionblockValue indoorTemperature = new FunctionblockValue(fbm);
indoorTemperature.withStatusProperty("value", 20.2);
FunctionblockValue outdoorTemperature = new FunctionblockValue(fbm);
outdoorTemperature.withStatusProperty("value", 9.2);
InfomodelValue infomodelValue = new InfomodelValue(infomodel);
infomodelValue.withFunctionblock("indoorTemperature", indoorTemperature);
infomodelValue.withFunctionblock("outdoorTemperature", outdoorTemperature);
System.out.println(gson.toJson(TwinPayloadFactory.toDittoProtocol(infomodelValue, "com.acme:Sensor-1")));
}
use of org.eclipse.vorto.model.Infomodel in project vorto by eclipse.
the class TwinPayloadFactoryTest method testCreateRequestSingleFbPropertyforEntireInfomodel.
@Test
public void testCreateRequestSingleFbPropertyforEntireInfomodel() {
FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("temperature", fbm).build()).build();
FunctionblockValue fbValue = new FunctionblockValue(fbm);
fbValue.withStatusProperty("value", 20.2);
InfomodelValue infomodelValue = new InfomodelValue(infomodel);
infomodelValue.withFunctionblock("temperature", fbValue);
System.out.println(gson.toJson(TwinPayloadFactory.toDittoProtocol(infomodelValue, "com.acme:Sensor-1")));
}
use of org.eclipse.vorto.model.Infomodel in project vorto by eclipse.
the class ModelContentToEcoreConverter method convertInformationModel.
private InformationModel convertInformationModel(Infomodel model, ModelContent context) {
InformationModelBuilder builder = BuilderUtils.newInformationModel(new ModelId(ModelType.InformationModel, model.getId().getName(), model.getId().getNamespace(), model.getId().getVersion()));
builder.withCategory(model.getCategory());
builder.withDescription(model.getDescription());
builder.withDisplayName(model.getDisplayName());
builder.withVortolang(model.getVortolang());
for (ModelProperty property : model.getFunctionblocks()) {
FunctionblockModel fbModel = (FunctionblockModel) context.getModels().get((org.eclipse.vorto.model.ModelId) property.getType());
org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel convertedFb = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) convertFunctionblock(fbModel, context);
builder.withReference(ModelIdFactory.newInstance(convertedFb));
builder.withFunctionBlock(convertedFb, property.getName(), property.getDescription(), property.isMandatory());
}
return builder.build();
}
Aggregations