示例#1
0
        private void ParseResponse(string srvResponse)
        {
            //                          2000-01-01 04:29:37.010437      0       0       0       0       0       0       0       0.00    0.75    55.00   0.34    0.75    0.50    0.51
            //datetime   QualityCMD  Propeller_A_MODE  Propeller_A_SPEED Propeller_B_MODE  Propeller_B_SPEED Propeller_C_MODE  Propeller_C_SPEED Voltage     depth     CPUTEMP     WaterTemp    Sensor1    Sensor2     Sensor3

            if (srvResponse == null)
            {
                return;
            }

            string[] parts = srvResponse.Split('\t');

            ResponseData data = new ResponseData();

            if (parts.Length > 0)
            {
                if (!DateTime.TryParse(parts[0], out data.MessageTime))
                {
                    Debug.WriteLine("Unable to parse date/time from rover");
                }
            }
            if (parts.Length > 1)
            {
                if (!int.TryParse(parts[1], out data.QualityCmd))
                {
                }
            }
            if (parts.Length > 2)
            {
                if (!int.TryParse(parts[2], out data.LeftThrusterMode))
                {
                }
            }
            if (parts.Length > 3)
            {
                if (!int.TryParse(parts[3], out data.LeftThrusterPower))
                {
                }
            }
            if (parts.Length > 4)
            {
                if (!int.TryParse(parts[4], out data.RightThrusterMode))
                {
                }
            }
            if (parts.Length > 5)
            {
                if (!int.TryParse(parts[5], out data.RightThrusterPower))
                {
                }
            }
            if (parts.Length > 6)
            {
                if (!int.TryParse(parts[6], out data.VertThrusterMode))
                {
                }
            }
            if (parts.Length > 7)
            {
                if (!int.TryParse(parts[7], out data.VertThrusterPower))
                {
                }
            }
            if (parts.Length > 8)
            {
                if (!double.TryParse(parts[8], out data.Voltage))
                {
                }
            }
            if (parts.Length > 9)
            {
                if (!double.TryParse(parts[9], out data.Depth))
                {
                }
            }
            if (parts.Length > 10)
            {
                if (!double.TryParse(parts[10], out data.CpuTemp))
                {
                }
            }
            if (parts.Length > 11)
            {
                if (!double.TryParse(parts[11], out data.WaterTemp))
                {
                }
            }
            if (parts.Length > 12)
            {
                if (!double.TryParse(parts[12], out data.Sensor1))
                {
                }
            }
            if (parts.Length > 13)
            {
                if (!double.TryParse(parts[13], out data.Sensor2))
                {
                }
            }
            if (parts.Length > 14)
            {
                if (!double.TryParse(parts[14], out data.Sensor3))
                {
                }
            }

            RoverPacketReceived(new RoverPacketReceivedEventArgs(true, data));

            UpdateFrameRate();
        }
示例#2
0
 public RoverPacketReceivedEventArgs(bool isValid, ResponseData data)
 {
     this.IsValid      = isValid;
     this.ResponseData = data;
 }