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