|
@@ -151,7 +151,10 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
comboBox_File.Items.Clear();
|
|
|
foreach (var file in FileList)
|
|
|
{
|
|
|
- comboBox_File.Items.Add(file.Substring(file.LastIndexOf("\\") + 1));
|
|
|
+ if (file.Contains(".ttcfg"))
|
|
|
+ {
|
|
|
+ comboBox_File.Items.Add(file.Substring(file.LastIndexOf("\\") + 1));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
@@ -184,13 +187,12 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
if (checkBox_LocalFile.Checked == false)//非本地模式从服务器下载文件
|
|
|
{
|
|
|
SelectFile = comboBox_cfgFileDate.SelectedItem.ToString() + "\\" + comboBox_File.SelectedItem.ToString();
|
|
|
- if (!File.Exists(LocalCfgFilePath + SelectFile))//检查本地是否存在选定文件
|
|
|
+ if (File.Exists(LocalCfgFilePath + SelectFile))//本地存在选定文件,先删除本地
|
|
|
{
|
|
|
- SelectFile = comboBox_cfgFileDate.SelectedItem.ToString() + "/" + comboBox_File.SelectedItem.ToString();
|
|
|
-
|
|
|
- StartForm.myFtp.DownloadFile(StartForm.myServerCfg.RootPath + "/cfg/" + SelectFile, LocalCfgFilePath + comboBox_cfgFileDate.SelectedItem.ToString());
|
|
|
-
|
|
|
+ File.Delete(LocalCfgFilePath + SelectFile);
|
|
|
}
|
|
|
+ SelectFile = comboBox_cfgFileDate.SelectedItem.ToString() + "/" + comboBox_File.SelectedItem.ToString();
|
|
|
+ StartForm.myFtp.DownloadFile(StartForm.myServerCfg.RootPath + "/cfg/" + SelectFile, LocalCfgFilePath + comboBox_cfgFileDate.SelectedItem.ToString());
|
|
|
}
|
|
|
SelectFile = comboBox_cfgFileDate.SelectedItem.ToString() + "\\" + comboBox_File.SelectedItem.ToString();
|
|
|
//打开选中文件
|
|
@@ -515,14 +517,17 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
{
|
|
|
this.Invoke((EventHandler)(delegate
|
|
|
{
|
|
|
- label_Boot_Version.BackColor = Color.Green;
|
|
|
- label_Boot_Version.Text = "OK";
|
|
|
- richTextBox_TestRecord.AppendText("Boot 版本:");
|
|
|
- for (ushort i = 0; i < 9; i++)
|
|
|
+ if (label_Boot_Version.Text != "OK")
|
|
|
{
|
|
|
- richTextBox_TestRecord.Text += ((char)binary_data_1[2 + i]).ToString();
|
|
|
+ richTextBox_TestRecord.AppendText("Bootloader版本:");
|
|
|
+ for (ushort i = 0; i < 9; i++)
|
|
|
+ {
|
|
|
+ richTextBox_TestRecord.Text += ((char)binary_data_1[2 + i]).ToString();
|
|
|
+ }
|
|
|
+ richTextBox_TestRecord.AppendText("\r\n");
|
|
|
}
|
|
|
- richTextBox_TestRecord.AppendText("\r\n");
|
|
|
+ label_Boot_Version.BackColor = Color.Green;
|
|
|
+ label_Boot_Version.Text = "OK";
|
|
|
}));
|
|
|
}
|
|
|
break;
|
|
@@ -815,6 +820,12 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
portsettings_form.comboBox_ComIndex.Enabled = true;
|
|
|
portsettings_form.button_Enter.Text = "确认";
|
|
|
portsettings_form.g_blnIsOpen = false;
|
|
|
+#if false
|
|
|
+ //针对越南和工程账户,直接退出,不执行删除本地配置
|
|
|
+ if ((StartForm.EnterForm1.comboBox_User.Text == "越南Vietnam")|| (StartForm.EnterForm1.comboBox_User.Text == "工程Engineer"))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
//关闭前,删除本地所有配置文件
|
|
|
string path = StartForm.UserPath + "\\cfg\\";
|
|
|
try
|
|
@@ -839,6 +850,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
{
|
|
|
MessageBox.Show("文件清理失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
}
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
//开关灯
|
|
@@ -1047,7 +1059,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- #region Step1:发送指令,系统清除
|
|
|
+#region Step1:发送指令,系统清除
|
|
|
if (系统清除执行ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
TestStep = TestStep_Enum.Step_SysClear;
|
|
@@ -1095,8 +1107,46 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "不执行系统清除" + "\r\n";
|
|
|
label_Sta_Clear.BackColor = Color.Yellow;
|
|
|
label_Sta_Clear.Text = "N/A";
|
|
|
+
|
|
|
+ //发送复位指令,等待电机复位
|
|
|
+ label_Step.Text = "系统复位,请等待!";
|
|
|
+ richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送系统复位指令" + "\r\n";
|
|
|
+ Array.Clear(Code, 0, 32);
|
|
|
+ Code[0] = (byte)'R';
|
|
|
+ Code[1] = (byte)'E';
|
|
|
+ Code[2] = (byte)'S';
|
|
|
+ Code[3] = (byte)'E';
|
|
|
+ Code[4] = (byte)'T';
|
|
|
+ SendCmd((ushort)0x751, (byte)0x16, (ushort)0x2505, Code);
|
|
|
+ Ack_Flag = false;
|
|
|
+ Ack_Cnt = 0;
|
|
|
+ StepTestFlag = StepTestResult_Enum.StepTestResult_Testing;
|
|
|
+ while (StepTestFlag == StepTestResult_Enum.StepTestResult_Testing) ;//等待测试结束
|
|
|
+ if (StepTestFlag == StepTestResult_Enum.StepTestResult_OK)//成功
|
|
|
+ {
|
|
|
+ richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "系统复位成功" + "\r\n";
|
|
|
+ }
|
|
|
+ else//失败
|
|
|
+ {
|
|
|
+ label_Step.Text = "系统复位失败,测试结束!";
|
|
|
+ richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "系统复位失败,测试结束" + "\r\n";
|
|
|
+ button_Start.Enabled = true;
|
|
|
+ //关机
|
|
|
+ Code[0] = 0xF0;
|
|
|
+ SendCmd(0x7FF, 0x16, 0x2201, Code);
|
|
|
+ 开ToolStripMenuItem.Checked = false;
|
|
|
+ 关ToolStripMenuItem.Checked = true;
|
|
|
+ Delay_ms(500);
|
|
|
+ //关闭串口
|
|
|
+ portsettings_form.closePort();
|
|
|
+ //存储测试数据
|
|
|
+ ErrorSaveLog();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //系统复位后会重启,等待1s
|
|
|
+ Delay_ms(1000);
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
//初始化助力档位为OFF,避免配置无仪表时默认为SMART,导致参数不保存
|
|
|
do
|
|
@@ -1133,11 +1183,11 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
- #region Step2:发送指令,依次写入参数
|
|
|
+#region Step2:发送指令,依次写入参数
|
|
|
TestStep = TestStep_Enum.Step_Write;
|
|
|
label_Step.Text = "参数写入中,请等待!";
|
|
|
|
|
|
- #region Step2.1:写入电机型号和序列号
|
|
|
+#region Step2.1:写入电机型号和序列号
|
|
|
string Mode = textBox_PDinfo.Text.Contains("%#") ? textBox_PDinfo.Text.Substring(0, textBox_PDinfo.Text.LastIndexOf('%'))
|
|
|
: textBox_PDinfo.Text.Substring(0, textBox_PDinfo.Text.LastIndexOf(' ')).Trim();
|
|
|
string SN = textBox_PDinfo.Text.Contains("%#") ? textBox_PDinfo.Text.Remove(0, textBox_PDinfo.Text.LastIndexOf('#') + 1)
|
|
@@ -1224,9 +1274,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
ErrorSaveLog();
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step2.2:写入用户参数1
|
|
|
+#region Step2.2:写入用户参数1
|
|
|
Delay_ms(200);
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "写入用户参数1" + "\r\n";
|
|
|
Array.Clear(Code, 0, 32);
|
|
@@ -1322,9 +1372,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step2.3:写入用户参数2
|
|
|
+#region Step2.3:写入用户参数2
|
|
|
Delay_ms(200);
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "写入用户参数2" + "\r\n";
|
|
|
Array.Clear(Code, 0, 32);
|
|
@@ -1370,9 +1420,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
ErrorSaveLog();
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step2.4:写入马达参数
|
|
|
+#region Step2.4:写入马达参数
|
|
|
Delay_ms(200);
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "写入马达参数" + "\r\n";
|
|
|
Array.Clear(Code, 0, 32);
|
|
@@ -1429,9 +1479,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step2.5:写入生产信息
|
|
|
+#region Step2.5:写入生产信息
|
|
|
Delay_ms(200);
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "写入生产信息" + "\r\n";
|
|
|
Array.Clear(Code, 0, 32);
|
|
@@ -1476,9 +1526,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
ErrorSaveLog();
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step2.6:写入校验密钥
|
|
|
+#region Step2.6:写入校验密钥
|
|
|
Delay_ms(200);
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "写入校验密钥" + "\r\n";
|
|
|
Array.Clear(Code, 0, 32);
|
|
@@ -1520,9 +1570,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
ErrorSaveLog();
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step2.7:写入自定义信息1、2、3
|
|
|
+#region Step2.7:写入自定义信息1、2、3
|
|
|
//自定义信息1
|
|
|
Delay_ms(200);
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "写入自定义信息1" + "\r\n";
|
|
@@ -1649,17 +1699,17 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
ErrorSaveLog();
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
//参数写入完成
|
|
|
label_Sta_Write.BackColor = Color.Green;
|
|
|
label_Sta_Write.Text = "OK";
|
|
|
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
if (推行测试执行ToolStripMenuItem.Checked == true)
|
|
|
{
|
|
|
- #region Step3:灯电压测试
|
|
|
+#region Step3:灯电压测试
|
|
|
TestStep = TestStep_Enum.Step_Light;
|
|
|
label_Step.Text = "灯电压测试,请确认电压!";
|
|
|
button_LightCtl.Text = "开灯";
|
|
@@ -1710,9 +1760,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "灯电压确认完成" + "\r\n";
|
|
|
button_LightCtl.Text = "关灯";
|
|
|
LightProcess();
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step4:推行测试
|
|
|
+#region Step4:推行测试
|
|
|
TestStep = TestStep_Enum.Step_Walk;
|
|
|
//判断母线电压
|
|
|
label_Step.Text = "母线电压检测!";
|
|
@@ -2213,9 +2263,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
label_BMS_COM.Text = "N/A";
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step5:转把模式测试(非必需)
|
|
|
+#region Step5:转把模式测试(非必需)
|
|
|
if (GasModeTest == false)
|
|
|
{
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "跳过指拨模式测试" + "\r\n";
|
|
@@ -2285,7 +2335,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2318,7 +2368,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
label_BMS_COM.Text = "N/A";
|
|
|
}
|
|
|
|
|
|
- #region Step6:版本查询和确认
|
|
|
+#region Step6:版本查询和确认
|
|
|
TestStep = TestStep_Enum.Step_CheckVer;
|
|
|
label_Step.Text = "版本查询和确认";
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送指令查询版本信息" + "\r\n";
|
|
@@ -2406,15 +2456,15 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
ErrorSaveLog();
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region 按照产品信息设置测试文件路径
|
|
|
+#region 按照产品信息设置测试文件路径
|
|
|
ResultPathName = textBox_PDinfo.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_");
|
|
|
if (System.IO.Directory.Exists(LogSavePath + "log\\" + DateTime.Now.ToString("yyyy-MM-dd").Replace("/", "-") + "\\" + ResultPathName) == false)
|
|
|
System.IO.Directory.CreateDirectory(LogSavePath + "log\\" + DateTime.Now.ToString("yyyy-MM-dd").Replace("/", "-") + "\\" + ResultPathName);
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region Step7:参数查询和保存
|
|
|
+#region Step7:参数查询和保存
|
|
|
TestStep = TestStep_Enum.Step_Save;
|
|
|
label_Step.Text = "参数导出";
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "开始导出电机内部参数" + "\r\n";
|
|
@@ -2568,7 +2618,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
Delay_ms(100);
|
|
|
|
|
|
richTextBox_TestRecord.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "电机参数导出完成" + "\r\n";
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
//检查是否有故障
|
|
|
if (label_error_code.Text != "OK")
|
|
@@ -2733,7 +2783,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- #region 检查配置文件
|
|
|
+#region 检查配置文件
|
|
|
if (comboBox_File.Items.Count == 0) //配置文件目录为空
|
|
|
{
|
|
|
label_Step.Text = "无可用配置文件!";
|
|
@@ -2745,9 +2795,9 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
label_Step.Text = "请选择配置文件!";
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
- #region 检查产品信息是否符合格式要求
|
|
|
+#region 检查产品信息是否符合格式要求
|
|
|
try
|
|
|
{
|
|
|
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]$");
|
|
@@ -2786,7 +2836,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
label_Step.ForeColor = Color.Red;
|
|
|
return;
|
|
|
}
|
|
|
- #endregion
|
|
|
+#endregion
|
|
|
|
|
|
//连接串口
|
|
|
if (portsettings_form.openPort() == false)
|
|
@@ -2945,7 +2995,7 @@ namespace MOTINOVA_Motor_Factory_Set
|
|
|
label_SerialNum.Text = "0";
|
|
|
label_OK_Count.Text = "0";
|
|
|
//存储
|
|
|
- string cfg_file = System.IO.Directory.GetCurrentDirectory() + "\\SerialNum";
|
|
|
+ string cfg_file = System.IO.Directory.GetCurrentDirectory() + "\\TestSerialNum";
|
|
|
StreamReader objReader = new StreamReader(cfg_file);
|
|
|
string sLine = "";
|
|
|
ArrayList arrText = new ArrayList();//创建一个动态数组
|