|
@@ -23,7 +23,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
#region 变量定义
|
|
|
//版本号
|
|
|
- public static string Version = "2.1.6";
|
|
|
+ public static string Version = "2.1.7";
|
|
|
//串口实例
|
|
|
Serial_Process mySerialProcess = new Serial_Process();
|
|
|
string PortNumSave = "";
|
|
@@ -131,6 +131,120 @@ namespace Welling_Motor_Debug_Tool
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region 屏幕缩放比例获取
|
|
|
+ public class PrimaryScreen
|
|
|
+ {
|
|
|
+ #region Win32 API
|
|
|
+ [DllImport("user32.dll")]
|
|
|
+ static extern IntPtr GetDC(IntPtr ptr);
|
|
|
+ [DllImport("gdi32.dll")]
|
|
|
+ static extern int GetDeviceCaps(
|
|
|
+ IntPtr hdc, // handle to DC
|
|
|
+ int nIndex // index of capability
|
|
|
+ );
|
|
|
+ [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
|
|
|
+ static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
|
|
|
+ #endregion
|
|
|
+ #region DeviceCaps常量
|
|
|
+ const int HORZRES = 8;
|
|
|
+ const int VERTRES = 10;
|
|
|
+ const int LOGPIXELSX = 88;
|
|
|
+ const int LOGPIXELSY = 90;
|
|
|
+ const int DESKTOPVERTRES = 117;
|
|
|
+ const int DESKTOPHORZRES = 118;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 属性
|
|
|
+ /// <summary>
|
|
|
+ /// 获取屏幕分辨率当前物理大小
|
|
|
+ /// </summary>
|
|
|
+ public static Size WorkingArea
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ IntPtr hdc = GetDC(IntPtr.Zero);
|
|
|
+ Size size = new Size();
|
|
|
+ size.Width = GetDeviceCaps(hdc, HORZRES);
|
|
|
+ size.Height = GetDeviceCaps(hdc, VERTRES);
|
|
|
+ ReleaseDC(IntPtr.Zero, hdc);
|
|
|
+ return size;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 当前系统DPI_X 大小 一般为96
|
|
|
+ /// </summary>
|
|
|
+ public static int DpiX
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ IntPtr hdc = GetDC(IntPtr.Zero);
|
|
|
+ int DpiX = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
+ ReleaseDC(IntPtr.Zero, hdc);
|
|
|
+ return DpiX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 当前系统DPI_Y 大小 一般为96
|
|
|
+ /// </summary>
|
|
|
+ public static int DpiY
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ IntPtr hdc = GetDC(IntPtr.Zero);
|
|
|
+ int DpiX = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
|
+ ReleaseDC(IntPtr.Zero, hdc);
|
|
|
+ return DpiX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 获取真实设置的桌面分辨率大小
|
|
|
+ /// </summary>
|
|
|
+ public static Size DESKTOP
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ IntPtr hdc = GetDC(IntPtr.Zero);
|
|
|
+ Size size = new Size();
|
|
|
+ size.Width = GetDeviceCaps(hdc, DESKTOPHORZRES);
|
|
|
+ size.Height = GetDeviceCaps(hdc, DESKTOPVERTRES);
|
|
|
+ ReleaseDC(IntPtr.Zero, hdc);
|
|
|
+ return size;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取宽度缩放百分比
|
|
|
+ /// </summary>
|
|
|
+ public static float ScaleX
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ IntPtr hdc = GetDC(IntPtr.Zero);
|
|
|
+ int t = GetDeviceCaps(hdc, DESKTOPHORZRES);
|
|
|
+ int d = GetDeviceCaps(hdc, HORZRES);
|
|
|
+ float ScaleX = (float)GetDeviceCaps(hdc, DESKTOPHORZRES) / (float)GetDeviceCaps(hdc, HORZRES);
|
|
|
+ ReleaseDC(IntPtr.Zero, hdc);
|
|
|
+ return ScaleX;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 获取高度缩放百分比
|
|
|
+ /// </summary>
|
|
|
+ public static float ScaleY
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ IntPtr hdc = GetDC(IntPtr.Zero);
|
|
|
+ float ScaleY = (float)(float)GetDeviceCaps(hdc, DESKTOPVERTRES) / (float)GetDeviceCaps(hdc, VERTRES);
|
|
|
+ ReleaseDC(IntPtr.Zero, hdc);
|
|
|
+ return ScaleY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
public mainForm()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -252,213 +366,231 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
|
|
|
//系统登录
|
|
|
- EnterForm1.ShowDialog();
|
|
|
- try
|
|
|
- {
|
|
|
- if (EnterForm1.textBox_Passwd.Text == EnterForm1.UserAccount[EnterForm1.comboBox_User.Text])//检验模式所有用户支持
|
|
|
+ do
|
|
|
+ {
|
|
|
+ EnterForm1.ShowDialog();
|
|
|
+ try
|
|
|
{
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("量产"))
|
|
|
+ if (EnterForm1.textBox_Passwd.Text == EnterForm1.UserAccount[EnterForm1.comboBox_User.Text])//检验模式所有用户支持
|
|
|
{
|
|
|
- //隐藏设置项
|
|
|
- 其它配置项ToolStripMenuItem.Visible = false;
|
|
|
- 写入存储ToolStripMenuItem.Visible = false;
|
|
|
- 离线使用ToolStripMenuItem.Visible = false;
|
|
|
- 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
- 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
- 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
- //显示生产信息
|
|
|
- 生产信息ToolStripMenuItem.Visible = true;
|
|
|
- //显示电机类型,但不可编辑
|
|
|
- 电机类型ToolStripMenuItem.Visible = true;
|
|
|
- 中置电机ToolStripMenuItem.Enabled = false;
|
|
|
- 轮毂电机ToolStripMenuItem.Enabled = false;
|
|
|
- //隐藏研发调试界面
|
|
|
- tabPage_MotorParam.Parent = null;
|
|
|
- tabPage_BikeParam.Parent = null;
|
|
|
- tabPage_ControlParam.Parent = null;
|
|
|
- tabPage_SensorParam.Parent = null;
|
|
|
- tabPage_AssistParam.Parent = null;
|
|
|
- tabPage_DebugParam.Parent = null;
|
|
|
- tabPage_RecordInfo.Parent = null;
|
|
|
- tabPage_OtherInfo.Parent = null;
|
|
|
- tabPage_OBC.Parent = null;
|
|
|
- tabPage_RAMorFLASH.Parent = null;
|
|
|
- tabPage_FactoryMode.Parent = null;
|
|
|
- tabPage_DebugInfo.Parent = null;
|
|
|
- //显示运行信息
|
|
|
- tabPage_RunInfo.Parent = tabControl2;
|
|
|
- //根据电机类型修改生产信息和电机类型
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("量产"))
|
|
|
+ {
|
|
|
+ //隐藏设置项
|
|
|
+ 其它配置项ToolStripMenuItem.Visible = false;
|
|
|
+ 写入存储ToolStripMenuItem.Visible = false;
|
|
|
+ 离线使用ToolStripMenuItem.Visible = false;
|
|
|
+ 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
+ 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
+ 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
+ //显示生产信息
|
|
|
+ 生产信息ToolStripMenuItem.Visible = true;
|
|
|
+ //显示电机类型,但不可编辑
|
|
|
+ 电机类型ToolStripMenuItem.Visible = true;
|
|
|
+ 中置电机ToolStripMenuItem.Enabled = false;
|
|
|
+ 轮毂电机ToolStripMenuItem.Enabled = false;
|
|
|
+ //隐藏研发调试界面
|
|
|
+ tabPage_MotorParam.Parent = null;
|
|
|
+ tabPage_BikeParam.Parent = null;
|
|
|
+ tabPage_ControlParam.Parent = null;
|
|
|
+ tabPage_SensorParam.Parent = null;
|
|
|
+ tabPage_AssistParam.Parent = null;
|
|
|
+ tabPage_DebugParam.Parent = null;
|
|
|
+ tabPage_RecordInfo.Parent = null;
|
|
|
+ tabPage_OtherInfo.Parent = null;
|
|
|
+ tabPage_OBC.Parent = null;
|
|
|
+ tabPage_RAMorFLASH.Parent = null;
|
|
|
+ tabPage_FactoryMode.Parent = null;
|
|
|
+ tabPage_DebugInfo.Parent = null;
|
|
|
+ //显示运行信息
|
|
|
+ tabPage_RunInfo.Parent = tabControl2;
|
|
|
+ //根据电机类型修改生产信息和电机类型
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ {
|
|
|
+ 中置电机ToolStripMenuItem.Checked = true;
|
|
|
+ 轮毂电机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("轮毂"))
|
|
|
+ {
|
|
|
+ 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
+ toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
+ toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
|
+ ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ }
|
|
|
+ //显示对应生产测试界面
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("写入"))
|
|
|
+ {
|
|
|
+ tabPage_ProductMode_Write.Parent = tabControl1;
|
|
|
+ tabPage_ProductMode_Write.Select();
|
|
|
+ tabPage_ProductMode_Read.Parent = null;
|
|
|
+ }
|
|
|
+ else if (EnterForm1.comboBox_User.Text.Contains("检验"))
|
|
|
+ {
|
|
|
+ tabPage_ProductMode_Read.Parent = tabControl1;
|
|
|
+ tabPage_ProductMode_Read.Select();
|
|
|
+ tabPage_ProductMode_Write.Parent = null;
|
|
|
+ }
|
|
|
+ //应答指令不提示
|
|
|
+ ACK_DisFlag = false;
|
|
|
+ //退出登录
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else if (EnterForm1.comboBox_User.Text == "工程参数配置")
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = true;
|
|
|
- 轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
- toolStripTextBox_MACPD.Text = "MM_MC1";
|
|
|
- toolStripTextBox_ServerPath.Text = "MIGIC_TEST";
|
|
|
- ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ //隐藏工作台内容,新建窗口完成配置
|
|
|
+ groupBox1.Visible = false;
|
|
|
+ groupBox3.Visible = false;
|
|
|
+ tabControl2.Visible = false;
|
|
|
+ //隐藏提示信息
|
|
|
+ label_StarInfo.Visible = false;
|
|
|
+ //打开参数配置框
|
|
|
+ //MessageBox.Show("开发中", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ GenerateParamsForm.ShowDialog();
|
|
|
+ System.Environment.Exit(0);
|
|
|
+ //退出登录
|
|
|
+ break;
|
|
|
}
|
|
|
- else if (EnterForm1.comboBox_User.Text.Contains("轮毂"))
|
|
|
+ else if (EnterForm1.comboBox_User.Text.Contains("样机"))
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
- 轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
- toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
- toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
|
- ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ //隐藏量产界面
|
|
|
+ tabPage_ProductMode_Read.Parent = null;
|
|
|
+ tabPage_ProductMode_Write.Parent = null;
|
|
|
+ //隐藏配置项
|
|
|
+ 其它配置项ToolStripMenuItem.Visible = false;
|
|
|
+ 离线使用ToolStripMenuItem.Visible = false;
|
|
|
+ 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
+ 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
+ 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
+ //显示生产信息
|
|
|
+ 生产信息ToolStripMenuItem.Visible = true;
|
|
|
+ //显示电机类型,但不可编辑
|
|
|
+ 电机类型ToolStripMenuItem.Visible = true;
|
|
|
+ 中置电机ToolStripMenuItem.Enabled = true;
|
|
|
+ 轮毂电机ToolStripMenuItem.Enabled = true;
|
|
|
+
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ {
|
|
|
+ 中置电机ToolStripMenuItem.Checked = true;
|
|
|
+ 轮毂电机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("轮毂"))
|
|
|
+ {
|
|
|
+ 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
+ toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
+ toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
|
+ ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ }
|
|
|
+ //退出登录
|
|
|
+ break;
|
|
|
}
|
|
|
- //显示对应生产测试界面
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("写入"))
|
|
|
+ else if (EnterForm1.comboBox_User.Text == "FCT治具测试")
|
|
|
{
|
|
|
+ //隐藏设置项
|
|
|
+ 其它配置项ToolStripMenuItem.Visible = false;
|
|
|
+ 写入存储ToolStripMenuItem.Visible = false;
|
|
|
+ 离线使用ToolStripMenuItem.Visible = false;
|
|
|
+ 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
+ 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
+ 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
+ //显示生产信息
|
|
|
+ 生产信息ToolStripMenuItem.Visible = true;
|
|
|
+ //显示电机类型,但不可编辑
|
|
|
+ 电机类型ToolStripMenuItem.Visible = true;
|
|
|
+ 中置电机ToolStripMenuItem.Enabled = true;
|
|
|
+ 轮毂电机ToolStripMenuItem.Enabled = true;
|
|
|
+ //隐藏研发调试界面
|
|
|
+ tabPage_MotorParam.Parent = null;
|
|
|
+ tabPage_BikeParam.Parent = null;
|
|
|
+ tabPage_ControlParam.Parent = null;
|
|
|
+ tabPage_SensorParam.Parent = null;
|
|
|
+ tabPage_AssistParam.Parent = null;
|
|
|
+ tabPage_DebugParam.Parent = null;
|
|
|
+ tabPage_RecordInfo.Parent = null;
|
|
|
+ tabPage_OtherInfo.Parent = null;
|
|
|
+ tabPage_OBC.Parent = null;
|
|
|
+ tabPage_RAMorFLASH.Parent = null;
|
|
|
+ tabPage_FactoryMode.Parent = null;
|
|
|
+ tabPage_DebugInfo.Parent = null;
|
|
|
+ //显示运行信息
|
|
|
+ tabPage_RunInfo.Parent = tabControl2;
|
|
|
+ //根据电机类型修改生产信息和电机类型
|
|
|
+ if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ {
|
|
|
+ 中置电机ToolStripMenuItem.Checked = true;
|
|
|
+ 轮毂电机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("轮毂"))
|
|
|
+ {
|
|
|
+ 中置电机ToolStripMenuItem.Checked = false;
|
|
|
+ 轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
+ toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
+ toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
|
+ ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ }
|
|
|
+ //显示量产测试界面
|
|
|
tabPage_ProductMode_Write.Parent = tabControl1;
|
|
|
tabPage_ProductMode_Write.Select();
|
|
|
tabPage_ProductMode_Read.Parent = null;
|
|
|
+ //允许离线使用
|
|
|
+ 允许ToolStripMenuItem.Checked = true;
|
|
|
+ 不允许ToolStripMenuItem.Checked = false;
|
|
|
+ checkBox_OffLineFacMode.Checked = true;
|
|
|
+ checkBox_OffLineFacMode.Enabled = true;
|
|
|
+ checkBox_OffLineCheckMode.Checked = true;
|
|
|
+ checkBox_OffLineCheckMode.Enabled = true;
|
|
|
+ //应答指令不提示
|
|
|
+ ACK_DisFlag = false;
|
|
|
+ //退出登录
|
|
|
+ break;
|
|
|
}
|
|
|
- else if (EnterForm1.comboBox_User.Text.Contains("检验"))
|
|
|
+ else if (EnterForm1.comboBox_User.Text == "研发调试")
|
|
|
{
|
|
|
- tabPage_ProductMode_Read.Parent = tabControl1;
|
|
|
- tabPage_ProductMode_Read.Select();
|
|
|
+ //隐藏量产界面
|
|
|
+ tabPage_ProductMode_Read.Parent = null;
|
|
|
tabPage_ProductMode_Write.Parent = null;
|
|
|
+ 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
+ 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
+ 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
+ //退出登录
|
|
|
+ break;
|
|
|
}
|
|
|
- //应答指令不提示
|
|
|
- ACK_DisFlag = false;
|
|
|
- }
|
|
|
- else if (EnterForm1.comboBox_User.Text == "工程参数配置")
|
|
|
- {
|
|
|
- //隐藏工作台内容,新建窗口完成配置
|
|
|
- groupBox1.Visible = false;
|
|
|
- groupBox3.Visible = false;
|
|
|
- tabControl2.Visible = false;
|
|
|
- //隐藏提示信息
|
|
|
- label_StarInfo.Visible = false;
|
|
|
- //打开参数配置框
|
|
|
- //MessageBox.Show("开发中", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- GenerateParamsForm.ShowDialog();
|
|
|
- System.Environment.Exit(0);
|
|
|
- }
|
|
|
- else if (EnterForm1.comboBox_User.Text.Contains("样机"))
|
|
|
- {
|
|
|
- //隐藏量产界面
|
|
|
- tabPage_ProductMode_Read.Parent = null;
|
|
|
- tabPage_ProductMode_Write.Parent = null;
|
|
|
- //隐藏配置项
|
|
|
- 其它配置项ToolStripMenuItem.Visible = false;
|
|
|
- 离线使用ToolStripMenuItem.Visible = false;
|
|
|
- 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
- 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
- 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
- //显示生产信息
|
|
|
- 生产信息ToolStripMenuItem.Visible = true;
|
|
|
- //显示电机类型,但不可编辑
|
|
|
- 电机类型ToolStripMenuItem.Visible = true;
|
|
|
- 中置电机ToolStripMenuItem.Enabled = true;
|
|
|
- 轮毂电机ToolStripMenuItem.Enabled = true;
|
|
|
-
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
- {
|
|
|
- 中置电机ToolStripMenuItem.Checked = true;
|
|
|
- 轮毂电机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("轮毂"))
|
|
|
- {
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
- 轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
- toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
- toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
|
- ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (EnterForm1.comboBox_User.Text == "FCT治具测试")
|
|
|
- {
|
|
|
- //隐藏设置项
|
|
|
- 其它配置项ToolStripMenuItem.Visible = false;
|
|
|
- 写入存储ToolStripMenuItem.Visible = false;
|
|
|
- 离线使用ToolStripMenuItem.Visible = false;
|
|
|
- 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
- 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
- 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
- //显示生产信息
|
|
|
- 生产信息ToolStripMenuItem.Visible = true;
|
|
|
- //显示电机类型,但不可编辑
|
|
|
- 电机类型ToolStripMenuItem.Visible = true;
|
|
|
- 中置电机ToolStripMenuItem.Enabled = true;
|
|
|
- 轮毂电机ToolStripMenuItem.Enabled = true;
|
|
|
- //隐藏研发调试界面
|
|
|
- tabPage_MotorParam.Parent = null;
|
|
|
- tabPage_BikeParam.Parent = null;
|
|
|
- tabPage_ControlParam.Parent = null;
|
|
|
- tabPage_SensorParam.Parent = null;
|
|
|
- tabPage_AssistParam.Parent = null;
|
|
|
- tabPage_DebugParam.Parent = null;
|
|
|
- tabPage_RecordInfo.Parent = null;
|
|
|
- tabPage_OtherInfo.Parent = null;
|
|
|
- tabPage_OBC.Parent = null;
|
|
|
- tabPage_RAMorFLASH.Parent = null;
|
|
|
- tabPage_FactoryMode.Parent = null;
|
|
|
- tabPage_DebugInfo.Parent = null;
|
|
|
- //显示运行信息
|
|
|
- tabPage_RunInfo.Parent = tabControl2;
|
|
|
- //根据电机类型修改生产信息和电机类型
|
|
|
- if (EnterForm1.comboBox_User.Text.Contains("中置"))
|
|
|
+ else if (EnterForm1.comboBox_User.Text == "管理员")
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = true;
|
|
|
- 轮毂电机ToolStripMenuItem.Checked = false;
|
|
|
- toolStripTextBox_MACPD.Text = "MM_MC1";
|
|
|
- toolStripTextBox_ServerPath.Text = "MIGIC_TEST";
|
|
|
- ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ //不隐藏任何界面
|
|
|
+ //...
|
|
|
+ //退出登录
|
|
|
+ break;
|
|
|
}
|
|
|
- else if (EnterForm1.comboBox_User.Text.Contains("轮毂"))
|
|
|
+ else
|
|
|
{
|
|
|
- 中置电机ToolStripMenuItem.Checked = false;
|
|
|
- 轮毂电机ToolStripMenuItem.Checked = true;
|
|
|
- toolStripTextBox_MACPD.Text = "GF_250_1";
|
|
|
- toolStripTextBox_ServerPath.Text = "HUB_Control_TEST";
|
|
|
- ConfigFileSave(false, localInfo.LocalPath + localInfo.ConfigFileName);
|
|
|
+ MessageBox.Show("权限不支持", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ //重新登录
|
|
|
+ continue;
|
|
|
}
|
|
|
- //显示量产测试界面
|
|
|
- tabPage_ProductMode_Write.Parent = tabControl1;
|
|
|
- tabPage_ProductMode_Write.Select();
|
|
|
- tabPage_ProductMode_Read.Parent = null;
|
|
|
- //允许离线使用
|
|
|
- 允许ToolStripMenuItem.Checked = true;
|
|
|
- 不允许ToolStripMenuItem.Checked = false;
|
|
|
- checkBox_OffLineFacMode.Checked = true;
|
|
|
- checkBox_OffLineFacMode.Enabled = true ;
|
|
|
- checkBox_OffLineCheckMode.Checked = true;
|
|
|
- checkBox_OffLineCheckMode.Enabled = true;
|
|
|
- //应答指令不提示
|
|
|
- ACK_DisFlag = false;
|
|
|
- }
|
|
|
- else if (EnterForm1.comboBox_User.Text == "研发调试")
|
|
|
- {
|
|
|
- //隐藏量产界面
|
|
|
- tabPage_ProductMode_Read.Parent = null;
|
|
|
- tabPage_ProductMode_Write.Parent = null;
|
|
|
- 判断阈值ToolStripMenuItem.Visible = false;
|
|
|
- 力矩传感器检验ToolStripMenuItem.Visible = false;
|
|
|
- 服务器配置ToolStripMenuItem.Visible = false;
|
|
|
- }
|
|
|
- else if (EnterForm1.comboBox_User.Text == "管理员")
|
|
|
- {
|
|
|
- //不隐藏任何界面
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MessageBox.Show("权限不支持", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- System.Environment.Exit(0);
|
|
|
+ MessageBox.Show("密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ //重新登录
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception)
|
|
|
{
|
|
|
- MessageBox.Show("密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
System.Environment.Exit(0);
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- MessageBox.Show("用户不存在或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- System.Environment.Exit(0);
|
|
|
- }
|
|
|
+ } while (true);
|
|
|
|
|
|
//端口自动连接
|
|
|
if ((PortNumSave != string.Empty) && (PortBaudrateSave != string.Empty)) //有数值时采用上次使用的值
|
|
@@ -489,43 +621,56 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// </summary>
|
|
|
private void NetworkCheck()
|
|
|
{
|
|
|
- //初始化第一次连接FTP服务器
|
|
|
- bool Result = myFtp.CheckFtp();
|
|
|
- if (Result == true)//服务器连接成功
|
|
|
+ //允许离线使用,直接退出
|
|
|
+ if (允许ToolStripMenuItem.Checked == true) //允许离线使用
|
|
|
{
|
|
|
- myFtp.IsNetConnected = true;
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("离线使用,不检测网络状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ return;
|
|
|
}
|
|
|
- else//服务器连接失败
|
|
|
+ //不允许离线使用,实时监测网络状态
|
|
|
+ else
|
|
|
{
|
|
|
- myFtp.IsNetConnected = false;
|
|
|
- if (允许ToolStripMenuItem.Checked == false) ///不允许离线使用,自动关闭
|
|
|
+ //初始化第一次连接FTP服务器
|
|
|
+ bool Result = myFtp.CheckFtp();
|
|
|
+ if (Result == true)//服务器连接成功
|
|
|
{
|
|
|
+ myFtp.IsNetConnected = true;
|
|
|
+ }
|
|
|
+ else//服务器连接失败
|
|
|
+ {
|
|
|
+ myFtp.IsNetConnected = false;
|
|
|
if ((EnterForm1.comboBox_User.Text != "管理员") && (EnterForm1.comboBox_User.Text != "FCT治具测试"))
|
|
|
{
|
|
|
timer_1s.Enabled = false;
|
|
|
MessageBox.Show("网络断开,将自动关闭!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
timer_1s.Enabled = true;
|
|
|
this.Close();
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
- else //离线使用
|
|
|
+
|
|
|
+ //创建定时器,定时30s检查网络
|
|
|
+ System.Timers.Timer timer_CheckNet = new System.Timers.Timer();
|
|
|
+ timer_CheckNet.Enabled = true;
|
|
|
+ timer_CheckNet.Interval = 10000;
|
|
|
+ timer_CheckNet.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_CheckNet_Tick);
|
|
|
+ timer_CheckNet.Start();
|
|
|
+ while (true)
|
|
|
{
|
|
|
- timer_1s.Enabled = false;
|
|
|
- MessageBox.Show("网络断开,离线使用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- timer_1s.Enabled = true;
|
|
|
+ Thread.Sleep(1);
|
|
|
+ if (myFtp.IsNetConnected == false)
|
|
|
+ {
|
|
|
+ label_Server_ComStatus.Text = "网络已断开";
|
|
|
+ label_ServerStatus.BackColor = Color.Red;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ label_Server_ComStatus.Text = "网络已连接";
|
|
|
+ label_ServerStatus.BackColor = Color.Green;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //创建定时器,定时30s检查网络
|
|
|
- System.Timers.Timer timer_CheckNet = new System.Timers.Timer();
|
|
|
- timer_CheckNet.Enabled = true;
|
|
|
- timer_CheckNet.Interval = 30000;
|
|
|
- timer_CheckNet.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_CheckNet_Tick);
|
|
|
- timer_CheckNet.Start();
|
|
|
- while (true)
|
|
|
- {
|
|
|
- Thread.Sleep(1);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -540,25 +685,24 @@ namespace Welling_Motor_Debug_Tool
|
|
|
if (Result == true)//服务器连接成功
|
|
|
{
|
|
|
myFtp.IsNetConnected = true;
|
|
|
+ //允许使用
|
|
|
+ groupBox1.Enabled = true;
|
|
|
+ groupBox3.Enabled = true;
|
|
|
+ tabControl2.Enabled = true;
|
|
|
}
|
|
|
else//服务器连接失败
|
|
|
{
|
|
|
myFtp.IsNetConnected = false;
|
|
|
- if (允许ToolStripMenuItem.Checked == false) ///不允许离线使用,自动关闭
|
|
|
- {
|
|
|
- if ((EnterForm1.comboBox_User.Text != "管理员") && (EnterForm1.comboBox_User.Text != "FCT治具测试"))
|
|
|
- {
|
|
|
- timer_1s.Enabled = false;
|
|
|
- MessageBox.Show("网络断开,将自动关闭!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
- timer_1s.Enabled = true;
|
|
|
- System.Environment.Exit(0);
|
|
|
- }
|
|
|
- }
|
|
|
- else //离线使用
|
|
|
+ if ((EnterForm1.comboBox_User.Text != "管理员") && (EnterForm1.comboBox_User.Text != "FCT治具测试"))
|
|
|
{
|
|
|
timer_1s.Enabled = false;
|
|
|
- MessageBox.Show("网络断开,离线使用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ MessageBox.Show("网络断开, 请检查网络!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
timer_1s.Enabled = true;
|
|
|
+ //禁止使用
|
|
|
+ groupBox1.Enabled = false;
|
|
|
+ groupBox3.Enabled = false;
|
|
|
+ tabControl2.Enabled = false;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2141,22 +2285,6 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//写入参数等待计时
|
|
|
ACK_WaitCnt++;
|
|
|
|
|
|
- //更新网络状态
|
|
|
- if (myFtp.IsNetConnected == true)
|
|
|
- {
|
|
|
- label_Server_ComStatus.Text = "网络已连接";
|
|
|
- label_ServerStatus.BackColor = Color.Green;
|
|
|
- label_Server_ComStatus.Text= "网络已连接";
|
|
|
- label_ServerStatus.BackColor = Color.Green;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- label_Server_ComStatus.Text = "网络已断开";
|
|
|
- label_ServerStatus.BackColor = Color.Red;
|
|
|
- label_Server_ComStatus.Text = "网络已断开";
|
|
|
- label_ServerStatus.BackColor = Color.Red;
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -4228,9 +4356,13 @@ namespace Welling_Motor_Debug_Tool
|
|
|
|
|
|
//保存页面
|
|
|
string PIC_SaveFileName = "";
|
|
|
- Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
|
|
|
+ Double scaleX = PrimaryScreen.ScaleX;
|
|
|
+ Double scaleY = PrimaryScreen.ScaleY;
|
|
|
+
|
|
|
+ //保存页面
|
|
|
+ Bitmap bit = new Bitmap((int)(this.Width * scaleX), (int)(this.Height * scaleY));//实例化一个和窗体一样大的bitmap
|
|
|
Graphics g = Graphics.FromImage(bit);
|
|
|
- g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片
|
|
|
+ g.CopyFromScreen((int)(this.Left * scaleX), (int)(this.Top * scaleY), 0, 0, new Size((int)(this.Width * scaleX), (int)(this.Height * scaleY)));//保存整个窗体为图片
|
|
|
PIC_SaveFileName = Save_Path + "\\" + textBox_FacModeName.Text + "_" + textBox_FacModeNum.Text + "_测试页面" + ".png";
|
|
|
bit.Save(PIC_SaveFileName);
|
|
|
|
|
@@ -4370,10 +4502,13 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// <param name="e"></param>
|
|
|
private void 页面保存ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
+ Double scaleX = PrimaryScreen.ScaleX;
|
|
|
+ Double scaleY = PrimaryScreen.ScaleY;
|
|
|
+
|
|
|
//保存页面
|
|
|
- Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
|
|
|
+ Bitmap bit = new Bitmap((int)(this.Width * scaleX), (int)(this.Height * scaleY));//实例化一个和窗体一样大的bitmap
|
|
|
Graphics g = Graphics.FromImage(bit);
|
|
|
- g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片
|
|
|
+ g.CopyFromScreen((int)(this.Left * scaleX), (int)(this.Top * scaleY), 0, 0, new Size((int)(this.Width * scaleX), (int)(this.Height * scaleY)));//保存整个窗体为图片
|
|
|
SaveFileDialog sf = new SaveFileDialog();
|
|
|
sf.Title = "页面保存";
|
|
|
sf.FileName = "MotorInfo_" + textBox_FacModeName.Text + "_" + textBox_FacModeNum.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_") + ".png";
|
|
@@ -5341,9 +5476,11 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Directory.CreateDirectory(LogSavePath);
|
|
|
}
|
|
|
//测试页面
|
|
|
- Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
|
|
|
+ Double scaleX = PrimaryScreen.ScaleX;
|
|
|
+ Double scaleY = PrimaryScreen.ScaleY;
|
|
|
+ Bitmap bit = new Bitmap((int)(this.Width * scaleX), (int)(this.Height * scaleY));//实例化一个和窗体一样大的bitmap
|
|
|
Graphics g = Graphics.FromImage(bit);
|
|
|
- g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片
|
|
|
+ g.CopyFromScreen((int)(this.Left * scaleX), (int)(this.Top * scaleY), 0, 0, new Size((int)(this.Width * scaleX), (int)(this.Height * scaleY)));//保存整个窗体为图片
|
|
|
LogSaveFileName = LogSavePath + "\\" + ProductInfo + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_测试页面" + ".png";
|
|
|
bit.Save(LogSaveFileName);
|
|
|
//上传测试页面到服务器
|
|
@@ -5395,6 +5532,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
richTextBox_FacModeLog.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "服务器断开" + "\r\n";
|
|
|
}
|
|
|
|
|
|
+ //扫码框清空
|
|
|
+ textBox_FacModeScan.Text = "";
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -6676,9 +6815,11 @@ namespace Welling_Motor_Debug_Tool
|
|
|
Directory.CreateDirectory(LogSavePath);
|
|
|
}
|
|
|
//测试页面
|
|
|
- Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
|
|
|
+ Double scaleX = PrimaryScreen.ScaleX;
|
|
|
+ Double scaleY = PrimaryScreen.ScaleY;
|
|
|
+ Bitmap bit = new Bitmap((int)(this.Width * scaleX), (int)(this.Height * scaleY));//实例化一个和窗体一样大的bitmap
|
|
|
Graphics g = Graphics.FromImage(bit);
|
|
|
- g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片
|
|
|
+ g.CopyFromScreen((int)(this.Left * scaleX), (int)(this.Top * scaleY), 0, 0, new Size((int)(this.Width * scaleX), (int)(this.Height * scaleY)));//保存整个窗体为图片
|
|
|
LogSaveFileName = LogSavePath + "\\" + ProductInfo + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_测试页面" + ".png";
|
|
|
bit.Save(LogSaveFileName);
|
|
|
//上传测试页面到服务器
|
|
@@ -6722,6 +6863,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
richTextBox_CheckModeLog.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "测试记录上传服务器成功" + "\r\n";
|
|
|
}
|
|
|
|
|
|
+ //扫码框清空
|
|
|
+ textBox_CheckModeScan.Text = "";
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -7599,5 +7742,64 @@ namespace Welling_Motor_Debug_Tool
|
|
|
MessageBox.Show("数据填写不完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 测试模式点击文本框自动全选
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void textBox_FacModeScan_MouseClick(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ textBox_FacModeScan.SelectAll();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 检验模式点击文本框自动全选
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void textBox_CheckModeScan_MouseClick(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ textBox_CheckModeScan.SelectAll();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 鼠标放置显示连接服务器信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void label_ServerStatus_MouseHover(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ // 创建the ToolTip
|
|
|
+ ToolTip toolTip1 = new ToolTip();
|
|
|
+
|
|
|
+ // 设置显示样式
|
|
|
+ toolTip1.AutoPopDelay = 30000;//提示信息的可见时间
|
|
|
+ toolTip1.InitialDelay = 50;//事件触发多久后出现提示
|
|
|
+ toolTip1.ReshowDelay = 50;//指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框
|
|
|
+ toolTip1.ShowAlways = true;//是否显示提示框
|
|
|
+
|
|
|
+ if (myFtp.IsNetConnected)
|
|
|
+ {
|
|
|
+ toolTip1.SetToolTip(this.label_ServerStatus, "IP: " + toolStripTextBox_ServerIP.Text);//设置故障内容显示
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ toolTip1.SetToolTip(this.label_ServerStatus, "网络断开");//设置故障内容显示
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// UART协议类型修改
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void 协议类型ToolStripMenuItem_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ var Code = new byte[2];
|
|
|
+ Code[0] = (byte)协议类型ToolStripMenuItem.SelectedIndex;
|
|
|
+ Code[1] = 0x00;
|
|
|
+ mySerialProcess.SendCmd((ushort)0x7FF, (byte)0x16, (ushort)0x7702, Code);
|
|
|
+ }
|
|
|
}
|
|
|
}
|