|
@@ -23,6 +23,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
private List<MachineStateModel> machineStateResumeModels = new List<MachineStateModel>();
|
|
|
|
|
|
public string IsExitState { get; set; }
|
|
|
+ public bool IsReadyCode { get; set; }
|
|
|
|
|
|
public FXMachine(string machieID) : base(machieID)
|
|
|
{
|
|
@@ -73,7 +74,6 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
else
|
|
|
{
|
|
|
|
|
|
-
|
|
|
MachineStateModel machineStateResumeModel = new MachineStateModel();
|
|
|
machineStateResumeModel.StateCode = "停止标志位";
|
|
|
machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
|
|
@@ -101,42 +101,42 @@ 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 (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.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 (e.ChangeType == DateTimeChangeType.SecondChanged & e.TimeFlag.Second % 15 == 0)
|
|
|
{
|
|
|
if (machineStateResumeModels.Count > 0)
|
|
@@ -157,30 +157,37 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
|
|
|
protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
|
|
|
{
|
|
|
+
|
|
|
base.RegReadValueChanged(sender, e);
|
|
|
+ var reg= (RegInfo)sender;
|
|
|
if (!IsOpenTime)
|
|
|
{
|
|
|
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);
|
|
|
- }
|
|
|
-
|
|
|
+ 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 == "换模标志位" ||
|
|
@@ -284,15 +291,15 @@ 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);
|
|
|
- //}
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|