private void ToggleSwitch_Click(object sender, RoutedEventArgs e)
        {
            ToggleSwitch toggleSwitch = sender as ToggleSwitch;

            if ((bool)toggleSwitch.IsChecked)
            {
                ChartHood.HideZeroLevel();
                ChartInsAir.HideZeroLevel();
                ChartInsWall.HideZeroLevel();
                ChartAttAir.HideZeroLevel();
                ChartTemperature1.HideZeroLevel();
                ChartTemperature2.HideZeroLevel();
                ChartAttWalls1.HideZeroLevel();
                ChartAttWalls2.HideZeroLevel();
                ChartAttWalls3.HideZeroLevel();
                ChartAttWalls4.HideZeroLevel();
                ChartAttWalls5.HideZeroLevel();
                ChartAttWalls6.HideZeroLevel();
                ChartInsPresure.HideZeroLevel();
                ChartAttiPresure.HideZeroLevel();
                ChartPresure.HideZeroLevel();
                ChartLevel1Presure.HideZeroLevel();
                ChartLevel2Transmitter.HideZeroLevel();
                ChartGestureControlHigh.HideZeroLevel();
                ChartGestureControlLow.HideZeroLevel();
                ChartShake1.HideZeroLevel();
                ChartShake2.HideZeroLevel();
                ChartShake3.HideZeroLevel();
                ChartShake4.HideZeroLevel();
                ChartShake5.HideZeroLevel();
                ChartShake6.HideZeroLevel();
                ChartShake7.HideZeroLevel();
                ChartShake8.HideZeroLevel();
                ChartShake9.HideZeroLevel();
                ChartShake10.HideZeroLevel();
                ChartShake11.HideZeroLevel();
                ChartShake12.HideZeroLevel();
                ChartLash1X.HideZeroLevel();
                ChartLash1Y.HideZeroLevel();
                ChartLash1Z.HideZeroLevel();
                ChartLash2X.HideZeroLevel();
                ChartLash2Y.HideZeroLevel();
                ChartLash2Z.HideZeroLevel();
                ChartLash1_1.HideZeroLevel();
                ChartLash1_2.HideZeroLevel();
                ChartLash1_3.HideZeroLevel();
                ChartLash2.HideZeroLevel();
                ChartNoise1.HideZeroLevel();
                ChartNoise2.HideZeroLevel();
                ChartNoise.HideZeroLevel();
            }
            else
            {
                ChartHood.SetFixedRange();
                ChartInsAir.SetFixedRange();
                ChartInsWall.SetFixedRange();
                ChartAttAir.SetFixedRange();
                ChartTemperature1.SetFixedRange();
                ChartTemperature2.SetFixedRange();
                ChartAttWalls1.SetFixedRange();
                ChartAttWalls2.SetFixedRange();
                ChartAttWalls3.SetFixedRange();
                ChartAttWalls4.SetFixedRange();
                ChartAttWalls5.SetFixedRange();
                ChartAttWalls6.SetFixedRange();
                ChartInsPresure.SetFixedRange();
                ChartAttiPresure.SetFixedRange();
                ChartPresure.SetFixedRange();
                ChartLevel1Presure.SetFixedRange();
                ChartLevel2Transmitter.SetFixedRange();
                ChartGestureControlHigh.SetFixedRange();
                ChartGestureControlLow.SetFixedRange();
                ChartShake1.SetFixedRange();
                ChartShake2.SetFixedRange();
                ChartShake3.SetFixedRange();
                ChartShake4.SetFixedRange();
                ChartShake5.SetFixedRange();
                ChartShake6.SetFixedRange();
                ChartShake7.SetFixedRange();
                ChartShake8.SetFixedRange();
                ChartShake9.SetFixedRange();
                ChartShake10.SetFixedRange();
                ChartShake11.SetFixedRange();
                ChartShake12.SetFixedRange();
                ChartLash1X.SetFixedRange();
                ChartLash1Y.SetFixedRange();
                ChartLash1Z.SetFixedRange();
                ChartLash2X.SetFixedRange();
                ChartLash2Y.SetFixedRange();
                ChartLash2Z.SetFixedRange();
                ChartLash1_1.SetFixedRange();
                ChartLash1_2.SetFixedRange();
                ChartLash1_3.SetFixedRange();
                ChartLash2.SetFixedRange();
                ChartNoise1.SetFixedRange();
                ChartNoise2.SetFixedRange();
                ChartNoise.SetFixedRange();
            }
        }
        private void InitChartTitle()
        {
            ChartHood.SetTitle("头罩内温度传感器T1");
            ChartHood.SetYRange(-1, 6);
            ChartInsAir.SetTitle("仪器舱内接收机附近空腔温度传感器T2");
            ChartInsAir.SetYRange(-1, 6);
            ChartInsWall.SetTitle("仪器舱内筋条壁面温度传感器T3");
            ChartInsWall.SetYRange(-1, 6);
            ChartAttAir.SetTitle("姿控仓内空腔温度T4");
            ChartAttAir.SetYRange(-1, 6);
            ChartTemperature1.SetTitle("级间断内窗口加强筋上温度传感器T5");
            ChartTemperature1.SetYRange(-1, 6);
            ChartTemperature2.SetTitle("尾段内温度传感器T6");
            ChartTemperature2.SetYRange(-1, 6);
            ChartAttWalls1.SetTitle("Ⅱ象限气瓶表面温度TZ1");
            ChartAttWalls1.SetYRange(-1, 6);
            ChartAttWalls2.SetTitle("Ⅳ象限气瓶表面温度TZ2");
            ChartAttWalls2.SetYRange(-1, 6);
            ChartAttWalls3.SetTitle("Ⅰ象限贮箱表面温度TZ3");
            ChartAttWalls3.SetYRange(-1, 6);
            ChartAttWalls4.SetTitle("Ⅰ象限贮箱表面温度TZ4");
            ChartAttWalls4.SetYRange(-1, 6);
            ChartAttWalls5.SetTitle("Ⅲ象限贮箱表面温度TZ5");
            ChartAttWalls5.SetYRange(-1, 6);
            ChartAttWalls6.SetTitle("Ⅲ象限贮箱表面温度TZ6");
            ChartAttWalls6.SetYRange(-1, 6);

            ChartInsPresure.SetTitle("仪器内仓压力传感器P1");
            ChartInsPresure.SetYRange(-1, 6);
            ChartAttiPresure.SetTitle("姿控仓内空腔压力传感器P2");
            ChartAttiPresure.SetYRange(-1, 6);
            ChartPresure.SetTitle("尾段内压力传感器P3");
            ChartPresure.SetYRange(-1, 6);
            ChartLevel1Presure.SetTitle("级间段一级发动机压力传感器");
            ChartLevel1Presure.SetYRange(-1, 6);
            ChartLevel2Transmitter.SetTitle("仪器舱内二级发动机压力传感器PD2");
            ChartLevel2Transmitter.SetYRange(-1, 6);
            ChartGestureControlHigh.SetTitle("姿控高压传感器PZ1");
            ChartGestureControlHigh.SetYRange(-1, 6);
            ChartGestureControlLow.SetTitle("姿控低压传感器PZ2");
            ChartGestureControlLow.SetYRange(-1, 6);

            ChartShake1.SetTitle("姿控仓内安装板前版面振动传感器V1-X");
            ChartShake1.SetYRange(-1, 6);
            ChartShake2.SetTitle("姿控仓内安装板前版面振动传感器V1-Y");
            ChartShake2.SetYRange(-1, 6);
            ChartShake3.SetTitle("姿控仓内安装板前版面振动传感器V1-Z");
            ChartShake3.SetYRange(-1, 6);
            ChartShake4.SetTitle("仪器舱内十字梁上振动传感器V2-X");
            ChartShake4.SetYRange(-1, 6);
            ChartShake5.SetTitle("仪器舱内十字梁上振动传感器V2-Y");
            ChartShake5.SetYRange(-1, 6);
            ChartShake6.SetTitle("仪器舱内十字梁上振动传感器V2-Z");
            ChartShake6.SetYRange(-1, 6);
            ChartShake7.SetTitle("仪器舱内IMU上振动传感器V3-X");
            ChartShake7.SetYRange(-1, 6);
            ChartShake8.SetTitle("仪器舱内IMU上振动传感器V3-Y");
            ChartShake8.SetYRange(-1, 6);
            ChartShake9.SetTitle("仪器舱内IMU上振动传感器V3-Z");
            ChartShake9.SetYRange(-1, 6);
            ChartShake10.SetTitle("仪器舱内后框上振动传感器V4-X");
            ChartShake10.SetYRange(-1, 6);
            ChartShake11.SetTitle("仪器舱内后框上振动传感器V4-Y");
            ChartShake11.SetYRange(-1, 6);
            ChartShake12.SetTitle("仪器舱内后框上振动传感器V4-Z");
            ChartShake12.SetYRange(-1, 6);
            ChartLash1X.SetTitle("级间段内后法兰振动传感器V5-X");
            ChartLash1X.SetYRange(-1, 6);
            ChartLash1Y.SetTitle("级间段内后法兰振动传感器V5-Y");
            ChartLash1Y.SetYRange(-1, 6);
            ChartLash1Z.SetTitle("级间段内后法兰振动传感器V5-Z");
            ChartLash1Z.SetYRange(-1, 6);
            ChartLash2X.SetTitle("尾段内振动传感器V6-X");
            ChartLash2X.SetYRange(-1, 6);
            ChartLash2Y.SetTitle("尾段内振动传感器V6-Y");
            ChartLash2Y.SetYRange(-1, 6);
            ChartLash2Z.SetTitle("尾段内振动传感器V6-Z");
            ChartLash2Z.SetYRange(-1, 6);

            ChartLash1_1.SetTitle("仪器舱内前端框冲击传感器SH1-X");
            ChartLash1_1.SetYRange(-1, 6);
            ChartLash1_2.SetTitle("仪器舱内前端框冲击传感器SH1-Y");
            ChartLash1_2.SetYRange(-1, 6);
            ChartLash1_3.SetTitle("姿控仓后端框x向冲击传感器SH2(轴向)");
            ChartLash1_3.SetYRange(-1, 6);
            ChartLash2.SetTitle("姿控仓后端框y向冲击传感器SH3(Ⅱ-Ⅳ)");
            ChartLash2.SetYRange(-1, 6);
            ChartNoise1.SetTitle("仪器舱内噪声传感器N1(dB)");
            ChartNoise1.SetYRange(-1, 6);
            ChartNoise2.SetTitle("姿控仓内噪声传感器N2(dB)");
            ChartNoise2.SetYRange(-1, 6);
            ChartNoise.SetTitle("尾段内噪声传感器N3(dB)");
            ChartNoise.SetYRange(-1, 6);

            ChartNavLat.SetTitle("纬度(°)");
            ChartNavLon.SetTitle("经度(°)");
            ChartNavHeight.SetTitle("高度(m)");
            ChartNavSpeedNorth.SetTitle("北向速度(m/s)");
            ChartNavSpeedSky.SetTitle("天向速度(m/s)");
            ChartNavSpeedEast.SetTitle("东向速度(m/s)");
            ChartNavPitchAngle.SetTitle("俯仰角(°)");
            ChartNavCrabAngle.SetTitle("偏航角(°)");
            ChartNavRollAngle.SetTitle("滚转角(°)");

            ChartAccX.SetTitle("加速度X(m/s2)");
            ChartAccY.SetTitle("加速度Y(m/s2)");
            ChartAccZ.SetTitle("加速度Z(m/s2)");
            ChartAngelX.SetTitle("角速度X(°/s)");
            ChartAngelY.SetTitle("角速度Y(°/s)");
            ChartAngelZ.SetTitle("角速度Z(°/s)");

            ChartServoVol28.SetTitle("28V供电电压(V)");
            ChartServoVol160.SetTitle("160V供电电压(V)");
            ChartServo1Iq.SetTitle("电机1Iq电流(A)");
            ChartServo2Iq.SetTitle("电机2Iq电流(A)");
            ChartServo3Iq.SetTitle("电机3Iq电流(A)");
            ChartServo4Iq.SetTitle("电机4Iq电流(A)");
        }
        private void DrawSlowPackets(List <SlowPacket> packets)
        {
            foreach (SlowPacket packet in packets)
            {
                for (int i = 0; i < 2; ++i)
                {
                    ChartHood.WriteData(packet.temperatureSensor.hood[i] * ratios.slowTemp + ratios.slowTempFix);
                    ChartInsAir.WriteData(packet.temperatureSensor.insAir[i] * ratios.slowTemp + ratios.slowTempFix);
                    ChartInsWall.WriteData(packet.temperatureSensor.insWall[i] * ratios.slowTemp + ratios.slowTempFix);
                    ChartAttAir.WriteData(packet.temperatureSensor.attAir[i] * ratios.slowTemp + ratios.slowTempFix);
                }
                ChartAttWalls1.WriteData(packet.temperatureSensor.attWalls[0] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls1.WriteData(packet.temperatureSensor.attWalls[1] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls2.WriteData(packet.temperatureSensor.attWalls[2] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls2.WriteData(packet.temperatureSensor.attWalls[3] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls3.WriteData(packet.temperatureSensor.attWalls[4] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls3.WriteData(packet.temperatureSensor.attWalls[5] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls4.WriteData(packet.temperatureSensor.attWalls[6] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls4.WriteData(packet.temperatureSensor.attWalls[7] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls5.WriteData(packet.temperatureSensor.attWalls[8] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls5.WriteData(packet.temperatureSensor.attWalls[9] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls6.WriteData(packet.temperatureSensor.attWalls[10] * ratios.slowTemp + ratios.slowTempFix);
                ChartAttWalls6.WriteData(packet.temperatureSensor.attWalls[11] * ratios.slowTemp + ratios.slowTempFix);
                for (int i = 0; i < 2; ++i)
                {
                    ChartInsPresure.WriteData(packet.pressureSensor.instrument[i] * ratios.slowPress + ratios.slowPressFix);
                    ChartAttiPresure.WriteData(packet.pressureSensor.attitudeControl[i] * ratios.slowPress + ratios.slowPressFix);
                }

                for (int i = 0; i < packet.level2Transmitter.Length; ++i)
                {
                    ChartLevel2Transmitter.WriteData(packet.level2Transmitter[i] * ratios.slowPress + ratios.slowPressFix);
                }

                for (int i = 0; i < packet.gestureControlHigh.Length; ++i)
                {
                    ChartGestureControlHigh.WriteData(packet.gestureControlHigh[i] * ratios.slowPress + ratios.slowPressFix);
                }

                for (int i = 0; i < packet.gestureControlLow.Length; ++i)
                {
                    ChartGestureControlLow.WriteData(packet.gestureControlLow[i] * ratios.slowPress + ratios.slowPressFix);
                }
            }

            ChartHood.EndWrite();
            ChartInsAir.EndWrite();
            ChartInsWall.EndWrite();
            ChartAttAir.EndWrite();
            ChartAttWalls1.EndWrite();
            ChartAttWalls2.EndWrite();
            ChartAttWalls3.EndWrite();
            ChartAttWalls4.EndWrite();
            ChartAttWalls5.EndWrite();
            ChartAttWalls6.EndWrite();
            ChartInsPresure.EndWrite();
            ChartAttiPresure.EndWrite();
            ChartLevel2Transmitter.EndWrite();
            ChartGestureControlHigh.EndWrite();
            ChartGestureControlLow.EndWrite();
        }