Browse Source

临时保存

谢翼翔 1 year ago
parent
commit
1643758ed0

+ 63 - 64
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs

@@ -13,6 +13,7 @@ using SCADA_DAQ.Customer.Models;
 using SqlSchema.DBNames;
 using static NPOI.HSSF.Util.HSSFColor;
 using static System.Windows.Forms.AxHost;
+using Mysqlx.Crud;
 
 namespace SCADA_DAQ.Customer.Machines
 {
@@ -62,15 +63,17 @@ namespace SCADA_DAQ.Customer.Machines
                             var toolChangeFlag = this.GetListenReg("换模标志位");
                             var repairFlag = this.GetListenReg("维修时间");
                             RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-                            if (reg !=null)
+                            if (reg != null)
                             {
                                 InsertStateRecord(reg);
                             }
-                     
+
 
                         }
                         else
-                        {
+                       {
+                          
+
                             MachineStateModel machineStateResumeModel = new MachineStateModel();
                             machineStateResumeModel.StateCode = "停止标志位";
                             machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
@@ -98,42 +101,42 @@ namespace SCADA_DAQ.Customer.Machines
         {
             if (!IsOpenTime)
             {
-                if (e.ChangeType == DateTimeChangeType.DayChanged)
-                {
-                    if (BaseDevice.ConnectState == SCADA.Comm.ConnectStates.Connected)
-                    {
-                        var runFlag = this.GetListenReg("运行标志位");
-                        var stopFlag = this.GetListenReg("停止标志位");
-                        var toolChangeFlag = this.GetListenReg("换模标志位");
-                        var repairFlag = this.GetListenReg("维修时间");
-                        if (runFlag != null && stopFlag != null && toolChangeFlag != null && repairFlag != null)
-                        {
-                            RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-
-                            if (reg != null)
-                            {
-                                if (machineStateResumeModels.Count > 0)
-                                {
-                                    if (machineStateResumeModels[0].TagName == reg.Comment.Variable)
-                                    {
-                                        machineStateResumeModels[0].EndTime = DateTime.Parse(DateTime.Now.Format());
-                                        Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                            $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{machineStateResumeModels[0].StateId}'",
-                                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now.Format()),
-                                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime),
-                                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime).TotalSeconds)
-                                            );
-
-                                    }
-                                    machineStateResumeModels.Clear();
-                                }
-                                InsertStateRecord(reg);
-                            }
-
-                        }
-                    }
-
-                }
+                //if (e.ChangeType == DateTimeChangeType.DayChanged)
+                //{
+                //    if (BaseDevice.ConnectState == SCADA.Comm.ConnectStates.Connected)
+                //    {
+                //        var runFlag = this.GetListenReg("运行标志位");
+                //        var stopFlag = this.GetListenReg("停止标志位");
+                //        var toolChangeFlag = this.GetListenReg("换模标志位");
+                //        var repairFlag = this.GetListenReg("维修时间");
+                //        if (runFlag != null && stopFlag != null && toolChangeFlag != null && repairFlag != null)
+                //        {
+                //            RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
+
+                //            if (reg != null)
+                //            {
+                //                if (machineStateResumeModels.Count > 0)
+                //                {
+                //                    if (machineStateResumeModels[0].TagName == reg.Comment.Variable)
+                //                    {
+                //                        machineStateResumeModels[0].EndTime = DateTime.Parse(DateTime.Now.Format());
+                //                        Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                //                            $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{machineStateResumeModels[0].StateId}'",
+                //                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now.Format()),
+                //                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime),
+                //                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime).TotalSeconds)
+                //                            );
+
+                //                    }
+                //                    //machineStateResumeModels.Clear();
+                //                }
+                //                InsertStateRecord(reg);
+                //            }
+
+                //        }
+                //    }
+
+                //}
                 if (e.ChangeType == DateTimeChangeType.SecondChanged & e.TimeFlag.Second % 15 == 0)
                 {
                     if (machineStateResumeModels.Count > 0)
@@ -157,32 +160,27 @@ namespace SCADA_DAQ.Customer.Machines
             base.RegReadValueChanged(sender, e);
             if (!IsOpenTime)
             {
-                var runFlag = this.GetListenReg("运行标志位");
-                var stopFlag = this.GetListenReg("停止标志位");
-                var toolChangeFlag = this.GetListenReg("换模标志位");
-                var repairFlag = this.GetListenReg("维修时间");
-                if (runFlag != null && stopFlag != null && toolChangeFlag != null && repairFlag != null)
+                if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                 {
+                     var runFlag = this.GetListenReg("运行标志位");
+                    var stopFlag = this.GetListenReg("停止标志位");
+                    var toolChangeFlag = this.GetListenReg("换模标志位");
+                    var repairFlag = this.GetListenReg("维修时间");
                     RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-
                     if (reg != null)
                     {
                         InsertStateRecord(reg);
                     }
-                }
-
+                  
+                }                    
+         
             }
 
         }
 
-        protected override void ScanCompleted(object sender, EventArgs e)
-        {
-            base.ScanCompleted(sender, e);
-
-        }
-
         private void InsertStateRecord(RegInfo reg)
         {
+
             if (reg.Comment.Variable == "运行标志位" ||
                  reg.Comment.Variable == "停止标志位" ||
                   reg.Comment.Variable == "换模标志位" ||
@@ -209,6 +207,7 @@ namespace SCADA_DAQ.Customer.Machines
                     }
 
                 }
+              
                 if (reg?.OldValue != null && reg.Value == 0)
                 {
                     if (machineStateResumeModels.Count > 0)
@@ -284,17 +283,17 @@ namespace SCADA_DAQ.Customer.Machines
                         machineStateResumeModels.RemoveAt(0);
                         Log.Info($"设备名{BaseDevice.DeviceID},重连更新停止状态,记录列表有{machineStateResumeModels.Count}条数据");
                     }
-                    
-                    var runFlag = this.GetListenReg("运行标志位");
-                    var stopFlag = this.GetListenReg("停止标志位");
-                    var toolChangeFlag = this.GetListenReg("换模标志位");
-                    var repairFlag = this.GetListenReg("维修时间");
-                    RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-                    if (reg != null)
-                    {
-                        InsertStateRecord(reg);
-                    }
-                   
+
+                    //var runFlag = this.GetListenReg("运行标志位");
+                    //var stopFlag = this.GetListenReg("停止标志位");
+                    //var toolChangeFlag = this.GetListenReg("换模标志位");
+                    //var repairFlag = this.GetListenReg("维修时间");
+                    //RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
+                    //if (reg != null)
+                    //{
+                    //    InsertStateRecord(reg);
+                    //}
+
                 }
 
             }