浏览代码

优化离线使用逻辑。

Dail 2 年之前
父节点
当前提交
2716b049f7

二进制
.vs/Welling_Motor_Debug_Tool/v17/.suo


+ 29 - 40
Welling_Motor_Debug_Tool/Form1.Designer.cs

@@ -404,7 +404,6 @@ namespace Welling_Motor_Debug_Tool
             this.label43 = new System.Windows.Forms.Label();
             this.label44 = new System.Windows.Forms.Label();
             this.label45 = new System.Windows.Forms.Label();
-            this.label46 = new System.Windows.Forms.Label();
             this.pictureBox2 = new System.Windows.Forms.PictureBox();
             this.label96 = new System.Windows.Forms.Label();
             this.label_Server_ComStatus = new System.Windows.Forms.Label();
@@ -489,7 +488,7 @@ namespace Welling_Motor_Debug_Tool
             // 刷新ToolStripMenuItem
             // 
             this.刷新ToolStripMenuItem.Name = "刷新ToolStripMenuItem";
-            this.刷新ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.刷新ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
             this.刷新ToolStripMenuItem.Text = "刷新";
             this.刷新ToolStripMenuItem.Click += new System.EventHandler(this.刷新ToolStripMenuItem_Click);
             // 
@@ -498,7 +497,7 @@ namespace Welling_Motor_Debug_Tool
             this.端口号ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripComboBox_ComNum});
             this.端口号ToolStripMenuItem.Name = "端口号ToolStripMenuItem";
-            this.端口号ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.端口号ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
             this.端口号ToolStripMenuItem.Text = "端口号";
             this.端口号ToolStripMenuItem.Click += new System.EventHandler(this.ConfigFileSave_Click);
             // 
@@ -516,7 +515,7 @@ namespace Welling_Motor_Debug_Tool
             this.波特率ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripComboBox_Baudrate});
             this.波特率ToolStripMenuItem.Name = "波特率ToolStripMenuItem";
-            this.波特率ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.波特率ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
             this.波特率ToolStripMenuItem.Text = "波特率";
             // 
             // toolStripComboBox_Baudrate
@@ -535,14 +534,14 @@ namespace Welling_Motor_Debug_Tool
             // 连接ToolStripMenuItem
             // 
             this.连接ToolStripMenuItem.Name = "连接ToolStripMenuItem";
-            this.连接ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.连接ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
             this.连接ToolStripMenuItem.Text = "连接";
             this.连接ToolStripMenuItem.Click += new System.EventHandler(this.连接ToolStripMenuItem_Click);
             // 
             // toolStripSeparator1
             // 
             this.toolStripSeparator1.Name = "toolStripSeparator1";
-            this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
+            this.toolStripSeparator1.Size = new System.Drawing.Size(157, 6);
             // 
             // 其它配置项ToolStripMenuItem
             // 
@@ -551,7 +550,7 @@ namespace Welling_Motor_Debug_Tool
             this.断开关机ToolStripMenuItem,
             this.识别通讯盒ToolStripMenuItem});
             this.其它配置项ToolStripMenuItem.Name = "其它配置项ToolStripMenuItem";
-            this.其它配置项ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.其它配置项ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
             this.其它配置项ToolStripMenuItem.Text = "其它配置项";
             // 
             // 连接开机ToolStripMenuItem
@@ -615,14 +614,14 @@ namespace Welling_Motor_Debug_Tool
             this.允许ToolStripMenuItem.Checked = true;
             this.允许ToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
             this.允许ToolStripMenuItem.Name = "允许ToolStripMenuItem";
-            this.允许ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.允许ToolStripMenuItem.Size = new System.Drawing.Size(128, 26);
             this.允许ToolStripMenuItem.Text = "允许";
             this.允许ToolStripMenuItem.Click += new System.EventHandler(this.允许ToolStripMenuItem_Click);
             // 
             // 不允许ToolStripMenuItem
             // 
             this.不允许ToolStripMenuItem.Name = "不允许ToolStripMenuItem";
-            this.不允许ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.不允许ToolStripMenuItem.Size = new System.Drawing.Size(128, 26);
             this.不允许ToolStripMenuItem.Text = "不允许";
             this.不允许ToolStripMenuItem.Click += new System.EventHandler(this.不允许ToolStripMenuItem_Click);
             // 
@@ -643,7 +642,7 @@ namespace Welling_Motor_Debug_Tool
             this.IP地址ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripTextBox_ServerIP});
             this.IP地址ToolStripMenuItem.Name = "IP地址ToolStripMenuItem";
-            this.IP地址ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.IP地址ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.IP地址ToolStripMenuItem.Text = "IP地址";
             // 
             // toolStripTextBox_ServerIP
@@ -659,7 +658,7 @@ namespace Welling_Motor_Debug_Tool
             this.端口ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripTextBox_ServerPort});
             this.端口ToolStripMenuItem.Name = "端口ToolStripMenuItem";
-            this.端口ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.端口ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.端口ToolStripMenuItem.Text = "端口";
             // 
             // toolStripTextBox_ServerPort
@@ -675,7 +674,7 @@ namespace Welling_Motor_Debug_Tool
             this.用户名ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripTextBox_ServerUser});
             this.用户名ToolStripMenuItem.Name = "用户名ToolStripMenuItem";
-            this.用户名ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.用户名ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.用户名ToolStripMenuItem.Text = "用户名";
             // 
             // toolStripTextBox_ServerUser
@@ -691,7 +690,7 @@ namespace Welling_Motor_Debug_Tool
             this.密码ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripTextBox_ServerPasswd});
             this.密码ToolStripMenuItem.Name = "密码ToolStripMenuItem";
-            this.密码ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.密码ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.密码ToolStripMenuItem.Text = "密码";
             // 
             // toolStripTextBox_ServerPasswd
@@ -707,7 +706,7 @@ namespace Welling_Motor_Debug_Tool
             this.存储路径ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripTextBox_ServerPath});
             this.存储路径ToolStripMenuItem.Name = "存储路径ToolStripMenuItem";
-            this.存储路径ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.存储路径ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.存储路径ToolStripMenuItem.Text = "存储路径";
             // 
             // toolStripTextBox_ServerPath
@@ -733,21 +732,21 @@ namespace Welling_Motor_Debug_Tool
             // 运行信息记录ToolStripMenuItem
             // 
             this.运行信息记录ToolStripMenuItem.Name = "运行信息记录ToolStripMenuItem";
-            this.运行信息记录ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.运行信息记录ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
             this.运行信息记录ToolStripMenuItem.Text = "运行信息记录";
             this.运行信息记录ToolStripMenuItem.Click += new System.EventHandler(this.记录数据ToolStripMenuItem_Click);
             // 
             // 计算器ToolStripMenuItem
             // 
             this.计算器ToolStripMenuItem.Name = "计算器ToolStripMenuItem";
-            this.计算器ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.计算器ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
             this.计算器ToolStripMenuItem.Text = "计算器";
             this.计算器ToolStripMenuItem.Click += new System.EventHandler(this.计算器ToolStripMenuItem_Click);
             // 
             // 页面保存ToolStripMenuItem
             // 
             this.页面保存ToolStripMenuItem.Name = "页面保存ToolStripMenuItem";
-            this.页面保存ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.页面保存ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
             this.页面保存ToolStripMenuItem.Text = "页面保存";
             this.页面保存ToolStripMenuItem.Click += new System.EventHandler(this.页面保存ToolStripMenuItem_Click);
             // 
@@ -757,20 +756,20 @@ namespace Welling_Motor_Debug_Tool
             this.开机ToolStripMenuItem,
             this.关机ToolStripMenuItem});
             this.系统开关ToolStripMenuItem.Name = "系统开关ToolStripMenuItem";
-            this.系统开关ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.系统开关ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
             this.系统开关ToolStripMenuItem.Text = "电源控制";
             // 
             // 开机ToolStripMenuItem
             // 
             this.开机ToolStripMenuItem.Name = "开机ToolStripMenuItem";
-            this.开机ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.开机ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
             this.开机ToolStripMenuItem.Text = "开机";
             this.开机ToolStripMenuItem.Click += new System.EventHandler(this.开机ToolStripMenuItem_Click);
             // 
             // 关机ToolStripMenuItem
             // 
             this.关机ToolStripMenuItem.Name = "关机ToolStripMenuItem";
-            this.关机ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.关机ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
             this.关机ToolStripMenuItem.Text = "关机";
             this.关机ToolStripMenuItem.Click += new System.EventHandler(this.关机ToolStripMenuItem_Click);
             // 
@@ -787,13 +786,13 @@ namespace Welling_Motor_Debug_Tool
             // 帮助ToolStripMenuItem
             // 
             this.帮助ToolStripMenuItem.Name = "帮助ToolStripMenuItem";
-            this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.帮助ToolStripMenuItem.Text = "查看帮助";
             // 
             // 版本ToolStripMenuItem
             // 
             this.版本ToolStripMenuItem.Name = "版本ToolStripMenuItem";
-            this.版本ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.版本ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
             this.版本ToolStripMenuItem.Text = "版本信息";
             // 
             // statusStrip1
@@ -4396,11 +4395,11 @@ namespace Welling_Motor_Debug_Tool
             this.label_BuildTime.BackColor = System.Drawing.Color.DodgerBlue;
             this.label_BuildTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.label_BuildTime.ForeColor = System.Drawing.Color.White;
-            this.label_BuildTime.Location = new System.Drawing.Point(670, 622);
+            this.label_BuildTime.Location = new System.Drawing.Point(664, 622);
             this.label_BuildTime.Name = "label_BuildTime";
-            this.label_BuildTime.Size = new System.Drawing.Size(153, 17);
+            this.label_BuildTime.Size = new System.Drawing.Size(186, 17);
             this.label_BuildTime.TabIndex = 10;
-            this.label_BuildTime.Text = "BT:2022-05-22 14:00:00";
+            this.label_BuildTime.Text = "编译时间:2022-05-22 14:00:00";
             // 
             // label_SystemTime
             // 
@@ -4408,11 +4407,11 @@ namespace Welling_Motor_Debug_Tool
             this.label_SystemTime.BackColor = System.Drawing.Color.DodgerBlue;
             this.label_SystemTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.label_SystemTime.ForeColor = System.Drawing.Color.White;
-            this.label_SystemTime.Location = new System.Drawing.Point(837, 622);
+            this.label_SystemTime.Location = new System.Drawing.Point(858, 622);
             this.label_SystemTime.Name = "label_SystemTime";
-            this.label_SystemTime.Size = new System.Drawing.Size(153, 17);
+            this.label_SystemTime.Size = new System.Drawing.Size(162, 17);
             this.label_SystemTime.TabIndex = 11;
-            this.label_SystemTime.Text = "CT:2022-05-22 14:00:00";
+            this.label_SystemTime.Text = "当前:2022-05-22 14:00:00";
             // 
             // label_COM_Sta
             // 
@@ -4445,19 +4444,11 @@ namespace Welling_Motor_Debug_Tool
             // label45
             // 
             this.label45.BackColor = System.Drawing.Color.Silver;
-            this.label45.Location = new System.Drawing.Point(658, 623);
+            this.label45.Location = new System.Drawing.Point(654, 623);
             this.label45.Name = "label45";
             this.label45.Size = new System.Drawing.Size(1, 15);
             this.label45.TabIndex = 14;
             // 
-            // label46
-            // 
-            this.label46.BackColor = System.Drawing.Color.Silver;
-            this.label46.Location = new System.Drawing.Point(829, 623);
-            this.label46.Name = "label46";
-            this.label46.Size = new System.Drawing.Size(1, 15);
-            this.label46.TabIndex = 15;
-            // 
             // pictureBox2
             // 
             this.pictureBox2.BackColor = System.Drawing.Color.DodgerBlue;
@@ -4492,7 +4483,7 @@ namespace Welling_Motor_Debug_Tool
             // label_ServerStatus
             // 
             this.label_ServerStatus.BackColor = System.Drawing.Color.Red;
-            this.label_ServerStatus.Location = new System.Drawing.Point(633, 623);
+            this.label_ServerStatus.Location = new System.Drawing.Point(630, 623);
             this.label_ServerStatus.Name = "label_ServerStatus";
             this.label_ServerStatus.Size = new System.Drawing.Size(15, 15);
             this.label_ServerStatus.TabIndex = 19;
@@ -4516,7 +4507,6 @@ namespace Welling_Motor_Debug_Tool
             this.Controls.Add(this.label_Server_ComStatus);
             this.Controls.Add(this.label96);
             this.Controls.Add(this.pictureBox2);
-            this.Controls.Add(this.label46);
             this.Controls.Add(this.label45);
             this.Controls.Add(this.label44);
             this.Controls.Add(this.label43);
@@ -4782,7 +4772,6 @@ namespace Welling_Motor_Debug_Tool
         private Label label43;
         private Label label44;
         private Label label45;
-        private Label label46;
         private Label label47;
         private ComboBox comboBox_AssistTorque;
         private ComboBox comboBox_AssistCadence;

+ 24 - 4
Welling_Motor_Debug_Tool/Form1.cs

@@ -172,16 +172,29 @@ namespace Welling_Motor_Debug_Tool
                     myFtp.IsNetConnected = true;
                 }
                 else//服务器连接失败
-                {
+                {                                        
                     label_Server_ComStatus.Text = "网络断开";
                     label_ServerStatus.BackColor = Color.Red;
                     myFtp.IsNetConnected = false;
+                    if (允许ToolStripMenuItem.Checked == true) //离线使用
+                    {
+                        timer_1s.Enabled = false;
+                        MessageBox.Show("网络断开,离线使用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                        timer_1s.Enabled = true;
+                    }
+                    else //不允许离线使用,自动关闭 
+                    {
+                        timer_1s.Enabled = false;
+                        MessageBox.Show("网络断开,将自动关闭!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                        timer_1s.Enabled = true;
+                        this.Close();
+                    }
                 }
             }));
-            //创建定时器,定时10s检查网络
+            //创建定时器,定时30s检查网络
             System.Timers.Timer timer_CheckNet = new System.Timers.Timer();
             timer_CheckNet.Enabled = true;
-            timer_CheckNet.Interval = 10000;
+            timer_CheckNet.Interval = 30000;
             timer_CheckNet.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_CheckNet_Tick);
             timer_CheckNet.Start();
             while (true)
@@ -4024,6 +4037,12 @@ namespace Welling_Motor_Debug_Tool
             Delay_ms(200);
 #endif
 
+                //判断数据是否有效
+                if ((textBox_FacModeName.Text == "---") || (textBox_FacModeNum.Text == "--"))
+                {
+                    break;
+                }
+
                 //设置文件存储路径
                 string Save_Path = LocalPath + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\"; ;
                 string PD_PathName = textBox_FacModeName.Text + "_" + textBox_FacModeNum.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_"); ;
@@ -4144,8 +4163,9 @@ namespace Welling_Motor_Debug_Tool
             } while (false);
 
             timer_1s.Enabled = false;
-            MessageBox.Show("无效数据,读取失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            MessageBox.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             timer_1s.Enabled = true;
+            Button_FacModeSaveResult.Text = "保存数据";
         }
 
         /// <summary>

二进制
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.exe


二进制
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.pdb


二进制
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool_202308311017.exe


二进制
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.AssemblyReference.cache


二进制
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.GenerateResource.cache


二进制
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.exe


二进制
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.pdb