浏览代码

临时提交

谢翼翔 1 年之前
父节点
当前提交
7e5f1f335a

+ 51 - 56
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs

@@ -23,6 +23,7 @@ namespace SCADA_DAQ.Customer.Machines
         private List<MachineStateModel> machineStateResumeModels = new List<MachineStateModel>();
 
         public string IsExitState { get; set; }
+        public bool IsReadyCode { get; set; }
 
         public FXMachine(string machieID) : base(machieID)
         {
@@ -73,7 +74,6 @@ namespace SCADA_DAQ.Customer.Machines
                         else
                        {
                           
-
                             MachineStateModel machineStateResumeModel = new MachineStateModel();
                             machineStateResumeModel.StateCode = "停止标志位";
                             machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
@@ -101,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,21 +157,16 @@ namespace SCADA_DAQ.Customer.Machines
 
         protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
         {
+         
             base.RegReadValueChanged(sender, e);
+            var reg= (RegInfo)sender;
             if (!IsOpenTime)
             {
                 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);
-                    }
-                  
+                    InsertStateRecord(reg);
+                                  
+
                 }                    
          
             }
@@ -284,15 +279,15 @@ namespace SCADA_DAQ.Customer.Machines
                         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);
+                    }
 
                 }