浏览代码

临时提交

谢翼翔 1 年之前
父节点
当前提交
0772619c4b

+ 253 - 231
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CP1HMachine.cs

@@ -4,6 +4,7 @@ using SCADA.CommonLib;
 using SCADA.CommonLib.Data.DIL;
 using SCADA.Drive;
 using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Plugin.Machine;
 using SCADA_DAQ.Plugin.Machine.Device;
 using SqlSchema.DBNames;
 using System;
@@ -20,6 +21,8 @@ namespace SCADA_DAQ.Customer.Machines
     [DisplayName("CP1H")]
     public class CP1HMachine : SampleMachine
     {
+        public SampleMachine machine = MachineServer.GetInstance().GetMachine<SampleMachine>("高机母线冲剪机");
+
         public YaweiStateInfoModel ProgramStart = new YaweiStateInfoModel();
 
         public YaweiStateInfoModel ChangeModel = new YaweiStateInfoModel();
@@ -33,12 +36,15 @@ namespace SCADA_DAQ.Customer.Machines
         public string WaitNameStateCode { get; set; }
 
         public string OrgID { get; set; }
-        private int _MyProperty;
 
+
+        public bool AlarmCode { get; set; }
         public CP1HMachine(string machieID) : base(machieID)
         {
+
             Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
             PropertyChanged += CP1HMachine_PropertyChanged;
+
         }
 
 
@@ -51,6 +57,7 @@ namespace SCADA_DAQ.Customer.Machines
 
         private void CP1HMachine_PropertyChanged(object sender, PropertyChangedEventArgs e)
         {
+            AlarmCode = this.BaseDevice.IsAlarmed;
             if (e.PropertyName == nameof(IsOpenTime))
             {
                 if (IsOpenTime == true)
@@ -98,12 +105,14 @@ namespace SCADA_DAQ.Customer.Machines
                 {
                     if (!IsOpenTime)
                     {
-                        if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+                        if (!AlarmCode)
                         {
-                            var repairTime = this.GetListenReg("维修时间");
-                            int RepairValueRegFlag = 0;
-                            RepairValueRegFlag =(int)repairTime.Value;
-                            if (repairTime.Value == 1)
+                            if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+                            {
+                                var repairTime = this.GetListenReg("维修时间");
+                                int RepairValueRegFlag = 0;
+                                RepairValueRegFlag = (int)repairTime.Value;
+                                if (repairTime.Value == 1)
                                 {
                                     RepairValueRegTrue = true;
                                     RepairTime.OnOrgID_Str = Guid.NewGuid().ToString();
@@ -119,7 +128,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 {
                                     if (RepairTime.OnOrgID_Str != "")
                                     {
-                                       RepairValueRegTrue = false;
+                                        RepairValueRegTrue = false;
                                         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),
@@ -127,12 +136,12 @@ namespace SCADA_DAQ.Customer.Machines
                                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
                                         RepairTime.OnOrgID_Str = "";
                                     }
-                               
 
-                            }
 
-                            var runTIme = this.GetListenReg("运行标志位");
-                              if (runTIme.Value == 1 &&  RepairValueRegTrue != true)
+                                }
+
+                                var runTIme = this.GetListenReg("运行标志位");
+                                if (runTIme.Value == 1 && RepairValueRegTrue != true)
                                 {
                                     ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
                                     ProgramStart.StateOnTime_Dt = DateTime.Now;
@@ -157,8 +166,8 @@ namespace SCADA_DAQ.Customer.Machines
 
                                 }
 
-                            var changeMoldTime = this.GetListenReg("换模标志位");
-                               if (changeMoldTime.Value == 0 && RepairValueRegTrue != true)
+                                var changeMoldTime = this.GetListenReg("换模标志位");
+                                if (changeMoldTime.Value == 0 && RepairValueRegTrue != true)
                                 {
                                     ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
                                     ChangeModel.StateOnTime_Dt = DateTime.Now;
@@ -179,55 +188,57 @@ namespace SCADA_DAQ.Customer.Machines
                                       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("维修时间");
-                            RegInfo reg = runFlag.Value == 1 ? runFlag : toolChangeFlag.Value == 0 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-                            if (reg == null)
-                            {
-                                if (WaitNameStateCode != "停止标志位")
+
+                                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)
                                 {
-                                    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 (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
+                                {
+                                    if (WaitTime.OnOrgID_Str != "")
+                                    {
+                                        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 (WaitTime.OnOrgID_Str != "")
-                                {
-                                    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 = "";
-                                }
-
+                                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
-                        {
-                            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 = "停止标志位";
                         }
+
                     }
                 }
 
@@ -235,150 +246,154 @@ namespace SCADA_DAQ.Customer.Machines
         }
         protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
         {
-
+            AlarmCode = this.BaseDevice.IsAlarmed;
             if (!IsOpenTime)
             {
-                if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+                if (!AlarmCode)
                 {
-                    base.RegReadValueChanged(sender, e);
-                    var reg = (RegInfo)sender;
-                    int RepairValueRegFlag = 0;
-                    if (reg.Comment.Variable == "维修时间")
+                    if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                     {
-
-                        RepairValueRegFlag = (int)reg.Value;
-                        if (reg.Value == 1)
+                        base.RegReadValueChanged(sender, e);
+                        var reg = (RegInfo)sender;
+                        int RepairValueRegFlag = 0;
+                        if (reg.Comment.Variable == "维修时间")
                         {
-                            RepairValueRegTrue = true;
-                            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)
-                        {
-                            RepairValueRegTrue = false;
-                            if (RepairTime.OnOrgID_Str != "")
+                            RepairValueRegFlag = (int)reg.Value;
+                            if (reg.Value == 1)
                             {
-                                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 = "";
+                                RepairValueRegTrue = true;
+                                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)
+                            {
+                                RepairValueRegTrue = false;
+                                if (RepairTime.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 = "";
+                                }
+
 
 
+                            }
 
                         }
 
-                    }
 
+                        if (reg.Comment.Variable == "运行标志位" && RepairValueRegTrue == false)
+                        {
 
-                    if (reg.Comment.Variable == "运行标志位" && RepairValueRegTrue==false)
-                    {
+                            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)
+                            {
+                                if (ProgramStart.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 = "";
+                                }
+
+                            }
 
-                        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)
+
+                        if (reg.Comment.Variable == "换模标志位" && RepairValueRegTrue == false)
                         {
-                            if (ProgramStart.OnOrgID_Str != "")
+                            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 = "";
+                                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
+                            {
+                                if (ChangeModel.OnOrgID_Str != "")
+                                {
+                                    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.Comment.Variable == "换模标志位" && RepairValueRegTrue == false)
-                    {
-                        if (reg.Value == 0)
+                        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)
                         {
-                            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, "换模标志位"));
+                            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, "停止标志位"),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"));
+                                WaitNameStateCode = "停止标志位";
+                            }
+
                         }
                         else
                         {
-                            if (ChangeModel.OnOrgID_Str != "")
+                            if (WaitTime.OnOrgID_Str != "")
                             {
                                 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 = "";
+                                  $"{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 = "";
                             }
 
                         }
                     }
-                    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, "停止标志位"),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"));
-                            WaitNameStateCode = "停止标志位";
-                        }
-
-                    }
                     else
                     {
-                        if (WaitTime.OnOrgID_Str != "")
-                        {
-                            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 = "";
-                        }
-
+                        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
-                {
-                    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 = "停止标志位";
-                }
+
             }
 
         }
@@ -387,49 +402,54 @@ namespace SCADA_DAQ.Customer.Machines
         public override void ConnectStateChanged(object sender, ConnectStateChangedEventArgs e)
         {
             base.ConnectStateChanged(sender, e);
+            AlarmCode = this.BaseDevice.IsAlarmed;
             if (!IsOpenTime)
             {
-                if (ConnectState != SCADA.Comm.ConnectStates.Connected)
-                {
-                    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;
-
-                    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, "停止标志位"),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"));
-                    WaitNameStateCode = "停止标志位";
-                    OrgID = WaitTime.OnOrgID_Str;
-                }
-                else if (ConnectState == SCADA.Comm.ConnectStates.Connected)
+                if (!AlarmCode)
                 {
-
-                    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;
+
+                        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, "停止标志位"),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"));
+                        WaitNameStateCode = "停止标志位";
+                        OrgID = WaitTime.OnOrgID_Str;
                     }
-
-                    if (WaitTime.OnOrgID_Str != "")
+                    else if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                     {
-                        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));
-                    }
+
+                        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 = "";
+                        }
+
+                        if (WaitTime.OnOrgID_Str != "")
+                        {
+                            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));
+                        }
 
 
+                    }
                 }
+
             }
 
         }
@@ -460,54 +480,56 @@ namespace SCADA_DAQ.Customer.Machines
 
             }
 
-
-
-            if (e.ChangeType == DateTimeChangeType.MinuteChanged)
+            if (e.ChangeType == DateTimeChangeType.SecondChanged & e.TimeFlag.Second % 15 == 0)
             {
-                if (ConnectState != SCADA.Comm.ConnectStates.Connected)
+                AlarmCode = this.BaseDevice.IsAlarmed;
+                if (!AlarmCode)
                 {
+                    if (ConnectState != SCADA.Comm.ConnectStates.Connected)
+                    {
+                        if (WaitTime.OnOrgID_Str != "")
+                        {
+                            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));
+                        }
+                    }
+
                     if (WaitTime.OnOrgID_Str != "")
                     {
                         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),
+                         $"{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));
                     }
-                }
-
-                if (WaitTime.OnOrgID_Str != "")
-                {
-                    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));
-                }
-                if (ChangeModel.OnOrgID_Str != "")
-                {
-                    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));
+                    if (ChangeModel.OnOrgID_Str != "")
+                    {
+                        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));
 
-                }
+                    }
 
-                if (ProgramStart.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));
+                    if (ProgramStart.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));
 
-                }
+                    }
 
-                if (RepairTime.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));
+                    if (RepairTime.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));
 
+                    }
                 }
             }
         }

+ 21 - 5
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs

@@ -62,7 +62,11 @@ 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;
-                            InsertStateRecord(reg);
+                            if (reg !=null)
+                            {
+                                InsertStateRecord(reg);
+                            }
+                     
 
                         }
                         else
@@ -130,7 +134,7 @@ namespace SCADA_DAQ.Customer.Machines
                     }
 
                 }
-                if (e.ChangeType == DateTimeChangeType.MinuteChanged)
+                if (e.ChangeType == DateTimeChangeType.SecondChanged & e.TimeFlag.Second % 15 == 0)
                 {
                     if (machineStateResumeModels.Count > 0)
                     {
@@ -145,16 +149,28 @@ namespace SCADA_DAQ.Customer.Machines
 
                 }
             }
-            
+
         }
 
         protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
         {
             base.RegReadValueChanged(sender, e);
-            var reg = (RegInfo)sender;
             if (!IsOpenTime)
             {
-                InsertStateRecord(reg);
+                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)
+                    {
+                        InsertStateRecord(reg);
+                    }
+                }
+
             }
 
         }

+ 3 - 4
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmKanbanForPressBrakeEquipment.xaml.cs

@@ -55,7 +55,6 @@ namespace SCADA_DAQ.Customer
             GetRepairTime();
             GetScheduleStopTime();
             GetDeviceScheduleStopBetweenTime();
-            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
             ToolBar.Visibility = Visibility.Collapsed;
             Image_Title.Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"Icon\VertivBck.png");
             LocalTime.Text = DateTime.Now.ToString("dddd yyyy年MM月dd日 HH:mm");
@@ -222,7 +221,7 @@ namespace SCADA_DAQ.Customer
             KanbanForPressBrakeEquipmentFive.DeviceNameThree.Value = baiChaoMoldTimeSpan;
             KanbanForPressBrakeEquipmentFive.DeviceNameFour.Value = baiChaoTimeMaintenanceTable;
             KanbanForPressBrakeEquipmentFive.DeviceNameFive.Value = baiChaoRepairTime;
-
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
         }
 
         public List<MachineInfoModel> deviceInformation { get; set; }
@@ -392,8 +391,8 @@ namespace SCADA_DAQ.Customer
 
             try
             {
-                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.MinuteChanged &&
-                            e.TimeFlag.Minute % 1 == 0)
+                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged &&
+                            e.TimeFlag.Second % 16 == 0)
                 {
                     GetDBData();
                     GetTableTime();

+ 10 - 10
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmLaserCNCInterface.xaml

@@ -9,15 +9,15 @@
       d:DesignHeight="1080" d:DesignWidth="1920"
       Title="UctFrmLaserCNCInterface">
     <Viewbox Stretch="Fill">
-    <Grid Width="1920" Height="1080">
-        <Grid.RowDefinitions>
-            <RowDefinition Height="60"/>
-            <RowDefinition/>
-        </Grid.RowDefinitions>
-        <Image x:Name="Image_Title" Grid.RowSpan="2" Stretch="Fill"/>
-        <TextBlock x:Name="LocalTime" Foreground="White" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,10,10,0" FontWeight="Bold"/>
-        <TextBlock Text="激光机及数冲运行信息" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="White" FontWeight="Bold" />
-             <dashboard:LaserAndDigitalPunchingEquipmentWidget Grid.Row="1"  x:Name="startRun"/>
-    </Grid>
+        <Grid Width="1920" Height="1080">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="60"/>
+                <RowDefinition/>
+            </Grid.RowDefinitions>
+            <Image x:Name="Image_Title" Grid.RowSpan="2" Stretch="Fill"/>
+            <TextBlock x:Name="LocalTime" Foreground="White" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,10,10,0" FontWeight="Bold"/>
+            <TextBlock Text="激光机及数冲运行信息" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="White" FontWeight="Bold" />
+            <dashboard:LaserAndDigitalPunchingEquipmentWidget Grid.Row="1"  x:Name="startRun"/>
+        </Grid>
     </Viewbox>
 </wpfcontrol:BaseUctFrm>

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

@@ -52,7 +52,7 @@ namespace SCADA_DAQ.Customer
             GetScheduleStopTime();
             GetDeviceAlarmTime();
             GetDeviceStopTime();
-            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
+         
             ToolBar.Visibility = Visibility.Collapsed;
             Image_Title.Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"Icon\VertivBck.png");
             PunchingMachineEquipmentKanbanOne.Title = new string[] { "高机冲孔机运行时间:",
@@ -142,7 +142,7 @@ namespace SCADA_DAQ.Customer
             PunchingMachineEquipmentKanbanTwo.DeviceNameFour.Value = kimFangyuanMoldTimeSpan;
             //PunchingMachineEquipmentKanbanTwo.DeviceNameFive.Value = kimFangyuanTimeMaintenanceTableString;
             PunchingMachineEquipmentKanbanTwo.DeviceNameFive.Value = kimFangyuanRepairTime;
-
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
         }
         public List<MachineInfoModel> deviceInformation { get; set; }
         public void GetDBData()//设备运行状态时间
@@ -248,8 +248,8 @@ namespace SCADA_DAQ.Customer
             deviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();
 
             var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
-            var classesDayEndTime = Convert.ToDateTime(DateTime.Now);
-            DistinctDeviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.StartTime >= classesYesterdayStartTime & t.EndTime <= classesDayEndTime).ToList();
+            var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+            DistinctDeviceAlarmTime =DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToList();
 
         }
         public List<DeviceScheduleStopModel> deviceStopTime { get; set; }
@@ -277,17 +277,20 @@ namespace SCADA_DAQ.Customer
                     
             var informationValue = deviceAlarmTime?.ToLookup(t => t.Device_Str)[deviceName];
             var deviceValueInformation = DistinctDeviceAlarmTime.ToLookup(t => t.Device_Str)[deviceName];
-
             var timePieces = new List<TimePiece>();
             if (deviceValueInformation.Count() != 0)
             {
                 foreach (var item in deviceValueInformation)
                 {
-                    timePieces.Add(new TimePiece
+                    if (item.StartTime < Convert.ToDateTime(DateTime.Now.ToString("00:00:00")) & item.EndTime > Convert.ToDateTime(DateTime.Now.ToString("00:00:00")))
                     {
-                        StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
-                        EndTime = item.EndTime.TimeOfDay
-                    });
+                        timePieces.Add(new TimePiece
+                        {
+                            StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
+                            EndTime = item.EndTime.TimeOfDay
+                        });
+                    }
+
                 }
 
             }
@@ -324,8 +327,8 @@ namespace SCADA_DAQ.Customer
 
             try
             {
-                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.MinuteChanged  &&
-                            e.TimeFlag.Minute % 1 == 0)
+                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged  &&
+                            e.TimeFlag.Second % 16 == 0)
                 {
                     GetDBData();
                     GetTableTime();

+ 14 - 96
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmRunHistory.xaml.cs

@@ -45,7 +45,7 @@ namespace SCADA_DAQ.Customer
         public UctFrmRunHistory()
         {
             InitializeComponent();
-            
+
             var timeListAdd = new List<List<TimePiece>>();
             var timeStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>().ToLookup(t => t.Device)["高机母线冲剪机"];
             var timeStopPieces = new List<TimePiece>();
@@ -65,21 +65,24 @@ namespace SCADA_DAQ.Customer
             var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
             var informationValue = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToLookup(t => t.Device_Str)["高机母线冲剪机"];
 
-
             var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
-            var classesDayEndTime = Convert.ToDateTime(DateTime.Now);
-            var deviceValueInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.StartTime >= classesYesterdayStartTime & t.EndTime <= classesDayEndTime).ToLookup(t => t.Device_Str)["高机母线冲剪机"];
+            var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+            var deviceValueInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToLookup(t => t.Device_Str)["高机母线冲剪机"];
 
             var timePieces = new List<TimePiece>();
-            if (deviceValueInformation.Count() !=0)
+            if (deviceValueInformation.Count() != 0)
             {
                 foreach (var item in deviceValueInformation)
                 {
-                    timePieces.Add(new TimePiece
+                    if (item.StartTime < Convert.ToDateTime(DateTime.Now.ToString("00:00:00")) & item.EndTime > Convert.ToDateTime(DateTime.Now.ToString("00:00:00")))
                     {
-                        StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
-                        EndTime = item.EndTime.TimeOfDay
-                    });
+                        timePieces.Add(new TimePiece
+                        {
+                            StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
+                            EndTime = item.EndTime.TimeOfDay
+                        });
+                    }
+
                 }
 
             }
@@ -102,7 +105,7 @@ namespace SCADA_DAQ.Customer
                           EndTime = TimeSpan.FromSeconds(DateTime.Now.ToOADate())},
                      };
             }
-        
+
 
             var total = TimeTotalHelper.DistinctPlanStopTime(TimeTotalHelper.DistinctTime(timePieces), timeStopPieces);
 
@@ -111,92 +114,7 @@ namespace SCADA_DAQ.Customer
 
     }
 
-        //class TimePiece
-        //{
-        //    public TimeSpan StartTime { get; set; }
-
-        //    public TimeSpan EndTime { get; set; }
-        //}
-
-        //class TimeTotalHelper
-        //{
-        //    public static List<TimePiece> DistinctTime(List<TimePiece> timePieces)
-        //    {
-        //        var result = new List<TimePiece>();
-
-        //        if (timePieces?.Count != null)
-        //        {
-        //            var ascTime = timePieces.OrderBy(t => t.StartTime).ToList();
-        //            result.Add(ascTime.First());
-        //            for (global::System.Int32 i = 0; i < ascTime.Count - 1; i++)
-        //            {
-        //                if (ascTime[i + 1].StartTime <= ascTime[i].EndTime)
-        //                {
-        //                    if (ascTime[i + 1].EndTime > ascTime[i].EndTime)
-        //                    {
-        //                        result.Last().EndTime = ascTime[i + 1].EndTime;
-        //                    }
-        //                }
-        //                else
-        //                {
-        //                    result.Add(ascTime[i + 1]);
-        //                }
-        //            }
-
-        //        }
-
-        //        return result;
-        //    }
-
-        //    public static TimeSpan DistinctPlanStopTime(List<TimePiece> timePieces, List<TimePiece> planStops)
-        //    {
-        //        var result = new TimeSpan();
-        //        var isInclude = false;
-        //        if (timePieces?.Count != null && planStops?.Count != null)
-        //        {
-        //            if (timePieces.Count > 0)
-        //            {
-
-        //                for (int i = 0; i < timePieces.Count; i++)
-        //                {
-        //                    isInclude = false;
-        //                    if (planStops.Count > 0)
-        //                    {
-        //                        for (int j = 0; j < planStops.Count; j++)
-        //                        {
-        //                            if ((timePieces[i].StartTime > planStops[j].StartTime && timePieces[i].StartTime < planStops[j].EndTime) ||
-        //                                    (timePieces[i].EndTime > planStops[j].StartTime && timePieces[i].EndTime < planStops[j].EndTime) ||
-        //                                        (timePieces[i].StartTime < planStops[j].StartTime && timePieces[i].EndTime > planStops[j].EndTime) ||
-        //                                            (timePieces[i].StartTime > planStops[j].StartTime && timePieces[i].EndTime < planStops[j].EndTime))
-        //                            {
-        //                                if (timePieces[i].StartTime < planStops[j].StartTime)
-        //                                {
-        //                                    result = result + (planStops[j].StartTime - timePieces[i].StartTime);
-        //                                }
-        //                                if (timePieces[i].EndTime > planStops[j].EndTime)
-        //                                {
-        //                                    result = result + (timePieces[i].EndTime - planStops[j].EndTime);
-        //                                }
-        //                                isInclude = true;
-        //                            }
-
-        //                        }
-        //                        if (!isInclude)
-        //                        {
-        //                            result = result + (timePieces[i].EndTime - timePieces[i].StartTime);
-        //                        }
-        //                    }
-        //                    else
-        //                    {
-        //                        result = result + (timePieces[i].EndTime - timePieces[i].StartTime);
-        //                    }
-        //                }
-
-        //            }
-        //        }
-        //        return result;
-        //    }
-        //}
+       
 
     }
 

+ 15 - 11
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Dashboard/LaserAndDigitalPunchingEquipmentWidget.xaml.cs

@@ -46,7 +46,6 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         public LaserAndDigitalPunchingEquipmentWidget()
         {
             InitializeComponent();
-         
             GetDBData();
             GetTableTime();
             GetScheduleStopTime();
@@ -98,7 +97,7 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             //double totalTimeOfDay = TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds;
 
             var laserStopTime = DeviceTimeValue("激光机", "停止标志位") - DevicMainTableTime("激光机").TotalSeconds;//激光机等待时间
-            var siemensStopTime = AllDeviceWorkTime("西门子840D数冲") - DevicMainTableTime("西门子840D数冲").TotalSeconds;//西门子等待时间
+            var siemensStopTime = DeviceTimeValue("西门子840D数冲","停止标志位") - DevicMainTableTime("西门子840D数冲").TotalSeconds;//西门子等待时间
             var behwiftStopTime = DeviceTimeValue("倍福数冲机", "停止标志位") - DevicMainTableTime("倍福数冲机").TotalSeconds;//倍福数冲等待时间
             //var laserStopTime = totalTimeOfDay - laserRunTime - DevicScheduleStop("激光机") - laserArlamDouble
             //     + DeviceScheduleStopBetweenTime("激光机") + DeviceAlarmScheduleStopBetweenTime("激光机");//激光机等待时间
@@ -190,6 +189,7 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             LaserMmachineOne.ChartInit(laserValue);
             SiemensNumberPunch.ChartInit(siemensValue);
             DoubleBlessingNumberRush.ChartInit(blessingValue);
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
         }
         public List<MachineInfoModel> deviceInformation { get; set; }
         public void GetDBData()//设备运行状态时间
@@ -290,8 +290,8 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             deviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();
 
             var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
-            var classesDayEndTime = Convert.ToDateTime(DateTime.Now);
-            DistinctDeviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.StartTime >= classesYesterdayStartTime & t.EndTime <= classesDayEndTime).ToList();
+            var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+            DistinctDeviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToList();
         }
         public List<DeviceScheduleStopModel> deviceStopTime { get; set; }
 
@@ -323,11 +323,15 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             {
                 foreach (var item in deviceValueInformation)
                 {
-                    timePieces.Add(new TimePiece
+                    if (item.StartTime < Convert.ToDateTime(DateTime.Now.ToString("00:00:00")) & item.EndTime > Convert.ToDateTime(DateTime.Now.ToString("00:00:00")))
                     {
-                        StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
-                        EndTime = item.EndTime.TimeOfDay
-                    });
+                        timePieces.Add(new TimePiece
+                        {
+                            StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
+                            EndTime = item.EndTime.TimeOfDay
+                        });
+                    }
+
                 }
 
             }
@@ -454,8 +458,8 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
 
             try
             {
-                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.MinuteChanged   &&
-                            e.TimeFlag.Minute % 2 == 0)
+                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged   &&
+                            e.TimeFlag.Second % 16 == 0)
 
                 {
                     GetDBData();
@@ -501,7 +505,7 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
 
 
                     var laserStopTime = DeviceTimeValue("激光机", "停止标志位") - DevicMainTableTime("激光机").TotalSeconds;//激光机等待时间
-                    var siemensStopTime = AllDeviceWorkTime("西门子840D数冲") - DevicMainTableTime("西门子840D数冲").TotalSeconds;//西门子等待时间
+                    var siemensStopTime = DeviceTimeValue("西门子840D数冲", "停止标志位") - DevicMainTableTime("西门子840D数冲").TotalSeconds;//西门子等待时间
                     var behwiftStopTime = DeviceTimeValue("倍福数冲机", "停止标志位") - DevicMainTableTime("倍福数冲机").TotalSeconds;//倍福数冲等待时间
 
 

+ 3 - 4
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Dashboard/YaweiPressBrakeOneWidget.xaml.cs

@@ -44,7 +44,6 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         public YaweiPressBrakeOneWidget()
         {
             InitializeComponent();
-            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
             GetDBData();
             GetScheduleStopTime();
             GetTableTime();
@@ -143,7 +142,7 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             YaweiPressBrakeThree.ChartInit(pressBrakeThreeValue);
             YaweiPressBrakeFour.ChartInit(pressBrakeFourValue);
             YaweiPressBrakeFive.ChartInit(pressBrakeFiveValue);
-
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
         }
         public List<MachineInfoModel> deviceInformation { get; set; }
         public void GetDBData()//设备运行状态时间
@@ -291,8 +290,8 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         {
             try
             {
-                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.MinuteChanged  &&
-                            e.TimeFlag.Minute % 1 == 0)
+                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged  &&
+                            e.TimeFlag.Second % 16 == 0)
                 {
                     GetDBData();
                     GetScheduleStopTime();