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