4 Commits 552402e6a5 ... 1643758ed0

Author SHA1 Message Date
  谢翼翔 1643758ed0 临时保存 1 year ago
  谢翼翔 f7aa72941d 临时提交 1 year ago
  谢翼翔 498972112b Merge branch '45维谛技术数采一期' of http://www.imaodou.com.cn:30030/c_jack/Aliyun_EICP3.0 into 45维谛技术数采一期 1 year ago
  谢翼翔 0772619c4b 临时提交 1 year ago

+ 327 - 166
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();
@@ -30,15 +33,20 @@ namespace SCADA_DAQ.Customer.Machines
 
         public YaweiStateInfoModel RepairTime = new YaweiStateInfoModel();
 
+        public YaweiStateInfoModel AlarmTime = new YaweiStateInfoModel();
+
         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 +59,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)
@@ -92,6 +101,16 @@ namespace SCADA_DAQ.Customer.Machines
                         RepairTime.OnOrgID_Str = "";
                     }
 
+                    if (AlarmTime.OnOrgID_Str != "")
+                    {
+                        Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                        $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.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 - AlarmTime.StateOnTime_Dt)),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                        AlarmTime.OnOrgID_Str = "";
+                    }
+
 
                 }
                 else
@@ -101,92 +120,90 @@ namespace SCADA_DAQ.Customer.Machines
                         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();
-                                    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, "维修时间"));
+                            {
+                                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 (repairTime.Value == 0)
+                            }
+                            else if (repairTime.Value == 0)
+                            {
+                                if (RepairTime.OnOrgID_Str != "")
                                 {
-                                    if (RepairTime.OnOrgID_Str != "")
-                                    {
-                                       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),
-                                        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 = 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),
+                                    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 = "";
+                                }
+
 
                             }
 
                             var runTIme = this.GetListenReg("运行标志位");
-                              if (runTIme.Value == 1 &&  RepairValueRegTrue != true)
-                                {
-                                    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 (runTIme.Value == 0)
+                            if (runTIme.Value == 1 && RepairValueRegTrue != true && AlarmCode != true)
+                            {
+                                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 (runTIme.Value == 0)
+                            {
+                                if (ProgramStart.OnOrgID_Str != "")
                                 {
-                                    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 = "";
+                                    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 = "";
 
-                                    }
+                                }
 
 
-                                }
+                            }
 
                             var changeMoldTime = this.GetListenReg("换模标志位");
-                               if (changeMoldTime.Value == 0 && RepairValueRegTrue != true)
-                                {
-                                    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 (changeMoldTime.Value == 0 && RepairValueRegTrue != true && AlarmCode != true)
+                            {
+                                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 != "")
                                 {
-                                    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 = "";
-                                    }
-                                  
+                                    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("维修时间");
                             RegInfo reg = runFlag.Value == 1 ? runFlag : toolChangeFlag.Value == 0 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-                            if (reg == null)
+                            if (reg == null && AlarmCode != true)
                             {
                                 if (WaitNameStateCode != "停止标志位")
                                 {
@@ -216,18 +233,83 @@ namespace SCADA_DAQ.Customer.Machines
 
                             }
 
+                            if (AlarmCode == true && RepairValueRegTrue != true)
+                            {
+                                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));
+                                    WaitTime.OnOrgID_Str = "";
+                                    WaitNameStateCode = "";
+                                }
+                                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));
+                                    ChangeModel.OnOrgID_Str = "";
+                                }
+                                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 (AlarmTime.OnOrgID_Str == "")
+                                {
+                                    AlarmTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                                    AlarmTime.StateOnTime_Dt = DateTime.Now;
+                                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, AlarmTime.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 (AlarmTime.OnOrgID_Str != "")
+                                {
+                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.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 - AlarmTime.StateOnTime_Dt)),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                                    AlarmTime.OnOrgID_Str = "";
+                                }
+                            }
+
                         }
                         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 (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 = "停止标志位";
+                            }
+                            //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 = "停止标志位";
                         }
+
+
                     }
                 }
 
@@ -236,6 +318,7 @@ 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)
@@ -271,15 +354,13 @@ namespace SCADA_DAQ.Customer.Machines
                                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 && AlarmCode != true)
                     {
 
                         if (reg.Value == 1)
@@ -307,7 +388,7 @@ namespace SCADA_DAQ.Customer.Machines
 
                     }
 
-                    if (reg.Comment.Variable == "换模标志位" && RepairValueRegTrue == false)
+                    if (reg.Comment.Variable == "换模标志位" && RepairValueRegTrue == false && AlarmCode != true)
                     {
                         if (reg.Value == 0)
                         {
@@ -337,9 +418,9 @@ namespace SCADA_DAQ.Customer.Machines
                     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 (reg == null && AlarmCode != true)
                     {
-                        if (WaitNameStateCode != "停止标志位")
+                        if (WaitTime.OnOrgID_Str == "" & WaitNameStateCode != "停止标志位")
                         {
                             WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
                             WaitTime.StateOnTime_Dt = DateTime.Now;
@@ -347,8 +428,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 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, "停止标志位"));
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
                             WaitNameStateCode = "停止标志位";
                         }
 
@@ -367,69 +447,139 @@ namespace SCADA_DAQ.Customer.Machines
                         }
 
                     }
+                  
+
+                    if (AlarmCode == true && RepairValueRegTrue != true)
+                    {
+                        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));
+                            WaitTime.OnOrgID_Str = "";
+                            WaitNameStateCode = "";
+                        }
+                        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));
+                            ChangeModel.OnOrgID_Str = "";
+                        }
+                        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 (AlarmTime.OnOrgID_Str == "")
+                        {
+                            AlarmTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                            AlarmTime.StateOnTime_Dt = DateTime.Now;
+                            Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, AlarmTime.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 (AlarmTime.OnOrgID_Str != "")
+                        {
+                            Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                            $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.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 - AlarmTime.StateOnTime_Dt)),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                            AlarmTime.OnOrgID_Str = "";
+                        }
+                    }
+                
                 }
                 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 (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 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;
+                
+                    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 (PowerOn.OnOrgID_Str != "")
+                    if (WaitNameStateCode != "停止标志位")
                     {
-                        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 = "";
+                        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,55 +610,66 @@ 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 (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),
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                         $"{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 (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 (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));
+                    }
 
-                }
+                    if (AlarmTime.OnOrgID_Str != "")
+                    {
+                        Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                        $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.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 - AlarmTime.StateOnTime_Dt)),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+
+                    }
+                
             }
         }
 

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

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

+ 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();