|
@@ -21,6 +21,9 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Params myParams = new Params();
|
|
|
//记录文件名称
|
|
|
string SaveFilename = "";
|
|
|
+ //BMS运行信息超时计数
|
|
|
+ bool BMS_RunInfo_Refresh = false;
|
|
|
+ ushort BMS_RunInfo_Refresh_Cnt = 0;
|
|
|
#endregion
|
|
|
|
|
|
public Form1()
|
|
@@ -86,7 +89,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
if (buffer[0] == 0x55 && buffer[1] == 0xAA)//判断帧头
|
|
|
{
|
|
|
PackageID = (ushort)(buffer[2] * 256 + buffer[3]);
|
|
|
- if ((PackageID == 0x0710) || (PackageID == 0x0715) || (PackageID == 0x07FF))
|
|
|
+ if ((PackageID == 0x0710) || (PackageID == 0x0715) || (PackageID == 0x07FF) || (PackageID == 0x0720) || (PackageID == 0x0713))
|
|
|
{
|
|
|
int CmdLen = buffer[5];
|
|
|
if (buffer.Count < CmdLen + 11) break;//如果接收到的数据没有达到一帧数据的指定长度, 则执行下次循环
|
|
@@ -132,6 +135,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
private void DataCmdProcess(ushort ID, ushort CmdTemp, byte[] Data)
|
|
|
{
|
|
|
int DataTemp;
|
|
|
+ ushort uData16;
|
|
|
unchecked
|
|
|
{
|
|
|
this.Invoke((EventHandler)(delegate { label_RecCount.Text = Convert.ToString(Convert.ToInt32(label_RecCount.Text) + 1); }));
|
|
@@ -141,7 +145,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
switch (CmdTemp)
|
|
|
{
|
|
|
- case 0x1100://TE APP版本信息
|
|
|
+ case 0x1100://
|
|
|
{
|
|
|
unchecked
|
|
|
{
|
|
@@ -150,17 +154,6 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//CDL连接成功
|
|
|
mySerialProcess.CDL_Online_Flag = true;
|
|
|
MessageBox.Show("连接成功!", "提示");
|
|
|
- //显示其它界面
|
|
|
- foreach (Control c in this.Controls)
|
|
|
- {
|
|
|
- if (c is GroupBox)
|
|
|
- {
|
|
|
- if (c != groupBox1)
|
|
|
- {
|
|
|
- c.Visible = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}));
|
|
|
}
|
|
|
break;
|
|
@@ -229,7 +222,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
textBox_RunInfo_GearSt.Text = "Walk";
|
|
|
comboBox_GearSt.SelectedIndex = 6;
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
textBox_RunInfo_GearSt.Text = Convert.ToString(DataTemp);
|
|
@@ -248,7 +241,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
comboBox_LightSwitch.SelectedIndex = 0;
|
|
|
}
|
|
|
//剩余电量
|
|
|
- DataTemp = (ushort)(Data[15]);
|
|
|
+ DataTemp = (ushort)(Data[15]);
|
|
|
textBox_RunInfo_SOC.Text = Convert.ToString(DataTemp) + " %";
|
|
|
//剩余续航里程
|
|
|
DataTemp = (ushort)(Data[17] * 256 + Data[16]);
|
|
@@ -450,6 +443,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
//电机型号
|
|
|
textBox_Model.Text = "";
|
|
|
+ textBox_OBC_ReadModel.Text = "";
|
|
|
for (ushort i = 0; i < 16; i++)
|
|
|
{
|
|
|
if (Data[i] == 0x2E)
|
|
@@ -457,11 +451,13 @@ namespace Welling_Motor_Debug_Tool
|
|
|
break;
|
|
|
}
|
|
|
textBox_Model.Text += ((char)Data[i]).ToString();
|
|
|
+ textBox_OBC_ReadModel.Text += ((char)Data[i]).ToString();
|
|
|
}
|
|
|
Class_Motor_Ver.Mode = textBox_Model.Text;
|
|
|
|
|
|
//电机SN
|
|
|
textBox_SN.Text = "";
|
|
|
+ textBox_OBC_ReadSN.Text = "";
|
|
|
for (ushort i = 0; i < 16; i++)
|
|
|
{
|
|
|
if (Data[16 + i] == 0x2E)
|
|
@@ -469,23 +465,27 @@ namespace Welling_Motor_Debug_Tool
|
|
|
break;
|
|
|
}
|
|
|
textBox_SN.Text += ((char)Data[16 + i]).ToString();
|
|
|
+ textBox_OBC_ReadSN.Text += ((char)Data[16 + i]).ToString();
|
|
|
}
|
|
|
Class_Motor_Ver.SN = textBox_SN.Text;
|
|
|
|
|
|
//电机HW
|
|
|
textBox_HW.Text = "";
|
|
|
- for (ushort i = 0; i < 10; i++)
|
|
|
+ textBox_OBC_ReadHW.Text = "";
|
|
|
+ for (ushort i = 0; i < 16; i++)
|
|
|
{
|
|
|
if (Data[32 + i] == 0x2E)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
textBox_HW.Text += ((char)Data[32 + i]).ToString();
|
|
|
+ textBox_OBC_ReadHW.Text += ((char)Data[32 + i]).ToString();
|
|
|
}
|
|
|
Class_Motor_Ver.HW = textBox_HW.Text;
|
|
|
|
|
|
//电机FW
|
|
|
textBox_FW.Text = "";
|
|
|
+ textBox_OBC_ReadFW.Text = "";
|
|
|
for (ushort i = 0; i < 16; i++)
|
|
|
{
|
|
|
if (Data[48 + i] == 0x2E)
|
|
@@ -497,6 +497,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Data[48 + i] = (byte)'.';
|
|
|
}
|
|
|
textBox_FW.Text += ((char)Data[48 + i]).ToString();
|
|
|
+ textBox_OBC_ReadFW.Text += ((char)Data[48 + i]).ToString();
|
|
|
}
|
|
|
Class_Motor_Ver.FW = textBox_FW.Text;
|
|
|
|
|
@@ -635,18 +636,136 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
this.Invoke((EventHandler)(delegate
|
|
|
{
|
|
|
- textBox_Online.Text = Convert.ToString(Data[3], 16).PadLeft(2, '0').ToUpper()+"H";
|
|
|
+ textBox_Online.Text = Convert.ToString(Data[3], 16).PadLeft(2, '0').ToUpper() + "H";
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x1510://骑行历史信息
|
|
|
+ {
|
|
|
+ unchecked
|
|
|
+ {
|
|
|
+ this.Invoke((EventHandler)(delegate
|
|
|
+ {
|
|
|
+ long DataTemp32;
|
|
|
+ //ODO里程
|
|
|
+ DataTemp32 = (long)((Data[3] << 24) + (Data[2] << 16) + (Data[1] << 8) + Data[0]);
|
|
|
+ textBox_OBC_ODO_KM.Text = ((float)DataTemp32 / 10f).ToString("0.0") + " km";
|
|
|
+ //ODO时间
|
|
|
+ DataTemp32 = (long)((Data[7] << 24) + (Data[6] << 16) + (Data[5] << 8) + Data[4]);
|
|
|
+ if (DataTemp32 >= 60 * 100000)
|
|
|
+ textBox_OBC_ODO_TIME.Text = Convert.ToString(DataTemp32 / 60) + " h";
|
|
|
+ else
|
|
|
+ textBox_OBC_ODO_TIME.Text = Convert.ToString(DataTemp32 / 60) + " h " + Convert.ToString(DataTemp32 % 60) + " m";
|
|
|
+ //TRIP里程
|
|
|
+ DataTemp32 = (long)((Data[11] << 24) + (Data[10] << 16) + (Data[9] << 8) + Data[8]);
|
|
|
+ textBox_OBC_TRIP_KM.Text = ((float)DataTemp32 / 10f).ToString("0.0") + " km";
|
|
|
+ //TRIP时间
|
|
|
+ DataTemp32 = (long)((Data[15] << 24) + (Data[14] << 16) + (Data[13] << 8) + Data[12]);
|
|
|
+ if (DataTemp32 >= 60 * 100000)
|
|
|
+ textBox_OBC_TRIP_TIME.Text = Convert.ToString(DataTemp32 / 60) + " h";
|
|
|
+ else
|
|
|
+ textBox_OBC_TRIP_TIME.Text = Convert.ToString(DataTemp32 / 60) + " h " + Convert.ToString(DataTemp32 % 60) + " m";
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default: break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 解析BMS广播的命令
|
|
|
+ else if (ID == 0x720)
|
|
|
+ {
|
|
|
+ switch (CmdTemp)
|
|
|
+ {
|
|
|
+ case 0x1010://BMS运行信息
|
|
|
+ {
|
|
|
+ unchecked
|
|
|
+ {
|
|
|
+ this.Invoke((EventHandler)(delegate
|
|
|
+ {
|
|
|
+ BMS_RunInfo_Refresh = true;
|
|
|
+ richTextBox_OBC_BMS_RunInfo.Clear();
|
|
|
+ //电压
|
|
|
+ uData16 = (ushort)(Data[1] * 256 + Data[0]);
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("电压:" + Convert.ToString(uData16) + " mV" + "\r\n");
|
|
|
+ //电流
|
|
|
+ uData16 = (ushort)(Data[3] * 256 + Data[2]);
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("电流:" + Convert.ToString(uData16) + " mA" + "\r\n");
|
|
|
+ //剩余容量
|
|
|
+ uData16 = (ushort)(Data[5] * 256 + Data[4]);
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("剩余容量:" + Convert.ToString(uData16) + " mAh" + "\r\n");
|
|
|
+ //满充容量
|
|
|
+ uData16 = (ushort)(Data[7] * 256 + Data[6]);
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("满充容量:" + Convert.ToString(uData16) + " mV" + "\r\n");
|
|
|
+ //电芯温度
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("电芯温度:" + Convert.ToString((int)(Data[8] - 40) + " ℃" + "\r\n"));
|
|
|
+ //剩余电量
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("剩余电量:" + Convert.ToString(Data[9]) + " %" + "\r\n");
|
|
|
+ //电池状态
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("电池状态:" + Convert.ToString(Data[10], 16).PadLeft(2, '0').ToUpper() + " H" + "\r\n");
|
|
|
+ //SOH
|
|
|
+ richTextBox_OBC_BMS_RunInfo.AppendText("电池寿命:" + Convert.ToString(Data[11]) + " %" + "\r\n");
|
|
|
}));
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
+ default: break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
|
|
|
- default:break;
|
|
|
+ #region 解析电机发送OBC的命令
|
|
|
+ else if (ID == 0x713)
|
|
|
+ {
|
|
|
+ switch (CmdTemp)
|
|
|
+ {
|
|
|
+ case 0x5408://电机用户参数
|
|
|
+ {
|
|
|
+ unchecked
|
|
|
+ {
|
|
|
+ this.Invoke((EventHandler)(delegate
|
|
|
+ {
|
|
|
+ richTextBox_OBC_ReadUserInfo.Clear();
|
|
|
+ //默认周长
|
|
|
+ richTextBox_OBC_ReadUserInfo.AppendText("默认周长:" + Convert.ToString((int)Data[0]) + " cm" + "\r\n");
|
|
|
+ //启动模式
|
|
|
+ richTextBox_OBC_ReadUserInfo.AppendText("启动模式:" + ((Data[1] == 0x01) ? "柔和" : (Data[1] == 0x02) ? "正常" : (Data[1] == 0x03) ? "强劲" : "无效") + "\r\n");
|
|
|
+ comboBox_OBC_StartMode.SelectedIndex = Data[1] - 1;
|
|
|
+ //限速
|
|
|
+ richTextBox_OBC_ReadUserInfo.AppendText("限速:" + Convert.ToString(Data[2]) + " km/h" + "\r\n");
|
|
|
+ //周长微调
|
|
|
+ numericUpDown_OBC_WheelAdj.Value = (int)(Data[3] > 128 ? (Data[3] - 256) : Data[3]);
|
|
|
+ richTextBox_OBC_ReadUserInfo.AppendText("周长微调:" + Convert.ToString(numericUpDown_OBC_WheelAdj.Value) + " cm" + "\r\n");
|
|
|
+ //助力方案
|
|
|
+ richTextBox_OBC_ReadUserInfo.AppendText("助力方案:" + Convert.ToString(Data[4]) + "\r\n");
|
|
|
+ comboBox_OBC_AssistFunc.SelectedIndex = Data[4] - 1;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x5303://电机应答反馈
|
|
|
+ {
|
|
|
+ unchecked
|
|
|
+ {
|
|
|
+ this.Invoke((EventHandler)(delegate
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("OK", "反馈指令", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default: break;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
}
|
|
|
- #endregion
|
|
|
+ #endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 端口连接事件
|
|
@@ -732,7 +851,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
if (MC_RunInfo_Refresh == false)
|
|
|
{
|
|
|
MC_RunInfo_Refresh_Cnt++;
|
|
|
- if (MC_RunInfo_Refresh_Cnt > 3)
|
|
|
+ if (MC_RunInfo_Refresh_Cnt > 5)//5s
|
|
|
{
|
|
|
MC_RunInfo_Clear();
|
|
|
MC_RunInfo_Refresh_Cnt = 0;
|
|
@@ -744,11 +863,27 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
MC_RunInfo_Refresh = false;
|
|
|
|
|
|
+ //BMS_RunInfo超时清除
|
|
|
+ if (BMS_RunInfo_Refresh == false)
|
|
|
+ {
|
|
|
+ BMS_RunInfo_Refresh_Cnt++;
|
|
|
+ if (BMS_RunInfo_Refresh_Cnt > 5)//5s
|
|
|
+ {
|
|
|
+ richTextBox_OBC_BMS_RunInfo.Clear();
|
|
|
+ BMS_RunInfo_Refresh_Cnt = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BMS_RunInfo_Refresh_Cnt = 0;
|
|
|
+ }
|
|
|
+ BMS_RunInfo_Refresh = false;
|
|
|
+
|
|
|
//故障码超时清除
|
|
|
if (MC_ErrorCode_Refresh == false)
|
|
|
{
|
|
|
MC_ErrorCode_Refresh_Cnt++;
|
|
|
- if (MC_ErrorCode_Refresh_Cnt > 50)
|
|
|
+ if (MC_ErrorCode_Refresh_Cnt > 5)//5s
|
|
|
{
|
|
|
textBox_ErrorCode.Text = "---";
|
|
|
MC_ErrorCode_Refresh_Cnt = 0;
|
|
@@ -765,7 +900,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
if (mySerialProcess.CDL_Online_Flag == false)
|
|
|
{
|
|
|
mySerialProcess.CDL_OnlineCheck_Cnt++;
|
|
|
- if (mySerialProcess.CDL_OnlineCheck_Cnt > 3)
|
|
|
+ if (mySerialProcess.CDL_OnlineCheck_Cnt > 3)//3s
|
|
|
{
|
|
|
timer_1s.Enabled = false;
|
|
|
MessageBox.Show("连接失败!", "提示");
|
|
@@ -781,6 +916,26 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
+ //OBC定时发送设置档位
|
|
|
+ if (checkBox_OBC_StartSetGearSt.Checked == true)
|
|
|
+ {
|
|
|
+ var CtrlCode = new byte[2];
|
|
|
+ if (comboBox_OBC_SetGearST.SelectedIndex == 6)//档位
|
|
|
+ CtrlCode[0] = 0x22;
|
|
|
+ else
|
|
|
+ CtrlCode[0] = (byte)comboBox_OBC_SetGearST.SelectedIndex;
|
|
|
+ if (comboBox_OBC_LightSw.SelectedIndex == 0)//车灯
|
|
|
+ CtrlCode[1] = 0xF1;
|
|
|
+ else
|
|
|
+ CtrlCode[1] = 0xF0;
|
|
|
+ mySerialProcess.SendCmd((ushort)0x731, (byte)0x0C, (ushort)0x3002, CtrlCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ //OBC定时发送查询电池
|
|
|
+ if (checkBox_OBC_StartReadBMS.Checked == true)
|
|
|
+ {
|
|
|
+ mySerialProcess.SendCmd((ushort)0x732, (byte)0x11, (ushort)0x5000, null);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1206,6 +1361,10 @@ namespace Welling_Motor_Debug_Tool
|
|
|
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 = "---";
|
|
|
Class_Motor_Ver.Mode = "---";
|
|
|
Class_Motor_Ver.SN = "---";
|
|
|
Class_Motor_Ver.HW = "---";
|
|
@@ -1693,20 +1852,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// <param name="e"></param>
|
|
|
private void comboBox_AssistTorque_SelectionChangeCommitted(object sender, EventArgs e)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- int DataNum = Convert.ToInt32(comboBox_AssistTorque.Text);
|
|
|
- int index_1 = richTextBox_AssistParam.Text.IndexOf("助力转矩曲线编号=") + "助力转矩曲线编号=".Length;
|
|
|
- int index_2 = richTextBox_AssistParam.Text.IndexOf("助力踏频曲线编号");
|
|
|
- richTextBox_AssistParam.Select(index_1, index_2 - index_1);
|
|
|
- richTextBox_AssistParam.SelectedText = Convert.ToString(DataNum) + ", ";
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- timer_1s.Enabled = false;
|
|
|
- MessageBox.Show("数据格式不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- timer_1s.Enabled = true;
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1716,20 +1862,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// <param name="e"></param>
|
|
|
private void comboBox_AssistCadence_SelectionChangeCommitted(object sender, EventArgs e)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- int DataNum = Convert.ToInt32(comboBox_AssistCadence.Text);
|
|
|
- int index_1 = richTextBox_AssistParam.Text.IndexOf("助力踏频曲线编号=") + "助力踏频曲线编号=".Length;
|
|
|
- int index_2 = richTextBox_AssistParam.Text.IndexOf("转矩曲线.a");
|
|
|
- richTextBox_AssistParam.Select(index_1, index_2 - index_1);
|
|
|
- richTextBox_AssistParam.SelectedText = Convert.ToString(DataNum) + ", ";
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- timer_1s.Enabled = false;
|
|
|
- MessageBox.Show("数据格式不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- timer_1s.Enabled = true;
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1765,5 +1898,150 @@ namespace Welling_Motor_Debug_Tool
|
|
|
CtrlCode[1] = 0xF0;
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2802, CtrlCode);
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 仪表启动控制档位开关事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void checkBox_OBC_StartSetGearSt_CheckedChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (checkBox_OBC_StartSetGearSt.Checked == true)
|
|
|
+ {
|
|
|
+ //检查是否选择档位和打开车灯
|
|
|
+ if ((comboBox_OBC_SetGearST.SelectedIndex == -1) || (comboBox_OBC_LightSw.SelectedIndex == -1))
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请检查档位设置和大灯开关!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ checkBox_OBC_StartSetGearSt.Checked = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //检查串口是否打开
|
|
|
+ if (!mySerialProcess.mySerial.IsOpen)
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请检查是否打开串口!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ checkBox_OBC_StartSetGearSt.Checked = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// OBC查询电机用户参数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_OBC_ReadUserInfo_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ richTextBox_OBC_ReadUserInfo.Clear();
|
|
|
+ mySerialProcess.SendCmd((ushort)0x731, (byte)0x11, (ushort)0x3300, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// OBC设置电机用户参数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_OBC_WriteUserInfo_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ var UserInfoCode = new byte[8];
|
|
|
+ for (int i = 0; i < UserInfoCode.Length; i++)
|
|
|
+ UserInfoCode[i] = 0;
|
|
|
+ if (comboBox_OBC_StartMode.SelectedIndex == -1)//检查数据有效性
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请选择启动模式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (comboBox_OBC_AssistFunc.SelectedIndex == -1)//检查数据有效性
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请选择助力方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ UserInfoCode[0] = (byte)(int)numericUpDown_OBC_WheelAdj.Value;
|
|
|
+ UserInfoCode[1] = (byte)(comboBox_OBC_StartMode.SelectedIndex + 1);
|
|
|
+ UserInfoCode[2] = (byte)(comboBox_OBC_AssistFunc.SelectedIndex + 1);
|
|
|
+ mySerialProcess.SendCmd((ushort)0x731, (byte)0x16, (ushort)0x3408, UserInfoCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// OBC查询电机版本信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_OBC_ReadVerInfo_Click(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 = "---";
|
|
|
+ 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>
|
|
|
+ /// OBC读取骑行历史
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_OBC_ReadRideInfo_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ textBox_OBC_TRIP_KM.Text = "";
|
|
|
+ textBox_OBC_TRIP_TIME.Text = "";
|
|
|
+ textBox_OBC_ODO_KM.Text = "";
|
|
|
+ textBox_OBC_ODO_TIME.Text = "";
|
|
|
+ mySerialProcess.SendCmd((ushort)0x731, (byte)0x11, (ushort)0x3500, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// OBC清除TRIP里程
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_OBC_ClearTrip_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("TRIP清除后将无法恢复", "确认清除?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
|
+ mySerialProcess.SendCmd((ushort)0x731, (byte)0x16, (ushort)0x3605, Code);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkBox_OBC_StartReadBMS_CheckedChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (checkBox_OBC_StartReadBMS.Checked == true)
|
|
|
+ {
|
|
|
+ //检查串口是否打开
|
|
|
+ if (!mySerialProcess.mySerial.IsOpen)
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请检查是否打开串口!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ checkBox_OBC_StartReadBMS.Checked = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|