示例#1
0
文件: GQHSM.cs 项目: klhurley/qf4net
        /// <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);
            }
        }
示例#2
0
文件: QHsm.cs 项目: ianblenke/qhsm
        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());
            }
        }
示例#3
0
文件: QF.cs 项目: klhurley/qf4net
 /// <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);
             }
         }
     }
 }
示例#4
0
		/// <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)
示例#5
0
 public void Receive(IQPort fromPort, IQEvent ev)
 {
     ev = new QEvent (_Name, _Key, ev.QSignal, ev.QData, ev.QSent);
     _Qhsm.AsyncDispatch (ev);
 }
示例#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();
 }
示例#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);
 }
示例#8
0
文件: QF.cs 项目: djpnewton/ddraw
 /// <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);
             }
         }
     }
 }
示例#9
0
 public SimpleTransactionalCmd(IQSimpleCommand cmd)
 {
     _Cmd         = cmd;
     _Transaction = QEvent.GetThreadTransaction();
 }
示例#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);
 }
示例#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
示例#12
0
文件: QPort.cs 项目: klhurley/qf4net
 public void Receive(IQPort fromPort, IQEvent ev)
 {
     ev = new QEvent(_Name, _Key, ev.QSignal, ev.QData, ev.QSent);
     _Qhsm.AsyncDispatch(ev);
 }