Procházet zdrojové kódy

增加生产模式。

CN\zhouxiong9 před 2 roky
rodič
revize
87af2cc4db
18 změnil soubory, kde provedl 2040 přidání a 34 odebrání
  1. binární
      .vs/Welling_Motor_Debug_Tool/FileContentIndex/53188313-0abe-436a-8d4c-1f3027c774fd.vsidx
  2. binární
      .vs/Welling_Motor_Debug_Tool/v17/.suo
  3. 989 28
      Welling_Motor_Debug_Tool/Form1.Designer.cs
  4. 1037 6
      Welling_Motor_Debug_Tool/Form1.cs
  5. 10 0
      Welling_Motor_Debug_Tool/Properties/Resources.Designer.cs
  6. 3 0
      Welling_Motor_Debug_Tool/Properties/Resources.resx
  7. binární
      Welling_Motor_Debug_Tool/Resources/about.png
  8. 1 0
      Welling_Motor_Debug_Tool/Welling_Motor_Debug_Tool.csproj
  9. binární
      Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.exe
  10. binární
      Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.pdb
  11. binární
      Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool202212102205.exe
  12. binární
      Welling_Motor_Debug_Tool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
  13. binární
      Welling_Motor_Debug_Tool/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll
  14. binární
      Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.Properties.Resources.resources
  15. binární
      Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.AssemblyReference.cache
  16. binární
      Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.GenerateResource.cache
  17. binární
      Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.exe
  18. binární
      Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.pdb

binární
.vs/Welling_Motor_Debug_Tool/FileContentIndex/53188313-0abe-436a-8d4c-1f3027c774fd.vsidx


binární
.vs/Welling_Motor_Debug_Tool/v17/.suo


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 989 - 28
Welling_Motor_Debug_Tool/Form1.Designer.cs


+ 1037 - 6
Welling_Motor_Debug_Tool/Form1.cs

@@ -24,6 +24,8 @@ namespace Welling_Motor_Debug_Tool
         //BMS运行信息超时计数
         bool BMS_RunInfo_Refresh = false;
         ushort BMS_RunInfo_Refresh_Cnt = 0;
+        //生产模式关机指令反馈装
+        bool PowerOffAckStatus = false;
         #endregion
 
         public Form1()
@@ -31,6 +33,17 @@ namespace Welling_Motor_Debug_Tool
             InitializeComponent();
         }
 
+        #region 非独占性延时函数
+        public static void Delay_ms(int milliSecond)
+        {
+            int start = Environment.TickCount;
+            while (Math.Abs(Environment.TickCount - start) < milliSecond)//毫秒
+            {
+                Application.DoEvents();
+            }
+        }
+        #endregion
+
         private void Form1_Load(object sender, System.EventArgs e)
         {
             //页面初始化
@@ -200,13 +213,13 @@ namespace Welling_Motor_Debug_Tool
                                     Class_MotorSpeed.Data = DataTemp;
                                     //电功率
                                     DataTemp = (ushort)(Data[5] * 256 + Data[4]);
-                                    textBox_RunInfo_Power.Text = Convert.ToString(DataTemp * 2) + " W";
+                                    textBox_RunInfo_Power.Text = Convert.ToString(DataTemp) + " W";
                                     //母线电压
                                     DataTemp = (ushort)(Data[7] * 256 + Data[6]);
-                                    textBox_RunInfo_Vol.Text = Convert.ToString(DataTemp) + " mV";
+                                    textBox_RunInfo_Vol.Text = (DataTemp / 1000f).ToString("0.0") + " V";
                                     //母线电流
                                     DataTemp = (ushort)(Data[9] * 256 + Data[8]);
-                                    textBox_RunInfo_Current.Text = Convert.ToString(DataTemp) + " mA";
+                                    textBox_RunInfo_Current.Text = (DataTemp / 1000f).ToString("0.0") + " A";
                                     Class_CurrentData.String = textBox_RunInfo_Current.Text;
                                     Class_CurrentData.Data = DataTemp;
                                     //踏频
@@ -285,13 +298,13 @@ namespace Welling_Motor_Debug_Tool
                                     textBox_RunInfo_AvgPower.Text = Convert.ToString(DataTemp * 10) + " mAh/km";
                                     //PCB温度
                                     DataTemp = (ushort)(Data[21]);
-                                    textBox_RunInfo_T_PCB.Text = Convert.ToString((int)(DataTemp - 40));
+                                    textBox_RunInfo_T_PCB.Text = Convert.ToString((int)(DataTemp - 40))+" ℃";
                                     //绕组温度
                                     DataTemp = (ushort)(Data[22]);
-                                    textBox_RunInfo_T_Coil.Text = Convert.ToString((int)(DataTemp - 40));
+                                    textBox_RunInfo_T_Coil.Text = Convert.ToString((int)(DataTemp - 40)) + " ℃";
                                     //MCU温度
                                     DataTemp = (ushort)(Data[23]);
-                                    textBox_RunInfo_T_MCU.Text = Convert.ToString((int)(DataTemp - 40));
+                                    textBox_RunInfo_T_MCU.Text = Convert.ToString((int)(DataTemp - 40)) + " ℃";
                                     //单次里程
                                     DataTemp = (ushort)(Data[25] * 256 + Data[24]);
                                     textBox_RunInfo_Trip.Text = ((float)DataTemp / 10f).ToString("0.0") + " km";
@@ -331,6 +344,8 @@ namespace Welling_Motor_Debug_Tool
                                     timer_1s.Enabled = false;
                                     MessageBox.Show("OK", "反馈指令", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                     timer_1s.Enabled = true;
+                                    //关机反馈
+                                    PowerOffAckStatus = true;
                                 }));
                             }
                             break;
@@ -363,6 +378,27 @@ namespace Welling_Motor_Debug_Tool
                                         richTextBox_BikeParam.AppendText(myParams.BikeParma[i] + "=" + Convert.ToString(Data[2 * i + 1] * 256 + Data[2 * i]) + ", ");
                                     }
                                     richTextBox_BikeParam.Text = richTextBox_BikeParam.Text.Substring(0, richTextBox_BikeParam.Text.Length - 2);
+                                    //更新生产模式中整车参数
+                                    textBox_FacModeWheelSize.Text = (Data[1] * 256 + Data[0]).ToString();//周长
+                                    textBox_FacModeSpeedLimit.Text= (Data[5] * 256 + Data[4]).ToString();//限速
+                                    DataTemp = (int)(Data[13] * 256 + Data[12]);//助力方案1
+                                    if (DataTemp == 0) comboBox_FacModeAssist1.SelectedIndex = 0;
+                                    else if (DataTemp == 341) comboBox_FacModeAssist1.SelectedIndex = 1;
+                                    else if (DataTemp == 682) comboBox_FacModeAssist1.SelectedIndex = 2;
+                                    else comboBox_FacModeAssist1.SelectedIndex = 3;
+                                    DataTemp = (int)(Data[15] * 256 + Data[14]);//助力方案2
+                                    if (DataTemp == 0) comboBox_FacModeAssist2.SelectedIndex = 0;
+                                    else if (DataTemp == 341) comboBox_FacModeAssist2.SelectedIndex = 1;
+                                    else if (DataTemp == 682) comboBox_FacModeAssist2.SelectedIndex = 2;
+                                    else comboBox_FacModeAssist2.SelectedIndex = 3;
+                                    DataTemp = (int)(Data[17] * 256 + Data[16]);//灯压
+                                    if (DataTemp == 6) comboBox_FacModeLightVol.SelectedIndex = 0;
+                                    else if (DataTemp == 12) comboBox_FacModeLightVol.SelectedIndex = 1;
+                                    else comboBox_FacModeLightVol.SelectedIndex = 2;
+                                    DataTemp = (int)(Data[21] * 256 + Data[20]);//启动模式
+                                    if (DataTemp == 1) comboBox_FacModeStartMode.SelectedIndex = 0;
+                                    else if (DataTemp == 3) comboBox_FacModeStartMode.SelectedIndex = 2;
+                                    else comboBox_FacModeStartMode.SelectedIndex = 1;
                                 }));
                             }
                             break;
@@ -395,6 +431,12 @@ namespace Welling_Motor_Debug_Tool
                                         richTextBox_SensorParam.AppendText(myParams.SensorParam[i] + "=" + Convert.ToString(Data[2 * i + 1] * 256 + Data[2 * i]) + ", ");
                                     }
                                     richTextBox_SensorParam.Text = richTextBox_SensorParam.Text.Substring(0, richTextBox_SensorParam.Text.Length - 2);
+                                    //更新生产模式页面传感器零点和标定值
+                                    textBox_FacModeSensorADC0.Text = (Data[1] * 256 + Data[0]).ToString();
+                                    textBox_FacModeSensorADC1.Text = (Data[15] * 256 + Data[14]).ToString();
+                                    textBox_FacModeSensorADC2.Text = (Data[19] * 256 + Data[18]).ToString();
+                                    textBox_FacModeSensorADC3.Text = (Data[23] * 256 + Data[22]).ToString();
+                                    textBox_FacModeSensorADC4.Text = (Data[27] * 256 + Data[26]).ToString();
                                 }));
                             }
                             break;
@@ -425,6 +467,13 @@ namespace Welling_Motor_Debug_Tool
 
                                     }
                                     richTextBox_AssistParam.Text = richTextBox_AssistParam.Text.Substring(0, richTextBox_AssistParam.Text.Length - 2);
+                                    //更新生产模式中助力参数
+                                    textBox_FacModeStartGain.Text = (Data[1] * 256 + Data[0]).ToString();//零速增益
+                                    textBox_FacModeCircuitK.Text = (Data[45] * 256 + Data[44]).ToString();//电流阶梯
+                                    textBox_FacModeFltCounter.Text = (Data[49] * 256 + Data[48]).ToString();//滤波脉冲
+                                    textBox_FacModeSpeedLimitTh.Text = (Data[55] * 256 + Data[54]).ToString();//限速启动
+                                    textBox_FacModeSpeedLimitEnd.Text = (Data[57] * 256 + Data[56]).ToString();//限速停止
+                                    textBox_FacModeCadencePer.Text = (Data[59] * 256 + Data[58]).ToString();//踏频占比
                                 }));
                             }
                             break;
@@ -503,6 +552,7 @@ namespace Welling_Motor_Debug_Tool
                                     //电机型号
                                     textBox_Model.Text = "";
                                     textBox_OBC_ReadModel.Text = "";
+                                    textBox_FacModeName.Text = "";
                                     for (ushort i = 0; i < 16; i++)
                                     {
                                         if (Data[i] == 0x2E)
@@ -511,12 +561,14 @@ namespace Welling_Motor_Debug_Tool
                                         }
                                         textBox_Model.Text += ((char)Data[i]).ToString();
                                         textBox_OBC_ReadModel.Text += ((char)Data[i]).ToString();
+                                        textBox_FacModeName.Text += ((char)Data[i]).ToString(); ;
                                     }
                                     Class_Motor_Ver.Mode = textBox_Model.Text;
 
                                     //电机SN
                                     textBox_SN.Text = "";
                                     textBox_OBC_ReadSN.Text = "";
+                                    textBox_FacModeNum.Text = "";
                                     for (ushort i = 0; i < 16; i++)
                                     {
                                         if (Data[16 + i] == 0x2E)
@@ -525,12 +577,14 @@ namespace Welling_Motor_Debug_Tool
                                         }
                                         textBox_SN.Text += ((char)Data[16 + i]).ToString();
                                         textBox_OBC_ReadSN.Text += ((char)Data[16 + i]).ToString();
+                                        textBox_FacModeNum.Text += ((char)Data[16 + i]).ToString();
                                     }
                                     Class_Motor_Ver.SN = textBox_SN.Text;
 
                                     //电机HW
                                     textBox_HW.Text = "";
                                     textBox_OBC_ReadHW.Text = "";
+                                    textBox_FacModeHW.Text = "";
                                     for (ushort i = 0; i < 16; i++)
                                     {
                                         if (Data[32 + i] == 0x2E)
@@ -539,12 +593,14 @@ namespace Welling_Motor_Debug_Tool
                                         }
                                         textBox_HW.Text += ((char)Data[32 + i]).ToString();
                                         textBox_OBC_ReadHW.Text += ((char)Data[32 + i]).ToString();
+                                        textBox_FacModeHW.Text += ((char)Data[32 + i]).ToString();
                                     }
                                     Class_Motor_Ver.HW = textBox_HW.Text;
 
                                     //电机FW
                                     textBox_FW.Text = "";
                                     textBox_OBC_ReadFW.Text = "";
+                                    textBox_FacModeFW.Text = "";
                                     for (ushort i = 0; i < 16; i++)
                                     {
                                         if (Data[48 + i] == 0x2E)
@@ -557,6 +613,7 @@ namespace Welling_Motor_Debug_Tool
                                         }
                                         textBox_FW.Text += ((char)Data[48 + i]).ToString();
                                         textBox_OBC_ReadFW.Text += ((char)Data[48 + i]).ToString();
+                                        textBox_FacModeFW.Text += ((char)Data[48 + i]).ToString();
                                     }
                                     Class_Motor_Ver.FW = textBox_FW.Text;
 
@@ -903,6 +960,10 @@ namespace Welling_Motor_Debug_Tool
         /// <param name="e"></param>
         private void numericUpDown_SpeedAdj_ValueChanged(object sender, EventArgs e)
         {
+            //生产模式转速设置值更新
+            trackBar_FacModeMotorSpeedAdj.Value = (int)numericUpDown_SpeedAdj.Value;
+            label_FacModeMotorSpeedSet.Text = trackBar_FacModeMotorSpeedAdj.Value.ToString() + "%";
+            //设置转速百分比
             var Data = new byte[1];
             Data[0] = (byte)numericUpDown_SpeedAdj.Value;
             mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2C01, Data);
@@ -1462,6 +1523,10 @@ namespace Welling_Motor_Debug_Tool
             textBox_OBC_ReadSN.Text = "---";
             textBox_OBC_ReadHW.Text = "---";
             textBox_OBC_ReadFW.Text = "---";
+            textBox_FacModeName.Text = "---";
+            textBox_FacModeNum.Text = "---";
+            textBox_FacModeHW.Text = "---";
+            textBox_FacModeFW.Text = "---";
             Class_Motor_Ver.Mode = "---";
             Class_Motor_Ver.SN = "---";
             Class_Motor_Ver.HW = "---";
@@ -1787,7 +1852,34 @@ namespace Welling_Motor_Debug_Tool
             timer_1s.Enabled = false;
             if (MessageBox.Show("系统将关机", "确认关机?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
+                timer_1s.Enabled = true;
                 mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2505, Code);
+                PowerOffAckStatus = false;
+                Delay_ms(250);
+                int TryCnt = 3;
+                while ((TryCnt--) >= 0)
+                {
+                    if (!PowerOffAckStatus)
+                    {
+                        mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2505, Code);
+                        PowerOffAckStatus = false;
+                        Delay_ms(250);
+                    }
+                    else break;
+                }
+
+                if (PowerOffAckStatus)
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("已关机!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
+                    timer_1s.Enabled = true;
+                }
+                else
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("关机失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                }
             }
             timer_1s.Enabled = true;
         }
@@ -2032,6 +2124,10 @@ namespace Welling_Motor_Debug_Tool
             textBox_OBC_ReadSN.Text = "---";
             textBox_OBC_ReadHW.Text = "---";
             textBox_OBC_ReadFW.Text = "---";
+            textBox_FacModeName.Text = "---";
+            textBox_FacModeNum.Text = "---";
+            textBox_FacModeHW.Text = "---";
+            textBox_FacModeFW.Text = "---";
             Class_Motor_Ver.Mode = "---";
             Class_Motor_Ver.SN = "---";
             Class_Motor_Ver.HW = "---";
@@ -2293,5 +2389,940 @@ namespace Welling_Motor_Debug_Tool
             comboBox_GearSt.SelectedIndex = comboBox_OBC_SetGearST.SelectedIndex;
             comboBox_LightSwitch.SelectedIndex = comboBox_OBC_LightSw.SelectedIndex;
         }
+
+        /// <summary>
+        /// 生产模式初始化
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeInit_Click(object sender, EventArgs e)
+        {
+            var Code = new byte[5];
+
+            Code[0] = (byte)'C';
+            Code[1] = (byte)'L';
+            Code[2] = (byte)'E';
+            Code[3] = (byte)'A';
+            Code[4] = (byte)'R';
+
+            timer_1s.Enabled = false;
+            if (MessageBox.Show("电机即将初始化!", "确认?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+            {
+                if (MessageBox.Show("请再次确认", "确认?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+                {
+                    timer_1s.Enabled = true;
+                    if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2605, Code)) return;
+                    PowerOffAckStatus = false;
+                    Delay_ms(250);
+                    int TryCnt = 3;
+                    while ((TryCnt--) >= 0)
+                    {
+                        if (!PowerOffAckStatus)
+                        {
+                            if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2505, Code)) return;
+                            PowerOffAckStatus = false;
+                            Delay_ms(250);
+                        }
+                        else break;
+                    }
+
+                    if (PowerOffAckStatus)
+                    {
+                        timer_1s.Enabled = false;
+                        MessageBox.Show("系统已关机,请保持无负载重新开机!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
+                        timer_1s.Enabled = true;
+                    }
+                    else
+                    {
+                        timer_1s.Enabled = false;
+                        MessageBox.Show("初始化失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                        timer_1s.Enabled = true;
+                    }
+                    timer_1s.Enabled = true;
+                }
+            }
+            timer_1s.Enabled = true;
+
+            //清除历史测试记录
+            textBox_FacModeSensorADC0.Text = "";
+            textBox_FacModeSensorADC1.Text = "";
+            textBox_FacModeSensorADC2.Text = "";
+            textBox_FacModeSensorADC3.Text = "";
+            textBox_FacModeSensorADC4.Text = "";
+            checkBox_FacModeCheckBikeSpeed.Checked = false;
+            checkBox_FacModeCheckCadence.Checked = false;
+            checkBox_FacModeCheckNTC.Checked = false;
+            checkBox_FacModeCheckVol.Checked = false;
+            LightSwitchStatus = false;
+            MotorRunStatus = false;
+            trackBar_FacModeMotorSpeedAdj.Value = 5;
+            textBox_FacModeWheelSize.Text = "";
+            textBox_FacModeSpeedLimit.Text = "";
+            comboBox_FacModeAssist1.SelectedIndex = -1;
+            comboBox_FacModeAssist2.SelectedIndex = -1;
+            comboBox_FacModeLightVol.SelectedIndex = -1;
+            comboBox_FacModeStartMode.SelectedIndex = -1;
+            textBox_FacModeStartGain.Text = "";
+            textBox_FacModeCircuitK.Text = "";
+            textBox_FacModeFltCounter.Text = "";
+            textBox_FacModeSpeedLimitTh.Text = "";
+            textBox_FacModeSpeedLimitEnd.Text = "";
+            textBox_FacModeCadencePer.Text = "";
+            textBox_FacModeName.Text = "";
+            textBox_FacModeNum.Text = "";
+            textBox_FacModeHW.Text = "";
+            textBox_FacModeFW.Text = "";
+
+        }
+
+        /// <summary>
+        /// 生产模式读取传感器参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeSensorRead_Click(object sender, EventArgs e)
+        {
+            richTextBox_SensorParam.Clear();
+            textBox_FacModeSensorADC0.Text = "";
+            textBox_FacModeSensorADC1.Text = "";
+            textBox_FacModeSensorADC2.Text = "";
+            textBox_FacModeSensorADC3.Text = "";
+            textBox_FacModeSensorADC4.Text = "";
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
+        }
+
+        /// <summary>
+        /// 生产模式传感器标定1
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void buttonFacModeSet1_Click(object sender, EventArgs e)
+        {
+            var ConfigParam = new byte[4];
+            for (int i = 0; i < 4; i++)
+                ConfigParam[i] = 0;
+            ushort uwDataTemp = 0;
+            try
+            {
+                uwDataTemp = 1;//负载序号
+                ConfigParam[0] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[1] = (byte)(uwDataTemp >> 8);
+                uwDataTemp = (ushort)(decimal.Parse(textBox_FacModeSensorCal1.Text) * 10); ;//负载值0.1Nm
+                ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[3] = (byte)(uwDataTemp >> 8);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
+                Delay_ms(200);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
+            }
+            catch (Exception)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+        /// <summary>
+        /// 生产模式传感器标定2
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void buttonFacModeSet2_Click(object sender, EventArgs e)
+        {
+            var ConfigParam = new byte[4];
+            for (int i = 0; i < 4; i++)
+                ConfigParam[i] = 0;
+            ushort uwDataTemp = 0;
+            try
+            {
+                uwDataTemp = 2;//负载序号
+                ConfigParam[0] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[1] = (byte)(uwDataTemp >> 8);
+                uwDataTemp = (ushort)(decimal.Parse(textBox_FacModeSensorCal2.Text) * 10); ;//负载值0.1Nm
+                ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[3] = (byte)(uwDataTemp >> 8);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
+                Delay_ms(200);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
+            }
+            catch (Exception)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+
+        /// <summary>
+        /// 生产模式传感器标定3
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void buttonFacModeSet3_Click(object sender, EventArgs e)
+        {
+            var ConfigParam = new byte[4];
+            for (int i = 0; i < 4; i++)
+                ConfigParam[i] = 0;
+            ushort uwDataTemp = 0;
+            try
+            {
+                uwDataTemp = 3;//负载序号
+                ConfigParam[0] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[1] = (byte)(uwDataTemp >> 8);
+                uwDataTemp = (ushort)(decimal.Parse(textBox_FacModeSensorCal3.Text) * 10); ;//负载值0.1Nm
+                ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[3] = (byte)(uwDataTemp >> 8);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
+                Delay_ms(200);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
+            }
+            catch (Exception)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+        /// <summary>
+        /// 生产模式传感器标定3
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void buttonFacModeSet4_Click(object sender, EventArgs e)
+        {
+            var ConfigParam = new byte[4];
+            for (int i = 0; i < 4; i++)
+                ConfigParam[i] = 0;
+            ushort uwDataTemp = 0;
+            try
+            {
+                uwDataTemp = 4;//负载序号
+                ConfigParam[0] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[1] = (byte)(uwDataTemp >> 8);
+                uwDataTemp = (ushort)(decimal.Parse(textBox_FacModeSensorCal4.Text) * 10); ;//负载值0.1Nm
+                ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
+                ConfigParam[3] = (byte)(uwDataTemp >> 8);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
+                Delay_ms(200);
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
+            }
+            catch (Exception)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+
+        /// <summary>
+        /// 生产模式采集按钮
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeWorkMode_Click(object sender, EventArgs e)
+        {
+            var RunMode = new byte[1];
+            if (button_FacModeWorkMode.Text == "开始")
+            {
+                RunMode[0] = 0x01;
+                if (mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x1901, RunMode))
+                {
+                    button_FacModeWorkMode.Text = "停止";
+                    button_FacModeWorkMode.BackColor = Color.Yellow;
+                }
+            }
+            else if (button_FacModeWorkMode.Text == "停止")
+            {
+                RunMode[0] = 0x00;
+                if (mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x1901, RunMode))
+                {
+                    button_FacModeWorkMode.Text = "开始";
+                    button_FacModeWorkMode.BackColor = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
+                }
+            }
+        }
+
+        /// <summary>
+        /// 生产模式开关灯
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        bool LightSwitchStatus = false;
+        private void button_FacModeLightSW_Click(object sender, EventArgs e)
+        {
+            var CtrlCode = new byte[2];
+            CtrlCode[0] = 0x00;
+            if (LightSwitchStatus)
+            {
+                CtrlCode[1] = 0xF0;
+                button_FacModeLightSW.BackColor = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128)))));
+            }
+            else
+            { 
+                CtrlCode[1] = 0xF1;
+                button_FacModeLightSW.BackColor = Color.Yellow;
+            }             
+            if(mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2802, CtrlCode))
+            {
+                LightSwitchStatus = !LightSwitchStatus;
+                comboBox_LightSwitch.SelectedIndex = LightSwitchStatus ? 0 : 1;
+                comboBox_OBC_LightSw.SelectedIndex = LightSwitchStatus ? 0 : 1;
+            }
+        }
+
+        /// <summary>
+        /// 生产模式电机控制
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        bool MotorRunStatus = false;
+        private void button_FacModeMotorRun_Click(object sender, EventArgs e)
+        {
+            //DebugMtbDefaultInfo = "整体运行模式=5, 位置获取模式=1, 采样模式=2, 旋转方向=0, 定位电流=1000, 拖拽电压=18, 拖拽电流=1000, 拖拽频率=20, 加速斜率=500, 减速斜率=100, 转速环控制器带宽=15, 转速环控制器m=4, 电流环控制器带宽=300, 电流环控制器m=1, 磁链观测器带宽=10, 磁链观测器m=10, 锁相环带宽=150, 锁相环m=2, 惯量=500, PWM 最大占空比=900, PWM七段式切五段式阈值=700, 功率限幅值=6500, 功率Error=500, 功率限幅Kp=20, 功率限幅Ki=3000";
+            //DebugCityDefaultInfo = "整体运行模式=4, 位置获取模式=1, 采样模式=2, 旋转方向=1, 定位电流=1000, 拖拽电压=18, 拖拽电流=1000, 拖拽频率=20, 加速斜率=500, 减速斜率=100, 转速环控制器带宽=15, 转速环控制器m=4, 电流环控制器带宽=300, 电流环控制器m=1, 磁链观测器带宽=10, 磁链观测器m=10, 锁相环带宽=150, 锁相环m=2, 惯量=300, PWM 最大占空比=900, PWM七段式切五段式阈值=700, 功率限幅值=6500, 功率Error=500, 功率限幅Kp=20, 功率限幅Ki=3000";
+            string DebugDefaultInfo = "整体运行模式=4, 位置获取模式=1, 采样模式=2, 旋转方向=1, 定位电流=1000, 拖拽电压=18, 拖拽电流=1000, 拖拽频率=20, 加速斜率=500, 减速斜率=100, 转速环控制器带宽=15, 转速环控制器m=4, 电流环控制器带宽=300, 电流环控制器m=1, 磁链观测器带宽=10, 磁链观测器m=10, 锁相环带宽=150, 锁相环m=2, 惯量=300, PWM 最大占空比=900, PWM七段式切五段式阈值=700, 功率限幅值=6500, 功率Error=500, 功率限幅Kp=20, 功率限幅Ki=3000";
+            string[] strDataTemp = DebugDefaultInfo.Split(new string[] { ", " }, StringSplitOptions.None);
+            
+            var ConfigParam = new byte[60];
+            for (int i = 0; i < 60; i++)
+                ConfigParam[i] = 0;
+            ConfigParam[0] = 0x00;
+            ushort uwDataTemp = 0;
+
+            if (!MotorRunStatus) //停止状态
+            { 
+                //设置电机调试参数
+                strDataTemp[0] = "整体运行模式=3";
+                if (radioButton_FacModeDriverCity.Checked == true)
+                {
+                    strDataTemp[3] = "旋转方向=1";
+                    strDataTemp[10] = "转速环控制器带宽=3";
+                    strDataTemp[18] = "惯量=300";
+                }
+                else if (radioButton_FacModeDriverMtb.Checked == true)
+                {
+                    strDataTemp[3] = "旋转方向=0";
+                    strDataTemp[10] = "转速环控制器带宽=3";
+                    strDataTemp[18] = "惯量=500";
+                }
+                else
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("请选择电机类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                    return;
+                }
+
+                try
+                {
+                    for (int i = 0; i < strDataTemp.Length; i++)
+                    {
+                        uwDataTemp = Convert.ToUInt16(strDataTemp[i].Split('=')[1]);
+                        ConfigParam[2 * i + 2] = (byte)uwDataTemp;
+                        ConfigParam[2 * i + 3] = (byte)(uwDataTemp >> 8);
+                    }
+                    if(!mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x463C, ConfigParam))
+                        return;
+                }
+                catch (Exception)
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                }
+
+                //设置转速百分比50%
+                trackBar_FacModeMotorSpeedAdj.Value = 100;
+                MotorRunStatus = !MotorRunStatus;
+                button_FacModeMotorRun.BackColor = Color.Yellow;
+
+                //电机进入配置模式
+                var RunMode = new byte[1];
+                RunMode[0] = 0x01;
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x1901, RunMode);
+                button_FacModeWorkMode.Text = "停止";
+                button_FacModeWorkMode.BackColor = Color.Yellow;
+            }
+            else //运转状态
+            {
+                //设置电机调试参数
+                strDataTemp[0] = "整体运行模式=5";
+                if (radioButton_FacModeDriverCity.Checked == true)
+                {
+                    strDataTemp[3] = "旋转方向=1";
+                    strDataTemp[10] = "转速环控制器带宽=15";
+                    strDataTemp[18] = "惯量=300";
+                }
+                else if (radioButton_FacModeDriverMtb.Checked == true)
+                {
+                    strDataTemp[3] = "旋转方向=0";
+                    strDataTemp[10] = "转速环控制器带宽=15";
+                    strDataTemp[18] = "惯量=500";
+                }
+                else
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("请选择电机类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                    return;
+                }
+
+                try
+                {
+                    for (int i = 0; i < strDataTemp.Length; i++)
+                    {
+                        uwDataTemp = Convert.ToUInt16(strDataTemp[i].Split('=')[1]);
+                        ConfigParam[2 * i + 2] = (byte)uwDataTemp;
+                        ConfigParam[2 * i + 3] = (byte)(uwDataTemp >> 8);
+                    }
+                    if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x463C, ConfigParam))
+                        return;
+                }
+                catch (Exception)
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                }
+
+                //设置转速百分比50%
+                trackBar_FacModeMotorSpeedAdj.Value = 5;
+                MotorRunStatus = !MotorRunStatus;
+                button_FacModeMotorRun.BackColor = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
+
+                //电机退出配置模式
+                var RunMode = new byte[1];
+                RunMode[0] = 0x00;
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x1901, RunMode);
+                button_FacModeWorkMode.Text = "开始";
+                button_FacModeWorkMode.BackColor = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
+            }
+        }
+
+        /// <summary>
+        /// 生产模式转速调节
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void trackBar_FacModeMotorSpeedAdj_ValueChanged(object sender, EventArgs e)
+        {
+            //转速百分比更新
+            label_FacModeMotorSpeedSet.Text = trackBar_FacModeMotorSpeedAdj.Value.ToString() + "%";
+            numericUpDown_SpeedAdj.Value = trackBar_FacModeMotorSpeedAdj.Value;
+            //设置转速百分比
+            var Data = new byte[1];
+            Data[0] = (byte)trackBar_FacModeMotorSpeedAdj.Value;
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2C01, Data);
+        }
+
+        /// <summary>
+        /// 生产模式读取整车参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeBikeParaRead_Click(object sender, EventArgs e)
+        {
+            textBox_FacModeWheelSize.Text = "";
+            textBox_FacModeSpeedLimit.Text = "";
+            comboBox_FacModeAssist1.SelectedIndex = -1;
+            comboBox_FacModeAssist2.SelectedIndex = -1;
+            comboBox_FacModeLightVol.SelectedIndex = -1;
+            comboBox_FacModeStartMode.SelectedIndex = -1;
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x3C00, null);
+        }
+
+        /// <summary>
+        /// 生产模式写入整车参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeBikeParaSet_Click(object sender, EventArgs e)
+        {
+            string BikeDefaultInfo = "轮胎周长=219, 电控传动比=35, 助力最大限速=25, 推行模式限速=6, 前牙盘T数=38, 后牙盘T数=11, 助力方案1=341, 助力方案2=682, 前后灯电压=6, 轮胎周长微调=0, 启动模式=2, 自动关机时间=15";
+            var ConfigParam = new byte[28];
+            for (int i = 0; i < 28; i++)
+                ConfigParam[i] = 0;
+            ConfigParam[0] = (byte)(0x01);
+            ushort uwDataTemp = 0;
+            string[] strDataTemp = BikeDefaultInfo.Split(new string[] { ", " }, StringSplitOptions.None);
+            try
+            {
+                for (int i = 0; i < strDataTemp.Length; i++)
+                {
+                    uwDataTemp = Convert.ToUInt16(strDataTemp[i].Split('=')[1]);
+                    ConfigParam[2 * i + 2] = (byte)uwDataTemp;
+                    ConfigParam[2 * i + 3] = (byte)(uwDataTemp >> 8);
+                }
+                //周长
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeWheelSize.Text);
+                ConfigParam[2] = (byte)uwDataTemp;
+                ConfigParam[3] = (byte)(uwDataTemp >> 8);
+                //限速
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeSpeedLimit.Text);
+                ConfigParam[6] = (byte)uwDataTemp;
+                ConfigParam[7] = (byte)(uwDataTemp >> 8);
+                //助力方案1
+                if (comboBox_FacModeAssist1.SelectedIndex == 0) uwDataTemp = 0;
+                else if (comboBox_FacModeAssist1.SelectedIndex == 1) uwDataTemp = 341;
+                else if (comboBox_FacModeAssist1.SelectedIndex == 2) uwDataTemp = 682;
+                else
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                    return;
+                }
+                ConfigParam[14] = (byte)uwDataTemp;
+                ConfigParam[15] = (byte)(uwDataTemp >> 8);
+                //助力方案2
+                if(comboBox_FacModeAssist2.SelectedIndex == 0) uwDataTemp = 0;
+                else if (comboBox_FacModeAssist2.SelectedIndex == 1) uwDataTemp = 341;
+                else if (comboBox_FacModeAssist2.SelectedIndex == 2) uwDataTemp = 682;
+                else
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                    return;
+                }
+                ConfigParam[16] = (byte)uwDataTemp;
+                ConfigParam[17] = (byte)(uwDataTemp >> 8);
+                //灯压
+                if(comboBox_FacModeLightVol.SelectedIndex == 0) uwDataTemp = 6;
+                else if (comboBox_FacModeLightVol.SelectedIndex == 1) uwDataTemp = 12;
+                else
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    timer_1s.Enabled = true;
+                    return;
+                }
+                ConfigParam[18] = (byte)uwDataTemp;
+                ConfigParam[19] = (byte)(uwDataTemp >> 8);
+                //启动模式
+                if (comboBox_FacModeStartMode.SelectedIndex == 0) uwDataTemp = 1;
+                else if (comboBox_FacModeStartMode.SelectedIndex == 2) uwDataTemp = 3;
+                else uwDataTemp = 2;
+                ConfigParam[22] = (byte)uwDataTemp;
+                ConfigParam[23] = (byte)(uwDataTemp >> 8);
+
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x3D1C, ConfigParam);
+            }
+            catch (Exception)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+
+        /// <summary>
+        /// 生产模式读取助力参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeAssistParaRead_Click(object sender, EventArgs e)
+        {
+            var ConfigParam = new byte[4];
+            textBox_FacModeStartGain.Text = "";
+            textBox_FacModeCircuitK.Text = "";
+            textBox_FacModeFltCounter.Text = "";
+            textBox_FacModeSpeedLimitTh.Text ="";
+            textBox_FacModeSpeedLimitEnd.Text = "";
+            textBox_FacModeCadencePer.Text = "";
+            ConfigParam[0] = (byte)(1 & 0xFF);
+            ConfigParam[1] = (byte)(1 >> 8);
+            ConfigParam[2] = (byte)(1 & 0xFF);
+            ConfigParam[3] = (byte)(1 >> 8);
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4304, ConfigParam);
+        }
+
+        /// <summary>
+        /// 生产模式写入助力参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeAssistParaSet_Click(object sender, EventArgs e)
+        {
+            string AssistDefaultInfo = "零速启动增益=4096, 巡航启动增益=4096, 助力转矩曲线编号=1, 助力踏频曲线编号=1, 转矩曲线.a=0, 转矩曲线.b=0, 转矩曲线.c=2048, 转矩曲线.d=137, 踏频曲线.a=0, 踏频曲线.b=0, 踏频曲线.c=35000, 踏频曲线.d=0, 助力启动阈值=80, 助力停止阈值=40, 启动时电流增长阶梯=10, 启动对应踏频脉冲数=32, 转矩滤波对应踏频脉冲数=45, 待速转速=0, 待速最大电流=500, 车速限幅启动阈值=25, 车速限幅停止阈值=27, 踏频占比=1229";
+            var ConfigParam = new byte[80];
+            for (int i = 0; i < 80; i++)
+                ConfigParam[i] = 0;
+            ConfigParam[0] = (byte)(0x01);
+            ushort uwDataTemp = 0;
+            ulong ulDataTemp = 0;
+            int index_1 = 0, index_2 = 0;
+            string[] strDataTemp = AssistDefaultInfo.Split(new string[] { ", " }, StringSplitOptions.None);
+            try
+            {
+                //因数据类型不同,预处理
+                for (int i = 0; i < strDataTemp.Length; i++)
+                {
+                    if (strDataTemp[i].Split('=')[0] == "转矩曲线.a")
+                    {
+                        index_1 = i;
+                        break;
+                    }
+                }
+                for (int i = 0; i < strDataTemp.Length; i++)
+                {
+                    if (strDataTemp[i].Split('=')[0] == "踏频曲线.d")
+                    {
+                        index_2 = i;
+                        break;
+                    }
+                }
+                for (int i = 0; i < strDataTemp.Length; i++)
+                {
+                    ulDataTemp = Convert.ToUInt32(strDataTemp[i].Split('=')[1]);
+                    if (i < index_1)
+                    {
+                        ConfigParam[2 * i + 4] = (byte)ulDataTemp;
+                        ConfigParam[2 * i + 5] = (byte)(ulDataTemp >> 8);
+                    }
+                    else if (i <= index_2)
+                    {
+                        ConfigParam[4 * i - 4] = (byte)ulDataTemp;
+                        ConfigParam[4 * i - 3] = (byte)(ulDataTemp >> 8);
+                        ConfigParam[4 * i - 2] = (byte)(ulDataTemp >> 16);
+                        ConfigParam[4 * i - 1] = (byte)(ulDataTemp >> 24);
+                    }
+                    else
+                    {
+                        ConfigParam[2 * i + 20] = (byte)ulDataTemp;
+                        ConfigParam[2 * i + 21] = (byte)(ulDataTemp >> 8);
+                    }
+                }
+
+                //零速增益
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeStartGain.Text);
+                ConfigParam[4] = (byte)uwDataTemp;
+                ConfigParam[5] = (byte)(uwDataTemp >> 8);
+                //电流阶梯
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeCircuitK.Text);
+                ConfigParam[48] = (byte)uwDataTemp;
+                ConfigParam[49] = (byte)(uwDataTemp >> 8);
+                //滤波脉冲
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeFltCounter.Text);
+                ConfigParam[52] = (byte)uwDataTemp;
+                ConfigParam[53] = (byte)(uwDataTemp >> 8);
+                //限速启动
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeSpeedLimitTh.Text);
+                ConfigParam[58] = (byte)uwDataTemp;
+                ConfigParam[59] = (byte)(uwDataTemp >> 8);
+                //限速停止
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeSpeedLimitEnd.Text);
+                ConfigParam[60] = (byte)uwDataTemp;
+                ConfigParam[61] = (byte)(uwDataTemp >> 8);
+                //踏频占比
+                uwDataTemp = Convert.ToUInt16(textBox_FacModeCadencePer.Text);
+                ConfigParam[62] = (byte)uwDataTemp;
+                ConfigParam[63] = (byte)(uwDataTemp >> 8);
+
+                mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4450, ConfigParam);
+            }
+            catch (Exception)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("数据格式不正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+
+        /// <summary>
+        /// 生产模式写入型号
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button_FacModeSetName_Click(object sender, EventArgs e)
+        {
+            string Mode = textBox_FacModeName.Text;
+            var ModeArray = new byte[16];
+
+            for (ushort i = 0; i < Mode.Length; i++)
+            {
+                ModeArray[i] = (byte)Mode[i];
+            }
+            if (Mode.Length < 16)
+            {
+                ModeArray[Mode.Length] = (byte)'.';
+                for (ushort i = 0; i < 16 - Mode.Length - 1; i++)
+                {
+                    ModeArray[Mode.Length + 1 + i] = 0x20;
+                }
+            }
+
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2210, ModeArray);
+        }
+
+        /// <summary>
+        /// 生产模式写入SN
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Button_FacModeSetNum_Click(object sender, EventArgs e)
+        {
+            string SN = textBox_FacModeNum.Text;
+            var SNArray = new byte[16];
+
+            for (ushort i = 0; i < SN.Length; i++)
+            {
+                SNArray[i] = (byte)SN[i];
+            }
+            if (SN.Length < 16)
+            {
+                SNArray[SN.Length] = (byte)'.';
+                for (ushort i = 0; i < 16 - SN.Length - 1; i++)
+                {
+                    SNArray[SN.Length + 1 + i] = 0x20;
+                }
+            }
+
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2310, SNArray);
+        }
+
+        /// <summary>
+        /// 生产模式读取版本信息
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Button_FacModeReadVer_Click_1(object sender, EventArgs e)
+        {
+            textBox_Model.Text = "---";
+            textBox_SN.Text = "---";
+            textBox_HW.Text = "---";
+            textBox_FW.Text = "---";
+            textBox_OBC_ReadModel.Text = "---";
+            textBox_OBC_ReadSN.Text = "---";
+            textBox_OBC_ReadHW.Text = "---";
+            textBox_OBC_ReadFW.Text = "---";
+            textBox_FacModeName.Text = "---";
+            textBox_FacModeNum.Text = "---";
+            textBox_FacModeHW.Text = "---";
+            textBox_FacModeFW.Text = "---";
+            Class_Motor_Ver.Mode = "---";
+            Class_Motor_Ver.SN = "---";
+            Class_Motor_Ver.HW = "---";
+            Class_Motor_Ver.FW = "---";
+            Class_Motor_Ver.Special = "---";
+            mySerialProcess.SendCmd((ushort)0x731, (byte)0x11, (ushort)0x3900, null);
+        }
+
+        /// <summary>
+        /// 生产模式写入生产信息
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Button_FacModeSetMacDate_Click(object sender, EventArgs e)
+        {
+            var MACArray = new byte[32];
+            string MacDefaultInfo = "Welling";
+            string MacAddDefaultInfo = "Shunde";
+            string MacDateDefaultInfo = DateTime.Now.ToString("yyyyMMdd");
+            string MacPPDefaultInfo = "MM_MC1";
+
+            //填入生产商
+            for (ushort i = 0; i < MacDefaultInfo.Length; i++)
+            {
+                MACArray[i] = (byte)MacDefaultInfo[i];
+            }
+            if (MacDefaultInfo.Length < 8)
+            {
+                MACArray[MacDefaultInfo.Length] = (byte)'.';
+                for (ushort i = 0; i < 8 - MacDefaultInfo.Length - 1; i++)
+                {
+                    MACArray[MacDefaultInfo.Length + 1 + i] = 0x20;
+                }
+            }
+            //填入生产地
+            for (ushort i = 0; i < MacAddDefaultInfo.Length; i++)
+            {
+                MACArray[8 + i] = (byte)MacAddDefaultInfo[i];
+            }
+            if (MacAddDefaultInfo.Length < 8)
+            {
+                MACArray[MacAddDefaultInfo.Length + 8] = (byte)'.';
+                for (ushort i = 0; i < 8 - MacAddDefaultInfo.Length - 1; i++)
+                {
+                    MACArray[MacAddDefaultInfo.Length + 1 + i + 8] = 0x20;
+                }
+            }
+            //填入生产日期
+            for (ushort i = 0; i < MacDateDefaultInfo.Length; i++)
+            {
+                MACArray[16 + i] = (byte)MacDateDefaultInfo[i];
+            }
+            if (MacDateDefaultInfo.Length < 8)
+            {
+                MACArray[MacDateDefaultInfo.Length + 16] = (byte)'.';
+                for (ushort i = 0; i < 8 - MacDateDefaultInfo.Length - 1; i++)
+                {
+                    MACArray[MacDateDefaultInfo.Length + 1 + i + 16] = 0x20;
+                }
+            }
+            //填入产品标识
+            for (ushort i = 0; i < MacPPDefaultInfo.Length; i++)
+            {
+                MACArray[24 + i] = (byte)MacPPDefaultInfo[i];
+            }
+            if (MacPPDefaultInfo.Length < 8)
+            {
+                MACArray[MacPPDefaultInfo.Length + 24] = (byte)'.';
+                for (ushort i = 0; i < 8 - MacPPDefaultInfo.Length - 1; i++)
+                {
+                    MACArray[MacPPDefaultInfo.Length + 1 + i + 24] = 0x20;
+                }
+            }
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2420, MACArray);
+        }
+
+        /// <summary>
+        /// 生产模式保存测试页面
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Button_FacModeSaveResult_Click(object sender, EventArgs e)
+        {
+            //查询传感器
+            richTextBox_SensorParam.Clear();
+            textBox_FacModeSensorADC0.Text = "";
+            textBox_FacModeSensorADC1.Text = "";
+            textBox_FacModeSensorADC2.Text = "";
+            textBox_FacModeSensorADC3.Text = "";
+            textBox_FacModeSensorADC4.Text = "";
+            if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null)) return;
+            Delay_ms(100);
+            //读取一次电机信息
+            var CtrlCode = new byte[2];
+            CtrlCode[0] = 0x00;
+            CtrlCode[1] = 0xF0;
+            if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2802, CtrlCode)) return;
+            Delay_ms(100);
+            //读取一次整车参数
+            textBox_FacModeWheelSize.Text = "";
+            textBox_FacModeSpeedLimit.Text = "";
+            comboBox_FacModeAssist1.SelectedIndex = -1;
+            comboBox_FacModeAssist2.SelectedIndex = -1;
+            comboBox_FacModeLightVol.SelectedIndex = -1;
+            comboBox_FacModeStartMode.SelectedIndex = -1;
+            if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x3C00, null)) return;
+            Delay_ms(100);
+            //读取一次助力参数
+            var ConfigParam = new byte[4];
+            textBox_FacModeStartGain.Text = "";
+            textBox_FacModeCircuitK.Text = "";
+            textBox_FacModeFltCounter.Text = "";
+            textBox_FacModeSpeedLimitTh.Text = "";
+            textBox_FacModeSpeedLimitEnd.Text = "";
+            textBox_FacModeCadencePer.Text = "";
+            ConfigParam[0] = (byte)(1 & 0xFF);
+            ConfigParam[1] = (byte)(1 >> 8);
+            ConfigParam[2] = (byte)(1 & 0xFF);
+            ConfigParam[3] = (byte)(1 >> 8);
+            if (!mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4304, ConfigParam)) return;
+            Delay_ms(100);
+            //读取一次版本信息
+            textBox_Model.Text = "---";
+            textBox_SN.Text = "---";
+            textBox_HW.Text = "---";
+            textBox_FW.Text = "---";
+            textBox_OBC_ReadModel.Text = "---";
+            textBox_OBC_ReadSN.Text = "---";
+            textBox_OBC_ReadHW.Text = "---";
+            textBox_OBC_ReadFW.Text = "---";
+            textBox_FacModeName.Text = "---";
+            textBox_FacModeNum.Text = "---";
+            textBox_FacModeHW.Text = "---";
+            textBox_FacModeFW.Text = "---";
+            Class_Motor_Ver.Mode = "---";
+            Class_Motor_Ver.SN = "---";
+            Class_Motor_Ver.HW = "---";
+            Class_Motor_Ver.FW = "---";
+            Class_Motor_Ver.Special = "---";
+            if (!mySerialProcess.SendCmd((ushort)0x731, (byte)0x11, (ushort)0x3900, null)) return;
+            Delay_ms(100);
+
+            //提示检查
+            timer_1s.Enabled = false;
+            if (MessageBox.Show("请检查信息是否完整!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+            {
+                MessageBox.Show("请检查参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+                return;
+            }
+            timer_1s.Enabled = true;
+
+            //保存页面
+            Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
+            Graphics g = Graphics.FromImage(bit);
+            g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片       
+            SaveFileDialog sf = new SaveFileDialog();
+            sf.Title = "页面保存";
+            sf.FileName = textBox_FacModeName.Text + "_" + textBox_FacModeNum.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_") + "_页面存储" + ".png";
+            sf.Filter = "图片|*.png";
+            timer_1s.Enabled = false;
+            if (sf.ShowDialog() == DialogResult.OK)
+            {
+                bit.Save(sf.FileName);//默认保存格式为PNG,保存成jpg格式质量不是很好
+            }
+            timer_1s.Enabled = true;
+
+            //关机保存参数
+            var Code = new byte[5];
+            Code[0] = (byte)'R';
+            Code[1] = (byte)'E';
+            Code[2] = (byte)'S';
+            Code[3] = (byte)'E';
+            Code[4] = (byte)'T';
+            mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2505, Code);
+            PowerOffAckStatus = false;
+            Delay_ms(250);
+            int TryCnt = 3;
+            while ((TryCnt--) >= 0)
+            {
+                if (!PowerOffAckStatus)
+                {
+                    mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2505, Code);
+                    PowerOffAckStatus = false;
+                    Delay_ms(250);
+                }
+                else  break;
+            }
+
+            if (PowerOffAckStatus)
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("测试完成,已关机!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
+                timer_1s.Enabled = true;
+            }
+            else
+            {
+                timer_1s.Enabled = false;
+                MessageBox.Show("关机失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                timer_1s.Enabled = true;
+            }
+        }
+
+        /// <summary>
+        /// 工具箱页面保存
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void 页面保存ToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            //保存页面
+            Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
+            Graphics g = Graphics.FromImage(bit);
+            g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片       
+            SaveFileDialog sf = new SaveFileDialog();
+            sf.Title = "页面保存";
+            sf.FileName = "MotorInfo_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_") + ".png";
+            sf.Filter = "图片|*.png";
+            timer_1s.Enabled = false;
+            if (sf.ShowDialog() == DialogResult.OK)
+            {
+                bit.Save(sf.FileName);//默认保存格式为PNG,保存成jpg格式质量不是很好
+            }
+            timer_1s.Enabled = true;
+        }
     }
 }

+ 10 - 0
Welling_Motor_Debug_Tool/Properties/Resources.Designer.cs

@@ -60,6 +60,16 @@ namespace Welling_Motor_Debug_Tool.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap about {
+            get {
+                object obj = ResourceManager.GetObject("about", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>

+ 3 - 0
Welling_Motor_Debug_Tool/Properties/Resources.resx

@@ -121,4 +121,7 @@
   <data name="Welling Log" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\Welling Log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="about" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\about.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>

binární
Welling_Motor_Debug_Tool/Resources/about.png


+ 1 - 0
Welling_Motor_Debug_Tool/Welling_Motor_Debug_Tool.csproj

@@ -106,6 +106,7 @@
   </ItemGroup>
   <ItemGroup>
     <Content Include="motor.ico" />
+    <None Include="Resources\about.png" />
   </ItemGroup>
   <ItemGroup>
     <BootstrapperPackage Include=".NETFramework,Version=v4.7.2">

binární
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.exe


binární
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.pdb


binární
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool202212102205.exe


binární
Welling_Motor_Debug_Tool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


binární
Welling_Motor_Debug_Tool/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll


binární
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.Properties.Resources.resources


binární
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.AssemblyReference.cache


binární
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.GenerateResource.cache


binární
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.exe


binární
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.pdb


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů