public VisualElementHistoryItem(VisualElementGeneric VisualElement,
                                 AdminShell.Identification ReferableAasId = null, AdminShell.Reference ReferableReference = null)
 {
     this.VisualElement      = VisualElement;
     this.ReferableAasId     = ReferableAasId;
     this.ReferableReference = ReferableReference;
 }
Exemplo n.º 2
0
 public NodeLateActionLinkToReference(NodeState uanode, AdminShell.Reference targetReference,
                                      ActionType actionType)
 {
     this.uanode          = uanode;
     this.targetReference = targetReference;
     this.actionType      = actionType;
 }
        public static AdminShell.ConceptDescription CreateSparseConceptDescription(
            string lang,
            string idType,
            string idShort,
            string id,
            string definitionHereString,
            AdminShell.Reference isCaseOf = null)
        {
            // access
            if (idShort == null || idType == null || id == null)
            {
                return(null);
            }

            // create CD
            var cd    = AdminShell.ConceptDescription.CreateNew(idShort, idType, id);
            var dsiec = cd.CreateDataSpecWithContentIec61360();

            dsiec.preferredName = new AdminShellV20.LangStringSetIEC61360(lang, "" + idShort);
            dsiec.definition    = new AdminShellV20.LangStringSetIEC61360(lang,
                                                                          "" + AdminShellUtil.CleanHereStringWithNewlines(nl: " ", here: definitionHereString));

            // options
            if (isCaseOf != null)
            {
                cd.IsCaseOf = new List <AdminShell.Reference>(new[] { isCaseOf });
            }

            // ok
            return(cd);
        }
Exemplo n.º 4
0
 public AasEventMsgEnvelope(
     DateTime timestamp,
     AdminShell.Reference source                = null,
     AdminShell.SemanticId sourceSemanticId     = null,
     AdminShell.Reference observableReference   = null,
     AdminShell.SemanticId observableSemanticId = null,
     string topic                   = null,
     string subject                 = null,
     AasPayloadBase payload         = null,
     List <AasPayloadBase> payloads = null)
 {
     Timestamp            = timestamp;
     Source               = source;
     SourceSemanticId     = sourceSemanticId;
     ObservableReference  = observableReference;
     ObservableSemanticId = observableSemanticId;
     Topic   = topic;
     Subject = subject;
     if (payload != null)
     {
         Payloads.Add(payload);
     }
     if (payloads != null)
     {
         Payloads.AddRange(payloads);
     }
 }
        private void RecurseIndexSME(AdminShell.Reference currRef, AdminShell.SubmodelElement sme)
        {
            // access
            if (currRef == null || sme == null)
            {
                return;
            }

            // add to the currRef
            currRef.Keys.Add(
                new AdminShell.Key(
                    sme.GetElementName(), false, AdminShell.Identification.IdShort, sme.idShort));

            // index
            var hk = ComputeHashOnReference(currRef);

            dict.Add(hk, sme);

            // recurse
            var childs = (sme as AdminShell.IEnumerateChildren)?.EnumerateChildren();

            if (childs != null)
            {
                foreach (var sme2 in childs)
                {
                    RecurseIndexSME(currRef, sme2?.submodelElement);
                }
            }

            // remove from currRef
            currRef.Keys.RemoveAt(currRef.Keys.Count - 1);
        }
Exemplo n.º 6
0
        //
        // V11
        //

        private static void SearchForRelations(
            AdminShell.SubmodelElementWrapperCollection smwc,
            DocumentEntity.DocRelationType drt,
            AdminShell.Reference semId,
            DocumentEntity intoDoc)
        {
            // access
            if (smwc == null || semId == null || intoDoc == null)
            {
                return;
            }

            foreach (var re in smwc.FindAllSemanticIdAs <AdminShell.ReferenceElement>(semId,
                                                                                      AdminShellV20.Key.MatchMode.Relaxed))
            {
                // access
                if (re.value == null || re.value.Count < 1)
                {
                    continue;
                }

                // be a bit picky
                if (re.value.Last.type.ToLower().Trim() != AdminShell.Key.Entity.ToLower())
                {
                    continue;
                }

                // add
                intoDoc.Relations.Add(new Tuple <DocumentEntity.DocRelationType, AdminShellV20.Reference>(
                                          drt, re.value));
            }
        }
            private void repReference(string head, string refName, AdminShell.Reference rid)
            {
                if (rid == null || refName == null || rid.Keys == null)
                {
                    return;
                }

                // add together
                //-9- {Reference}
                rep(head + refName + "", "" + rid.ToString(1));

                // add the single parts of the sid
                for (int ki = 0; ki < rid.Keys.Count; ki++)
                {
                    var k = rid.Keys[ki];
                    if (k != null)
                    {
                        // in nice form
                        //-9- {Reference}[0..n]
                        rep(head + refName + $"[{ki}]", "" + k.ToString(1));
                        // but also in separate parts
                        //-9- {Reference}[0..n].{type, local, idType, value}
                        rep(head + refName + $"[{ki}].type", "" + k.type);
                        rep(head + refName + $"[{ki}].local", (!k.local) ? "no-local" : "local");
                        rep(head + refName + $"[{ki}].idType", "" + k.idType);
                        rep(head + refName + $"[{ki}].value", "" + k.value);
                    }
                }
            }
        public void Push(VisualElementGeneric ve)
        {
            // access
            if (ve == null)
            {
                return;
            }

            // for ve, try to find the AAS (in the parent hierarchy)
            var veAas = ve.FindAllParents((v) => { return(v is VisualElementAdminShell); },
                                          includeThis: true).FirstOrDefault();

            // for ve, find the Referable to be ve or superordinate ..
            var veRef = ve.FindAllParents((v) =>
            {
                var derefdo = v?.GetDereferencedMainDataObject();
                // success implies AdminShell.IGetReference as well
                return(derefdo is AdminShell.Referable);
            }, includeThis: true).FirstOrDefault();

            // check, if ve can identify a Referable, to which a symbolic link can be done ..
            AdminShell.Identification aasid  = null;
            AdminShell.Reference      refref = null;

            if (veAas != null && veRef != null)
            {
                aasid = (veAas as VisualElementAdminShell)?.theAas?.identification;

                var derefdo = veRef.GetDereferencedMainDataObject();
                refref = (derefdo as AdminShell.IGetReference)?.GetReference();
            }

            // some more special cases
            if (refref == null && ve is VisualElementConceptDescription vecd)
            {
                refref = vecd.theCD?.GetReference();
            }

            // found some referable Reference?
            if (refref == null)
            {
                return;
            }

            // in case of plug in, make it more specific
            if (ve is VisualElementPluginExtension vepe && vepe.theExt?.Tag != null)
            {
                refref += new AdminShell.Key(AdminShell.Key.FragmentReference, false,
                                             AdminShell.Key.Custom, "Plugin:" + vepe.theExt.Tag);
            }

            // add, only if not already there
            if (history.Count < 1 || history[history.Count - 1].VisualElement != ve)
            {
                history.Add(new VisualElementHistoryItem(ve, aasid, refref));
            }

            // is enabled
            buttonBack.IsEnabled = true;
        }
Exemplo n.º 9
0
 public AdminShell.Referable FindReferableByReference(AdminShell.Reference r)
 {
     if (refStore == null)
     {
         return(this.env?.FindReferableByReference(r));
     }
     return(refStore.FindReferableByReference(r));
 }
 public AdminShell.Referable FindReferableByReference(AdminShell.Reference r)
 {
     if (_refStore == null)
     {
         return(this._env?.FindReferableByReference(r));
     }
     return(_refStore.FindElementByReference(r, AdminShell.Key.MatchMode.Relaxed));
 }
Exemplo n.º 11
0
        //
        // Constructor
        //

        public AasPayloadUpdateValueItem(
            AdminShell.KeyList path      = null,
            string value                 = null,
            AdminShell.Reference valueId = null)
        {
            Path    = path;
            Value   = value;
            ValueId = valueId;
        }
Exemplo n.º 12
0
 public AnyUiLambdaActionNavigateTo(
     AdminShell.Reference targetReference,
     bool translateAssetToAAS = false,
     bool alsoDereferenceObjects = true)
 {
     this.targetReference = targetReference;
     this.translateAssetToAAS = translateAssetToAAS;
     this.alsoDereferenceObjects = alsoDereferenceObjects;
 }
        public void Index(AdminShell.Reference rf, T elem)
        {
            // access
            if (elem == null || rf == null)
            {
                return;
            }

            // make curr ref and index
            dict.Add(ComputeHashOnReference(rf), elem);
        }
Exemplo n.º 14
0
        public static List<string> ToOpcUaReferenceList(AdminShell.Reference refid)
        {
            if (refid == null || refid.IsEmpty)
                return null;

            var res = new List<string>();
            foreach (var k in refid.Keys)
            {
                res.Add(String.Format("({0})({1})[{2}]{3}",
                            k.type, k.local ? "local" : "no-local", k.idType, k.value));
            }

            return res;
        }
Exemplo n.º 15
0
 public VisualElementReference(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.Reference rf)
     : base()
 {
     this.Parent       = parent;
     this.Cache        = cache;
     this.theEnv       = env;
     this.theReference = rf;
     this.Background   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0D0D0"));
     this.Border       = (SolidColorBrush)(new BrushConverter().ConvertFrom("#606060"));
     this.TagString    = "\u2b95";
     this.TagBg        = this.Border;
     this.TagFg        = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Exemplo n.º 16
0
        public static string ToOpcUaReference(AdminShell.Reference refid)
        {
            if (refid == null || refid.IsEmpty)
                return null;

            var semstr = "";
            foreach (var k in refid.Keys)
            {
                if (semstr != "")
                    semstr += ",";
                semstr += String.Format("({0})({1})[{2}]{3}",
                            k.type, k.local ? "local" : "no-local", k.idType, k.value);
            }

            return semstr;
        }
        protected uint ComputeHashOnReference(AdminShell.Reference r)
        {
            // access
            if (r == null || r.Keys == null)
            {
                return(0);
            }

            // use memory stream for effcient behaviour
            byte[] dataBytes = null;
            using (var mems = new MemoryStream())
            {
                foreach (var k in r.Keys)
                {
                    var bs = System.Text.Encoding.UTF8.GetBytes(k.type.Trim().ToLower());
                    mems.Write(bs, 0, bs.Length);

                    bs = System.Text.Encoding.UTF8.GetBytes(k.idType.Trim().ToLower());
                    mems.Write(bs, 0, bs.Length);

                    bs = System.Text.Encoding.UTF8.GetBytes(k.value.Trim().ToLower());
                    mems.Write(bs, 0, bs.Length);
                }

                dataBytes = mems.ToArray();
            }

            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            // ReSharper disable HeuristicUnreachableCode
            if (dataBytes == null)
            {
                return(0);
            }
            // ReSharper enable ConditionIsAlwaysTrueOrFalse
            // ReSharper enable HeuristicUnreachableCode

            uint sum = 0;

            foreach (var b in dataBytes)
            {
                sum += b;
            }
            return(sum);
        }
        public VisualElementReference(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env,
            AdminShell.Reference rf)
            : base()
        {
            this.Parent       = parent;
            this.Cache        = cache;
            this.theEnv       = env;
            this.theReference = rf;

            this.Background = Brushes.White;
            this.Border     = Brushes.White;
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "\u2b95";
            RefreshFromMainData();
            RestoreFromCache();
        }
Exemplo n.º 19
0
        public AdminShell.Referable FindReferableByReference(AdminShell.Reference r)
        {
            var hk = ComputeHashOnReference(r);

            if (hk == 0 || !dict.ContainsKey(hk))
            {
                return(null);
            }

            foreach (var test in dict[hk])
            {
                var xx = (test as AdminShell.IGetReference)?.GetReference();
                if (xx != null && xx.Matches(r))
                {
                    return(test);
                }
            }

            return(null);
        }
Exemplo n.º 20
0
        private AdminShell.Referable FindAllReferableByReference(AdminShellPackageEnv[] packages,
                                                                 AdminShell.Reference rf)
        {
            // access
            if (packages == null || rf == null)
            {
                return(null);
            }

            // find
            foreach (var pck in packages)
            {
                var x = pck?.AasEnv?.FindReferableByReference(rf);
                if (x != null)
                {
                    return(x);
                }
            }

            // oh, no
            return(null);
        }
        public T FindElementByReference(
            AdminShell.Reference r,
            AdminShell.Key.MatchMode matchMode = AdminShell.Key.MatchMode.Strict)
        {
            var hk = ComputeHashOnReference(r);

            if (hk == 0 || !dict.ContainsKey(hk))
            {
                return(default(T));
            }

            foreach (var test in dict[hk])
            {
                var xx = (test as AdminShell.IGetReference)?.GetReference();
                if (xx != null && xx.Matches(r, matchMode))
                {
                    return(test);
                }
            }

            return(default(T));
        }
Exemplo n.º 22
0
 public LambdaActionNavigateTo(AdminShell.Reference targetReference)
 {
     this.targetReference = targetReference;
 }
Exemplo n.º 23
0
        public SupplementaryReferenceInformation StripSupplementaryReferenceInformation(AdminShell.Reference rf)
        {
            // in any case, provide record
            var sri = new SupplementaryReferenceInformation();

            sri.CleanReference = new AdminShell.Reference(rf);

            // plug-in?
            var srl = sri.CleanReference.Last;

            if (srl?.type == AdminShell.Key.FragmentReference && srl?.idType == AdminShell.Key.Custom &&
                srl?.value?.StartsWith("Plugin:") == true)
            {
                sri.SearchPluginTag = srl.value.Substring("Plugin:".Length);
                sri.CleanReference.Keys.Remove(srl);
            }

            // ok
            return(sri);
        }