Search in sources :

Example 6 with FunctionblockModel

use of org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel in project vorto by eclipse.

the class ModelTransformer method transformFunctionblock.

private void transformFunctionblock(FunctionblockModel fbm) {
    IMapped<FunctionblockModel> map = this.context.getMappedElement(fbm, "Service");
    if (map.hasAttribute("uuid")) {
        String uuid = map.getAttributeValue("uuid", "");
        Service service = null;
        for (Service s : this.device.getServices()) {
            if (s.getUuid().equals(uuid)) {
                service = s;
                break;
            }
        }
        if (service == null) {
            service = this.factory.createService();
            service.setUuid(uuid);
            if (map.hasAttribute("serviceName")) {
                service.setName(map.getAttributeValue("serviceName", ""));
            } else {
                service.setName(fbm.getName());
            }
            this.device.getServices().add(service);
        }
        service.getFunctionblocks().add(fbm);
        FunctionBlock fb = fbm.getFunctionblock();
        if (fb.getStatus() != null) {
            for (Property property : fb.getStatus().getProperties()) {
                transformProperty(service, property);
            }
        }
        if (fb.getConfiguration() != null) {
            for (Property property : fb.getConfiguration().getProperties()) {
                transformProperty(service, property);
            }
        }
        if (fb.getFault() != null) {
            for (Property property : fb.getFault().getProperties()) {
                transformProperty(service, property);
            }
        }
    }
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) Service(org.eclipse.vorto.codegen.ble.model.blegatt.Service) CharacteristicProperty(org.eclipse.vorto.codegen.ble.model.blegatt.CharacteristicProperty) FunctionblockProperty(org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty) Property(org.eclipse.vorto.core.api.model.datatype.Property) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)

Example 7 with FunctionblockModel

use of org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel in project vorto by eclipse.

the class InformationModelElement method addModelReference.

@Override
public void addModelReference(IModelElement modelElementReference) {
    ModelReference modelReference = modelElementReference.getId().asModelReference();
    if (!containsModelReference(modelReference)) {
        getModel().getReferences().add(modelReference);
        getModel().eResource().getContents().add(modelElementReference.getModel());
    }
    InformationModel infomodel = (InformationModel) getModel();
    infomodel.getProperties().add(createFunctionblockProperty((FunctionblockModel) modelElementReference.getModel(), getVariableNames(infomodel.getProperties())));
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ModelReference(org.eclipse.vorto.core.api.model.model.ModelReference)

Example 8 with FunctionblockModel

use of org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel in project vorto by eclipse.

the class JavabeanGenerator method generateForFunctionBlock.

private void generateForFunctionBlock(InformationModel infomodel, FunctionblockModel fbm, IGeneratedWriter outputter) {
    ChainedCodeGeneratorTask<FunctionblockModel> generator = new ChainedCodeGeneratorTask<FunctionblockModel>();
    if (fbm.getFunctionblock().getStatus() != null) {
        generator.addTask(new JavaFunctionblockStatusGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, STATUS_SUFFIX, ENTITY_PACKAGE));
    }
    if (fbm.getFunctionblock().getConfiguration() != null) {
        generator.addTask(new JavaFunctionblockConfigurationGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, CONFIG_SUFFIX, ENTITY_PACKAGE));
    }
    if (fbm.getFunctionblock().getFault() != null) {
        generator.addTask(new JavaFunctionblockFaultGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, FAULT_SUFFIX, ENTITY_PACKAGE));
    }
    generator.addTask(new JavaFunctionblockImplGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, JAVA_IMPL_SUFFIX, ENTITY_PACKAGE));
    generator.addTask(new JavaFunctionblockInterfaceGeneratorTask(JAVA_FILE_EXTENSION, FB_TARGET_PATH, FB_PACKAGE, JAVA_INTERFACE_PREFIX, ENTITY_PACKAGE));
    generator.generate(fbm, null, outputter);
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) ChainedCodeGeneratorTask(org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask) JavaFunctionblockInterfaceGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockInterfaceGeneratorTask) JavaFunctionblockConfigurationGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockConfigurationGeneratorTask) JavaFunctionblockStatusGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockStatusGeneratorTask) JavaFunctionblockFaultGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockFaultGeneratorTask) JavaFunctionblockImplGeneratorTask(org.eclipse.vorto.codegen.javabean.tasks.JavaFunctionblockImplGeneratorTask)

Example 9 with FunctionblockModel

use of org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel in project vorto by eclipse.

the class InvocationContext method matchesOperation.

private boolean matchesOperation(final Operation srcOp, final Operation tgtOp) {
    FunctionBlock srcFb = (FunctionBlock) srcOp.eContainer();
    FunctionBlock tgtFb = (FunctionBlock) tgtOp.eContainer();
    FunctionblockModel srcFbModel = (FunctionblockModel) srcFb.eContainer();
    FunctionblockModel tgtFbModel = (FunctionblockModel) tgtFb.eContainer();
    return EcoreUtil.equals(srcOp, tgtOp) && EcoreUtil.equals(srcFbModel, tgtFbModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)

Example 10 with FunctionblockModel

use of org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel in project vorto by eclipse.

the class InvocationContext method matchesProperty.

private boolean matchesProperty(final Property srcProp, final Property tgtProp) {
    FunctionBlock srcFb = (FunctionBlock) srcProp.eContainer().eContainer();
    FunctionBlock tgtFb = (FunctionBlock) tgtProp.eContainer().eContainer();
    FunctionblockModel srcFbModel = (FunctionblockModel) srcFb.eContainer();
    FunctionblockModel tgtFbModel = (FunctionblockModel) tgtFb.eContainer();
    return EcoreUtil.equals(srcProp, tgtProp) && EcoreUtil.equals(srcFbModel, tgtFbModel);
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)

Aggregations

FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)17 ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)5 FunctionBlock (org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)5 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)5 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)5 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)4 Property (org.eclipse.vorto.core.api.model.datatype.Property)4 IGenerationResult (org.eclipse.vorto.codegen.api.IGenerationResult)3 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)3 ZipInputStream (java.util.zip.ZipInputStream)2 CharacteristicProperty (org.eclipse.vorto.codegen.ble.model.blegatt.CharacteristicProperty)2 Model (org.eclipse.vorto.core.api.model.model.Model)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Collectors (java.util.stream.Collectors)1 Generated (org.eclipse.vorto.codegen.api.Generated)1 IMapped (org.eclipse.vorto.codegen.api.mapping.IMapped)1 Characteristic (org.eclipse.vorto.codegen.ble.model.blegatt.Characteristic)1