public static JObject createTDActions(AdminShell.SubmodelElement actionsSem) { JObject actionsJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(actionsSem); foreach (AdminShell.SubmodelElementWrapper _tempAction in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement _action = _tempAction.submodelElement; JObject actionJObject = createInteractionAvoidance(_action); AdminShell.SubmodelElementCollection _actionItems = new AdminShell.SubmodelElementCollection(_action); foreach (AdminShell.SubmodelElementWrapper _tempActionItem in _actionItems.EnumerateChildren()) { AdminShell.SubmodelElement _actionItem = _tempActionItem.submodelElement; if (_actionItem.idShort == "input") { actionJObject["input"] = JToken.FromObject(createDataSchema(_actionItem)); } if (_actionItem.idShort == "output") { actionJObject["output"] = JToken.FromObject(createDataSchema(_actionItem)); } } foreach (AdminShell.Qualifier actionQual in _action.qualifiers) { if (actionQual.type == "safe" || actionQual.type == "idempotent") { actionJObject[actionQual.type] = Convert.ToBoolean(actionQual.value); } } actionsJObject[_action.idShort] = JToken.FromObject(actionJObject); } return(actionsJObject); }
public static JObject createTDEvents(AdminShell.SubmodelElement eventsSem) { JObject eventsJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(eventsSem); foreach (AdminShell.SubmodelElementWrapper _tempEvent in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement _event = _tempEvent.submodelElement; JObject actionJObject = createInteractionAvoidance(_event); AdminShell.SubmodelElementCollection _eventItems = new AdminShell.SubmodelElementCollection(_event); foreach (AdminShell.SubmodelElementWrapper _tempEventItem in _eventItems.EnumerateChildren()) { AdminShell.SubmodelElement _eventItem = _tempEventItem.submodelElement; if (_eventItem.idShort == "subscription") { actionJObject["subscription"] = JToken.FromObject(createDataSchema(_eventItem)); } if (_eventItem.idShort == "data") { actionJObject["data"] = JToken.FromObject(createDataSchema(_eventItem)); } if (_eventItem.idShort == "cancellation") { actionJObject["cancellation"] = JToken.FromObject(createDataSchema(_eventItem)); } } eventsJObject[_event.idShort] = JToken.FromObject(actionJObject); } return(eventsJObject); }
public static JObject createArraySchema(AdminShell.SubmodelElement sem) { JObject semJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(sem); foreach (AdminShell.SubmodelElementWrapper _tempChild in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement dsElement = _tempChild.submodelElement; if (dsElement.idShort == "items") { AdminShell.SubmodelElementCollection _items = new AdminShell.SubmodelElementCollection(dsElement); List <JObject> itemsJObject = new List <JObject>(); foreach (AdminShell.SubmodelElementWrapper _itemTemp in _items.EnumerateChildren()) { AdminShell.SubmodelElement item = _itemTemp.submodelElement; JObject dsJObject = createDataSchema(item); itemsJObject.Add(dsJObject); } if (itemsJObject.Count == 1) { semJObject["items"] = JToken.FromObject(itemsJObject[0]); } else { semJObject["items"] = JToken.FromObject(itemsJObject); } } } return(semJObject); }
public static JObject createObjectSchema(AdminShell.SubmodelElement sem) { JObject semJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(sem); foreach (AdminShell.SubmodelElementWrapper _tempChild in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement dsElement = _tempChild.submodelElement; if (dsElement.idShort == "properties") { AdminShell.SubmodelElementCollection _properties = new AdminShell.SubmodelElementCollection(dsElement); JObject propertiesJObject = new JObject(); foreach (AdminShell.SubmodelElementWrapper _itemTemp in _properties.EnumerateChildren()) { AdminShell.SubmodelElement item = _itemTemp.submodelElement; JObject dsJObject = createDataSchema(item); propertiesJObject[item.idShort] = JToken.FromObject(dsJObject); } semJObject["properties"] = JToken.FromObject(propertiesJObject); } if (dsElement.idShort == "required") { List <string> requiredList = new List <string>(); foreach (AdminShell.Qualifier _requiredQual in dsElement.qualifiers) { requiredList.Add(_requiredQual.value); } semJObject["required"] = JToken.FromObject(requiredList); } } return(semJObject); }
static void parseJSON(string url, string username, string password, AdminShell.SubmodelElementCollection c) { var handler = new HttpClientHandler(); handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials; var client = new HttpClient(handler); if (username != "" && password != "") { var authToken = System.Text.Encoding.ASCII.GetBytes(username + ":" + password); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(authToken)); } Console.WriteLine("GetJSON: " + url); string response = client.GetStringAsync(url).Result; Console.WriteLine(response); if (response != "") { JObject parsed = JObject.Parse(response); Program.parseJson(c, parsed); } }
public static JObject createTDSecurityDefinitions(AdminShell.SubmodelElement sdSem) { JObject securityDefinitionsJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(sdSem); foreach (AdminShell.SubmodelElementWrapper _tempSD in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement _securityDefinition = _tempSD.submodelElement; JObject securityJObject = createSecurityScheme(_securityDefinition); AdminShell.SubmodelElementCollection _securityDItems = new AdminShell.SubmodelElementCollection(_securityDefinition); foreach (var temp in (JToken)securityJObject) { JProperty secObject = (JProperty)temp; string key = secObject.Name.ToString(); if (key == "scheme") { string securityScheme = (secObject.Value).ToString(); if (securityScheme == "combo") { foreach (AdminShell.SubmodelElementWrapper _temp_combosecurityDItems in _securityDItems.EnumerateChildren()) { AdminShell.SubmodelElementCollection csdItem = new AdminShell.SubmodelElementCollection(_temp_combosecurityDItems.submodelElement); List <string> csdItemList = new List <string>(); foreach (AdminShell.Qualifier _csdQual in csdItem.qualifiers) { csdItemList.Add(_csdQual.value); } securityJObject[csdItem.idShort] = JToken.FromObject(csdItemList); } securityDefinitionsJObject[_securityDefinition.idShort] = JToken.FromObject(securityJObject); } if (securityScheme == "oauth2") { foreach (AdminShell.SubmodelElementWrapper _temp_combosecurityDItems in _securityDItems.EnumerateChildren()) { AdminShell.SubmodelElementCollection oauth2SDItem = new AdminShell.SubmodelElementCollection(_temp_combosecurityDItems.submodelElement); List <string> csdItemList = new List <string>(); foreach (AdminShell.Qualifier _csdQual in oauth2SDItem.qualifiers) { csdItemList.Add(_csdQual.value); } securityJObject[oauth2SDItem.idShort] = JToken.FromObject(csdItemList); } securityDefinitionsJObject[_securityDefinition.idShort] = JToken.FromObject(securityJObject); } } } securityDefinitionsJObject[_securityDefinition.idShort] = securityJObject; } return(securityDefinitionsJObject); }
public AdminShell.SubmodelElementCollection GenerateDefault() { var res = new AdminShell.SubmodelElementCollection(); this.InitSme(res); res.value = this.value.GenerateDefault(); return(res); }
public static JObject createuriVariables(AdminShell.SubmodelElement uriSem) { JObject uriVarJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(uriSem); foreach (AdminShell.SubmodelElementWrapper _tempuriVarElement in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement _uriVariable = _tempuriVarElement.submodelElement; uriVarJObject[_uriVariable.idShort] = JToken.FromObject(createDataSchema(_uriVariable)); } return(uriVarJObject); }
public static void createSubmodelElements( UaNode n, AdminShell.AdministrationShellEnv env, AdminShell.SubmodelElementCollection smec, AdminShell.SubmodelRef smref, string path, AdminShell.SubmodelElementCollection concepts) { String name = n.BrowseName; if (n.SymbolicName != null && n.SymbolicName != "") { name = n.SymbolicName; } var semanticID = AdminShell.Key.CreateNew("GlobalReference", false, "IRI", path + name); if ((n.children != null && n.children.Count != 0) || (n.fields != null && n.fields.Count != 0)) { var sme = AdminShell.SubmodelElementCollection.CreateNew(name, null, semanticID); sme.semanticId.Keys.Add(AdminShell.Key.CreateNew("UATypeName", false, "OPC", n.UAObjectTypeName)); smec.Add(sme); if (n.Value != "") { var p = createSE(n, path); sme.Add(p); addLeaf(concepts, p); } foreach (field f in n.fields) { sme.semanticId.Keys.Add( AdminShell.Key.CreateNew( "UAField", false, "OPC", f.name + " = " + f.value + " : " + f.description)); semanticID = AdminShell.Key.CreateNew("GlobalReference", false, "IRI", path + name + "/" + f.name); var p = AdminShell.Property.CreateNew(f.name, null, semanticID); p.valueType = "string"; p.value = f.value; sme.Add(p); addLeaf(concepts, p); } if (n.children != null) { foreach (UaNode c in n.children) { createSubmodelElements(c, env, sme, smref, path + name + "/", concepts); } } } else { var se = createSE(n, path); smec.Add(se); addLeaf(concepts, se); } }
public static bool operation_checkCollection(AdminShell.Operation op, i40LanguageAutomaton auto) { // inputVariable property checkType: isEmpty, isNotEmpty; // inputVariable reference collection proposal if (auto.name == debugAutomaton) { int i = 0; // set breakpoint here to debug specific automaton } if (op.inputVariable.Count != 2 && op.outputVariable.Count != 0) { return(false); } AdminShell.Property checkType = null; AdminShell.SubmodelElementCollection refCollection = null; foreach (var input in op.inputVariable) { var inputRef = input.value.submodelElement; if (inputRef is AdminShell.Property) { checkType = (inputRef as AdminShell.Property); continue; } if (!(inputRef is AdminShell.ReferenceElement)) { return(false); } var refElement = Program.env[0].AasEnv.FindReferableByReference((inputRef as AdminShell.ReferenceElement).value); if (refElement is AdminShell.SubmodelElementCollection) { refCollection = refElement as AdminShell.SubmodelElementCollection; } } int count = refCollection.value.Count; switch (checkType.idShort) { case "isEmpty": return(count == 0); case "isNotEmpty": return(count != 0); } return(false); }
public static JObject createTDProfile(AdminShell.SubmodelElement profileSem) { JObject profileJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(profileSem); List <string> profileList = new List <string>(); foreach (AdminShell.Qualifier _profileQual in _tempCollection.qualifiers) { profileList.Add(_profileQual.value); } profileJObject["profile"] = JToken.FromObject(profileList); return(profileJObject); }
public static JObject createTDSecurity(AdminShell.SubmodelElement securitySem) { AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(securitySem); List <string> securityList = new List <string>(); foreach (AdminShell.Qualifier _security in _tempCollection.qualifiers) { securityList.Add(_security.value); } JObject securityJObject = new JObject(); securityJObject["security"] = JToken.FromObject(securityList); return(securityJObject); }
public FormInstanceSubmodelElementCollection( FormInstanceListOfSame parentInstance, FormDescSubmodelElementCollection parentDesc, AdminShell.SubmodelElement source = null) { // way back to description this.desc = parentDesc; this.parentInstance = parentInstance; var smecDesc = this.desc as FormDescSubmodelElementCollection; // initialize Referable var smec = new AdminShell.SubmodelElementCollection(); this.sme = smec; InitReferable(parentDesc, source); // initially create pairs if (smecDesc?.value != null) { foreach (var subDesc in smecDesc.value) { var los = new FormInstanceListOfSame(this, subDesc); var pair = new FormDescInstancesPair(subDesc, los); PairInstances.Add(pair); } } // check, if a source is present this.sourceSme = source; var smecSource = this.sourceSme as AdminShell.SubmodelElementCollection; if (smecSource != null) { if (this.PairInstances != null) { foreach (var pair in this.PairInstances) { pair?.instances?.PresetInstancesBasedOnSource(smecSource.value); } } } // create user control this.subControl = new FormSubControlSMEC(); this.subControl.DataContext = this; }
public static JObject createTDProperties(AdminShell.SubmodelElement propertiesSem) { JObject propertiesJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(propertiesSem); foreach (AdminShell.SubmodelElementWrapper _tempProperty in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement _propoerty = _tempProperty.submodelElement; JObject propetyJObject = createInteractionAvoidance(_propoerty); if (propetyJObject.ContainsKey("observable")) { propetyJObject["observable"] = Convert.ToBoolean(propetyJObject["observable"]); } propertiesJObject[_propoerty.idShort] = propetyJObject; } return(propertiesJObject); }
public static JObject createTDLinks(AdminShell.SubmodelElement linksSem) { List <JObject> links = new List <JObject>(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(linksSem); foreach (AdminShell.SubmodelElementWrapper _tempLink in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement link = _tempLink.submodelElement; JObject jObject = new JObject(); foreach (AdminShell.Qualifier linkItem in link.qualifiers) { jObject[linkItem.type] = linkItem.value; } links.Add(jObject); } JObject linksJObject = new JObject(); linksJObject["links"] = JToken.FromObject(links); return(linksJObject); }
public static JObject createInteractionAvoidance(AdminShell.SubmodelElement sem) { JObject semJObject = createDataSchema(sem); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(sem); foreach (AdminShell.SubmodelElementWrapper _tempChild in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement dsElement = _tempChild.submodelElement; if (dsElement.idShort == "forms") { semJObject["forms"] = createForms(dsElement)["forms"]; } if (dsElement.idShort == "uriVariables") { createuriVariables(dsElement); semJObject["uriVariables"] = createuriVariables(dsElement); } } return(semJObject); }
public static void ImportBMEcatToSubModel( string inputFn, AdminShell.AdministrationShellEnv env, AdminShell.Submodel sm, AdminShell.SubmodelRef smref) { // Select between BMEcat and XML publication // Tag "<BMECAT" for BMEcat File // Tag "<Publication" for XML from GWIS Boolean isBMEcat = false; Boolean isPublication = false; XmlTextReader reader = new XmlTextReader(inputFn); StreamWriter sw = File.CreateText(inputFn + ".log.txt"); // BMEcat or Publication? while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "BMECAT") { isBMEcat = true; } if (reader.Name == "Publication") { isPublication = true; } break; } if (isBMEcat || isPublication) { break; } } // BMEcat String FT_ID = ""; String FT_NAME = ""; String[] FVALUE = new string[] { "", "", "", "", "", "", "", "", "", "" }; int i_FVALUE = 0; String FUNIT = ""; String FID = ""; String FPARENT_ID = ""; Boolean is_FT_ID = false; Boolean is_FT_NAME = false; Boolean is_FVALUE = false; Boolean is_FUNIT = false; Boolean is_FID = false; Boolean is_FPARENT_ID = false; String[] Stack_FID = new string[10]; int StackPointer_FID = 0; // GWIS XML Publication String attribute_label_id = ""; String attribute_value = ""; String subheadline = ""; Boolean is_technical_data = false; Boolean is_attribute_list = false; Boolean is_subheadline = false; Boolean is_attribute = false; Boolean is_attribute_label = false; Boolean is_attribute_value = false; AdminShell.SubmodelElementCollection[] propGroup = new AdminShell.SubmodelElementCollection[10]; // GWIS XML Publication if (isPublication) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "technical_data") { is_technical_data = true; } if (reader.Name == "attribute_list") { is_attribute_list = true; } if (reader.Name == "subheadline") { is_subheadline = true; } if (reader.Name == "attribute") { is_attribute = true; } if (reader.Name == "label") { is_attribute_label = true; } if (reader.Name == "value") { is_attribute_value = true; } break; case XmlNodeType.Text: //Display the text in each element. if (is_technical_data && is_attribute_list && is_attribute && is_attribute_label) { attribute_label_id = reader.Value; is_attribute_label = false; } if (is_technical_data && is_attribute_list && is_attribute && is_attribute_value) { attribute_value = reader.Value; is_attribute_value = false; } if (is_technical_data && is_attribute_list && is_subheadline) { subheadline = reader.Value; } break; case XmlNodeType.EndElement: //Display the end of the element. if (reader.Name == "subheadline") { if (subheadline != "") { propGroup[0] = AdminShell.SubmodelElementCollection.CreateNew(subheadline); sm.Add(propGroup[0]); } } if (reader.Name == "attribute") { if (attribute_label_id != "" && attribute_value != "") { sw.WriteLine(attribute_label_id + " | " + attribute_value); using (var cd = AdminShell.ConceptDescription.CreateNew( "" + attribute_label_id, AdminShell.Identification.IRDI, FT_ID)) { env.ConceptDescriptions.Add(cd); cd.SetIEC61360Spec( preferredNames: new[] { "EN", attribute_label_id }, shortName: attribute_label_id, unit: "string", valueFormat: "STRING", definition: new[] { "EN", attribute_label_id } ); var p = AdminShell.Property.CreateNew( cd.GetDefaultShortName(), "PARAMETER", AdminShell.Key.GetFromRef(cd.GetCdReference())); if (is_subheadline) { propGroup[0].Add(p); } else { sm.Add(p); } p.valueType = "string"; p.value = attribute_value; } } is_attribute = false; attribute_value = ""; attribute_label_id = ""; } if (reader.Name == "attribute_list") { is_attribute_list = false; is_subheadline = false; subheadline = ""; } break; } } sw.Close(); return; } // BMEcat if (isBMEcat) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. if (reader.Name == "FT_ID") { is_FT_ID = true; } if (reader.Name == "FT_NAME") { is_FT_NAME = true; } if (reader.Name == "FVALUE") { var rString = reader.GetAttribute("lang"); // only no language or English values if (rString == null || rString == "" || rString == "eng") { is_FVALUE = true; } } if (reader.Name == "FUNIT") { is_FUNIT = true; } if (reader.Name == "FID") { is_FID = true; } if (reader.Name == "FPARENT_ID") { is_FPARENT_ID = true; } break; case XmlNodeType.Text: //Display the text in each element. // BMEcat if (is_FT_ID) { FT_ID = reader.Value; is_FT_ID = false; } if (is_FT_NAME) { FT_NAME = reader.Value; is_FT_NAME = false; } if (is_FVALUE) { FVALUE[i_FVALUE++] = reader.Value; is_FVALUE = false; } if (is_FUNIT) { FUNIT = reader.Value; is_FUNIT = false; } if (is_FUNIT) { FUNIT = reader.Value; is_FUNIT = false; } if (is_FID) { FID = reader.Value; is_FID = false; } if (is_FPARENT_ID) { FPARENT_ID = reader.Value; is_FPARENT_ID = false; } break; case XmlNodeType.EndElement: //Display the end of the element. // BMEcat if (reader.Name == "FEATURE") { Boolean is_AXIS1D = (i_FVALUE == 6); int k; for (k = 0; k < i_FVALUE; k++) { sw.WriteLine(FT_ID + " | " + FT_NAME + " | " + FVALUE[k] + " | " + FUNIT + " | " + FID + " | " + FPARENT_ID); } if (FT_ID != "" && FT_NAME != "") // korrekter Eintrag { if (FPARENT_ID == "-1") { StackPointer_FID = 0; } if (i_FVALUE > 0) // Property { for (k = 0; k < i_FVALUE; k++) { if (FUNIT != "") { if (FUNIT == "0173-1#05-AAA480#002") { FUNIT = "mm | " + FUNIT; } else if (FUNIT == "0173-1#05-AAA731#002") { FUNIT = "kg | " + FUNIT; } else if (FUNIT == "0173-1#05-AAA153#002") { FUNIT = "V | " + FUNIT; } else if (FUNIT == "0173-1#05-AAA295#002") { FUNIT = "mm² | " + FUNIT; } else if (FUNIT == "0173-1#05-AAA723#002") { FUNIT = "mA | " + FUNIT; } else if (FUNIT == "0173-1#05-AAA114#002") { FUNIT = "ms | " + FUNIT; } else if (FUNIT == "0173-1#05-AAA220#002") { FUNIT = "A | " + FUNIT; } } string extendedname = FT_NAME; if (is_AXIS1D) // checked by IRDIs { extendedname += " " + names_AXIS1D[k]; } else if (i_FVALUE > 1 && i_FVALUE <= 4) { extendedname += " " + names_LEVELTYPE[k]; // MIN, MAX, ... } using (var cd = AdminShell.ConceptDescription.CreateNew( "" + extendedname, AdminShell.Identification.IRDI, FT_ID)) { env.ConceptDescriptions.Add(cd); cd.SetIEC61360Spec( preferredNames: new[] { "DE", extendedname, "EN", extendedname }, shortName: extendedname, unit: FUNIT, valueFormat: "REAL_MEASURE", definition: new[] { "DE", extendedname, "EN", extendedname } ); var p = AdminShell.Property.CreateNew( cd.GetDefaultShortName(), "PARAMETER", AdminShell.Key.GetFromRef(cd.GetCdReference())); p.valueType = "double"; p.value = FVALUE[k]; if (StackPointer_FID == 0) // am Submodell { sm.Add(p); } else // an Collection { for (int j = 0; j < StackPointer_FID; j++) { if (Stack_FID[j] == FPARENT_ID) // Vater gefunden { propGroup[j].Add(p); StackPointer_FID = j + 1; break; } } } } } } else // Collection { if (StackPointer_FID == 0) // oberste Collection { Stack_FID[0] = FID; propGroup[0] = AdminShell.SubmodelElementCollection.CreateNew(FT_NAME); sm.Add(propGroup[0]); StackPointer_FID++; // nächste Ebene } else // Collection suchen { for (int j = 0; j < StackPointer_FID; j++) { if (Stack_FID[j] == FPARENT_ID) // Vater gefunden { StackPointer_FID = j + 1; Stack_FID[StackPointer_FID] = FID; propGroup[StackPointer_FID] = AdminShell.SubmodelElementCollection.CreateNew(FT_NAME); propGroup[StackPointer_FID - 1].Add(propGroup[StackPointer_FID]); StackPointer_FID++; // nächste Ebene break; } } } } } FT_ID = ""; FT_NAME = ""; i_FVALUE = 0; FUNIT = ""; FID = ""; FPARENT_ID = ""; } break; } } } sw.Close(); // OZ end }
private void RecurseToCopyTechnicalProperties( AasxPredefinedConcepts.ZveiTechnicalDataV11 defsV11, AasxPredefinedConcepts.DefinitionsZveiTechnicalData.SetOfDefs defsV10, AdminShell.SubmodelElementCollection smcDest, AdminShell.SubmodelElementCollection smcSrc) { // access if (defsV10 == null || defsV11 == null || smcDest?.value == null || smcSrc?.value == null) { return; } // for EACH property foreach (var sme in smcSrc.value) { // access if (sme?.submodelElement == null) { continue; } var special = false; // Submodel Handling if (sme.submodelElement is AdminShell.SubmodelElementCollection smcSectSrc) { // what to create? AdminShell.SubmodelElementCollection smcSectDst = null; if (smcSectSrc.semanticId?.Matches(defsV10.CD_MainSection.GetSingleKey()) == true) { smcSectDst = smcDest.value.CreateSMEForCD <AdminShell.SubmodelElementCollection>( defsV11.CD_MainSection, addSme: false); } if (smcSectSrc.semanticId?.Matches(defsV10.CD_SubSection.GetSingleKey()) == true) { smcSectDst = smcDest.value.CreateSMEForCD <AdminShell.SubmodelElementCollection>( defsV11.CD_SubSection, addSme: false); } smcSectDst ??= new AdminShell.SubmodelElementCollection(smcSectSrc, shallowCopy: true); // add manually smcSectDst.idShort = smcSectSrc.idShort; smcSectDst.category = smcSectSrc.category; if (smcSectSrc.description != null) { smcSectDst.description = new AdminShell.Description(smcSectSrc.description); } smcDest.value.Add(smcSectDst); // recurse RecurseToCopyTechnicalProperties(defsV11, defsV10, smcSectDst, smcSectSrc); // was special special = true; } if (!special) { // just move "by hand", as the old SMEs are already detached smcDest.Add(sme.submodelElement); // do some fix for "non-standardized" if (sme.submodelElement.semanticId? .MatchesExactlyOneKey(defsV10.CD_NonstandardizedProperty.GetSingleKey(), AdminShell.Key.MatchMode.Relaxed) == true) { // fix sme.submodelElement.semanticId = new AdminShell.SemanticId( defsV11.CD_SemanticIdNotAvailable.GetReference()); } } } }
public static void ImportCSVtoSubModel( string inputFn, AdminShell.AdministrationShellEnv env, AdminShell.Submodel sm, AdminShell.SubmodelRef smref) { AdminShell.SubmodelElementCollection[] propGroup = new AdminShell.SubmodelElementCollection[10]; int i_propGroup = 0; var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(inputFn); parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); string[] rows = parser.ReadFields(); if (rows == null) { throw new InvalidOperationException( $"There were no fields read from the inputFn: {inputFn}"); } if ((rows[0] != "typeName" || rows[1] != "idShort" || rows[2] != "value") || (rows.Length > 3 && ( rows[3] != "valueType" || rows[4] != "category" || rows[5] != "descriptionEN" || rows[6] != "descriptionDE" ))) { return; } sm.idShort = inputFn.Split('\\').Last().Replace(".csv", ""); while (!parser.EndOfData) { rows = parser.ReadFields(); if (rows == null) { throw new InvalidOperationException( $"There were no fields read from inputFn: {inputFn}"); } switch (rows[0]) { case "SubmodelElementCollection": propGroup[i_propGroup] = AdminShell.SubmodelElementCollection.CreateNew(rows[1]); if (i_propGroup == 0) { sm.Add(propGroup[0]); if (rows.Length > 3) { if (rows[7] != "") { propGroup[0].semanticId = new AdminShellV20.SemanticId( AdminShell.Reference.CreateNew( "ConceptDescription", false, "IRI", rows[7])); } } propGroup[0].kind = AdminShellV20.ModelingKind.CreateAsInstance(); } else { propGroup[i_propGroup - 1].Add(propGroup[i_propGroup]); } i_propGroup++; break; case "End-SubmodelElementCollection": if (i_propGroup != 0) { i_propGroup--; } break; case "Property": var p = AdminShell.Property.CreateNew(rows[1].Replace("-", "_")); p.value = rows[2]; if (rows.Length > 3) { p.valueType = rows[3]; p.category = rows[4]; if (rows[5] != "") { p.AddDescription("en", rows[5]); } if (rows[6] != "") { p.AddDescription("de", rows[6]); } p.kind = AdminShellV20.ModelingKind.CreateAsInstance(); if (rows[7] != "") { p.semanticId = new AdminShell.SemanticId( AdminShell.Reference.CreateNew( "ConceptDescription", false, "IRI", rows[7])); } } if (i_propGroup == 0) { sm.Add(p); } else { propGroup[i_propGroup - 1].Add(p); } break; } } }
public static void addLeaf(AdminShell.SubmodelElementCollection concepts, AdminShell.SubmodelElement sme) { var se = AdminShell.Property.CreateNew(sme.idShort, null, sme.semanticId[0]); concepts.Add(se); }
public static JObject createDataSchema(AdminShell.SubmodelElement sem) { JObject semJObject = new JObject(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(sem); string dschemaType = ""; foreach (AdminShell.SubmodelElementWrapper _tempChild in _tempCollection.EnumerateChildren()) { AdminShell.SubmodelElement dsElement = _tempChild.submodelElement; if (dsElement.idShort == "titles") { JObject _titlesJObject = new JObject(); AdminShell.MultiLanguageProperty mlp = new AdminShell.MultiLanguageProperty(dsElement); AdminShell.LangStringSet _titles = new AdminShell.LangStringSet(mlp.value); foreach (AdminShell.LangStr _title in _titles.langString) { _titlesJObject[_title.lang] = _title.str; } semJObject["titles"] = _titlesJObject; } if (dsElement.idShort == "oneOf") { List <JObject> oneOfJObjects = new List <JObject>(); AdminShell.SubmodelElementCollection _enumCOllection = new AdminShell.SubmodelElementCollection(dsElement); foreach (AdminShell.SubmodelElementWrapper _temponeOf in _enumCOllection.EnumerateChildren()) { AdminShell.SubmodelElement _oneOf = _temponeOf.submodelElement; oneOfJObjects.Add(createDataSchema(_oneOf)); } semJObject["oneOf"] = JToken.FromObject(oneOfJObjects); } if (dsElement.idShort == "enum") { semJObject["enum"] = JToken.FromObject(enumELement(dsElement.qualifiers)); } } if (sem.description != null) { AdminShell.ListOfLangStr tdDescription = sem.description.langString; if (tdDescription.Count != 1) { semJObject["description"] = tdDescription[0].str; int index = 1; JObject descriptions = new JObject(); for (index = 1; index < tdDescription.Count; index++) { AdminShell.LangStr desc = tdDescription[index]; descriptions[desc.lang] = desc.str; } semJObject["descriptions"] = JToken.FromObject(descriptions); } else { semJObject["description"] = tdDescription[0].str; } } foreach (AdminShell.Qualifier smQualifier in sem.qualifiers) { if (smQualifier.type == "readOnly" || smQualifier.type == "writeOnly") { semJObject[smQualifier.type] = Convert.ToBoolean(smQualifier.value); } else if (smQualifier.type == "minItems" || smQualifier.type == "maxItems" || smQualifier.type == "minLength" || smQualifier.type == "maxLength") { semJObject[smQualifier.type] = Convert.ToUInt32(smQualifier.value); } else if (smQualifier.type == "data1.type" || smQualifier.type == "type") { if (smQualifier.type == "type") { semJObject[smQualifier.type] = smQualifier.value; } if (smQualifier.type == "data1.type") { semJObject["data1"] = JToken.FromObject(new JObject { ["type"] = smQualifier.value }); } dschemaType = smQualifier.value; } else { semJObject[smQualifier.type] = smQualifier.value; } } if (dschemaType == "array") { JObject arrayObject = createArraySchema(sem); if (arrayObject.ContainsKey("items")) { semJObject["items"] = arrayObject["items"]; } } else if (dschemaType == "object") { JObject objectSchemaJObject = createObjectSchema(sem); if (objectSchemaJObject.ContainsKey("properties")) { semJObject["properties"] = JToken.FromObject(objectSchemaJObject["properties"]); } if (objectSchemaJObject.ContainsKey("required")) { semJObject["required"] = JToken.FromObject(objectSchemaJObject["required"]); } } else if (dschemaType == "integer") { List <string> integerSchema = new List <string> { "minimum", "exclusiveMinimum", "maximum", "exclusiveMaximum", "multipleOf" }; foreach (string elem in integerSchema) { foreach (AdminShell.Qualifier semQual in sem.qualifiers) { if (elem == semQual.type) { semJObject[semQual.type] = (int)Convert.ToDouble(semQual.value); } } } } else if (dschemaType == "number") { List <string> numberSchema = new List <string> { "minimum", "exclusiveMinimum", "maximum", "exclusiveMaximum", "multipleOf" }; foreach (string elem in numberSchema) { foreach (AdminShell.Qualifier semQual in sem.qualifiers) { if (elem == semQual.type) { semJObject[semQual.type] = Convert.ToDecimal(semQual.value.ToString()); } } } } return(semJObject); }
public static void ImportCSVtoSubModel( string inputFn, AdminShell.AdministrationShellEnv env, AdminShell.Submodel sm, AdminShell.SubmodelRef smref) { AdminShell.SubmodelElementCollection[] propGroup = new AdminShell.SubmodelElementCollection[10]; int i_propGroup = 0; var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(inputFn); parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); string[] rows = parser.ReadFields(); if (rows == null || rows.Length < 3 || rows[0] != "typeName" || rows[1] != "idShort" || rows[2] != "value") { return; } while (!parser.EndOfData) { rows = parser.ReadFields(); if (rows == null || rows.Length < 1) { continue; } switch (rows[0]) { case "SubmodelElementCollection": propGroup[i_propGroup] = AdminShell.SubmodelElementCollection.CreateNew(rows[1]); if (i_propGroup == 0) { sm.Add(propGroup[0]); } else { propGroup[i_propGroup - 1].Add(propGroup[i_propGroup]); } i_propGroup++; break; case "End-SubmodelElementCollection": if (i_propGroup != 0) { i_propGroup--; } break; case "Property": var p = AdminShell.Property.CreateNew(rows[1]); p.valueType = "string"; p.value = rows[2]; if (i_propGroup == 0) { sm.Add(p); } else { propGroup[i_propGroup - 1].Add(p); } break; } } }
public static bool operation_sendFrame(AdminShell.Operation op, i40LanguageAutomaton auto) { // inputVariable property protocol: memory, connect // inputVariable reference frame proposal: collection // inputVariable reference submodel // outputVariable reference property sendFrameJSON if (auto.name == debugAutomaton) { int i = 0; // set breakpoint here to debug specific automaton } if (op.inputVariable.Count != 3 && op.outputVariable.Count != 1) { return(false); } AdminShell.Property protocol = null; AdminShell.SubmodelElementCollection refFrame = null; AdminShell.Submodel refSubmodel = null; AdminShell.Property sendFrameJSON = null; foreach (var input in op.inputVariable) { var inputRef = input.value.submodelElement; if (inputRef is AdminShell.Property) { protocol = (inputRef as AdminShell.Property); continue; } if (!(inputRef is AdminShell.ReferenceElement)) { return(false); } var refElement = Program.env[0].AasEnv.FindReferableByReference((inputRef as AdminShell.ReferenceElement).value); if (refElement is AdminShell.SubmodelElementCollection) { refFrame = refElement as AdminShell.SubmodelElementCollection; } if (refElement is AdminShell.Submodel) { refSubmodel = refElement as AdminShell.Submodel; } } foreach (var output in op.outputVariable) { var outputRef = output.value.submodelElement; if (!(outputRef is AdminShell.ReferenceElement)) { return(false); } var refElement = Program.env[0].AasEnv.FindReferableByReference((outputRef as AdminShell.ReferenceElement).value); if (refElement is AdminShell.Property) { sendFrameJSON = refElement as AdminShell.Property; } } if (protocol.value != "memory" && protocol.value != "connect") { return(false); } int frameCount = refFrame.value.Count; string frame = "{ \"frame\": { "; foreach (var smew in refFrame.value) { var sme = smew.submodelElement; if (sme.idShort == "_insert_submodel_into_frame") { frame += "\"" + "submodel" + "\" : "; var smJson = JsonConvert.SerializeObject(refSubmodel, Newtonsoft.Json.Formatting.Indented); frame += smJson; } else { frame += "\"" + sme.idShort + "\" : "; if (sme is AdminShell.Property) { frame += "\"" + (sme as AdminShell.Property).value + "\""; } else { frame += "\"\""; } } if (frameCount-- != 1) { frame += ","; } } frame += " } }"; sendFrameJSON.value = frame; Console.WriteLine(frame); if (auto.name == "automatonServiceRequester") { switch (protocol.value) { case "memory": receivedFrameJSONProvider.Add(frame); break; case "connect": sendFrameJSONRequester.Add(frame); break; } } if (auto.name == "automatonServiceProvider") { switch (protocol.value) { case "memory": receivedFrameJSONRequester.Add(frame); break; case "connect": sendFrameJSONProvider.Add(frame); break; } } return(true); }
public static bool operation_receiveProposals(AdminShell.Operation op, i40LanguageAutomaton auto) { // inputVariable property protocol: memory, connect // inputVariable reference frame proposal: collection // inputVariable reference submodel // outputVariable reference collected proposals: collection // outputVariable reference collected not understood proposals: collection // outputVariable reference collected refused proposals: collection // outputVariable reference property receivedFrameJSON if (auto.name == debugAutomaton) { int i = 0; // set breakpoint here to debug specific automaton } if (op.inputVariable.Count != 3 && op.outputVariable.Count != 4) { return(false); } AdminShell.Submodel refSubmodel = null; AdminShell.Property protocol = null; AdminShell.Property receivedFrameJSON = null; foreach (var input in op.inputVariable) { var inputRef = input.value.submodelElement; if (inputRef is AdminShell.Property) { protocol = (inputRef as AdminShell.Property); continue; } if (!(inputRef is AdminShell.ReferenceElement)) { return(false); } var refElement = Program.env[0].AasEnv.FindReferableByReference((inputRef as AdminShell.ReferenceElement).value); if (refElement is AdminShell.Submodel) { refSubmodel = refElement as AdminShell.Submodel; } } foreach (var output in op.outputVariable) { var outputRef = output.value.submodelElement; if (!(outputRef is AdminShell.ReferenceElement)) { return(false); } var refElement = Program.env[0].AasEnv.FindReferableByReference((outputRef as AdminShell.ReferenceElement).value); if (refElement is AdminShell.Property) { receivedFrameJSON = refElement as AdminShell.Property; } } var out1 = op.outputVariable.First(); var r2 = out1.value.submodelElement; if (!(r2 is AdminShell.ReferenceElement)) { return(false); } var ref2 = Program.env[0].AasEnv.FindReferableByReference((r2 as AdminShell.ReferenceElement).value); if (!(ref2 is AdminShell.SubmodelElementCollection)) { return(false); } var smc2 = ref2 as AdminShell.SubmodelElementCollection; if (protocol.value != "memory" && protocol.value != "connect") { return(false); } while ((auto.name == "automatonServiceRequester" && receivedFrameJSONRequester.Count != 0) || (auto.name == "automatonServiceProvider" && receivedFrameJSONProvider.Count != 0)) { string receivedFrame = ""; if (auto.name == "automatonServiceRequester") { // receivedFrame = sendFrameJSONProvider; // sendFrameJSONProvider = ""; if (receivedFrameJSONRequester.Count != 0) { receivedFrame = receivedFrameJSONRequester[0]; receivedFrameJSONRequester.RemoveAt(0); } } if (auto.name == "automatonServiceProvider") { // receivedFrame = sendFrameJSONRequester; // sendFrameJSONRequester = ""; if (receivedFrameJSONProvider.Count != 0) { receivedFrame = receivedFrameJSONProvider[0]; receivedFrameJSONProvider.RemoveAt(0); } } receivedFrameJSON.value = receivedFrame; AdminShell.Submodel submodel = null; if (receivedFrame != "") { try { if (auto.name == debugAutomaton) { int i = 0; // set breakpoint here to debug specific automaton } JObject parsed = JObject.Parse(receivedFrame); foreach (JProperty jp1 in (JToken)parsed) { if (jp1.Name == "frame") { foreach (JProperty jp2 in jp1.Value) { if (jp2.Name == "submodel") { string text = jp2.Value.ToString(); submodel = JsonConvert.DeserializeObject <AdminShell.Submodel>(text, new AdminShellConverters.JsonAasxConverter("modelType", "name")); } } } } } catch { } } if (submodel != null) { AdminShell.SubmodelElementCollection smcSubmodel = new AdminShell.SubmodelElementCollection(); smcSubmodel.idShort = submodel.idShort; foreach (var sme in submodel.submodelElements) { smcSubmodel.Add(sme.submodelElement); } smc2.Add(smcSubmodel); } } return(true); }
public static JObject createForms(AdminShell.SubmodelElement formsSem) { List <JObject> forms = new List <JObject>(); AdminShell.SubmodelElementCollection _tempCollection = new AdminShell.SubmodelElementCollection(formsSem); foreach (AdminShell.SubmodelElementWrapper _tempChild in _tempCollection.EnumerateChildren()) { JObject formJObject = new JObject(); AdminShell.SubmodelElement form = _tempChild.submodelElement; foreach (AdminShell.Qualifier smQualifier in form.qualifiers) { formJObject[smQualifier.type] = smQualifier.value; } AdminShell.SubmodelElementCollection _formElementCollection = new AdminShell.SubmodelElementCollection(form); foreach (AdminShell.SubmodelElementWrapper _tempformElement in _formElementCollection.EnumerateChildren()) { AdminShell.SubmodelElement _formElement = _tempformElement.submodelElement; if (_formElement.idShort == "security") { List <string> securityList = new List <string>(); foreach (AdminShell.Qualifier _secQual in _formElement.qualifiers) { securityList.Add(_secQual.value); } formJObject["security"] = JToken.FromObject(securityList); } else if (_formElement.idShort == "scopes") { AdminShell.SubmodelElementCollection _scopesCollection = new AdminShell.SubmodelElementCollection(_formElement, false); List <string> scopesList = new List <string>(); foreach (AdminShell.Qualifier _scopeQual in _scopesCollection.qualifiers) { scopesList.Add(_scopeQual.value); } formJObject["scopes"] = JToken.FromObject(scopesList); } else if (_formElement.idShort == "response") { AdminShell.SubmodelElementCollection _response = new AdminShell.SubmodelElementCollection(_formElement, false); foreach (AdminShell.SubmodelElementWrapper _tempResponse in _response.EnumerateChildren()) { JObject contentTypeObject = new JObject(); contentTypeObject["contentType"] = (_tempResponse.submodelElement).ValueAsText(); formJObject["response"] = contentTypeObject; } } else if (_formElement.idShort == "additionalResponses") { AdminShell.SubmodelElementCollection _response = new AdminShell.SubmodelElementCollection(_formElement, false); JObject arJObject = new JObject(); foreach (AdminShell.SubmodelElementWrapper _tempResponse in _response.EnumerateChildren()) { if (_tempResponse.submodelElement.idShort == "success") { arJObject["success"] = Convert.ToBoolean((_tempResponse.submodelElement).ValueAsText()); } else { arJObject[_tempResponse.submodelElement.idShort] = (_tempResponse.submodelElement).ValueAsText(); } } } else if (_formElement.idShort == "op") { AdminShell.SubmodelElementCollection _opCollection = new AdminShell.SubmodelElementCollection(_formElement, false); List <string> opList = new List <string>(); foreach (AdminShell.Qualifier _opQual in _opCollection.qualifiers) { opList.Add(_opQual.value); } formJObject["op"] = JToken.FromObject(opList); } else { formJObject[_formElement.idShort] = _tempformElement.GetAs <AdminShell.Property>().value.ToString(); } } forms.Add(formJObject); } JObject formsjObject = new JObject(); formsjObject["forms"] = JToken.FromObject(forms); return(formsjObject); }
/* * static ulong ChangeNumber = 0; * * static bool setChangeNumber(AdminShell.Referable r, ulong changeNumber) * { * do * { * r.ChangeNumber = changeNumber; * if (r != r.parent) * { * r = r.parent; * } * else * r = null; * } * while (r != null); * * return true; * } */ public static bool timeSeriesSampling(bool final) { if (Program.isLoading) { return(true); } // ulong newChangeNumber = ChangeNumber + 1; // bool useNewChangeNumber = false; DateTime timeStamp = DateTime.Now; foreach (var tsb in timeSeriesBlockList) { if (tsb.sampleStatus.value == "stop") { tsb.sampleStatus.value = "stopped"; final = true; } else { if (tsb.sampleStatus.value != "start") { continue; } } if (tsb.sampleRate == null) { continue; } tsb.threadCounter -= 100; if (tsb.threadCounter > 0) { continue; } tsb.threadCounter = Convert.ToInt32(tsb.sampleRate.value); int actualSamples = Convert.ToInt32(tsb.actualSamples.value); int maxSamples = Convert.ToInt32(tsb.maxSamples.value); int actualSamplesInCollection = Convert.ToInt32(tsb.actualSamplesInCollection.value); int maxSamplesInCollection = Convert.ToInt32(tsb.maxSamplesInCollection.value); if (final || actualSamples < maxSamples) { int updateMode = 0; if (!final) { int valueCount = 1; if (tsb.sourceType == "json" && tsb.sourceAddress != "") { AdminShell.SubmodelElementCollection c = tsb.block.value.FindFirstIdShortAs <AdminShell.SubmodelElementCollection>("jsonData"); if (c == null) { c = new AdminShellV20.SubmodelElementCollection(); c.idShort = "jsonData"; c.TimeStampCreate = timeStamp; tsb.block.Add(c); c.setTimeStamp(timeStamp); } parseJSON(tsb.sourceAddress, "", "", c); foreach (var el in c.value) { if (el.submodelElement is AdminShell.Property p) { if (!tsb.samplesProperties.Contains(p)) { tsb.samplesProperties.Add(p); tsb.samplesValues.Add(""); } } } } if (tsb.sourceType == "opchd" && tsb.sourceAddress != "") { GetHistory(tsb); valueCount = 0; if (table != null) { valueCount = table.Count; } } if (tsb.sourceType == "opcda" && tsb.sourceAddress != "") { valueCount = GetDAData(tsb); } DateTime dt; int valueIndex = 0; while (valueIndex < valueCount) { if (tsb.sourceType == "opchd" && tsb.sourceAddress != "") { dt = (DateTime)table[valueIndex][0]; Console.WriteLine(valueIndex + " " + dt + " " + table[valueIndex][1] + " " + table[valueIndex][2]); } else { dt = DateTime.Now; } if (tsb.samplesTimeStamp == "") { tsb.samplesTimeStamp += dt.ToString("yy-MM-dd HH:mm:ss.fff"); } else { tsb.samplesTimeStamp += "," + dt.ToString("HH:mm:ss.fff"); } for (int i = 0; i < tsb.samplesProperties.Count; i++) { if (tsb.samplesValues[i] != "") { tsb.samplesValues[i] += ","; } if ((tsb.sourceType == "opchd" || tsb.sourceType == "opcda") && tsb.sourceAddress != "") { if (tsb.sourceType == "opchd") { string value = ""; if (table[valueIndex] != null && table[valueIndex][i + 1] != null) { value = table[valueIndex][i + 1].ToString(); } tsb.samplesValues[i] += value; } if (tsb.sourceType == "opcda") { tsb.samplesValues[i] += opcDAValues[i]; Console.WriteLine(tsb.opcNodes[i] + " " + opcDAValues[i]); } } else { var p = tsb.samplesProperties[i]; tsb.samplesValues[i] += p.value; // tsb.samplesValues[i] += dummy++; } } tsb.samplesValuesCount++; actualSamples++; tsb.actualSamples.value = "" + actualSamples; tsb.actualSamples.setTimeStamp(timeStamp); actualSamplesInCollection++; tsb.actualSamplesInCollection.value = "" + actualSamplesInCollection; tsb.actualSamplesInCollection.setTimeStamp(timeStamp); if (actualSamples >= maxSamples) { if (tsb.sampleMode.value == "continuous") { var first = tsb.data.value.FindFirstIdShortAs <AdminShell.SubmodelElementCollection>( "data" + tsb.lowDataIndex.value); if (first != null) { actualSamples -= maxSamplesInCollection; tsb.actualSamples.value = "" + actualSamples; tsb.actualSamples.setTimeStamp(timeStamp); AasxRestServerLibrary.AasxRestServer.TestResource.eventMessage.add( first, "Remove", tsb.submodel, (ulong)timeStamp.Ticks); tsb.data.Remove(first); tsb.data.setTimeStamp(timeStamp); tsb.lowDataIndex.value = "" + (Convert.ToInt32(tsb.lowDataIndex.value) + 1); tsb.lowDataIndex.setTimeStamp(timeStamp); updateMode = 1; } } } if (actualSamplesInCollection >= maxSamplesInCollection) { if (actualSamplesInCollection > 0) { if (tsb.highDataIndex != null) { tsb.highDataIndex.value = "" + tsb.samplesCollectionsCount; tsb.highDataIndex.setTimeStamp(timeStamp); } var nextCollection = AdminShell.SubmodelElementCollection.CreateNew("data" + tsb.samplesCollectionsCount++); var p = AdminShell.Property.CreateNew("timeStamp"); p.value = tsb.samplesTimeStamp; p.setTimeStamp(timeStamp); p.TimeStampCreate = timeStamp; tsb.samplesTimeStamp = ""; nextCollection.Add(p); nextCollection.setTimeStamp(timeStamp); nextCollection.TimeStampCreate = timeStamp; for (int i = 0; i < tsb.samplesProperties.Count; i++) { p = AdminShell.Property.CreateNew(tsb.samplesProperties[i].idShort); nextCollection.Add(p); p.value = tsb.samplesValues[i]; p.setTimeStamp(timeStamp); p.TimeStampCreate = timeStamp; tsb.samplesValues[i] = ""; } tsb.data.Add(nextCollection); tsb.data.setTimeStamp(timeStamp); AasxRestServerLibrary.AasxRestServer.TestResource.eventMessage.add( nextCollection, "Add", tsb.submodel, (ulong)timeStamp.Ticks); tsb.samplesValuesCount = 0; actualSamplesInCollection = 0; tsb.actualSamplesInCollection.value = "" + actualSamplesInCollection; tsb.actualSamplesInCollection.setTimeStamp(timeStamp); updateMode = 1; var json = JsonConvert.SerializeObject(nextCollection, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); Program.connectPublish(tsb.block.idShort + "." + nextCollection.idShort, json); } } valueIndex++; } } if (final || actualSamplesInCollection >= maxSamplesInCollection) { if (actualSamplesInCollection > 0) { if (tsb.highDataIndex != null) { tsb.highDataIndex.value = "" + tsb.samplesCollectionsCount; tsb.highDataIndex.setTimeStamp(timeStamp); } var nextCollection = AdminShell.SubmodelElementCollection.CreateNew("data" + tsb.samplesCollectionsCount++); var p = AdminShell.Property.CreateNew("timeStamp"); p.value = tsb.samplesTimeStamp; p.setTimeStamp(timeStamp); p.TimeStampCreate = timeStamp; tsb.samplesTimeStamp = ""; nextCollection.Add(p); nextCollection.setTimeStamp(timeStamp); nextCollection.TimeStampCreate = timeStamp; for (int i = 0; i < tsb.samplesProperties.Count; i++) { p = AdminShell.Property.CreateNew(tsb.samplesProperties[i].idShort); p.value = tsb.samplesValues[i]; p.setTimeStamp(timeStamp); p.TimeStampCreate = timeStamp; tsb.samplesValues[i] = ""; nextCollection.Add(p); } tsb.data.Add(nextCollection); tsb.data.setTimeStamp(timeStamp); AasxRestServerLibrary.AasxRestServer.TestResource.eventMessage.add( nextCollection, "Add", tsb.submodel, (ulong)timeStamp.Ticks); tsb.samplesValuesCount = 0; actualSamplesInCollection = 0; tsb.actualSamplesInCollection.value = "" + actualSamplesInCollection; tsb.actualSamplesInCollection.setTimeStamp(timeStamp); updateMode = 1; } } if (updateMode != 0) { Program.signalNewData(updateMode); } } } if (!test) { Thread.Sleep(100); } return(!final); }