浏览代码

临时提交

谢翼翔 1 年之前
父节点
当前提交
0a021d6b6b
共有 15 个文件被更改,包括 406 次插入157 次删除
  1. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/Img_bg2.png
  2. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/KejiBian.jpg
  3. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/SCADA2.png
  4. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/Title.png
  5. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/Title_Icon.png
  6. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/VertivBck.png
  7. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/img_bg.png
  8. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/logo.ico
  9. 282 109
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CP1HMachine.cs
  10. 103 30
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs
  11. 5 3
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.cs
  12. 1 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/ScheduleStop/DeviceScheduleStopModel.cs
  13. 1 1
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/ScheduleStop/QueryScheduleStop.cs
  14. 5 5
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmPunchingMachineEquipmentKanban.xaml.cs
  15. 9 9
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj

+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/Img_bg2.png → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/Img_bg2.png


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/KejiBian.jpg → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/KejiBian.jpg


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/SCADA2.png → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/SCADA2.png


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/Title.png → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/Title.png


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/Title_Icon.png → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/Title_Icon.png


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/VertivBck.png → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/VertivBck.png


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/img_bg.png → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/img_bg.png


+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Icon/logo.ico → skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Doc/Icon/logo.ico


+ 282 - 109
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CP1HMachine.cs

@@ -1,5 +1,6 @@
 using NPOI.SS.Formula.Functions;
 using SCADA;
+using SCADA.CommonLib;
 using SCADA.CommonLib.Data.DIL;
 using SCADA.Drive;
 using SCADA_DAQ.Customer.Models;
@@ -7,9 +8,11 @@ using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Configuration;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using static NPOI.HSSF.Util.HSSFColor;
 
 namespace SCADA_DAQ.Customer.Machines
 {
@@ -22,6 +25,13 @@ namespace SCADA_DAQ.Customer.Machines
 
         public YaweiStateInfoModel PowerOn = new YaweiStateInfoModel();
 
+        public YaweiStateInfoModel WaitTime = new YaweiStateInfoModel();
+
+        public YaweiStateInfoModel RepairTime = new YaweiStateInfoModel();
+
+        public string WaitNameStateCode { get; set; }
+        private int _MyProperty;
+
         public CP1HMachine(string machieID) : base(machieID)
         {
             Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
@@ -34,142 +44,220 @@ namespace SCADA_DAQ.Customer.Machines
 
         protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
         {
-            base.RegReadValueChanged(sender, e);
-            var reg = (RegInfo)sender;
 
-            int RepairValueRegFlag = 0;
-            int RunValueRegFlag = 0;
-            if (reg.Comment.Variable == "维修时间")
+            if (IsOpenTime == true)
             {
-                RepairValueRegFalse = reg.Value == 0;
-                RepairValueRegTrue = reg.Value == 1;
-                RepairValueRegFlag = (int)reg.Value;
-                if (reg.Value == 1)
-                {
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                WaitTime.OnOrgID_Str = "";
+                WaitNameStateCode = "";
 
-                    ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
-                    ProgramStart.StateOnTime_Dt = DateTime.Now;
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "维修时间"));
-               
-                }
-                else if (reg.Value == 0)
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                          $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
+                          new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                          new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                ChangeModel.OnOrgID_Str = "";
+
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                       $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                ProgramStart.OnOrgID_Str = "";
+
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
+                RepairTime.OnOrgID_Str = "";
+            }
+            else
+            {
+                if (!IsOpenTime)
                 {
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
-                    ProgramStart.OnOrgID_Str = "";
+                    if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+                    {
+                        base.RegReadValueChanged(sender, e);
+                        var reg = (RegInfo)sender;
 
+                        int RepairValueRegFlag = 0;
+                        if (reg.Comment.Variable == "维修时间")
+                        {
 
-                }
+                            RepairValueRegFlag = (int)reg.Value;
+                            if (reg.Value == 1)
+                            {
+                                RepairValueRegTrue = reg.Value == 1;
+                                RepairTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                                RepairTime.StateOnTime_Dt = DateTime.Now;
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, RepairTime.OnOrgID_Str),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "维修时间"));
 
-            }
+                            }
+                            else if (reg.Value == 0)
+                            {
+                                RepairValueRegFalse = reg.Value == 0;
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
+                                RepairTime.OnOrgID_Str = "";
 
 
-            if (reg.Comment.Variable == "运行标志位" && RepairValueRegFlag == 0 )
-            {
-                RunValueRegFlag = (int)reg.Value;
-                if (reg.Value == 1 && RepairValueRegFalse)
-                {
-                    ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
-                    ProgramStart.StateOnTime_Dt = DateTime.Now;
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "运行标志位"));
-                }
-                else if (reg.Value == 0 )
-                {
+                            }
 
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                        $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
-                    ProgramStart.OnOrgID_Str = "";
-                  
+                        }
 
-                }
 
-            }
+                        if (reg.Comment.Variable == "运行标志位" && RepairValueRegFalse)
+                        {
 
-            if (reg.Comment.Variable == "换模标志位" && RepairValueRegFalse)
-            {
-                if (reg.Value == 0)
-                {
-                    ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
-                    ChangeModel.StateOnTime_Dt = DateTime.Now;
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ChangeModel.OnOrgID_Str),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "换模标志位"));
-                }
-                else
-                {
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                        $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
-                    ChangeModel.OnOrgID_Str = "";
+                            if (reg.Value == 1)
+                            {
+                                ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
+                                ProgramStart.StateOnTime_Dt = DateTime.Now;
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "运行标志位"));
+                            }
+                            else if (reg.Value == 0)
+                            {
+
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                                ProgramStart.OnOrgID_Str = "";
+
+
+                            }
+
+                        }
+
+                        if (reg.Comment.Variable == "换模标志位" && RepairValueRegFalse)
+                        {
+                            if (reg.Value == 0)
+                            {
+                                ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
+                                ChangeModel.StateOnTime_Dt = DateTime.Now;
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ChangeModel.OnOrgID_Str),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "换模标志位"));
+                            }
+                            else
+                            {
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                                    //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                                ChangeModel.OnOrgID_Str = "";
+                            }
+                        }
+                        var runFlag = this.GetListenReg("运行标志位");
+                        var toolChangeFlag = this.GetListenReg("换模标志位");
+                        var repairFlag = this.GetListenReg("维修时间");
+                        reg = runFlag.Value == 1 ? runFlag : toolChangeFlag.Value == 0 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
+                        if (reg == null)
+                        {
+                            if (WaitNameStateCode != "停止标志位")
+                            {
+                                WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                                WaitTime.StateOnTime_Dt = DateTime.Now;
+                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
+                                WaitNameStateCode = "停止标志位";
+                            }
+
+                        }
+                        else
+                        {
+                            Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                                    //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                            WaitTime.OnOrgID_Str = "";
+                            WaitNameStateCode = "";
+                        }
+                    }
+                    else
+                    {
+                        WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                        WaitTime.StateOnTime_Dt = DateTime.Now;
+                        Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
+                        WaitNameStateCode = "停止标志位";
+                    }
                 }
             }
 
-            //if (reg.Comment.Variable == "故障标志位" && RepairValueRegFalse)
-            //{
-            //    if (reg.Value == 0)
-            //    {
-            //        ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
-            //        ChangeModel.StateOnTime_Dt = DateTime.Now;
-            //        Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-            //            new UpdateItem(T_Col_Name.Base_AlarmLog.AlarmId_Str, ChangeModel.OnOrgID_Str),
-            //            new UpdateItem(T_Col_Name.Base_AlarmLog.Device_Str, BaseDevice.DeviceID),
-            //            new UpdateItem(T_Col_Name.Base_AlarmLog.TriggedTime_Dt, DateTime.Now),
-            //            new UpdateItem(T_Col_Name.Base_AlarmLog.AlarmCode_Str, "故障标志位"));
-            //    }
-            //    else
-            //    {
-            //        Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-            //            $"{T_Col_Name.Base_AlarmLog.AlarmId_Str} = '{ChangeModel.OnOrgID_Str}'",
-            //            new UpdateItem(T_Col_Name.Base_AlarmLog.RecoverTime_Dt, DateTime.Now),
-            //            //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-            //            new UpdateItem(T_Col_Name.Base_AlarmLog.Duration_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
-            //        ChangeModel.OnOrgID_Str = "";
-            //    }
-            //}
+
+
         }
 
 
         public override void ConnectStateChanged(object sender, ConnectStateChangedEventArgs e)
         {
             base.ConnectStateChanged(sender, e);
-            if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+            if (!IsOpenTime)
             {
-                PowerOn.OnOrgID_Str = Guid.NewGuid().ToString();
-                Env.SqlDAL.App_Vertiv_WorkTime.Insert(
-                    new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.OrgID_Str, PowerOn.OnOrgID_Str),
-                    new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, BaseDevice.DeviceID));
-                PowerOn.StateOnTime_Dt = DateTime.Now;
-
-            }
-            else
-            {
-
-                if (PowerOn.OnOrgID_Str != "")
+                if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                 {
-                    Env.SqlDAL.App_Vertiv_WorkTime.Update($"{T_Col_Name.App_Vertiv_WorkTime.OrgID_Str} = '{PowerOn.OnOrgID_Str}'",
-                 new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.TurnOffTime_Dt, DateTime.Now),
-                 new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DurationSec_Dec, (DateTime.Now - PowerOn.StateOnTime_Dt).TotalSeconds));
-                    PowerOn.OnOrgID_Str = "";
+                    PowerOn.OnOrgID_Str = Guid.NewGuid().ToString();
+                    Env.SqlDAL.App_Vertiv_WorkTime.Insert(
+                        new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.OrgID_Str, PowerOn.OnOrgID_Str),
+                        new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, BaseDevice.DeviceID));
+                    PowerOn.StateOnTime_Dt = DateTime.Now;
+
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                             $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                             //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                    WaitTime.OnOrgID_Str = "";
+                    WaitNameStateCode = "";
                 }
+                else if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+                {
+
+                    if (PowerOn.OnOrgID_Str != "")
+                    {
+                        Env.SqlDAL.App_Vertiv_WorkTime.Update($"{T_Col_Name.App_Vertiv_WorkTime.OrgID_Str} = '{PowerOn.OnOrgID_Str}'",
+                     new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.TurnOffTime_Dt, DateTime.Now),
+                     new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DurationSec_Dec, (DateTime.Now - PowerOn.StateOnTime_Dt).TotalSeconds));
+                        PowerOn.OnOrgID_Str = "";
+                    }
 
+                    DeviceUpdate();
+
+                    WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                    WaitTime.StateOnTime_Dt = DateTime.Now;
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
+                    WaitNameStateCode = "停止标志位";
+                }
             }
+
         }
 
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
@@ -194,9 +282,94 @@ namespace SCADA_DAQ.Customer.Machines
                         new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, BaseDevice.DeviceID));
                     PowerOn.StateOnTime_Dt = DateTime.Now;
                 }
+
+
+            }
+
+
+
+            if (e.ChangeType == DateTimeChangeType.MinuteChanged)
+            {
+                if (!IsOpenTime)
+                {
+                    DeviceUpdate();
+                }
             }
         }
 
+        public void DeviceUpdate()
+        {
+            Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+
+
+            Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                      $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+
+
+            Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                   $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
+                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+
+
+            Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+            $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
+        }
+
+        public void DeviceInsert()
+        {
+            RepairTime.OnOrgID_Str = Guid.NewGuid().ToString();
+            RepairTime.StateOnTime_Dt = DateTime.Now;
+            Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, RepairTime.OnOrgID_Str),
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "维修时间"));
+
+            ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
+            ProgramStart.StateOnTime_Dt = DateTime.Now;
+            Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "运行标志位"));
+
+            ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
+            ChangeModel.StateOnTime_Dt = DateTime.Now;
+            Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ChangeModel.OnOrgID_Str),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "换模标志位"));
+
+            var runFlag = this.GetListenReg("运行标志位");
+            var toolChangeFlag = this.GetListenReg("换模标志位");
+            var repairFlag = this.GetListenReg("维修时间");
+            RegInfo reg = runFlag.Value == 1 ? runFlag : toolChangeFlag.Value == 0 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
+            if (reg == null)
+            {
+                if (WaitNameStateCode != "停止标志位")
+                {
+                    WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                    WaitTime.StateOnTime_Dt = DateTime.Now;
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
+                    WaitNameStateCode = "停止标志位";
+                }
+
+            }
+        }
         public override void Dispose()
         {
             Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged;

+ 103 - 30
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs

@@ -12,6 +12,7 @@ using System.Threading.Tasks;
 using SCADA_DAQ.Customer.Models;
 using SqlSchema.DBNames;
 using static NPOI.HSSF.Util.HSSFColor;
+using static System.Windows.Forms.AxHost;
 
 namespace SCADA_DAQ.Customer.Machines
 {
@@ -19,6 +20,9 @@ namespace SCADA_DAQ.Customer.Machines
     public class FXMachine : SampleMachine
     {
         private List<MachineStateModel> machineStateResumeModels = new List<MachineStateModel>();
+
+        public string IsExitState { get; set; }
+
         public FXMachine(string machieID) : base(machieID)
         {
             Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
@@ -41,27 +45,48 @@ namespace SCADA_DAQ.Customer.Machines
                             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.RemoveAt(0);
+                        machineStateResumeModels.RemoveAt(0);
+                        IsExitState = "计划停止";
 
                     }
 
                 }
                 else
                 {
-                    if (IsOpenTime == false )
+                    if (IsOpenTime == false)
                     {
-                        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)
+                        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);
+
+                        }
+                        else
+                        {
+                            MachineStateModel machineStateResumeModel = new MachineStateModel();
+                            machineStateResumeModel.StateCode = "停止标志位";
+                            machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
+                            machineStateResumeModel.TagName = "停止标志位";
+                            machineStateResumeModels.Add(machineStateResumeModel);
+                            Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, machineStateResumeModels[0].StateId),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, this.BaseDevice.DeviceID),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now.Format())
+                                );
+                            IsExitState = "";
                         }
-                   
-                    }
 
+                    }
 
                 }
             }
@@ -127,7 +152,11 @@ namespace SCADA_DAQ.Customer.Machines
         {
             base.RegReadValueChanged(sender, e);
             var reg = (RegInfo)sender;
-            InsertStateRecord(reg);
+            if (!IsOpenTime)
+            {
+                InsertStateRecord(reg);
+            }
+
         }
 
         protected override void ScanCompleted(object sender, EventArgs e)
@@ -145,18 +174,24 @@ namespace SCADA_DAQ.Customer.Machines
             {
                 if (reg?.Value != null && reg.Value == 1)
                 {
-                    MachineStateModel machineStateResumeModel = new MachineStateModel();
-                    machineStateResumeModels.Add(machineStateResumeModel);
-                    machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
-                    machineStateResumeModel.TagName = reg.Comment.Variable;
-                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, machineStateResumeModel.StateId),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, reg.Comment.Annotation),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, this.BaseDevice.DeviceID),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, reg.Comment.Variable),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now.Format())
-                        );
-                    log.Info($"设备名{BaseDevice.DeviceID},插入状态{reg.Comment.Variable},记录列表有{machineStateResumeModels.Count}条数据");
+                    if (IsExitState != reg.Comment.Variable)
+                    {
+                        MachineStateModel machineStateResumeModel = new MachineStateModel();
+                        machineStateResumeModel.StateCode = reg.Comment.Annotation;
+                        machineStateResumeModels.Add(machineStateResumeModel);
+                        machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
+                        machineStateResumeModel.TagName = reg.Comment.Variable;
+                        Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, machineStateResumeModel.StateId),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, reg.Comment.Annotation),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, this.BaseDevice.DeviceID),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, reg.Comment.Variable),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now.Format())
+                            );
+                        Log.Info($"设备名{BaseDevice.DeviceID},插入状态{reg.Comment.Variable},记录列表有{machineStateResumeModels.Count}条数据");
+                        IsExitState = reg.Comment.Variable;
+                    }
+
                 }
                 if (reg?.OldValue != null && reg.Value == 0)
                 {
@@ -171,7 +206,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 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)
                                 );
-                            log.Info($"设备名{BaseDevice.DeviceID},更新状态{reg.Comment.Variable},记录列表有{machineStateResumeModels.Count}条数据");
+                            Log.Info($"设备名{BaseDevice.DeviceID},更新状态{reg.Comment.Variable},记录列表有{machineStateResumeModels.Count}条数据");
                             machineStateResumeModels.RemoveAt(0);
                         }
 
@@ -184,22 +219,60 @@ namespace SCADA_DAQ.Customer.Machines
         public override void ConnectStateChanged(object sender, ConnectStateChangedEventArgs e)
         {
             base.ConnectStateChanged(sender, e);
-            if (ConnectState == SCADA.Comm.ConnectStates.UnConnect)
+            if (!IsOpenTime)
             {
-                //断线更新数据
-                if (machineStateResumeModels.Count > 0)
+                if (ConnectState != SCADA.Comm.ConnectStates.Connected)
+                {
+                    //断线更新数据
+                    if (machineStateResumeModels.Count > 0)
+                    {
+                        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.RemoveAt(0);
+                        //不写Log
+                        //Log.Info($"设备名{BaseDevice.DeviceID},断线更新状态{machineStateResumeModels[0].StateCode},记录列表有{machineStateResumeModels.Count}条数据");
+                    }
+                    //断线要清除列表
+                    //machineStateResumeModels.Clear();
+                    MachineStateModel machineStateResumeModel = new MachineStateModel();
+                    machineStateResumeModel.StateCode = "停止标志位";
+                    machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
+                    machineStateResumeModel.TagName = "停止标志位";
+                    machineStateResumeModels.Add(machineStateResumeModel);
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, machineStateResumeModels[0].StateId),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, this.BaseDevice.DeviceID),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now.Format())
+                        );
+                    IsExitState = "";
+                    Log.Info($"设备名{BaseDevice.DeviceID},断线插入停止状态,记录列表有{machineStateResumeModels.Count}条数据");
+                }
+                else if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                 {
                     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("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.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;
+                    InsertStateRecord(reg);
                 }
-                //断线要清除列表
-                //machineStateResumeModels.Clear();
+
             }
         }
 

+ 5 - 3
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.cs

@@ -75,7 +75,7 @@ namespace SCADA_DAQ.Customer.Machines
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
 
-            if ( e.ChangeType.HasFlag(DateTimeChangeType.MinuteChanged))
+            if ( e.ChangeType == DateTimeChangeType.DayChanged || e.ChangeType == DateTimeChangeType.HourChanged || e.ChangeType == DateTimeChangeType.MinuteChanged)
             {
                 var duration = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>().ToLookup(t => t.Device);
                 foreach (var item in duration)
@@ -105,11 +105,13 @@ namespace SCADA_DAQ.Customer.Machines
                                 IsOpenTime = false;
                                 var stopTimeValue = DateTime.Now;
                                 var lastTime = stopTimeValue - StartTime;
+                                var lastTimeInt = (stopTimeValue - StartTime).TotalSeconds;
                                 Env.SqlDAL.App_Vertiv_MachineInfo.Update
                                        (
                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{OrgID}'",
                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, stopTimeValue),
-                                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, lastTime)
+                                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, lastTime),
+                                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, lastTimeInt)
                                        );
                                 OrgID = null;
                              
@@ -154,7 +156,7 @@ namespace SCADA_DAQ.Customer.Machines
             //{
             //    BendOn = true;
             //}
-            //log.Debug($"{reg.RegName} Value Changed:{reg.OldValue}->{reg.Value}");
+            //Log.Debug($"{reg.RegName} Value Changed:{reg.OldValue}->{reg.Value}");
         }
 
 

+ 1 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/ScheduleStop/DeviceScheduleStopModel.cs

@@ -5,6 +5,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
 
 namespace SCADA_DAQ.Customer.Models.ScheduleStop
 {

+ 1 - 1
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/ScheduleStop/QueryScheduleStop.cs

@@ -56,7 +56,7 @@ namespace SCADA_DAQ.Customer.Models.ScheduleStop
                 }
             }
         }
-        private DateRange _CreateTime = new DateRange(Env.Schedual) { TimeInterval = DateRangeInterval.CurrentDay };
+        private DateRange _CreateTime = new DateRange(Env.Schedual) { TimeInterval = DateRangeInterval.All };
 
     }
 }

+ 5 - 5
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmPunchingMachineEquipmentKanban.xaml.cs

@@ -108,7 +108,7 @@ namespace SCADA_DAQ.Customer
             var kimFangyuanStopTime = DeviceTimeValue("金方圆数控母线冲孔机", "停止标志位");//金方圆数控母线冲孔机等待时间
             var kimFangyuanStopTimeSpan = TimeSpan.FromSeconds(Math.Round(kimFangyuanStopTime)).ToString();
 
-           var highmachineStopTime = totalTimeOfDay - highmachineRunTime - highmachineMoldTime - DevicScheduleStop("高机母线冲剪机") - highmachineArlamDouble
+           var highmachineStopTime = totalTimeOfDay - highmachineRunTime - highmachineMoldTime - DeviceTimeValue("高机母线冲剪机","计划停止时间")- highmachineArlamDouble
                + DeviceScheduleStopBetweenTime("高机母线冲剪机") + DeviceAlarmScheduleStopBetweenTime("高机母线冲剪机");//高机母线冲剪机等待时间
             var highmachineStopTimeSpan = TimeSpan.FromSeconds(Math.Round(highmachineStopTime)).ToString();
 
@@ -285,12 +285,12 @@ namespace SCADA_DAQ.Customer
         }
         public double DeviceScheduleStopBetweenTime(string deviceName)
         {
-
+            IntValue = 0;
             List<int> DeviceValue = new List<int>();
             var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
             foreach (var item in deviceScheduleStop)
             {
-
+              
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
                 var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
@@ -327,7 +327,7 @@ namespace SCADA_DAQ.Customer
 
         public double DeviceAlarmScheduleStopBetweenTime(string deviceName)
         {
-
+            DeviceAlarmIntValue = 0;
             List<int> DeviceValue = new List<int>();
             var deviceScheduleStop = DeviceAlarmScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
             foreach (var item in deviceScheduleStop)
@@ -393,7 +393,7 @@ namespace SCADA_DAQ.Customer
                     var kimFangyuanStopTime = DeviceTimeValue("金方圆数控母线冲孔机", "停止标志位");//金方圆数控母线冲孔机等待时间
                     var kimFangyuanStopTimeSpan = TimeSpan.FromSeconds(Math.Round(kimFangyuanStopTime)).ToString();
 
-                    var highmachineStopTime = totalTimeOfDay - highmachineRunTime - highmachineMoldTime - DevicScheduleStop("高机母线冲剪机") - highmachineArlamDouble
+                    var highmachineStopTime = totalTimeOfDay - highmachineRunTime - highmachineMoldTime - DeviceTimeValue("高机母线冲剪机", "计划停止时间") - highmachineArlamDouble
                         + DeviceScheduleStopBetweenTime("高机母线冲剪机") + DeviceAlarmScheduleStopBetweenTime("高机母线冲剪机");//高机母线冲剪机等待时间
                     var highmachineStopTimeSpan = TimeSpan.FromSeconds(Math.Round(highmachineStopTime)).ToString();
 

+ 9 - 9
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj

@@ -41,20 +41,20 @@
   </ItemGroup>
 
   <ItemGroup>
-    <None Remove="Customer\Icon\logo.ico" />
-    <None Remove="Customer\Icon\Title_Icon.png" />
+    <None Remove="Customer\Doc\Icon\logo.ico" />
+    <None Remove="Customer\Doc\Icon\Title_Icon.png" />
     <None Remove="Icon\Title_Icon.png" />
     <None Remove="LocalApp.zip" />
     <None Remove="QwPlatform.zip" />
   </ItemGroup>
 
   <ItemGroup>
-    <Content Include="Customer\Icon\logo.ico" />
+    <Content Include="Customer\Doc\Icon\logo.ico" />
     <Content Include="Icon\logo.ico" />
   </ItemGroup>
 
   <ItemGroup>
-    <Resource Include="Customer\Icon\Title_Icon.png">
+    <Resource Include="Customer\Doc\Icon\Title_Icon.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>
     <Resource Include="Icon\Title_Icon.png">
@@ -310,19 +310,19 @@
   </ItemGroup>
 
   <ItemGroup>
-    <None Update="Customer\Icon\img_bg.png">
+    <None Update="Customer\Doc\Icon\img_bg.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Update="Customer\Icon\Img_bg2.png">
+    <None Update="Customer\Doc\Icon\Img_bg2.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Update="Customer\Icon\KejiBian.jpg">
+    <None Update="Customer\Doc\Icon\KejiBian.jpg">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Update="Customer\Icon\Title.png">
+    <None Update="Customer\Doc\Icon\Title.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Update="Customer\Icon\VertivBck.png">
+    <None Update="Customer\Doc\Icon\VertivBck.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
     <None Update="Icon\img_bg.png">