示例#1
0
 public void Push(AasEventMsgEnvelope ev)
 {
     if (ev != null && _events != null)
     {
         _events.Add(ev);
     }
 }
示例#2
0
 public void PushEvent(AasEventMsgEnvelope ev)
 {
     if (ev == null || this._stack == null)
     {
         return;
     }
     lock (this._stack)
     {
         this._stack.Add(ev);
     }
 }
示例#3
0
        protected TraceStateBase FollowTraceState(TraceStateBase stateIn, AasEventMsgEnvelope ev)
        {
            // trivial
            if (ev == null)
            {
                return(null);
            }

            // basically a unfold state machine
            if (ev.SourceSemanticId.Matches(AasxPredefinedConcepts.AasEvents.Static.CD_StructureChangeOutwards,
                                            AdminShell.Key.MatchMode.Relaxed)
                // a in special format
                && ev.PayloadItems != null && ev.PayloadItems.Count == 1 &&
                ev.PayloadItems[0] is AasPayloadStructuralChange evplsc &&
                evplsc.Changes != null && evplsc.Changes.Count == 1 &&
                evplsc.Changes[0].Reason == StructuralChangeReason.Modify)
            {
                // structural change with exactly 1 modification

                // get a current key
                var rf = evplsc.Changes[0].GetDataAsReferable();
                rf.parent = null;
                var currKey = rf.GetReference()?.Last;

                // Transition NULL -> structural change
                if (currKey != null && stateIn == null)
                {
                    // start new state
                    var res = new TraceStateStructuralChangeOneModify()
                    {
                        CurrentPath = evplsc.Changes[0].Path.ReplaceLastKey(AdminShell.KeyList.CreateNew(currKey))
                    };
                    return(res);
                }
                else
                if (currKey != null &&
                    stateIn is TraceStateStructuralChangeOneModify stateCurr &&
                    evplsc.Changes[0].Path.Matches(stateCurr.CurrentPath, AdminShell.Key.MatchMode.Relaxed))
                {
                    // happy path: continue state
                    stateCurr.CurrentPath = stateCurr.CurrentPath.ReplaceLastKey(AdminShell.KeyList.CreateNew(currKey));
                    return(stateCurr);
                }
            }

            // ok, no condition met. Return "false"
            return(null);
        }
示例#4
0
        public AasEventMsgEnvelope PopEvent()
        {
            // result
            AasEventMsgEnvelope ev = null;

            // get?
            lock (this._stack)
            {
                if (this._stack.Count > 0)
                {
                    ev = this._stack[0];
                    this._stack.RemoveAt(0);
                }
            }

            // return if found or not ..
            return(ev);
        }
示例#5
0
        private AasEventMsgEnvelope JoinEvents_StructuralChangeOneModify(
            AasEventMsgEnvelope a, AasEventMsgEnvelope b)
        {
            // based on the old
            var joint = new AasEventMsgEnvelope(a);

            // add last modified contents
            if (joint.PayloadItems != null && joint.PayloadItems.Count == 1 &&
                joint.PayloadItems[0] is AasPayloadStructuralChange jsc &&
                jsc.Changes != null && jsc.Changes.Count == 1
                // also for b
                && b?.PayloadItems != null && b.PayloadItems.Count == 1 &&
                b.PayloadItems[0] is AasPayloadStructuralChange bsc &&
                bsc.Changes != null && bsc.Changes.Count == 1)
            {
                jsc.Changes[0].Data = "" + bsc.Changes[0].Data;
            }
            // and return
            return(joint);
        }
        public AasEventMsgEnvelope(AasEventMsgEnvelope other)
        {
            if (other == null)
            {
                return;
            }

            Timestamp            = other.Timestamp;
            Source               = other.Source;
            SourceSemanticId     = other.SourceSemanticId;
            ObservableReference  = other.ObservableReference;
            ObservableSemanticId = other.ObservableSemanticId;
            Topic   = other.Topic;
            Subject = other.Subject;
            if (other.PayloadItems != null)
            {
                Payloads = new ListOfAasPayloadBase(other.PayloadItems);
            }
            else if (other.PayloadsRaw != null)
            {
                Payloads = other;
            }
        }
 /// <summary>
 /// The Flyout can decide to handle events from the outside
 /// </summary>
 public virtual void PushEvent(AdminShellEvents.AasEventMsgEnvelope ev)
 {
     // default behavior: trigger event
     EventTriggered?.Invoke(ev);
 }