@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); } }
protected String getDescription(final FunctionblockModel fbModel) { String _description = fbModel.getDescription(); boolean _notEquals = (!Objects.equal(_description, null)); if (_notEquals) { return fbModel.getDescription(); } else { return ""; } }
_builder.append("#include \""); FunctionblockModel _type_1 = fb.getType(); String _name = _type_1.getName(); _builder.append(_name, ""); _builder.append("/"); FunctionblockModel _type_2 = fb.getType(); String _name_1 = _type_2.getName(); _builder.append(_name_1, ""); _builder.append(".h\""); FunctionBlock _functionblock = _type_3.getFunctionblock(); Status _status = _functionblock.getStatus(); EList<Property> _properties_2 = _status.getProperties(); _builder.append("void "); FunctionblockModel _type_4 = fb_1.getType(); String _name_2 = _type_4.getName(); _builder.append(_name_2, ""); _builder.append("_Cbk_"); _builder.append("("); FunctionblockModel _type_5 = fb_1.getType(); String _name_4 = _type_5.getName(); _builder.append(_name_4, ""); _builder.append("_t *"); FunctionblockModel _type_6 = fb_1.getType(); String _name_5 = _type_6.getName(); String _lowerCase = _name_5.toLowerCase(); _builder.append(_lowerCase, "");
EObject _eContainer_2 = _eContainer_1.eContainer(); FunctionblockModel fbm = ((FunctionblockModel) _eContainer_2); String _namespace = fbm.getNamespace(); String _plus = (_namespace + ":"); String _name = fbm.getName(); String _plus_1 = (_plus + _name); String _plus_2 = (_plus_1 + ":"); String _version = fbm.getVersion(); String definition = (_plus_2 + _version); CharSequence _handleProperty = EntityValidationTemplate.handleProperty(property, invocationContext);
StringConcatenation _builder = new StringConcatenation(); _builder.append("// "); String _name = fb.getName(); _builder.append(_name, ""); _builder.newLineIfNotEmpty(); _builder.newLine(); _builder.append("#ifndef __MODEL_"); String _name_1 = fb.getName(); String _upperCase = _name_1.toUpperCase(); _builder.append(_upperCase, ""); _builder.newLineIfNotEmpty(); _builder.append("#define __MODEL_"); String _name_2 = fb.getName(); String _upperCase_1 = _name_2.toUpperCase(); _builder.append(_upperCase_1, ""); FunctionBlock _functionblock = fb.getFunctionblock(); Status _status = _functionblock.getStatus(); boolean _notEquals = (!Objects.equal(_status, null)); if (_notEquals) { FunctionBlock _functionblock_1 = fb.getFunctionblock(); EList<org.eclipse.vorto.core.api.model.datatype.Enum> _referencedEnums = Utils.getReferencedEnums(_functionblock_1); for(final org.eclipse.vorto.core.api.model.datatype.Enum dataEnum : _referencedEnums) { FunctionBlock _functionblock_2 = fb.getFunctionblock(); EList<Entity> _referencedEntities = Utils.getReferencedEntities(_functionblock_2); for(final Entity dataEntity : _referencedEntities) {
@Override public String getPath(final FunctionblockModel fb) { String _name = fb.getName(); return ((BleGattTemplate.rootPath + File.separator) + _name); }
public static List<FunctionblockModel> getFunctionBlocksUsingStatus(InformationModel model) { List<FunctionblockModel> result = new ArrayList<>(); for (FunctionblockProperty fbProp : model.getProperties()) { if (fbProp.getType().getFunctionblock().getStatus() != null) { result.add(fbProp.getType()); } } return result; } }
final String name = model.getName(); // FB name final List<Object> lwm2mObjects = lwm2m.getObject(); final FunctionBlock functionblock = model.getFunctionblock(); lwm2mObject.setMultipleInstances(mappedFunctionblock.getAttributeValue(ATTR_MULTIPLE_INSTANCES_MULTIPLE_VALUE, "Single")); lwm2mObject.setMandatory(mappedFunctionblock.getAttributeValue(ATTRIBUTE_MANDATORY, "Optional")); lwm2mObject.setDescription1( model.getDescription()); lwm2mObject.setDescription2(mappedFunctionblock.getAttributeValue(ATTRIBUTE_DESCRIPTION2, ""));
public static InformationModel wrapFunctionBlock(final FunctionblockModel fbModel) { InformationModel infomodel = InformationModelFactory.eINSTANCE.createInformationModel(); String _category = fbModel.getCategory(); infomodel.setCategory(_category); String _description = fbModel.getDescription(); infomodel.setDescription(_description); String _displayname = fbModel.getDisplayname(); infomodel.setDisplayname(_displayname); String _name = fbModel.getName(); infomodel.setName(_name); String _namespace = fbModel.getNamespace(); infomodel.setNamespace(_namespace); String _version = fbModel.getVersion(); infomodel.setVersion(_version); FunctionblockProperty property = InformationModelFactory.eINSTANCE.createFunctionblockProperty(); property.setType(fbModel); String _name_1 = fbModel.getName(); String _lowerCase = _name_1.toLowerCase(); property.setName(_lowerCase); _properties.add(property); ModelReference reference = ModelFactory.eINSTANCE.createModelReference(); String _namespace_1 = fbModel.getNamespace(); String _plus = (_namespace_1 + "."); String _name_2 = fbModel.getName(); String _plus_1 = (_plus + _name_2); reference.setImportedNamespace(_plus_1); String _version_1 = fbModel.getVersion(); reference.setVersion(_version_1); EList<ModelReference> _references = infomodel.getReferences();
_builder.append("// "); FunctionblockModel _type = fbProperty.getType(); String _displayname_4 = _type.getDisplayname(); _builder.append(_displayname_4, " "); _builder.newLineIfNotEmpty(); _builder.append("if characteristics.UUID == "); FunctionblockModel _type_1 = fbProperty_1.getType(); String _name_9 = _type_1.getName(); _builder.append(_name_9, " "); _builder.append("DataUUID {"); FunctionBlock _functionblock = _type_2.getFunctionblock(); EList<Operation> _operations = _functionblock.getOperations(); for(final Operation operation : _operations) { _builder.append("let "); FunctionblockModel _type_3 = fbProperty_1.getType(); String _name_10 = _type_3.getName(); _builder.append(_name_10, " \t"); _builder.append("_value = ");
_builder.append("#include \"../functionblock/"); FunctionblockModel _type = fb.getType(); String _name_3 = _type.getName(); _builder.append(_name_3, ""); _builder.append(".h\""); _builder.append(" "); FunctionblockModel _type_1 = fb_1.getType(); String _namespace_1 = _type_1.getNamespace(); String _replace_1 = _namespace_1.replace(".", "_"); _builder.append(_replace_1, " "); _builder.append("::"); FunctionblockModel _type_2 = fb_1.getType(); String _name_6 = _type_2.getName(); _builder.append(_name_6, " "); _builder.append(" ");
String _displayname = fbModel.getDisplayname(); g.writeStringField("name", _displayname); g.writeStringField("type", "ThingShape"); g.writeStringField("tags", "Applications:Vorto_CodeGen"); g.writeArrayFieldStart("propertyDefinitions"); FunctionBlock _functionblock = fbModel.getFunctionblock(); Status _status = _functionblock.getStatus(); boolean _notEquals = (!Objects.equal(_status, null)); this.enumerateProperties(fbModel, g, ThingWorxCodeGenerator.VortoPropertyType.STATUS); FunctionBlock _functionblock_1 = fbModel.getFunctionblock(); Configuration _configuration = _functionblock_1.getConfiguration(); boolean _notEquals_1 = (!Objects.equal(_configuration, null));
public static FunctionblockModel convertToFlatHierarchy(FunctionblockModel fbm) { FunctionBlock fb = fbm.getFunctionblock(); // Consolidate all properties List<Property> properties = getFlatProperties(fbm); // remove super type reference if (fbm.getSuperType() != null) { removeSuperTypeModelReference(fbm); } properties.stream().filter(p -> p.getType() instanceof ObjectPropertyType) .forEach(p -> createReference(fbm, (ObjectPropertyType) p.getType())); Status status = FunctionblockFactory.eINSTANCE.createStatus(); status.getProperties().addAll(properties.stream().filter(p -> p.eContainer() instanceof Status) .collect(Collectors.toList())); fb.setStatus(status); Configuration configuration = FunctionblockFactory.eINSTANCE.createConfiguration(); configuration.getProperties().addAll(properties.stream() .filter(p -> p.eContainer() instanceof Configuration).collect(Collectors.toList())); fb.setConfiguration(configuration); // Consolidate all operations List<Operation> operations = getFlatOperations(fbm); fb.getOperations().clear(); fb.getOperations().addAll(operations); return fbm; }
private void generateForFunctionBlock(InvocationContext ctx, FunctionblockModel fbm, IGeneratedWriter outputter, String[] imports) { ChainedCodeGeneratorTask<FunctionblockModel> generator = new ChainedCodeGeneratorTask<FunctionblockModel>(); generator .addTask(new FunctionalItemGeneratorTask(JAVA_FILE_EXTENSION, SOURCE, fbm.getNamespace())); generator.addTask(new FunctionalItemImplGeneratorTask(JAVA_FILE_EXTENSION, SOURCE, fbm.getNamespace(), imports)); generator.generate(fbm, ctx, outputter); }
service.setName(map.getAttributeValue("serviceName", "")); } else { service.setName(fbm.getName()); FunctionBlock fb = fbm.getFunctionblock(); if (fb.getStatus() != null) { for (Property property : fb.getStatus().getProperties()) {
EObject _eContainer_1 = _eContainer.eContainer(); FunctionblockModel fbm = ((FunctionblockModel) _eContainer_1); String _namespace = fbm.getNamespace(); String _plus = (_namespace + ":"); String _name = fbm.getName(); String _plus_1 = (_plus + _name); String _plus_2 = (_plus_1 + ":"); String _version = fbm.getVersion(); String definition = (_plus_2 + _version); StringConcatenation _builder = new StringConcatenation();
StringConcatenation _builder = new StringConcatenation(); _builder.append("// "); String _name = fb.getName(); _builder.append(_name, ""); _builder.newLineIfNotEmpty(); _builder.newLine(); _builder.append("#include \""); String _name_1 = fb.getName(); _builder.append(_name_1, ""); _builder.append(".h\""); _builder.newLine(); _builder.append("using namespace "); String _namespace = fb.getNamespace(); String _replace = _namespace.replace(".", "_"); _builder.append(_replace, ""); _builder.newLineIfNotEmpty(); _builder.newLine(); String _name_2 = fb.getName(); _builder.append(_name_2, ""); _builder.append("::"); String _name_3 = fb.getName(); _builder.append(_name_3, ""); _builder.append("(){}"); FunctionBlock _functionblock = fb.getFunctionblock(); Status _status = _functionblock.getStatus(); boolean _notEquals = (!Objects.equal(_status, null));
@Override public String getFileName(final FunctionblockModel fb) { String _name = fb.getName(); return (_name + ".cpp"); }
public static List<FunctionblockModel> getFunctionBlocksUsingStatus(InformationModel model) { List<FunctionblockModel> result = new ArrayList<>(); for (FunctionblockProperty fbProp : model.getProperties()) { if (fbProp.getType().getFunctionblock().getStatus() != null) { result.add(fbProp.getType()); } } return result; } }
_builder.append("\t\t"); _builder.append("add(new Link(\""); String _name_1 = resource.getName(); String _firstLower = StringExtensions.toFirstLower(_name_1); _builder.append(_firstLower, "\t\t"); _builder.append("\t\t"); _builder.append("getAttributes().addAttribute(\"title\", \""); String _description = resource.getDescription(); _builder.append(_description, "\t\t\t\t"); _builder.append(" \");"); FunctionBlock _functionblock = _type.getFunctionblock(); EList<Operation> _operations = _functionblock.getOperations(); boolean _notEquals = (!Objects.equal(_operations, null)); FunctionBlock _functionblock_1 = _type_1.getFunctionblock(); EList<Operation> _operations_1 = _functionblock_1.getOperations(); for(final Operation operation : _operations_1) { FunctionBlock _functionblock_2 = _type_2.getFunctionblock(); EList<Event> _events = _functionblock_2.getEvents(); boolean _notEquals_1 = (!Objects.equal(_events, null)); FunctionBlock _functionblock_3 = _type_3.getFunctionblock(); EList<Event> _events_1 = _functionblock_3.getEvents(); for(final Event event : _events_1) { FunctionBlock _functionblock_4 = _type_4.getFunctionblock();