|
@@ -32,6 +32,23 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
|
|
|
}
|
|
|
|
|
|
+ protected override void ScanCompleted(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ base.ScanCompleted(sender, e);
|
|
|
+ var runFlag = this.GetListenReg("运行标志位");
|
|
|
+ var stopFlag = this.GetListenReg("停止标志位");
|
|
|
+ var toolChangeFlag = this.GetListenReg("换模标志位");
|
|
|
+ var repairFlag = this.GetListenReg("维修时间");
|
|
|
+ var alarmFlag = GetListenReg("故障标志位");
|
|
|
+ if (runFlag.Value == 0 && stopFlag.Value == 0 && toolChangeFlag.Value == 0 && repairFlag.Value == 0 && alarmFlag.Value == 0)
|
|
|
+ {
|
|
|
+ if (ConnectState == SCADA.Comm.ConnectStates.Connected)
|
|
|
+ {
|
|
|
+ Log.Info($"设备名{BaseDevice.DeviceID},插入状态{0}");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
private void FXMachine_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
{
|
|
|
if (e.PropertyName == nameof(IsOpenTime))
|
|
@@ -59,21 +76,11 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
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);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ GetAllStateValue();
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
-
|
|
|
+ {
|
|
|
+
|
|
|
MachineStateModel machineStateResumeModel = new MachineStateModel();
|
|
|
machineStateResumeModel.StateCode = "停止标志位";
|
|
|
machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
|
|
@@ -105,35 +112,21 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
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)
|
|
|
+ if (machineStateResumeModels.Count > 0)
|
|
|
{
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
+ machineStateResumeModels[0].EndTime = DateTime.Parse(DateTime.Now.Format());
|
|
|
+ Env.SqlDAL.App_Vertiv_MachineInfo.Update(
|
|
|
+ $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{machineStateResumeModels[0].StateId}'",
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now.Format()),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime).TotalSeconds)
|
|
|
+ );
|
|
|
+ machineStateResumeModels.RemoveAt(0);
|
|
|
+ IsExitState = "";
|
|
|
}
|
|
|
+ GetAllStateValue();
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -157,41 +150,32 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
|
|
|
protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
base.RegReadValueChanged(sender, e);
|
|
|
- var reg= (RegInfo)sender;
|
|
|
+ var reg = (RegInfo)sender;
|
|
|
if (!IsOpenTime)
|
|
|
{
|
|
|
if (ConnectState == SCADA.Comm.ConnectStates.Connected)
|
|
|
{
|
|
|
InsertStateRecord(reg);
|
|
|
-
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void InsertStateRecord(RegInfo reg)
|
|
|
{
|
|
|
- var runFlag = this.GetListenReg("运行标志位");
|
|
|
- var stopFlag = this.GetListenReg("停止标志位");
|
|
|
- var toolChangeFlag = this.GetListenReg("换模标志位");
|
|
|
- var repairFlag = this.GetListenReg("维修时间");
|
|
|
- if (runFlag.Value == 0 && stopFlag.Value == 0 && toolChangeFlag.Value == 0 && repairFlag.Value == 0)
|
|
|
- {
|
|
|
- if (ConnectState == SCADA.Comm.ConnectStates.Connected)
|
|
|
- {
|
|
|
- Log.Info($"设备名{BaseDevice.DeviceID},插入状态{0}");
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
if (reg.Comment.Variable == "运行标志位" ||
|
|
|
reg.Comment.Variable == "停止标志位" ||
|
|
|
reg.Comment.Variable == "换模标志位" ||
|
|
|
- reg.Comment.Variable == "维修时间")
|
|
|
+ reg.Comment.Variable == "维修时间" ||
|
|
|
+ reg.Comment.Variable == "故障标志位")
|
|
|
+
|
|
|
{
|
|
|
if (reg?.Value != null && reg.Value == 1)
|
|
|
{
|
|
@@ -214,7 +198,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (reg?.OldValue != null && reg.Value == 0)
|
|
|
{
|
|
|
if (machineStateResumeModels.Count > 0)
|
|
@@ -228,8 +212,9 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime),
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime).TotalSeconds)
|
|
|
);
|
|
|
- Log.Info($"设备名{BaseDevice.DeviceID},更新状态{reg.Comment.Variable},记录列表有{machineStateResumeModels.Count}条数据");
|
|
|
+
|
|
|
machineStateResumeModels.RemoveAt(0);
|
|
|
+ Log.Info($"设备名{BaseDevice.DeviceID},更新状态{reg.Comment.Variable},记录列表有{machineStateResumeModels.Count}条数据");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -291,21 +276,27 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
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);
|
|
|
- }
|
|
|
+ GetAllStateValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void GetAllStateValue()
|
|
|
+ {
|
|
|
+ var runFlag = this.GetListenReg("运行标志位");
|
|
|
+ var stopFlag = this.GetListenReg("停止标志位");
|
|
|
+ var toolChangeFlag = this.GetListenReg("换模标志位");
|
|
|
+ var repairFlag = this.GetListenReg("维修时间");
|
|
|
+ var alarmFlag = GetListenReg("故障标志位");
|
|
|
+ RegInfo reg = runFlag.Value == 1 ? runFlag : stopFlag.Value == 1 ? stopFlag : toolChangeFlag.Value == 1 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : alarmFlag.Value == 1 ? alarmFlag : null;
|
|
|
+ if (reg != null)
|
|
|
+ {
|
|
|
+ InsertStateRecord(reg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged;
|