Search in sources :

Example 6 with FunctionblockProperty

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;
}
Also used : Characteristic(org.eclipse.vorto.codegen.ble.model.blegatt.Characteristic) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) Service(org.eclipse.vorto.codegen.ble.model.blegatt.Service) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)

Example 7 with FunctionblockProperty

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;
}
Also used : FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)

Example 8 with FunctionblockProperty

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);
    }
}
Also used : FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)

Example 9 with FunctionblockProperty

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;
}
Also used : GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) IDataServiceTemplate(org.eclipse.vorto.codegen.hono.service.IDataServiceTemplate) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) FunctionblockTemplate(org.eclipse.vorto.codegen.hono.model.FunctionblockTemplate) HonoDataService(org.eclipse.vorto.codegen.hono.service.hono.HonoDataService) InformationModelTemplate(org.eclipse.vorto.codegen.hono.model.InformationModelTemplate) HonoMqttClientTemplate(org.eclipse.vorto.codegen.hono.service.hono.HonoMqttClientTemplate) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)

Example 10 with FunctionblockProperty

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;
}
Also used : Enum(org.eclipse.vorto.core.api.model.datatype.Enum) Entity(org.eclipse.vorto.core.api.model.datatype.Entity) PomFileTemplate(org.eclipse.vorto.codegen.javabean.tasks.template.PomFileTemplate) GenerationResultZip(org.eclipse.vorto.codegen.api.GenerationResultZip) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)

Aggregations

FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)15 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)9 ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)8 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)8 FunctionBlock (org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)5 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)4 Enum (org.eclipse.vorto.core.api.model.datatype.Enum)4 IGenerationResult (org.eclipse.vorto.codegen.api.IGenerationResult)2 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)2 HashSet (java.util.HashSet)1 EObject (org.eclipse.emf.ecore.EObject)1 GeneratorTaskFromFileTemplate (org.eclipse.vorto.codegen.api.GeneratorTaskFromFileTemplate)1 Characteristic (org.eclipse.vorto.codegen.ble.model.blegatt.Characteristic)1 Service (org.eclipse.vorto.codegen.ble.model.blegatt.Service)1 ThingsClientGeneratorTask (org.eclipse.vorto.codegen.bosch.things.javaclient.tasks.ThingsClientGeneratorTask)1 ThingsIntegrationUtilGeneratorTask (org.eclipse.vorto.codegen.bosch.things.javaclient.tasks.ThingsIntegrationUtilGeneratorTask)1 FunctionblockTemplate (org.eclipse.vorto.codegen.bosch.things.javaclient.templates.FunctionblockTemplate)1 LogbackTemplate (org.eclipse.vorto.codegen.bosch.things.javaclient.templates.LogbackTemplate)1 PomTemplate (org.eclipse.vorto.codegen.bosch.things.javaclient.templates.PomTemplate)1 CoAPClientInformationModelGeneratorTask (org.eclipse.vorto.codegen.coap.client.tasks.CoAPClientInformationModelGeneratorTask)1