|
@@ -1,4 +1,5 @@
|
|
|
using NPOI.POIFS.Crypt.Dsig;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
@@ -24,7 +25,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
#region 变量定义
|
|
|
//版本号
|
|
|
- public static string Version = "2.4.1";
|
|
|
+ public static string Version = "2.5.0";
|
|
|
//串口实例
|
|
|
Serial_Process mySerialProcess = new Serial_Process();
|
|
|
string PortNumSave = "";
|
|
@@ -570,6 +571,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
tabPage_FactoryMode.Parent = null;
|
|
|
tabPage_DebugInfo.Parent = null;
|
|
|
tabPage_AngleCal.Parent = null;
|
|
|
+ tabPage_FuncSet.Parent = null;
|
|
|
//显示运行信息
|
|
|
tabPage_RunInfo.Parent = tabControl2;
|
|
|
//根据电机类型修改生产信息和电机类型
|
|
@@ -696,6 +698,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
tabPage_FactoryMode.Parent = null;
|
|
|
tabPage_DebugInfo.Parent = null;
|
|
|
tabPage_AngleCal.Parent = null;
|
|
|
+ tabPage_FuncSet.Parent = null;
|
|
|
//显示运行信息
|
|
|
tabPage_RunInfo.Parent = tabControl2;
|
|
|
//目前仅轮毂使用
|
|
@@ -894,6 +897,16 @@ namespace Welling_Motor_Debug_Tool
|
|
|
dataGridView_AngleCal.Rows[index].Cells[0].Value = i + 1;
|
|
|
}
|
|
|
dataGridView_AngleCal.AllowUserToAddRows = false;
|
|
|
+
|
|
|
+ //拓展功能表格初始化
|
|
|
+ for (int i = 0; i < 8; i++)
|
|
|
+ {
|
|
|
+ int index = dataGridView_FunSet.Rows.Add();
|
|
|
+ dataGridView_FunSet.Rows[index].Cells[0].Value = "#" + (i + 1).ToString();
|
|
|
+ }
|
|
|
+ dataGridView_FunSet.AllowUserToAddRows = false;
|
|
|
+
|
|
|
+ //窗体显示版本
|
|
|
this.Text += Version;
|
|
|
|
|
|
//检查版本,自动更新
|
|
@@ -1406,6 +1419,18 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//单次时间
|
|
|
DataTemp = (ushort)(Data[27] * 256 + Data[26]);
|
|
|
textBox_RunInfo_Trip_Time.Text = Convert.ToString(DataTemp) + " s";
|
|
|
+ //RSV1
|
|
|
+ DataTemp = (ushort)(Data[28]);
|
|
|
+ textBox_RunInfo_RSV1.Text = Convert.ToString(DataTemp);
|
|
|
+ //RSV2
|
|
|
+ DataTemp = (ushort)(Data[29]);
|
|
|
+ textBox_RunInfo_RSV2.Text = Convert.ToString(DataTemp);
|
|
|
+ //RSV3
|
|
|
+ DataTemp = (ushort)(Data[30]);
|
|
|
+ textBox_RunInfo_RSV3.Text = Convert.ToString(DataTemp);
|
|
|
+ //GearBox
|
|
|
+ DataTemp = (ushort)(Data[31]);
|
|
|
+ textBox_RunInfo_GearBox.Text = Convert.ToString(DataTemp);
|
|
|
|
|
|
//数据保存
|
|
|
RunInfoAutoSave();
|
|
@@ -2280,7 +2305,20 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
case 0xC142: //功能配置表
|
|
|
{
|
|
|
-
|
|
|
+ unchecked
|
|
|
+ {
|
|
|
+ this.Invoke((EventHandler)(delegate
|
|
|
+ {
|
|
|
+ //块编号
|
|
|
+ ushort Num = (ushort)(Data[1] * 256 + Data[0]);
|
|
|
+ comboBox_FunSet_BlockNum.SelectedIndex = Num - 1;
|
|
|
+ //显示数据
|
|
|
+ for (int i = 0; i < 64; i++)
|
|
|
+ {
|
|
|
+ dataGridView_FunSet.Rows[i / 8].Cells[i % 8 + 1].Value = Data[i + 2].ToString();
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case 0xC220: //定制编号
|
|
@@ -10566,6 +10604,135 @@ namespace Welling_Motor_Debug_Tool
|
|
|
mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x5720, UserArray);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 读取指定块拓展功能
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_FunSet_Read_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (comboBox_FunSet_BlockNum.SelectedIndex < 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("请选择块编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //清空当前内容
|
|
|
+ for (int i = 0; i < 8; i++)
|
|
|
+ for (int j = 0; j < 8; j++)
|
|
|
+ {
|
|
|
+ dataGridView_FunSet.Rows[i].Cells[j + 1].Value = "";
|
|
|
+ }
|
|
|
+ //发送读取指令
|
|
|
+ ushort Num = (ushort)(comboBox_FunSet_BlockNum.SelectedIndex + 1);
|
|
|
+ var Code = new byte[2];
|
|
|
+ Code[0] = (byte)(Num & 0xFF);
|
|
|
+ Code[1] = (byte)(Num >> 8);
|
|
|
+ mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x5402, Code);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 写入指定块或指定单元参数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void button_FunSet_Write_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (radioButton_WriteByBlock.Checked == true)
|
|
|
+ {
|
|
|
+ if (comboBox_FunSet_BlockNum.SelectedIndex < 0)
|
|
|
+ MessageBox.Show("请选择块编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //开始按块写入
|
|
|
+ ushort Num = (ushort)(comboBox_FunSet_BlockNum.SelectedIndex + 1);
|
|
|
+ var Code = new byte[66];
|
|
|
+ Code[0] = (byte)(Num & 0xFF);
|
|
|
+ Code[1] = (byte)(Num >> 8);
|
|
|
+ for (int i = 0; i < 8; i++)
|
|
|
+ for (int j = 0; j < 8; j++)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ byte Data = Convert.ToByte(dataGridView_FunSet.Rows[i].Cells[j + 1].Value);
|
|
|
+ Code[i * 8 + j + 2] = (byte)(Data & 0xFF);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ MessageBox.Show("数据格式错误或超范围!\r\n" + "单元编号:" + (i + 1).ToString() + "\r\n" + "参数:" + (j + 1).ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (MessageBox.Show("请核对块编号!\r\n" + "块编号:" + (Num).ToString(), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
|
|
+ mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x5542, Code);
|
|
|
+ else
|
|
|
+ MessageBoxTimeOut.Show("取消写入", "提示", 500, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (radioButton_WriteByUnit.Checked == true)
|
|
|
+ {
|
|
|
+ if (comboBox_FunSet_BlockNum.SelectedIndex < 0)
|
|
|
+ MessageBox.Show("请选择块编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (comboBox_FunSet_UnitNum.SelectedIndex < 0)
|
|
|
+ MessageBox.Show("请选择单元编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //开始按单元写入
|
|
|
+ ushort Num1 = (ushort)(comboBox_FunSet_BlockNum.SelectedIndex + 1);
|
|
|
+ ushort Num2 = (ushort)(comboBox_FunSet_UnitNum.SelectedIndex + 1);
|
|
|
+ var Code = new byte[12];
|
|
|
+ Code[0] = (byte)(Num1 & 0xFF);
|
|
|
+ Code[1] = (byte)(Num1 >> 8);
|
|
|
+ Code[2] = (byte)(Num2 & 0xFF);
|
|
|
+ Code[3] = (byte)(Num2 >> 8);
|
|
|
+ for (int i = 0; i < 8; i++)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ byte Data = Convert.ToByte(dataGridView_FunSet.Rows[Num2 - 1].Cells[i + 1].Value);
|
|
|
+ Code[i + 4] = (byte)(Data & 0xFF);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ MessageBox.Show("数据格式错误或超范围!\r\n" + "单元编号:" + Num2.ToString() + "\r\n" + "参数:" + (i + 1).ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (MessageBox.Show("请核对块编号和单元编号!\r\n" + "块编号:" + Num1.ToString() + "\r\n" + "单元编号:" + Num2.ToString(), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
|
|
+ mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x550C, Code);
|
|
|
+ else
|
|
|
+ MessageBoxTimeOut.Show("取消写入", "提示", 500, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("请选择写入方式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 按块写入时隐藏单元编号
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void radioButton_WriteByUnit_CheckedChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (radioButton_WriteByUnit.Checked == true)
|
|
|
+ {
|
|
|
+ label159.Visible = true;
|
|
|
+ comboBox_FunSet_UnitNum.Visible = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ label159.Visible = false;
|
|
|
+ comboBox_FunSet_UnitNum.Visible = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 打开或关闭指令窗口
|
|
|
/// </summary>
|