use of org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty in project vorto by eclipse.
the class ModelTransformer method transform.
public Device transform() {
this.factory = ModelFactoryImpl.init();
this.device = this.factory.createDevice();
this.device.setName(this.infomodel.getName());
this.device.setInfomodel(this.infomodel);
IMapped<InformationModel> map = this.context.getMappedElement(infomodel, "DeviceInfoProfile");
if (map.hasAttribute("modelNumber")) {
String modelNumber = map.getAttributeValue("modelNumber", "0");
Service service = this.factory.createService();
service.setName("DeviceInformation");
service.setUuid("0000180a-0000-1000-8000-00805f9b34fb");
Characteristic characteristic = this.factory.createCharacteristic();
characteristic.setName("ModelNumber");
characteristic.setUuid("00002a24-0000-1000-8000-00805f9b34fb");
characteristic.setLength(modelNumber.length() / 2);
StringBuffer mnBuf = new StringBuffer();
mnBuf.append("{");
for (int i = 0; i < modelNumber.length(); i += 2) {
mnBuf.append("0x" + modelNumber.substring(i, i + 2));
if (i < modelNumber.length() - 2) {
mnBuf.append(", ");
}
}
mnBuf.append("}");
characteristic.setValue(mnBuf.toString());
service.getCharacteristics().add(characteristic);
this.device.getServices().add(service);
}
for (FunctionblockProperty property : infomodel.getProperties()) {
transformFunctionblock(property.getType());
}
return this.device;
}
use of org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty in project vorto by eclipse.
the class InformationModelElement method createFunctionblockProperty.
private FunctionblockProperty createFunctionblockProperty(FunctionblockModel fbm, Set<String> existingVariableNames) {
FunctionblockProperty fbp = InformationModelFactory.eINSTANCE.createFunctionblockProperty();
fbp.setType(fbm);
fbp.setName(generateFunctionBlockVariableName(fbm, existingVariableNames));
return fbp;
}
use of org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty in project vorto by eclipse.
the class SchemaValidatorTask method generate.
@Override
public void generate(InformationModel infomodel, InvocationContext invocationContext, IGeneratedWriter writer) {
for (FunctionblockProperty fbp : infomodel.getProperties()) {
FunctionBlock fb = fbp.getType().getFunctionblock();
generateForFunctionblock(fb, invocationContext, TARGET_PATH + "/" + fbp.getType().getNamespace() + "_" + fbp.getType().getName() + "_" + fbp.getType().getVersion(), JSON_SCHEMA_FILE_EXTENSION, writer);
}
}
use of org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty in project vorto by eclipse.
the class EclipseHonoGenerator method generate.
@Override
public IGenerationResult generate(InformationModel model, InvocationContext context, IVortoCodeGenProgressMonitor monitor) {
GenerationResultZip output = new GenerationResultZip(model, getServiceKey());
ChainedCodeGeneratorTask<InformationModel> generator = new ChainedCodeGeneratorTask<InformationModel>();
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new PomFileTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new Log4jTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new CertificateTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new AppTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new IDataServiceTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new HonoDataService()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new HonoMqttClientTemplate()));
generator.addTask(new GeneratorTaskFromFileTemplate<InformationModel>(new InformationModelTemplate()));
generator.generate(model, context, output);
for (FunctionblockProperty fbProperty : model.getProperties()) {
new GeneratorTaskFromFileTemplate<>(new FunctionblockTemplate(model)).generate(fbProperty.getType(), context, output);
}
return output;
}
use of org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty in project vorto by eclipse.
the class JavabeanGenerator method generate.
public IGenerationResult generate(InformationModel infomodel, InvocationContext invocationContext, IVortoCodeGenProgressMonitor monitor) throws VortoCodeGeneratorException {
GenerationResultZip zipOutputter = new GenerationResultZip(infomodel, getServiceKey());
for (FunctionblockProperty fbp : infomodel.getProperties()) {
this.generateForFunctionBlock(infomodel, fbp.getType(), zipOutputter);
FunctionBlock fb = fbp.getType().getFunctionblock();
for (Entity entity : Utils.getReferencedEntities(fb)) {
generateForEntity(infomodel, entity, zipOutputter);
}
for (Enum en : Utils.getReferencedEnums(fb)) {
generateForEnum(infomodel, en, zipOutputter);
}
}
new GeneratorTaskFromFileTemplate<InformationModel>(new PomFileTemplate()).generate(infomodel, invocationContext, zipOutputter);
return zipOutputter;
}
Aggregations