//Create Submodel Elements private static AdminShellV20.SubmodelElementWrapper createSubmodelElement(UANode node) { //Parent (node) // -> SemanticId // -> Category (Property) // -> Qualifier // -> Kind (Property) // -> DataNode (Same name as Type) AdminShellV20.SubmodelElementWrapper wrapper = new AdminShellV20.SubmodelElementWrapper(); wrapper.submodelElement = new SubmodelElement(); List <Key> keys = new List <Key>(); QualifierCollection quals = new QualifierCollection(); foreach (Reference _ref in node.References) { if (_ref.ReferenceType != "HasTypeDefinition") { var val = findNode(_ref.Value); string type = getTypeDefinition(val); if (type == "1:AASSemanticIdType") { keys = addSemanticID((UAVariable)val); } else if (getTypeDefinition(val) == "1:AASQualifierType") { quals.Add(getQualifier(val)); } else { setElementData(findNode(_ref.Value), wrapper); } } } wrapper.submodelElement.idShort = makePretty(node.BrowseName); wrapper.submodelElement.semanticId = SemanticId.CreateFromKeys(keys); wrapper.submodelElement.kind = getKind(node); wrapper.submodelElement.category = getCategory(node); wrapper.submodelElement.qualifiers = quals; return(wrapper); }
private static Qualifier getQualifier(UANode node) { //Qualifier // -> QualifierType (Property) // -> QualifierValue (Property) // -> Key (multiple) Qualifier qual = new Qualifier(); List <Key> keys = new List <Key>(); //create Keys keys = addSemanticID(node); foreach (Reference _ref in node.References) { if (_ref.ReferenceType != "HasTypeDefinition") { if (_ref.ReferenceType == "HasComponent") { } else { UAVariable var = (UAVariable)findNode(_ref.Value); if (var.BrowseName == "1:QualifierType") { qual.type = var.Value.InnerText; } if (var.BrowseName == "1:QualifierValue") { qual.value = var.Value.InnerText; } } } } qual.semanticId = SemanticId.CreateFromKeys(keys); return(qual); }