|
@@ -19,6 +19,7 @@ using System.Threading;
|
|
|
using System.Web;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Xml.Linq;
|
|
|
+using static NPOI.POIFS.Crypt.CryptoFunctions;
|
|
|
|
|
|
namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
@@ -26,7 +27,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
#region 变量定义
|
|
|
//版本号
|
|
|
- public static string Version = "2.5.2";
|
|
|
+ public static string Version = "2.5.3";
|
|
|
//串口实例
|
|
|
Serial_Process mySerialProcess = new Serial_Process();
|
|
|
string PortNumSave = "";
|
|
@@ -480,54 +481,67 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//解析配置文件
|
|
|
try
|
|
|
{
|
|
|
+ int index = -1;
|
|
|
//Port Set
|
|
|
- PortNumSave = array_CfgInfo[1].ToString().Split(':')[1];
|
|
|
- PortBaudrateSave = array_CfgInfo[2].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[PortSet]");
|
|
|
+ PortNumSave = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
+ PortBaudrateSave = array_CfgInfo[index + 2].ToString().Split(':')[1];
|
|
|
toolStripComboBox_ComNum.SelectedIndex = toolStripComboBox_ComNum.Items.IndexOf(PortNumSave);
|
|
|
toolStripComboBox_Baudrate.SelectedIndex = toolStripComboBox_Baudrate.Items.IndexOf(PortBaudrateSave);
|
|
|
- 连接开机ToolStripMenuItem.Checked = (array_CfgInfo[3].ToString().Split(':')[1] == "True");
|
|
|
- 断开关机ToolStripMenuItem.Checked = (array_CfgInfo[4].ToString().Split(':')[1] == "True");
|
|
|
- 识别通讯盒ToolStripMenuItem.Checked = (array_CfgInfo[5].ToString().Split(':')[1] == "True");
|
|
|
+ 连接开机ToolStripMenuItem.Checked = (array_CfgInfo[index + 3].ToString().Split(':')[1] == "True");
|
|
|
+ 断开关机ToolStripMenuItem.Checked = (array_CfgInfo[index + 4].ToString().Split(':')[1] == "True");
|
|
|
+ 识别通讯盒ToolStripMenuItem.Checked = (array_CfgInfo[index + 5].ToString().Split(':')[1] == "True");
|
|
|
//Option
|
|
|
- 写入存储ToolStripMenuItem.Checked = (array_CfgInfo[8].ToString().Split(':')[1] == "True");
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[Option]");
|
|
|
+ 写入存储ToolStripMenuItem.Checked = (array_CfgInfo[index + 1].ToString().Split(':')[1] == "True");
|
|
|
//Server Set
|
|
|
- toolStripTextBox_ServerPath.Text = array_CfgInfo[11].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[ServerSet]");
|
|
|
+ toolStripTextBox_ServerPath.Text = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
//MacInfo
|
|
|
- toolStripTextBox_MAC.Text = array_CfgInfo[14].ToString().Split(':')[1];
|
|
|
- toolStripTextBoxMACAddr.Text = array_CfgInfo[15].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[MacInfo]");
|
|
|
+ toolStripTextBox_MAC.Text = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
+ toolStripTextBoxMACAddr.Text = array_CfgInfo[index + 2].ToString().Split(':')[1];
|
|
|
toolStripTextBox_MACDate.Text = DateTime.Now.ToString("yyyyMMdd");
|
|
|
- toolStripTextBox_MACPD.Text = array_CfgInfo[17].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_MACPD.Text = array_CfgInfo[index + 4].ToString().Split(':')[1];
|
|
|
//Log Address
|
|
|
- textBox_LogAddrBegin.Text = array_CfgInfo[20].ToString().Split(':')[1];
|
|
|
- textBox_LogAddrEnd.Text = array_CfgInfo[21].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[LogAddress]");
|
|
|
+ textBox_LogAddrBegin.Text = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
+ textBox_LogAddrEnd.Text = array_CfgInfo[index + 2].ToString().Split(':')[1];
|
|
|
//电机类型
|
|
|
- 中置电机ToolStripMenuItem.Checked = (array_CfgInfo[24].ToString().Split(':')[1] == "True");
|
|
|
- 轮毂电机ToolStripMenuItem.Checked = !中置电机ToolStripMenuItem.Checked;
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[MotorType]");
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = (array_CfgInfo[index + 1].ToString().Split(':')[1] == "True");
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = (array_CfgInfo[index + 2].ToString().Split(':')[1] == "True");
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = (array_CfgInfo[index + 3].ToString().Split(':')[1] == "True");
|
|
|
//检测阈值
|
|
|
- toolStripTextBox_ThVol.Text = array_CfgInfo[28].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThCur.Text = array_CfgInfo[29].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThSpeed.Text = array_CfgInfo[30].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThTor.Text = array_CfgInfo[31].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThCad.Text = array_CfgInfo[32].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThBikeSpeed.Text = array_CfgInfo[33].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThT_PCB.Text = array_CfgInfo[34].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThT_MCU.Text = array_CfgInfo[35].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_ThT_Motor.Text = array_CfgInfo[36].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[CheckValue]");
|
|
|
+ toolStripTextBox_ThVol.Text = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThCur.Text = array_CfgInfo[index + 2].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThSpeed.Text = array_CfgInfo[index + 3].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThTor.Text = array_CfgInfo[index + 4].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThCad.Text = array_CfgInfo[index + 5].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThBikeSpeed.Text = array_CfgInfo[index + 6].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThT_PCB.Text = array_CfgInfo[index + 7].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThT_MCU.Text = array_CfgInfo[index + 8].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_ThT_Motor.Text = array_CfgInfo[index + 9].ToString().Split(':')[1];
|
|
|
//MOS内阻校准系数
|
|
|
- toolStripTextBox_MosCalK.Text = array_CfgInfo[39].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_MOS1.Text= array_CfgInfo[40].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_MOS2.Text = array_CfgInfo[41].ToString().Split(':')[1];
|
|
|
- toolStripTextBox_MOS3.Text = array_CfgInfo[42].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[MosCalK]");
|
|
|
+ toolStripTextBox_MosCalK.Text = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_MOS1.Text= array_CfgInfo[index + 2].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_MOS2.Text = array_CfgInfo[index + 3].ToString().Split(':')[1];
|
|
|
+ toolStripTextBox_MOS3.Text = array_CfgInfo[index + 4].ToString().Split(':')[1];
|
|
|
//通信协议类型
|
|
|
- cANToolStripMenuItem.Checked = (array_CfgInfo[45].ToString().Split(':')[1] == "True");
|
|
|
- uARTToolStripMenuItem.Checked = !cANToolStripMenuItem.Checked;
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[ProtocolType]");
|
|
|
+ cANToolStripMenuItem.Checked = (array_CfgInfo[index + 1].ToString().Split(':')[1] == "True");
|
|
|
+ uARTToolStripMenuItem.Checked = (array_CfgInfo[index + 2].ToString().Split(':')[1] == "True");
|
|
|
//自动更新开关
|
|
|
- 打开ToolStripMenuItem.Checked = (array_CfgInfo[49].ToString().Split(':')[1] == "True");
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[AutoUpdate]");
|
|
|
+ 打开ToolStripMenuItem.Checked = (array_CfgInfo[index + 1].ToString().Split(':')[1] == "True");
|
|
|
关闭ToolStripMenuItem.Checked = !打开ToolStripMenuItem.Checked;
|
|
|
//位置校准偏差
|
|
|
- textBox_AngleDiffTh.Text = array_CfgInfo[52].ToString().Split(':')[1];
|
|
|
+ index = Array.IndexOf(array_CfgInfo.ToArray(), "[AngleCal]");
|
|
|
+ textBox_AngleDiffTh.Text = array_CfgInfo[index + 1].ToString().Split(':')[1];
|
|
|
toolStripTextBox_AngleAvgMax.Text = textBox_AngleDiffTh.Text;
|
|
|
- textBox_AngleZeroTh.Text = array_CfgInfo[53].ToString().Split(':')[1];
|
|
|
+ textBox_AngleZeroTh.Text = array_CfgInfo[index + 2].ToString().Split(':')[1];
|
|
|
toolStripTextBox_AngleZeroMax.Text = textBox_AngleZeroTh.Text;
|
|
|
}
|
|
|
catch (System.Exception)
|
|
@@ -621,7 +635,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
生产信息ToolStripMenuItem.Visible = true;
|
|
|
//显示电机类型,但不可编辑
|
|
|
电机类型ToolStripMenuItem.Visible = true;
|
|
|
- 中置电机ToolStripMenuItem.Enabled = false;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Enabled = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Enabled = false;
|
|
|
轮毂电机ToolStripMenuItem.Enabled = false;
|
|
|
if (uARTToolStripMenuItem.Checked)
|
|
|
UART协议ToolStripMenuItem.Visible = true;
|
|
@@ -645,17 +660,28 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//显示运行信息
|
|
|
tabPage_RunInfo.Parent = tabControl2;
|
|
|
//根据电机类型修改生产信息和电机类型
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("中置MIGIC"))
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = true;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = true;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
toolStripTextBox_MACPD.Text = "MM_MC1";
|
|
|
toolStripTextBox_ServerPath.Text = "MIGIC_TEST";
|
|
|
ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
}
|
|
|
+ else if (EnterForm1.comboBox_User.Text.Contains("中置VP"))
|
|
|
+ {
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = true;
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
+ toolStripTextBox_MACPD.Text = "MM_MV1";
|
|
|
+ toolStripTextBox_ServerPath.Text = "MC_VP_TEST";
|
|
|
+ ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ }
|
|
|
else if (EnterForm1.comboBox_User.Text.Contains("轮毂"))
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
@@ -708,23 +734,35 @@ namespace Welling_Motor_Debug_Tool
|
|
|
位置校准偏差范围ToolStripMenuItem.Visible = false;
|
|
|
//显示生产信息
|
|
|
生产信息ToolStripMenuItem.Visible = true;
|
|
|
- //显示电机类型,但不可编辑
|
|
|
+ //显示电机类型
|
|
|
电机类型ToolStripMenuItem.Visible = true;
|
|
|
- 中置电机ToolStripMenuItem.Enabled = true;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Enabled = true;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Enabled=true;
|
|
|
轮毂电机ToolStripMenuItem.Enabled = true;
|
|
|
if (uARTToolStripMenuItem.Checked)
|
|
|
UART协议ToolStripMenuItem.Visible = true;
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("中置MIGIC"))
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = true;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = true;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
toolStripTextBox_MACPD.Text = "MM_MC1";
|
|
|
toolStripTextBox_ServerPath.Text = "MIGIC_TEST";
|
|
|
ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
}
|
|
|
+ else if (EnterForm1.comboBox_User.Text.Contains("中置VP"))
|
|
|
+ {
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = true;
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
+ toolStripTextBox_MACPD.Text = "MM_MV1";
|
|
|
+ toolStripTextBox_ServerPath.Text = "MC_VP_TEST";
|
|
|
+ ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ }
|
|
|
else if (EnterForm1.comboBox_User.Text.Contains("轮毂"))
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
@@ -748,7 +786,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
生产信息ToolStripMenuItem.Visible = true;
|
|
|
//显示电机类型,但不可编辑
|
|
|
电机类型ToolStripMenuItem.Visible = false;
|
|
|
- 中置电机ToolStripMenuItem.Enabled = false;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Enabled = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Enabled = false;
|
|
|
轮毂电机ToolStripMenuItem.Enabled = false;
|
|
|
if (uARTToolStripMenuItem.Checked)
|
|
|
UART协议ToolStripMenuItem.Visible = true;
|
|
@@ -772,7 +811,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//显示运行信息
|
|
|
tabPage_RunInfo.Parent = tabControl2;
|
|
|
//目前仅轮毂使用
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
toolStripTextBox_ServerPath.Text = "HUB_Control_FCT";
|
|
@@ -4398,7 +4438,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
|
|
|
ConfigParam[3] = (byte)(uwDataTemp >> 8);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
|
|
|
- Delay_ms(200);
|
|
|
+ Delay_ms(2000);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
|
|
|
//标定1判断
|
|
|
label1_TorqueCal1.BackColor = Color.Red;
|
|
@@ -4455,7 +4495,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
|
|
|
ConfigParam[3] = (byte)(uwDataTemp >> 8);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
|
|
|
- Delay_ms(200);
|
|
|
+ Delay_ms(2000);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
|
|
|
//标定2判断
|
|
|
label1_TorqueCal2.BackColor = Color.Red;
|
|
@@ -4513,7 +4553,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
|
|
|
ConfigParam[3] = (byte)(uwDataTemp >> 8);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
|
|
|
- Delay_ms(200);
|
|
|
+ Delay_ms(2000);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
|
|
|
//标定3判断
|
|
|
label1_TorqueCal3.BackColor = Color.Red;
|
|
@@ -4571,7 +4611,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
ConfigParam[2] = (byte)(uwDataTemp & 0xFF);
|
|
|
ConfigParam[3] = (byte)(uwDataTemp >> 8);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x4104, ConfigParam);
|
|
|
- Delay_ms(200);
|
|
|
+ Delay_ms(2000);
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4000, null);
|
|
|
//标定4判断
|
|
|
label1_TorqueCal4.BackColor = Color.Red;
|
|
@@ -5735,7 +5775,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
CfgFileInfo += "EndAddress:" + textBox_LogAddrEnd.Text + "\r\n";
|
|
|
CfgFileInfo += "\r\n";
|
|
|
CfgFileInfo += "[MotorType]" + "\r\n";
|
|
|
- CfgFileInfo += "MidMotor:" + 中置电机ToolStripMenuItem.Checked.ToString() + "\r\n";
|
|
|
+ CfgFileInfo += "MidMotor1:" + 中置电机MIGIC_ToolStripMenuItem.Checked.ToString() + "\r\n";
|
|
|
+ CfgFileInfo += "MidMotor2:" + 中置电机VP_ToolStripMenuItem.Checked.ToString() + "\r\n";
|
|
|
CfgFileInfo += "HubMotor:" + 轮毂电机ToolStripMenuItem.Checked.ToString() + "\r\n";
|
|
|
CfgFileInfo += "\r\n";
|
|
|
CfgFileInfo += "[CheckValue]" + "\r\n";
|
|
@@ -5814,11 +5855,37 @@ namespace Welling_Motor_Debug_Tool
|
|
|
string[] InfoList = { "" };
|
|
|
try
|
|
|
{
|
|
|
- if (中置电机ToolStripMenuItem.Checked == true)
|
|
|
+ if (中置电机MIGIC_ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
regexInfo = @"[0-9][0-9][V][0-9][0-9][0-9][W]";
|
|
|
InfoList = Regex.Split(ScanInfo, regexInfo, RegexOptions.IgnoreCase);
|
|
|
}
|
|
|
+ else if (中置电机VP_ToolStripMenuItem.Checked == true)
|
|
|
+ {
|
|
|
+ Regex regex = new Regex(@"^M[12][0-9](0?[1-9]|1[0-2])((0?[1-9])|((1|2)[0-9])|30|31)[A-Z]\d{4}[A-Z][A-Z]?$");
|
|
|
+ if (ScanInfo.Contains(" "))
|
|
|
+ {
|
|
|
+ InfoList = ScanInfo.Split(new string[] { " " }, StringSplitOptions.None);
|
|
|
+ string Mode = InfoList[0];
|
|
|
+ string Sn = InfoList[1];
|
|
|
+ if (regex.IsMatch(Sn) == false)
|
|
|
+ {
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "SN格式错误" + "\r\n");
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "标签格式错误";
|
|
|
+ Delay_ms(500);
|
|
|
+ //存储异常并上传
|
|
|
+ FacMode_Stop(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("SN格式错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
else if (轮毂电机ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (!ScanInfo.Contains("/")) //老编码规则
|
|
@@ -5855,13 +5922,13 @@ namespace Welling_Motor_Debug_Tool
|
|
|
};
|
|
|
InfoList = ScanInfo.Split(new string[] { " " }, StringSplitOptions.None);
|
|
|
string Model = InfoList[0].Replace("-", "").Replace("Q12", "QA").Replace("Q15", "QB").Replace("Q18", "QC");
|
|
|
- string Spec = InfoList[1].Replace("-", "").Replace("/","");
|
|
|
+ string Spec = InfoList[1].Replace("-", "").Replace("/", "");
|
|
|
string Sn = InfoList[2];
|
|
|
InfoList[0] = Model[2] + Dic_Ver[Model.Substring(3, 2)] + Model[5] + Dic_Ver[Model.Substring(6, 2)] + Model[9];
|
|
|
InfoList[0] += Dic_Vol[Spec.Substring(0, 3)] + Spec.Substring(3, 3) + Spec.Substring(13, 4) + Spec.Substring(Spec.Length - 4, 3);
|
|
|
InfoList[1] = Sn;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
catch (Exception)
|
|
@@ -5925,13 +5992,24 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// <param name="e"></param>
|
|
|
private void 中置电机ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = true;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = true;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
toolStripTextBox_MACPD.Text = "MM_MC1";
|
|
|
toolStripTextBox_ServerPath.Text = "MIGIC_TEST";
|
|
|
ConfigFileSave(true, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
}
|
|
|
|
|
|
+ private void 中置电机小牙盘ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = true;
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
+ toolStripTextBox_MACPD.Text = "MM_MV1";
|
|
|
+ toolStripTextBox_ServerPath.Text = "MC_VP_TEST";
|
|
|
+ ConfigFileSave(true, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 切换电机类型
|
|
|
/// </summary>
|
|
@@ -5939,7 +6017,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// <param name="e"></param>
|
|
|
private void 轮毂电机ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机MIGIC_ToolStripMenuItem.Checked = false;
|
|
|
+ 中置电机VP_ToolStripMenuItem.Checked = false;
|
|
|
轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
@@ -6242,7 +6321,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
- if (中置电机ToolStripMenuItem.Checked == true)
|
|
|
+ if (中置电机MIGIC_ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (textBox_FacModeScan.Text.Split(' ').Length != 7)
|
|
|
{
|
|
@@ -6253,7 +6332,18 @@ namespace Welling_Motor_Debug_Tool
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- else if (轮毂电机ToolStripMenuItem.Checked == true)
|
|
|
+ else if (中置电机VP_ToolStripMenuItem.Checked == true)
|
|
|
+ {
|
|
|
+ if (textBox_FacModeScan.Text.Split(new string[] { " " }, StringSplitOptions.None).Length != 2)
|
|
|
+ {
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "标签格式错误";
|
|
|
+ button__FacMode_Start.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (轮毂电机ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (textBox_FacModeScan.Text.Split(new string[] { " " }, StringSplitOptions.None).Length != 3)
|
|
|
{
|
|
@@ -6307,8 +6397,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//变量定义
|
|
|
var Code = new byte[255];//发送的指令数据
|
|
|
|
|
|
- label_FacModeStatus.Text = "开始测试";
|
|
|
- BootInfo = "";
|
|
|
+ label_FacModeStatus.Text = "开始测试";
|
|
|
Delay_ms(500);
|
|
|
label_FacModeStatus.Text = "系统开机";
|
|
|
|
|
@@ -6331,12 +6420,13 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Code[0] = 0xF0;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
Delay_ms(1500);
|
|
|
+ BootInfo = "";
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送开机指令" + "\r\n");
|
|
|
Code[0] = 0xF1;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
ACK_WaitCnt = 0;
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "等待控制器返回Boot信息……" + "\r\n");
|
|
|
- while (ACK_WaitCnt <= 20) ; //10s,等待开机成功,联动装置盒控制器接口波特率需等待5s接口自动切换为9600
|
|
|
+ while (ACK_WaitCnt <= 20); //10s,等待开机成功,联动装置盒控制器接口波特率需等待5s接口自动切换为9600
|
|
|
|
|
|
//检查BOOT版本
|
|
|
if (BootInfo != string.Empty)
|
|
@@ -6432,8 +6522,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- BootInfo = "";
|
|
|
+
|
|
|
//UART控制器发送复位指令把联动装置盒控制器接口波特率改为57600
|
|
|
if (uARTToolStripMenuItem.Checked)
|
|
|
{
|
|
@@ -6452,13 +6541,14 @@ namespace Welling_Motor_Debug_Tool
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "重新发送关机指令" + "\r\n");
|
|
|
Code[0] = 0xF0;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
- Delay_ms(1500);
|
|
|
+ Delay_ms(3000);
|
|
|
+ BootInfo = "";
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "重新发送开机指令" + "\r\n");
|
|
|
Code[0] = 0xF1;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
ACK_WaitCnt = 0;
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "等待控制器返回Boot信息……" + "\r\n");
|
|
|
- while (ACK_WaitCnt <= 20); //10s
|
|
|
+ while (ACK_WaitCnt <= 20);
|
|
|
|
|
|
//获取Boot版本信息
|
|
|
if (BootInfo != string.Empty)
|
|
@@ -6683,8 +6773,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//位置校准
|
|
|
if (checkBox_FacMode_AngleCal.Checked)
|
|
|
{
|
|
|
- //校准前进行一次开关机保存初始化数据
|
|
|
- BootInfo = "";
|
|
|
+ //校准前进行一次开关机保存初始化数据
|
|
|
label_FacModeStatus.Text = "位置校准";
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "开始位置校准" + "\r\n");
|
|
|
//确保测试前先关机,发送关机指令再发送开机指令
|
|
@@ -6692,6 +6781,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Code[0] = 0xF0;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
Delay_ms(1500);
|
|
|
+ BootInfo = "";
|
|
|
richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送开机指令" + "\r\n");
|
|
|
Code[0] = 0xF1;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
@@ -6867,11 +6957,43 @@ namespace Welling_Motor_Debug_Tool
|
|
|
string[] InfoList = { "" };
|
|
|
try
|
|
|
{
|
|
|
- if (中置电机ToolStripMenuItem.Checked == true)
|
|
|
+ if (中置电机MIGIC_ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
regexInfo = @"[0-9][0-9][V][0-9][0-9][0-9][W]";
|
|
|
InfoList = Regex.Split(ScanInfo.Replace(" ", ""), regexInfo, RegexOptions.IgnoreCase);
|
|
|
}
|
|
|
+ else if (中置电机VP_ToolStripMenuItem.Checked == true)
|
|
|
+ {
|
|
|
+ Regex regex = new Regex(@"^M[12][0-9](0?[1-9]|1[0-2])((0?[1-9])|((1|2)[0-9])|30|31)[A-Z]\d{4}[A-Z][A-Z]?$");
|
|
|
+ if (ScanInfo.Contains(" "))
|
|
|
+ {
|
|
|
+ InfoList = ScanInfo.Split(new string[] { " " }, StringSplitOptions.None);
|
|
|
+ string Mode = InfoList[0];
|
|
|
+ string Sn = InfoList[1];
|
|
|
+ if (regex.IsMatch(Sn) == false)
|
|
|
+ {
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "SN格式错误" + "\r\n");
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "标签格式错误";
|
|
|
+ Delay_ms(500);
|
|
|
+ //存储异常并上传
|
|
|
+ FacMode_Stop(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "标签格式错误" + "\r\n");
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "标签格式错误";
|
|
|
+ Delay_ms(500);
|
|
|
+ //存储异常并上传
|
|
|
+ FacMode_Stop(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
else if (轮毂电机ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (!ScanInfo.Contains("/")) //老编码规则
|
|
@@ -7460,6 +7582,28 @@ namespace Welling_Motor_Debug_Tool
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ //中置判断踏频
|
|
|
+ if ((中置电机MIGIC_ToolStripMenuItem.Checked == true) || (中置电机VP_ToolStripMenuItem.Checked == true))
|
|
|
+ {
|
|
|
+ if ((Convert.ToDouble(textBox_RunInfo_Cadence.Text.Split(' ')[0]) <= Convert.ToDouble(toolStripTextBox_ThCad.Text.Split(',')[1])) &&
|
|
|
+ (Convert.ToDouble(textBox_RunInfo_Cadence.Text.Split(' ')[0]) >= Convert.ToDouble(toolStripTextBox_ThCad.Text.Split(',')[0])))
|
|
|
+ {
|
|
|
+ label_FacModeCad.BackColor = Color.Green;
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "踏频传感器正常" + " " + textBox_RunInfo_Cadence.Text + "\r\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "踏频传感器异常" + " " + textBox_RunInfo_Cadence.Text + "\r\n");
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "测试异常";
|
|
|
+ Delay_ms(500);
|
|
|
+ //存储异常并上传
|
|
|
+ FacMode_Stop(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//发送指令停止电机
|
|
|
do
|
|
|
{
|
|
@@ -7946,7 +8090,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
} while (false);
|
|
|
//测试前先确定电机已停止
|
|
|
- UInt16 WaitTime = 10;
|
|
|
+ UInt16 WaitTime = 20;
|
|
|
do
|
|
|
{
|
|
|
WaitTime--;
|
|
@@ -8617,7 +8761,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
- if (中置电机ToolStripMenuItem.Checked == true)
|
|
|
+ if (中置电机MIGIC_ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (textBox_CheckModeScan.Text.Split(' ').Length != 7)
|
|
|
{
|
|
@@ -8628,6 +8772,17 @@ namespace Welling_Motor_Debug_Tool
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ else if (中置电机VP_ToolStripMenuItem.Checked == true)
|
|
|
+ {
|
|
|
+ if (textBox_CheckModeScan.Text.Split(new string[] { " " }, StringSplitOptions.None).Length != 2)
|
|
|
+ {
|
|
|
+ label_CheckModeStatus.Text = "存在故障!";
|
|
|
+ label_CheckModeResult.BackColor = Color.Red;
|
|
|
+ label_CheckModeResult.Text = "标签格式错误";
|
|
|
+ button_CheckModeStart.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
else if (轮毂电机ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (textBox_CheckModeScan.Text.Split(new string[] { " " }, StringSplitOptions.None).Length != 3)
|
|
@@ -8681,12 +8836,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
|
|
|
//变量定义
|
|
|
var Code = new byte[255];//发送的指令数据
|
|
|
- ushort DataTemp;
|
|
|
- short DataTemp_Int16;
|
|
|
- string ResultPathName = "";
|
|
|
|
|
|
label_CheckModeStatus.Text = "开始测试";
|
|
|
- BootInfo = "";
|
|
|
Delay_ms(500);
|
|
|
label_CheckModeStatus.Text = "系统开机";
|
|
|
|
|
@@ -8708,12 +8859,13 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Code[0] = 0xF0;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
Delay_ms(1500);
|
|
|
+ BootInfo = "";
|
|
|
richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送开机指令" + "\r\n");
|
|
|
Code[0] = 0xF1;
|
|
|
mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
ACK_WaitCnt = 0;
|
|
|
richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "等待控制器返回Boot信息……" + "\r\n");
|
|
|
- while (ACK_WaitCnt <= 20) ; //10s
|
|
|
+ while (ACK_WaitCnt <= 20);
|
|
|
|
|
|
//检查BOOT版本
|
|
|
if (BootInfo != string.Empty)
|
|
@@ -8850,11 +9002,43 @@ namespace Welling_Motor_Debug_Tool
|
|
|
string[] InfoList = { "" };
|
|
|
try
|
|
|
{
|
|
|
- if (中置电机ToolStripMenuItem.Checked == true)
|
|
|
+ if (中置电机MIGIC_ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
regexInfo = @"[0-9][0-9][V][0-9][0-9][0-9][W]";
|
|
|
InfoList = Regex.Split(ScanInfo.Replace(" ", ""), regexInfo, RegexOptions.IgnoreCase);
|
|
|
}
|
|
|
+ else if (中置电机VP_ToolStripMenuItem.Checked == true)
|
|
|
+ {
|
|
|
+ Regex regex = new Regex(@"^M[12][0-9](0?[1-9]|1[0-2])((0?[1-9])|((1|2)[0-9])|30|31)[A-Z]\d{4}[A-Z][A-Z]?$");
|
|
|
+ if (ScanInfo.Contains(" "))
|
|
|
+ {
|
|
|
+ InfoList = ScanInfo.Split(new string[] { " " }, StringSplitOptions.None);
|
|
|
+ string Mode = InfoList[0];
|
|
|
+ string Sn = InfoList[1];
|
|
|
+ if (regex.IsMatch(Sn) == false)
|
|
|
+ {
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "SN格式错误" + "\r\n");
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "标签格式错误";
|
|
|
+ Delay_ms(500);
|
|
|
+ //存储异常并上传
|
|
|
+ FacMode_Stop(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "标签格式错误" + "\r\n");
|
|
|
+ label_FacModeStatus.Text = "存在故障!";
|
|
|
+ label_FacModeResult.BackColor = Color.Red;
|
|
|
+ label_FacModeResult.Text = "标签格式错误";
|
|
|
+ Delay_ms(500);
|
|
|
+ //存储异常并上传
|
|
|
+ FacMode_Stop(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
else if (轮毂电机ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
if (!ScanInfo.Contains("/")) //老编码规则
|