コード例 #1
0
            public override object ReadJson(JsonReader reader,
                                            Type objectType,
                                            object existingValue,
                                            JsonSerializer serializer)
            {
                // Load JObject from stream
                JObject jObject = JObject.Load(reader);

                // Create target object based on JObject
                object target = new AdminShell.SubmodelElement();

                if (jObject.ContainsKey(UpperClassProperty))
                {
                    var j2 = jObject[UpperClassProperty];
                    if (j2 != null)
                    {
                        foreach (var c in j2.Children())
                        {
                            var cprop = c as Newtonsoft.Json.Linq.JProperty;
                            if (cprop == null)
                            {
                                continue;
                            }
                            if (cprop.Name == LowerClassProperty && cprop.Value.Type.ToString() == "String")
                            {
                                var cpval = cprop.Value.ToObject <string>();
                                if (cpval == null)
                                {
                                    continue;
                                }
                                var o = AdminShell.SubmodelElementWrapper.CreateAdequateType(cpval);
                                if (o != null)
                                {
                                    target = o;
                                }
                            }
                        }
                    }
                }

                // Populate the object properties
                serializer.Populate(jObject.CreateReader(), target);

                return(target);
            }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public FormInstanceProperty(
            FormInstanceListOfSame parentInstance, FormDescProperty parentDesc,
            AdminShell.SubmodelElement source = null, bool deepCopy = false)
        {
            // way back to description
            this.parentInstance = parentInstance;
            this.desc           = parentDesc;

            // initialize Referable
            var p = new AdminShell.Property();

            this.sme = p;
            InitReferable(parentDesc, source);

            // check, if a source is present
            this.sourceSme = source;
            var pSource = this.sourceSme as AdminShell.Property;

            if (pSource != null)
            {
                // take over
                p.valueType = pSource.valueType;
                p.value     = pSource.value;
            }
            else
            {
                // some more preferences
                if (parentDesc.allowedValueTypes != null && parentDesc.allowedValueTypes.Length >= 1)
                {
                    p.valueType = parentDesc.allowedValueTypes[0];
                }

                if (parentDesc.presetValue != null && parentDesc.presetValue.Length > 0)
                {
                    p.value = parentDesc.presetValue;
                    // immediately set touched in order to have this value saved
                    this.Touch();
                }
            }

            // create user control
            this.subControl             = new FormSubControlProperty();
            this.subControl.DataContext = this;
        }
コード例 #5
0
        public string UpdatePropertyValue(
            AdminShell.AdministrationShellEnv env, AdminShell.Submodel submodel, AdminShell.SubmodelElement sme)
        {
            // trivial fails
            if (env == null || sme == null)
            {
                return(null);
            }

            // need AAS, indirect
            var aas = env.FindAASwithSubmodel(submodel.identification);

            if (aas == null)
            {
                return(null);
            }

            // build path
            var aasId      = aas.idShort;
            var submodelId = submodel.idShort;
            var elementId  = sme.CollectIdShortByParent();
            var reqpath    = "./aas/" + aasId + "/submodels/" + submodelId + "/elements/" + elementId + "/property";

            // request
            var request = new RestRequest(reqpath);

            if (this.proxy != null)
            {
                request.Proxy = this.proxy;
            }
            var respose = client.Execute(request);

            if (respose.StatusCode != Grapevine.Shared.HttpStatusCode.Ok)
            {
                throw new Exception(
                          $"REST {respose.ResponseUri} response {respose.StatusCode} with {respose.StatusDescription}");
            }

            var json   = respose.GetContent();
            var parsed = JObject.Parse(json);
            var value  = parsed.SelectToken("value").Value <string>();

            return(value);
        }
コード例 #6
0
        /// <summary>
        /// Check if <c>smw.idShort</c>c> contains something like "{0:00}" and iterate index to make it unique
        /// </summary>
        public static void MakeIdShortUnique(
            AdminShell.SubmodelElementWrapperCollection collection, AdminShell.SubmodelElement sme)
        {
            // access
            if (collection == null || sme == null)
            {
                return;
            }

            // check, if to make idShort unique?
            if (sme.idShort.Contains("{0"))
            {
                var newIdShort = collection.IterateIdShortTemplateToBeUnique(sme.idShort, 999);
                if (newIdShort != null)
                {
                    sme.idShort = newIdShort;
                }
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public static void TakeOverSmeToSm(AdminShell.SubmodelElement sme, AdminShell.Submodel sm)
        {
            // access
            if (sme == null || sm == null)
            {
                return;
            }

            // tedious, manual, nor elegant
            if (sme.description != null)
            {
                sm.description = sme.description;
            }

            if (sme.idShort.HasContent())
            {
                sm.idShort = sme.idShort;
            }

            if (sme.category.HasContent())
            {
                sm.category = sme.category;
            }

            if (sme.semanticId != null)
            {
                sm.semanticId = sme.semanticId;
            }

            if (sme.qualifiers != null)
            {
                if (sm.qualifiers == null)
                {
                    sm.qualifiers = new AdminShell.QualifierCollection();
                }
                sm.qualifiers.AddRange(sme.qualifiers);
            }
        }
コード例 #10
0
        public AdminShell.SubmodelElementWrapperCollection GenerateDefault()
        {
            var res = new AdminShell.SubmodelElementWrapperCollection();

            foreach (var desc in this)
            {
                AdminShell.SubmodelElement sme = null;

                // generate element

                if (desc is FormDescProperty)
                {
                    sme = (desc as FormDescProperty).GenerateDefault();
                }
                if (desc is FormDescMultiLangProp)
                {
                    sme = (desc as FormDescMultiLangProp).GenerateDefault();
                }
                if (desc is FormDescFile)
                {
                    sme = (desc as FormDescFile).GenerateDefault();
                }
                if (desc is FormDescSubmodelElementCollection)
                {
                    sme = (desc as FormDescSubmodelElementCollection).GenerateDefault();
                }

                // multiplicity -> enumerate correctly
                FormInstanceHelper.MakeIdShortUnique(res, sme);

                if (sme != null)
                {
                    res.Add(sme);
                }
            }

            return(res);
        }
コード例 #11
0
        public string EvalInitialValue(AdminShell.SubmodelElement sme, int limitToChars = -1)
        {
            // access
            if (sme == null || limitToChars == 0)
            {
                return("");
            }

            var res = "";

            if (sme is AdminShell.Property || sme is AdminShell.Range ||
                sme is AdminShell.MultiLanguageProperty)
            {
                res = sme.ValueAsText();
            }

            if (limitToChars != -1 && res.Length > limitToChars)
            {
                res = res.Substring(0, Math.Max(0, limitToChars - 3)) + "...";
            }

            return(res);
        }
コード例 #12
0
        //
        // Rendering of attributes
        //

        // TODO (MIHO, 2021-12-24): check if to refactor multiplicity handling as utility

        public string EvalUmlMultiplicity(AdminShell.SubmodelElement sme, bool noOne = false)
        {
            var    one = AasFormConstants.FormMultiplicityAsUmlCardinality[(int)FormMultiplicity.One];
            string res = one;
            var    q   = sme?.qualifiers.FindType("Multiplicity");

            if (q != null)
            {
                foreach (var m in (FormMultiplicity[])Enum.GetValues(typeof(FormMultiplicity)))
                {
                    if (("" + q.value) == Enum.GetName(typeof(FormMultiplicity), m))
                    {
                        res = "" + AasFormConstants.FormMultiplicityAsUmlCardinality[(int)m];
                    }
                }
            }

            if (noOne && res == one)
            {
                res = "";
            }

            return(res);
        }
コード例 #13
0
        public void DispSmeCutCopyPasteHelper(
            AnyUiPanel stack,
            ModifyRepo repo,
            AdminShell.AdministrationShellEnv env,
            AdminShell.Referable parentContainer,
            CopyPasteBuffer cpbInternal,
            AdminShell.SubmodelElementWrapper wrapper,
            AdminShell.SubmodelElement sme,
            string label = "Buffer:")
        {
            // access
            if (parentContainer == null || cpbInternal == null || sme == null)
            {
                return;
            }

            // use an action
            this.AddAction(
                stack, label,
                new[] { "Cut", "Copy", "Paste above", "Paste below", "Paste into" }, repo,
                actionTags: new[] { "aas-elem-cut", "aas-elem-copy", "aas-elem-paste-above",
                                    "aas-elem-paste-below", "aas-elem-paste-into" },
                action: (buttonNdx) =>
            {
                if (buttonNdx == 0 || buttonNdx == 1)
                {
                    // store info
                    cpbInternal.Clear();
                    cpbInternal.Valid     = true;
                    cpbInternal.Duplicate = buttonNdx == 1;
                    AdminShell.EnumerationPlacmentBase placement = null;
                    if (parentContainer is AdminShell.IEnumerateChildren enc)
                    {
                        placement = enc.GetChildrenPlacement(sme);
                    }
                    cpbInternal.Items = new ListOfCopyPasteItem(
                        new CopyPasteItemSME(env, parentContainer, wrapper, sme, placement));
                    cpbInternal.CopyToClipboard(context, cpbInternal.Watermark);

                    // special case?

                    // user feedback
                    Log.Singleton.Info(
                        StoredPrint.Color.Blue,
                        "Stored SubmodelElement '{0}'({1}) to internal buffer.{2}", "" + sme.idShort,
                        "" + sme?.GetElementName(),
                        cpbInternal.Duplicate
                                ? " Paste will duplicate."
                                : " Paste will cut at original position.");
                }

                if (buttonNdx == 2 || buttonNdx == 3 || buttonNdx == 4)
                {
                    // which buffer?
                    var cbdata = context?.ClipboardGet();
                    var cpb    = cpbInternal.CheckIfUseExternalCopyPasteBuffer(cbdata);

                    // content?
                    if (!cpb.ContentAvailable)
                    {
                        this.context?.MessageBoxFlyoutShow(
                            "No sufficient infomation in internal paste buffer or external clipboard.",
                            "Copy & Paste",
                            AnyUiMessageBoxButton.OK, AnyUiMessageBoxImage.Error);
                        return(new AnyUiLambdaActionNone());
                    }

                    // uniform?
                    if (!cpb.Items.AllOfElementType <CopyPasteItemSME>())
                    {
                        this.context?.MessageBoxFlyoutShow(
                            "No (valid) information for SubmodelElements in copy/paste buffer.",
                            "Copy & Paste",
                            AnyUiMessageBoxButton.OK, AnyUiMessageBoxImage.Information);
                        return(new AnyUiLambdaActionNone());
                    }

                    // user feedback
                    Log.Singleton.Info($"Pasting {cpb.Items.Count} SubmodelElements from paste buffer");

                    // loop over items
                    object nextBusObj = null;
                    foreach (var it in cpb.Items)
                    {
                        // access
                        var item = it as CopyPasteItemSME;
                        if (item?.sme == null || item.wrapper == null ||
                            (!cpb.Duplicate && item?.parentContainer == null))
                        {
                            Log.Singleton.Error("When pasting SME, an element was invalid.");
                            continue;
                        }

                        // apply info
                        var smw2   = new AdminShell.SubmodelElementWrapper(item.sme, shallowCopy: false);
                        nextBusObj = smw2.submodelElement;

                        // insertation depends on parent container
                        if (buttonNdx == 2)
                        {
                            if (parentContainer is AdminShell.Submodel pcsm && wrapper != null)
                            {
                                this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                    pcsm.submodelElements, smw2, wrapper);
                            }

                            if (parentContainer is AdminShell.SubmodelElementCollection pcsmc &&
                                wrapper != null)
                            {
                                this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                    pcsmc.value, smw2, wrapper);
                            }

                            if (parentContainer is AdminShell.Entity pcent &&
                                wrapper != null)
                            {
                                this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                    pcent.statements, smw2, wrapper);
                            }

                            if (parentContainer is AdminShell.AnnotatedRelationshipElement pcarel &&
                                wrapper != null)
                            {
                                this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                    pcarel.annotations, smw2, wrapper);
                            }

                            // TODO (Michael Hoffmeister, 2020-08-01): Operation complete?
                            if (parentContainer is AdminShell.Operation pcop && wrapper?.submodelElement != null)
                            {
                                var place = pcop.GetChildrenPlacement(wrapper.submodelElement) as
                                            AdminShell.Operation.EnumerationPlacmentOperationVariable;
                                if (place?.OperationVariable != null)
                                {
                                    var op   = new AdminShell.OperationVariable();
                                    op.value = smw2;
                                    this.AddElementInListBefore <AdminShell.OperationVariable>(
                                        pcop[place.Direction], op, place.OperationVariable);
                                    nextBusObj = op;
                                }
                            }
                        }
コード例 #14
0
        public static void addLeaf(AdminShell.SubmodelElementCollection concepts, AdminShell.SubmodelElement sme)
        {
            var se = AdminShell.Property.CreateNew(sme.idShort, null, sme.semanticId[0]);

            concepts.Add(se);
        }
コード例 #15
0
        public static AdminShell.SubmodelElement createSE(UaNode n, string path)
        {
            AdminShell.SubmodelElement se = null;

            String name = n.BrowseName;

            if (n.SymbolicName != null && n.SymbolicName != "")
            {
                name = n.SymbolicName;
            }

            // Check that semanticID only exists once and no overlapping names
            if (!semanticIDPool.ContainsKey(path + name))
            {
                semanticIDPool.Add(path + name, 0);
            }
            else
            {
                // Names are not unique
                string[] split = n.NodeId.Split('=');
                name += split[split.Length - 1];
                semanticIDPool.Add(path + name, 0);
            }
            var semanticID = AdminShell.Key.CreateNew("GlobalReference", false, "IRI", path + name);

            switch (n.UAObjectTypeName)
            {
            case "UAReferenceType":
                se = AdminShell.RelationshipElement.CreateNew(name, null, semanticID);
                if (se == null)
                {
                    return(null);
                }
                break;

            default:
                se = AdminShell.Property.CreateNew(name, null, semanticID);
                if (se == null)
                {
                    return(null);
                }
                (se as AdminShell.Property).valueType = "string";
                (se as AdminShell.Property).value     = n.Value;
                break;
            }

            if (n.UAObjectTypeName == "UAVariable")
            {
                se.category = "VARIABLE";
            }

            se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UATypeName", false, "OPC", n.UAObjectTypeName));
            se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UANodeId", false, "OPC", n.NodeId));
            if (n.ParentNodeId != null && n.ParentNodeId != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UAParentNodeId", false, "OPC", n.ParentNodeId));
            }
            if (n.BrowseName != null && n.BrowseName != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UABrowseName", false, "OPC", n.BrowseName));
            }
            if (n.DisplayName != null && n.DisplayName != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UADisplayName", false, "OPC", n.DisplayName));
            }
            if (n.NameSpace != null && n.NameSpace != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UANameSpace", false, "OPC", n.NameSpace));
            }
            if (n.SymbolicName != null && n.SymbolicName != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UASymbolicName", false, "OPC", n.SymbolicName));
            }
            if (n.DataType != null && n.DataType != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UADataType", false, "OPC", n.DataType));
            }
            if (n.Description != null && n.Description != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UADescription", false, "OPC", n.Description));
            }
            foreach (string s in n.references)
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UAReference", false, "OPC", s));
            }
            if (n.DefinitionName != null && n.DefinitionName != "")
            {
                se.semanticId.Keys.Add(AdminShell.Key.CreateNew("UADefinitionName", false, "OPC", n.DefinitionName));
            }
            if (n.DefinitionNameSpace != null && n.DefinitionNameSpace != "")
            {
                se.semanticId.Keys.Add(
                    AdminShell.Key.CreateNew(
                        "UADefinitionNameSpace", false, "OPC", n.DefinitionNameSpace));
            }
            foreach (field f in n.fields)
            {
                se.semanticId.Keys.Add(
                    AdminShell.Key.CreateNew(
                        "UAField", false, "OPC", f.name + " = " + f.value + " : " + f.description));
            }

            return(se);
        }
コード例 #16
0
        public static JObject ExportSMtoJson(AdminShell.Submodel sm)
        {
            JObject exportData = new JObject();

            try
            {
                JObject TDJson = new JObject();
                if (sm.qualifiers != null)
                {
                    foreach (AdminShell.Qualifier smQualifier in sm.qualifiers)
                    {
                        TDJson[smQualifier.type] = smQualifier.value.ToString();
                    }
                }

                // description
                if (sm.description != null)
                {
                    AdminShell.ListOfLangStr tdDescription = sm.description.langString;
                    if (tdDescription.Count != 1)
                    {
                        TDJson["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;
                        }
                        TDJson["descriptions"] = descriptions;
                    }
                    else
                    {
                        TDJson["description"] = tdDescription[0].str;
                    }
                }
                //version
                if (sm.administration != null)
                {
                    JObject versionInfo           = new JObject();
                    AdminShell.Administration adm = sm.administration;
                    if (adm.version != "")
                    {
                        versionInfo["instance"] = adm.version;
                    }
                    if (adm.revision != "")
                    {
                        versionInfo["model"] = adm.version;
                    }
                    if (versionInfo.Count != 0)
                    {
                        TDJson["version"] = versionInfo;
                    }
                }
                // id
                TDJson["id"] = sm.identification.id;
                if (sm.submodelElements != null)
                {
                    foreach (AdminShell.SubmodelElementWrapper tdElementWrapper in sm.submodelElements)
                    {
                        AdminShell.SubmodelElement tdElement = tdElementWrapper.submodelElement;
                        if (tdElement.idShort == "@type")
                        {
                            List <object> typeList = new List <object>();
                            foreach (AdminShell.Qualifier _typeQual in tdElement.qualifiers)
                            {
                                typeList.Add((_typeQual.value));
                            }
                            TDJson["@type"] = JToken.FromObject(typeList);
                        }
                        if (tdElement.idShort == "titles")
                        {
                            JObject _titlesJObject = new JObject();
                            AdminShell.MultiLanguageProperty mlp     = new AdminShell.MultiLanguageProperty(tdElement);
                            AdminShell.LangStringSet         _titles = new AdminShell.LangStringSet(mlp.value);
                            foreach (AdminShell.LangStr _title in _titles.langString)
                            {
                                _titlesJObject[_title.lang] = _title.str;
                            }
                            TDJson["titles"] = _titlesJObject;
                        }
                        if (tdElement.idShort == "@context")
                        {
                            List <object> contextList  = new List <object>();
                            JObject       _conSemantic = new JObject();
                            foreach (AdminShell.Qualifier _con in tdElement.qualifiers)
                            {
                                if (_con.type == "@context")
                                {
                                    contextList.Add((_con.value));
                                }
                                else
                                {
                                    _conSemantic[_con.type] = _con.value;
                                }
                            }
                            if (_conSemantic.Count != 0)
                            {
                                contextList.Add(_conSemantic);
                            }
                            TDJson["@context"] = JToken.FromObject(contextList);
                        }
                        if (tdElement.idShort == "properties")
                        {
                            TDJson["properties"] = createTDProperties(tdElement);
                        }
                        else if (tdElement.idShort == "actions")
                        {
                            TDJson["actions"] = createTDActions(tdElement);
                        }
                        else if (tdElement.idShort == "events")
                        {
                            TDJson["events"] = createTDEvents(tdElement);
                        }
                        else if (tdElement.idShort == "links")
                        {
                            TDJson["links"] = createTDLinks(tdElement)["links"];
                        }
                        else if (tdElement.idShort == "forms")
                        {
                            TDJson["forms"] = createForms(tdElement)["forms"];
                        }
                        else if (tdElement.idShort == "security")
                        {
                            TDJson["security"] = createTDSecurity(tdElement)["security"];
                        }
                        else if (tdElement.idShort == "securityDefinitions")
                        {
                            TDJson["securityDefinitions"] = createTDSecurityDefinitions(tdElement);
                        }
                        else if (tdElement.idShort == "profile")
                        {
                            TDJson["profile"] = createTDProfile(tdElement);
                        }
                        else if (tdElement.idShort == "schemaDefinitions")
                        {
                            TDJson["schemaDefinitions"] = createTDSchemaDefinitions(tdElement);
                        }
                    }
                }
                exportData["status"] = "success";
                exportData["data"]   = TDJson;
            }
            catch (Exception ex)
            {
                exportData["status"] = "error";
                exportData["data"]   = ex.ToString();
            }
            return(exportData);
        }
コード例 #17
0
        public static JObject createTDSchemaDefinitions(AdminShell.SubmodelElement sem)
        {
            JObject semJObject = new JObject();

            return(semJObject);
        }
コード例 #18
0
        //
        // Event management
        //

        /* TODO (MIHO, 2021-08-17): check if to refactor/ move to another location
         * and to extend to Submodels .. */
        public static bool UpdateSmeFromEventPayloadItem(
            AdminShell.SubmodelElement smeToModify,
            AasPayloadUpdateValueItem vl)
        {
            // access
            if (smeToModify == null || vl == null)
            {
                return(false);
            }

            var changedSomething = false;

            // adopt
            // TODO (MIHO, 2021-08-17): add more type specific conversions?
            if (smeToModify is AdminShell.Property prop)
            {
                if (vl.Value is string vls)
                {
                    prop.value = vls;
                }
                if (vl.ValueId != null)
                {
                    prop.valueId = vl.ValueId;
                }
                changedSomething = true;
            }

            if (smeToModify is AdminShell.MultiLanguageProperty mlp)
            {
                if (vl.Value is AdminShell.LangStringSet lss)
                {
                    mlp.value = lss;
                }
                if (vl.ValueId != null)
                {
                    mlp.valueId = vl.ValueId;
                }
                changedSomething = true;
            }

            if (smeToModify is AdminShell.Range rng)
            {
                if (vl.Value is string[] sarr && sarr.Length >= 2)
                {
                    rng.min = sarr[0];
                    rng.max = sarr[1];
                }
                changedSomething = true;
            }

            if (smeToModify is AdminShell.Blob blob)
            {
                if (vl.Value is string vls)
                {
                    blob.value = vls;
                }
                changedSomething = true;
            }

            // ok
            return(changedSomething);
        }
コード例 #19
0
        private bool MatchEntity(
            AdminShell.SubmodelElement elem, string preset, string cell,
            ref string parentName, ref string elemName, ref string valueStr,
            bool allowMultiplicity = false)
        {
            // access
            if (elem == null || preset == null || cell == null)
            {
                return(false);
            }

            // lambda trick to save lines of code
            var res = false;
            Func <string, string> commit = (s) => { res = true; return(s); };

            if (preset == "elementName")
            {
                elemName = commit(cell);
            }

            if (preset == "parent")
            {
                parentName = commit(cell);
            }

            if (preset == "idShort")
            {
                elem.idShort = commit(cell);
            }

            if (preset == "category")
            {
                elem.category = commit(cell);
            }

            if (preset == "kind")
            {
                elem.kind = new AdminShell.ModelingKind(commit(cell));
            }

            if (preset == "semanticId")
            {
                elem.semanticId = CreateSemanticId(commit(cell));
            }

            if (preset == "description")
            {
                elem.description = new AdminShell.Description(
                    new AdminShell.LangStringSet(
                        AdminShell.ListOfLangStr.Parse(commit(cell))));
            }

            if (preset == "value")
            {
                valueStr = commit(cell);
            }

            if (preset == "valueType")
            {
                // value type can be distorted in many ways, so commit in each case
                var vt = commit(cell);

                // adopt
                var m = Regex.Match(vt, @"^\s*\[(.*)\]");
                if (m.Success)
                {
                    vt = m.Groups[1].ToString();
                }

                // exclude SMEs
                foreach (var x in AdminShell.SubmodelElementWrapper.AdequateElementNames
                         .Union(AdminShell.SubmodelElementWrapper.AdequateElementShortName))
                {
                    if (x != null && vt.Trim().ToLower() == x.ToLower())
                    {
                        return(true);
                    }
                }

                // very special case
                if (vt.Trim() == "n/a")
                {
                    return(true);
                }

                // set
                if (elem is AdminShell.Property prop)
                {
                    prop.valueType = vt;
                }
            }

            // very special
            if (allowMultiplicity && preset == "multiplicity")
            {
                var multival = "One";
                var tricell  = cell.Trim();
                if (tricell == "0..1" || tricell == "[0..1]" || tricell == "ZeroToOne")
                {
                    multival = "ZeroToOne";
                }
                if (tricell == "0..*" || tricell == "[0..*]" || tricell == "ZeroToMany")
                {
                    multival = "ZeroToMany";
                }
                if (tricell == "1..*" || tricell == "[1..*]" || tricell == "OneToMany")
                {
                    multival = "OneToMany";
                }
                if (elem.qualifiers == null)
                {
                    elem.qualifiers = new AdminShell.QualifierCollection();
                }
                elem.qualifiers.Add(new AdminShell.Qualifier()
                {
                    type = "Multiplicity", value = multival
                });
                return(true);
            }

            // very crazy to split in multiple Qualifiers
            // idea: use '|' to delimit Qualifiers, use 't,s=v,id' to parse Qualifiers,
            //       use ',' to delimit keys (after first ','), use xx[yy]zzz to parse keys
            if (preset == "qualifiers")
            {
                var qstr = commit(cell);
                if (qstr != null)
                {
                    var qparts = qstr.Split(new[] { '|', '*', '\r', '\n', '\t' },
                                            StringSplitOptions.RemoveEmptyEntries);
                    foreach (var qp in qparts)
                    {
                        var q = AdminShell.Qualifier.Parse(qp);
                        if (q != null)
                        {
                            elem.qualifiers.Add(q);
                        }
                    }
                }
            }

            return(res);
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: i-Asset/basyx
        private static void CreateStochasticViewOnSubmodelsRecurse(AdminShell.View vw, AdminShell.Submodel submodel, AdminShell.SubmodelElement sme)
        {
            if (vw == null || sme == null)
            {
                return;
            }

            var isSmc = (sme is AdminShell.SubmodelElementCollection);

            // spare out some of the leafs of the tree ..
            if (!isSmc)
            {
                if (Math.Abs(sme.idShort.GetHashCode() % 100) > 50)
                {
                    return;
                }
            }

            // ok, create
            var ce = new AdminShell.ContainedElementRef();

            sme.CollectReferencesByParent(ce.Keys);
            vw.AddContainedElement(ce.Keys);
            // recurse
            if (isSmc)
            {
                foreach (var sme2wrap in (sme as AdminShell.SubmodelElementCollection).value)
                {
                    CreateStochasticViewOnSubmodelsRecurse(vw, submodel, sme2wrap.submodelElement);
                }
            }
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
 /// <summary>
 /// Build a new instance, based on the description data
 /// </summary>
 public override FormInstanceSubmodelElement CreateInstance(
     FormInstanceListOfSame parentInstance, AdminShell.SubmodelElement source = null)
 {
     return(new FormInstanceReferenceElement(parentInstance, this, source));
 }
コード例 #24
0
        //
        // Helper functions
        //

        public void DispSmeCutCopyPasteHelper(
            Panel stack, ModifyRepo repo,
            AdminShell.AdministrationShellEnv env,
            AdminShell.Referable parentContainer,
            CopyPasteBuffer cpb,
            AdminShell.SubmodelElementWrapper wrapper,
            AdminShell.SubmodelElement sme,
            string label = "Buffer:")
        {
            // access
            if (parentContainer == null || cpb == null || sme == null)
            {
                return;
            }

            // use an action
            this.AddAction(
                stack, label,
                new[] { "Cut", "Copy", "Paste above", "Paste below", "Paste into" }, repo,
                (buttonNdx) =>
            {
                if (buttonNdx == 0 || buttonNdx == 1)
                {
                    // store info
                    cpb.valid     = true;
                    cpb.duplicate = buttonNdx == 1;
                    cpb.item      = new CopyPasteItemSME(env, parentContainer, wrapper, sme);

                    // user feedback
                    AasxPackageExplorer.Log.Singleton.Info(
                        StoredPrint.Color.Blue,
                        "Stored SubmodelElement '{0}'({1}) to internal buffer.{2}", "" + sme.idShort,
                        "" + sme?.GetElementName(),
                        cpb.duplicate
                                ? " Paste will duplicate."
                                : " Paste will cut at original position.");
                }

                if (buttonNdx == 2 || buttonNdx == 3 || buttonNdx == 4)
                {
                    // present
                    var item = cpb?.item as CopyPasteItemSME;
                    if (!cpb.valid || item?.sme == null || item?.wrapper == null ||
                        item?.parentContainer == null)
                    {
                        if (this.flyoutProvider != null)
                        {
                            this.flyoutProvider.MessageBoxFlyoutShow(
                                "No (valid) information for SubmodelElements in copy/paste buffer.",
                                "Copy & Paste",
                                MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        return(new ModifyRepo.LambdaActionNone());
                    }

                    // user feedback
                    AasxPackageExplorer.Log.Singleton.Info(
                        "Pasting buffer with SubmodelElement '{0}'({1}) to internal buffer.",
                        "" + item.sme.idShort, "" + item.sme.GetElementName());

                    // apply info
                    var smw2 = new AdminShell.SubmodelElementWrapper(item.sme, shallowCopy: false);

                    // insertation depends on parent container
                    if (buttonNdx == 2)
                    {
                        if (parentContainer is AdminShell.Submodel pcsm && wrapper != null)
                        {
                            this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                pcsm.submodelElements, smw2, wrapper);
                        }

                        if (parentContainer is AdminShell.SubmodelElementCollection pcsmc &&
                            wrapper != null)
                        {
                            this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                pcsmc.value, smw2, wrapper);
                        }

                        if (parentContainer is AdminShell.Entity pcent &&
                            wrapper != null)
                        {
                            this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                pcent.statements, smw2, wrapper);
                        }

                        if (parentContainer is AdminShell.AnnotatedRelationshipElement pcarel &&
                            wrapper != null)
                        {
                            this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>(
                                pcarel.annotations, smw2, wrapper);
                        }

                        // TODO (Michael Hoffmeister, 2020-08-01): Operation mssing here?
                    }
コード例 #25
0
        private void ExportTable_EnumerateSubmodel(
            ExportTableAasEntitiesList list, AdminShell.AdministrationShellEnv env,
            bool broadSearch, int depth,
            AdminShell.Submodel sm, AdminShell.SubmodelElement sme)
        {
            // check
            if (list == null || env == null || sm == null)
            {
                return;
            }

            //
            // Submodel or SME ??
            //

            AdminShell.IEnumerateChildren coll = null;
            if (sme == null)
            {
                // yield SM
                list.Add(new ExportTableAasEntitiesItem(depth, sm: sm));

                // use collection
                coll = sm;
            }
            else
            {
                // simple check for SME collection
                if (sme is AdminShell.IEnumerateChildren)
                {
                    coll = (sme as AdminShell.IEnumerateChildren);
                }
            }

            // pass 1: process value
            if (coll != null)
            {
                foreach (var ci in coll.EnumerateChildren())
                {
                    // gather data for this entity
                    var sme2 = ci.submodelElement;
                    var cd   = env.FindConceptDescription(sme2?.semanticId?.Keys);
                    list.Add(new ExportTableAasEntitiesItem(depth, sm, sme2, cd));

                    // go directly deeper?
                    if (!broadSearch && ci.submodelElement != null &&
                        ci.submodelElement is AdminShell.IEnumerateChildren)
                    {
                        ExportTable_EnumerateSubmodel(
                            list, env, broadSearch: false, depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                    }
                }
            }

            // pass 2: go for recursion AFTER?
            if (broadSearch)
            {
                if (coll != null)
                {
                    foreach (var ci in coll.EnumerateChildren())
                    {
                        if (ci.submodelElement != null && ci.submodelElement is AdminShell.IEnumerateChildren)
                        {
                            ExportTable_EnumerateSubmodel(
                                list, env, broadSearch: true, depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                        }
                    }
                }
            }
        }
コード例 #26
0
        private void ExportTable_EnumerateSubmodel(
            List <ExportTableAasEntitiesList> list, AdminShell.AdministrationShellEnv env,
            bool broadSearch, bool actInHierarchy, int depth,
            AdminShell.Submodel sm, AdminShell.SubmodelElement sme)
        {
            // check
            if (list == null || env == null || sm == null)
            {
                return;
            }

            //
            // Submodel or SME ??
            //

            AdminShell.IEnumerateChildren coll = null;
            if (sme == null)
            {
                // yield SM
                // MIHO 21-11-24: IMHO this makes no sense
                //// list.Add(new ExportTableAasEntitiesItem(depth, sm: sm, parentSm: sm));

                // use collection
                coll = sm;
            }
            else
            {
                // simple check for SME collection
                if (sme is AdminShell.IEnumerateChildren)
                {
                    coll = (sme as AdminShell.IEnumerateChildren);
                }
            }

            // prepare listItem
            ExportTableAasEntitiesList listItem = null;

            if (!actInHierarchy)
            {
                // add everything in one list
                if (list.Count < 1)
                {
                    list.Add(new ExportTableAasEntitiesList());
                }
                listItem = list[0];
            }
            else
            {
                // create a new list for each recursion
                listItem = new ExportTableAasEntitiesList();
                list.Add(listItem);
            }

            // pass 1: process value
            if (coll != null)
            {
                foreach (var ci in coll.EnumerateChildren())
                {
                    // gather data for this entity
                    var sme2 = ci.submodelElement;
                    var cd   = env.FindConceptDescription(sme2?.semanticId?.Keys);

                    // add
                    listItem.Add(new ExportTableAasEntitiesItem(depth, sm, sme2, cd,
                                                                parent: coll as AdminShell.Referable));

                    // go directly deeper?
                    if (!broadSearch && ci.submodelElement != null &&
                        ci.submodelElement is AdminShell.IEnumerateChildren)
                    {
                        ExportTable_EnumerateSubmodel(
                            list, env, broadSearch: false, actInHierarchy,
                            depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                    }
                }
            }

            // pass 2: go for recursion AFTER?
            if (broadSearch)
            {
                if (coll != null)
                {
                    foreach (var ci in coll.EnumerateChildren())
                    {
                        if (ci.submodelElement != null && ci.submodelElement is AdminShell.IEnumerateChildren)
                        {
                            ExportTable_EnumerateSubmodel(
                                list, env, broadSearch: true, actInHierarchy,
                                depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                        }
                    }
                }
            }
        }
コード例 #27
0
 /// <summary>
 /// Build a new instance, based on the description data
 /// </summary>
 public virtual FormInstanceSubmodelElement CreateInstance(
     FormInstanceListOfSame parentInstance, AdminShell.SubmodelElement source = null)
 {
     return(null);
 }
コード例 #28
0
        //
        // Event management
        //

        private bool CheckPushedEventInternal(AasEventMsgEnvelope ev)
        {
            // access
            if (ev == null)
            {
                return(false);
            }

            // to be applicable, the event message Observable has to relate into this's environment
            var foundObservable = Env?.AasEnv?.FindReferableByReference(ev?.ObservableReference);

            if (foundObservable == null)
            {
                return(false);
            }

            //
            // Update value?
            //
            // Note: an update will only be executed, if NOT ALREADY marked as being updated in the
            //       event message. MOST LIKELY, the AAS update will be done in the connector, already!
            //
            foreach (var pluv in ev.GetPayloads <AasPayloadUpdateValue>())
            {
                if (pluv.Values != null &&
                    !pluv.IsAlreadyUpdatedToAAS &&
                    foundObservable is AdminShell.IEnumerateChildren &&
                    (foundObservable is AdminShell.Submodel || foundObservable is AdminShell.SubmodelElement))
                {
                    // will later access children ..
                    var wrappers         = ((foundObservable as AdminShell.IEnumerateChildren).EnumerateChildren())?.ToList();
                    var changedSomething = false;

                    // go thru all value updates
                    if (pluv.Values != null)
                    {
                        foreach (var vl in pluv.Values)
                        {
                            if (vl == null)
                            {
                                continue;
                            }

                            // Note: currently only updating Properties
                            // TODO (MIHO, 2021-01-03): check to handle more SMEs for AasEventMsgUpdateValue

                            AdminShell.SubmodelElement smeToModify = null;
                            if (vl.Path == null && foundObservable is AdminShell.Property fop)
                            {
                                smeToModify = fop;
                            }
                            else if (vl.Path != null && vl.Path.Count >= 1 && wrappers != null)
                            {
                                var x = AdminShell.SubmodelElementWrapper.FindReferableByReference(
                                    wrappers, AdminShell.Reference.CreateNew(vl.Path), keyIndex: 0);
                                if (x is AdminShell.Property fpp)
                                {
                                    smeToModify = fpp;
                                }
                            }

                            // something to modify?
                            if (smeToModify is AdminShell.Property prop)
                            {
                                if (vl.Value != null)
                                {
                                    prop.value = vl.Value;
                                }
                                if (vl.ValueId != null)
                                {
                                    prop.valueId = vl.ValueId;
                                }
                                changedSomething = true;
                            }
                        }
                    }

                    // if something was changed, the event messages is to be consumed
                    if (changedSomething)
                    {
                        return(true);
                    }
                }
            }

            // no
            return(false);
        }