public void ReceiveCallback(IAsyncResult ar)
 {
     byte[] bytes = mpUdpClient.EndReceive(ar, ref mpEndPoint);
     UdpEventArgs udpAgs = new UdpEventArgs(Encoding.ASCII.GetString(bytes, 0, bytes.Length));
     OnReceived(udpAgs);
     mpMessageReceived = true;
 }
示例#2
0
        void ReceivedEventHandler(object sender, UdpEventArgs e)
        {
            Console.WriteLine(e.message);
            string[] status = new string[10];
            status = e.message.Split(',');
            if (status.Length == 6)
            {
                //Time
                mTime = Int64.Parse(status[0]);

                //Front Left
                mFLrpm = Int32.Parse(status[1]);

                //Front Right
                mFRrpm = Int32.Parse(status[2]);

                //Rear Left
                mRLrpm = Int32.Parse(status[3]);

                //Rear Right
                mRRrpm = Int32.Parse(status[4]);

                //Current
                try
                {
                    mCurrent = Double.Parse(status[5]);
                }
                catch (Exception ex)
                {
                    mCurrent = 0;
                }
            }
        }
 protected virtual void OnReceived(UdpEventArgs e)
 {
     if (Received != null)
         Received(this, e);
 }