Exemple #1
0
        /// <summary>
        /// Send an action to a list of ports for this state machine.
        /// </summary>
        /// <param name="actionName">the string for the action, i.e. PortName.ActionName</param>
        /// <param name="data">Generic data </param>
        public void SendPortAction(string sourcePortName, string actionName, object data)
        {
            GQHSMPort destPort = GetPort(sourcePortName);

            if (destPort != null)
            {
                QEvent ev = new QEvent(actionName, data);
                destPort.Port.Receive(destPort.Port, ev);
            }
        }
Exemple #2
0
        private MethodInfo Trigger(MethodInfo stateMethod, QSignals qSignal)
        {
            var evt = new QEvent((int)qSignal);

            OnEvent(stateMethod, evt);
            QState state = (QState)stateMethod.Invoke(this, new object[] { evt });

            if (state == null)
            {
                return(null);
            }
            else
            {
                return(state.GetMethodInfo());
            }
        }
Exemple #3
0
 /// <summary>
 /// Allows an event source to publish an event.
 /// </summary>
 /// <param name="qEvent">The <see cref="QEvent"/> to publish.</param>
 public void Publish(QEvent qEvent)
 {
     lock (m_SignalSubscribers)
     {
         int        hashCode             = qEvent.QSignal.GetHashCode();
         SortedList sortedSubscriberList = m_SignalSubscribers[hashCode];
         if (sortedSubscriberList != null)
         {
             // For simplicity we do not use the event propagae pattern that Miro Samek uses in his implementation.
             // This has two consequences:
             // a) We rely on the Garbage Collector to clean up events that are no longer used
             // b) We don't have the restriction that only once instance of a given type (signal value) can be in use at any given time
             for (int i = 0; i < sortedSubscriberList.Count; i++)
             {
                 IQActive subscribingQActive = (IQActive)sortedSubscriberList.GetByIndex(i);
                 subscribingQActive.PostFIFO(qEvent);
             }
         }
     }
 }
		/// <summary>
		/// If USE_DOTNET_EVENTS is defined, this method is intended to be used only for self-posting.
		/// Otherwise, it allows any object to add events to the Hsm's queue.
		/// </summary>
		/// <param name="qEvent">New message posted (to self) during processing</param>
		#if USE_DOTNET_EVENTS
		protected void Enqueue(QEvent qEvent)
 public void Receive(IQPort fromPort, IQEvent ev)
 {
     ev = new QEvent (_Name, _Key, ev.QSignal, ev.QData, ev.QSent);
     _Qhsm.AsyncDispatch (ev);
 }
Exemple #6
0
 /// <summary>
 /// Enqueues the first event then dequeues and dispatches all queued events to this state machine.
 /// Designed to be called in place of base.Dispatch in the event self-posting is to be 
 /// supported.
 /// </summary>
 public void DispatchQ(QEvent qEvent)
 {
     m_EventQueue.Enqueue(qEvent);
     DispatchQ();
 }
Exemple #7
0
 /// <summary>
 /// Designed to be used only for self-posting, but this design could easily be changed
 /// by making this method public.
 /// </summary>
 /// <param name="qEvent">New message posted to self during processing</param>
 protected void Enqueue(QEvent qEvent)
 {
     m_EventQueue.Enqueue(qEvent);
 }
Exemple #8
0
 /// <summary>
 /// Allows an event source to publish an event. 
 /// </summary>
 /// <param name="qEvent">The <see cref="QEvent"/> to publish.</param>
 public void Publish(QEvent qEvent)
 {
     lock(m_SignalSubscribers)
     {
         SortedList sortedSubscriberList = m_SignalSubscribers[qEvent.QSignal];
         if (sortedSubscriberList != null)
         {
             // For simplicity we do not use the event propagae pattern that Miro Samek uses in his implementation.
             // This has two consequences:
             // a) We rely on the Garbage Collector to clean up events that are no longer used
             // b) We don't have the restriction that only once instance of a given type (signal value) can be in use at any given time
             for(int i = 0; i < sortedSubscriberList.Count; i++)
             {
                 IQActive subscribingQActive = (IQActive)sortedSubscriberList.GetByIndex(i);
                 subscribingQActive.PostFIFO(qEvent);
             }
         }
     }
 }
 public SimpleTransactionalCmd(IQSimpleCommand cmd)
 {
     _Cmd         = cmd;
     _Transaction = QEvent.GetThreadTransaction();
 }
Exemple #10
0
 /// <summary>
 /// Designed to be used only for self-posting, but this design could easily be changed
 /// by making this method public.
 /// </summary>
 /// <param name="qEvent">New message posted to self during processing</param>
 protected void Enqueue(QEvent qEvent)
 {
     m_EventQueue.Enqueue(qEvent);
 }
Exemple #11
0
 /// <summary>
 /// Enqueues the first event then dequeues and dispatches all queued events to this state machine.
 /// Designed to be called in place of base.Dispatch in the event self-posting is to be
 /// supported.
 /// </summary>
 public void DispatchQ(QEvent qEvent)
 {
     m_EventQueue.Enqueue(qEvent);
     DispatchQ();
 }        //DispatchQ
Exemple #12
0
 public void Receive(IQPort fromPort, IQEvent ev)
 {
     ev = new QEvent(_Name, _Key, ev.QSignal, ev.QData, ev.QSent);
     _Qhsm.AsyncDispatch(ev);
 }