예제 #1
0
        private void timCheckFrame_Tick(object sender, EventArgs e)
        {
            if (com.CheckFrame())
            {
                switch (com.rxFrame.fnCode)
                {
                case FunctionCode.FC_DEV_STA:
                    //txtMotorCurVel.Text = (BitConverter.ToSingle(com.rxFrame.data, 0)).ToString("f3");
                    textBox1.Text = com.rxFrame.data[0] == 1 ? "在" : "不在";
                    textBox2.Text = com.rxFrame.data[1] == 1 ? "在" : "不在";
                    textBox3.Text = com.rxFrame.data[2] == 1 ? "在" : "不在";
                    break;

                case FunctionCode.FC_IMU_RAW:
                    textBox4.Text  = (BitConverter.ToSingle(com.rxFrame.data, 0)).ToString();
                    textBox5.Text  = (BitConverter.ToSingle(com.rxFrame.data, 4)).ToString();
                    textBox6.Text  = (BitConverter.ToSingle(com.rxFrame.data, 8)).ToString();
                    textBox7.Text  = (BitConverter.ToSingle(com.rxFrame.data, 12)).ToString();
                    textBox8.Text  = (BitConverter.ToSingle(com.rxFrame.data, 16)).ToString();
                    textBox9.Text  = (BitConverter.ToSingle(com.rxFrame.data, 20)).ToString();
                    textBox10.Text = (BitConverter.ToSingle(com.rxFrame.data, 24)).ToString();
                    textBox11.Text = (BitConverter.ToSingle(com.rxFrame.data, 28)).ToString();
                    textBox12.Text = (BitConverter.ToSingle(com.rxFrame.data, 32)).ToString();
                    break;

                case FunctionCode.FC_GPS_RAW:
                    textBox13.Text = com.rxFrame.data[0].ToString();
                    textBox14.Text = (BitConverter.ToDouble(com.rxFrame.data, 1)).ToString();
                    textBox15.Text = (BitConverter.ToDouble(com.rxFrame.data, 9)).ToString();
                    textBox16.Text = (BitConverter.ToDouble(com.rxFrame.data, 17)).ToString();
                    textBox17.Text = (BitConverter.ToDouble(com.rxFrame.data, 25)).ToString();
                    textBox18.Text = (BitConverter.ToDouble(com.rxFrame.data, 33)).ToString();
                    break;

                case FunctionCode.FC_RC_RAW:
                    textBox19.Text = (BitConverter.ToSingle(com.rxFrame.data, 0)).ToString();
                    textBox20.Text = (BitConverter.ToSingle(com.rxFrame.data, 4)).ToString();
                    textBox21.Text = (BitConverter.ToSingle(com.rxFrame.data, 8)).ToString();
                    textBox22.Text = (BitConverter.ToSingle(com.rxFrame.data, 12)).ToString();
                    break;

                case FunctionCode.FC_CIRCLE_CONTROL:
                    textBox23.Text = (BitConverter.ToSingle(com.rxFrame.data, 0) * 57.296).ToString();
                    textBox24.Text = (BitConverter.ToSingle(com.rxFrame.data, 4) * 57.296).ToString();
                    textBox25.Text = (BitConverter.ToSingle(com.rxFrame.data, 8) * 57.296).ToString();
                    textBox26.Text = (BitConverter.ToSingle(com.rxFrame.data, 12)).ToString();
                    textBox27.Text = (BitConverter.ToSingle(com.rxFrame.data, 16)).ToString();
                    textBox28.Text = (BitConverter.ToSingle(com.rxFrame.data, 20)).ToString();
                    textBox29.Text = (BitConverter.ToSingle(com.rxFrame.data, 24)).ToString();
                    textBox30.Text = (BitConverter.ToSingle(com.rxFrame.data, 28)).ToString();
                    textBox31.Text = (BitConverter.ToSingle(com.rxFrame.data, 32)).ToString();
                    textBox32.Text = (BitConverter.ToSingle(com.rxFrame.data, 36)).ToString();
                    textBox33.Text = com.rxFrame.data[40].ToString();
                    break;

                case FunctionCode.FC_IAP_UPDATE:
                    com.txFrame.fnCode = FunctionCode.FC_IAP_UPDATE;
                    if (1 == com.rxFrame.data[0])
                    {
                        if (filelength != 0)
                        {
                            byte length = (byte)((filelength >= 50 - 1) ? 50 - 2 : filelength);
                            com.txFrame.data[0] = length;
                            com.txFrame.data[1] = packetnum++;
                            for (int i = 0; i < length; i++)
                            {
                                com.txFrame.data[i + 2] = binContent[sendindex++];
                            }
                            filelength           -= length;
                            label5.Text           = "剩余" + filelength + "字节!";
                            com.txFrame.isUpdated = true;
                            com.SendFrame();
                            prechecksum = com.txFrame.checkSum;
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        if (filelength != 0)
                        {
                            com.txFrame.fnCode    = FunctionCode.FC_IAP_UPDATE;
                            com.txFrame.isUpdated = true;
                            com.SendFrame();
                        }
                    }
                    break;
                }
            }
        }