Example #1
0
        /// <summary>
        /// Manages the reception of message ON THE UI THREAD
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Connector_PacketReceived_CROSSTHREADED(object sender, ARCPO.ARCPO_ReceivedEventArgs e)
        {
            this.mLatestReceivedPacket = e.Packet;

            //Log ?
            if (ShowLog)
            {
                this.mLogForm.LogMessage(e.ReceivedTime, true, e.Packet);
            }

            //do something ?
            if (e.Packet != null)
            {
                //is a ardTouch packet ?
                if (e.Packet.mType == Constants.ARDTOUCH_TYPE && e.Packet.mSubType == Constants.ARDTOUCH_SUBTYPE)
                {
                    //ardTouch packet : the key is the first char of the body
                    if (ShowLog)
                    {
                        this.mLogForm.LogMessage(e.ReceivedTime, "Received ardTouch packet.");
                    }

                    if (e.Packet.ContentString != null && e.Packet.ContentString.Length > 0)
                    {
                        if (this.mRegisteredIntepreters.ContainsKey((byte)e.Packet.ContentString[0]))
                        {
                            this.mRegisteredIntepreters[(byte)e.Packet.ContentString[0]].Interprete(e.Packet);
                            if (ShowLog)
                            {
                                this.mLogForm.LogMessage(e.ReceivedTime, "Interpreter called.");
                            }
                        }
                        else
                        {
                            if (ShowLog)
                            {
                                this.mLogForm.LogMessage(e.ReceivedTime, "no interpreter for that packet");
                            }
                        }
                    }
                }
                else
                {
                    //generic packet from another tool
                    if (ShowLog)
                    {
                        this.mLogForm.LogMessage(e.ReceivedTime, "Received generic packet.");
                    }

                    if (this.mRegisteredIntepreters.ContainsKey((byte)e.Packet.mType))
                    {
                        this.mRegisteredIntepreters[(byte)e.Packet.mType].Interprete(e.Packet);
                        if (ShowLog)
                        {
                            this.mLogForm.LogMessage(e.ReceivedTime, "Interpreter called.");
                        }
                    }
                    else
                    {
                        if (ShowLog)
                        {
                            this.mLogForm.LogMessage(e.ReceivedTime, "no interpreter for that packet");
                        }
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Handles the reception of the mesage. BEWARE IT'S NOT ON THE UI Thread
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Connector_PacketReceived(object sender, ARCPO.ARCPO_ReceivedEventArgs e)
 {
     this.Invoke(new EventHandler <ARCPO.ARCPO_ReceivedEventArgs>(this.Connector_PacketReceived_CROSSTHREADED), sender, e);
 }