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);
}
}
}
}
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())));
}
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);
}
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);
}
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);
}
Aggregations