From c2c4bb6ff92c85b5f9da1422cade8af355405404 Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期二, 14 七月 2020 18:10:46 +0800 Subject: [PATCH] 测量结果 界面设计开发 --- src/Bro.M071.Process/M071Process_MotionCard.cs | 156 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 127 insertions(+), 29 deletions(-) diff --git a/src/Bro.M071.Process/M071Process_MotionCard.cs b/src/Bro.M071.Process/M071Process_MotionCard.cs index 62fd994..2821708 100644 --- a/src/Bro.M071.Process/M071Process_MotionCard.cs +++ b/src/Bro.M071.Process/M071Process_MotionCard.cs @@ -26,6 +26,9 @@ get => machineState; set { + if (machineState == value) + return; + machineState = value; switch (machineState) @@ -40,9 +43,10 @@ Task.Run(() => { - lock (machineStateLock) + + while (MachineState == MachineState.Ready) { - while (MachineState == MachineState.Ready) + lock (machineStateLock) { SwitchLightGreen(true); Thread.Sleep(1000); @@ -79,9 +83,9 @@ } Task.Run(() => { - lock (machineStateLock) + while (MachineState == MachineState.Pause) { - while (MachineState == MachineState.Pause) + lock (machineStateLock) { SwitchLightYellow(true); SwitchLightGreen(true); @@ -102,10 +106,11 @@ } Task.Run(() => { - lock (machineStateLock) + while (MachineState == MachineState.Resetting) { - while (MachineState == MachineState.Resetting) + lock (machineStateLock) { + SwitchLightYellow(true); Thread.Sleep(1000); SwitchLightYellow(false); @@ -185,6 +190,16 @@ } } + [ProcessMethod("MotionCardBase", "GotoReadyPosition", "杩愬姩鍒伴澶囦綅缃�", InvokeType.TestInvoke)] + public ProcessResponse GotoReadyPosition(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) + { + MotionCardDefaultRun("GotoReadyPosition", ref opConfig, ref invokeDevice); + + LogAsync(DateTime.Now, "杩愬姩鍒伴澶囦綅缃畬鎴�", ""); + + return new ProcessResponse(true); + } + [ProcessMethod("MotionCardBase", "Reset", "绠�鍗曞浣嶆搷浣�", InvokeType.TestInvoke)] public ProcessResponse Reset(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) { @@ -206,28 +221,45 @@ // } //} - if (IsSafetyBeamTrigged || IsSafetyDoorTrigged) - { - LogAsync(DateTime.Now, $"{(IsSafetyDoorTrigged ? "瀹夊叏闂�" : "")}{(IsSafetyBeamTrigged ? " 瀹夊叏鍏夌嚎" : "")}瑙﹀彂涓紝澶嶄綅澶辫触", ""); - return new ProcessResponse(false); - } - - MotionCardDefaultRun("Reset", ref opConfig, ref invokeDevice); - //(invokeDevice as IMotionCard).Reset(); - - RaisedAlarm(""); - MachineState = MachineState.Ready; - if (ResetTimer == null) { ResetTimer = new Timer(FullReset, null, -1, -1); } - if (opConfig.InputPara.Count > 0) + if (opConfig?.InputPara != null && opConfig.InputPara.Count > 0) { //澶у浣嶄俊鍙� - ResetTimer.Change(-1, opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1); + ResetTimer.Change(opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1, -1); + + if (opConfig.InputPara[0] == 0) + return new ProcessResponse(true); } + + if (!IsAllowedWork) + { + LogAsync(DateTime.Now, $"{SafetyMsg}锛屽浣嶅け璐�", ""); + return new ProcessResponse(false); + } + + MotionCardDefaultRun("Reset", ref opConfig, ref invokeDevice); + (invokeDevice as MotionCardBase).ResetAlarm(); + + RaisedAlarm(""); + MachineState = MachineState.Ready; + + if (IsEmergencyStopped) + { + RaisedAlarm("鎬ュ仠鎸夐挳鏈仮澶嶏紝璇锋墽琛屽ぇ澶嶄綅"); + MachineState = MachineState.Alarm; + } + + + + //if (opConfig.InputPara?.Count > 0) + //{ + // //澶у浣嶄俊鍙� + // ResetTimer.Change(-1, opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1); + //} //if (invokeDevice is MotionCardBase motionCard) //{ @@ -251,7 +283,8 @@ } } - [ProcessMethod("MotionCardOperationConfigCollection", "FullReset", "澶у浣嶆搷浣�", InvokeType.TestInvoke)] + //[ProcessMethod("MotionCardOperationConfigCollection", "FullReset", "澶у浣嶆搷浣�", InvokeType.TestInvoke)] + [ProcessMethod("MotionCardBase", "FullReset", "澶у浣嶆搷浣�", InvokeType.TestInvoke)] public ProcessResponse FullReset(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) { //if (opConfig == null) @@ -276,6 +309,7 @@ //{ // motionCard.Run(opConfig); //} + MachineState = MachineState.Resetting; MotionCardDefaultRun("FullReset", ref opConfig, ref invokeDevice); @@ -284,8 +318,14 @@ OnFullResetDone?.Invoke(); + isFullResetCovered = true; + LogAsync(DateTime.Now, "澶у浣嶅姩浣滃畬鎴�", ""); + + RaisedAlarm(""); MachineState = MachineState.Ready; + + GotoReadyPosition(null, null, null); return new ProcessResponse(true); } @@ -302,7 +342,7 @@ }; MachineState _machineStateBeforePause = MachineState.Unknown; List<MachineState> _statesAllowPause = new List<MachineState>() { MachineState.Running, MachineState.Ready, MachineState.Pause }; - [ProcessMethod("", "PauseJob", "鏆傚仠娴佺▼", InvokeType.TestInvoke)] + [ProcessMethod("", "SwitchJobStatus", "娴佺▼鐘舵�佸垏鎹�", InvokeType.TestInvoke)] public ProcessResponse SwitchJobStatus(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) { if (!_statesAllowPause.Contains(MachineState)) @@ -318,9 +358,17 @@ throw new ProcessException("鏈幏鍙栨澘鍗¤澶�"); bool? isToPause = null; //true 鏆傚仠 false 缁х画 - if (opConfig.InputPara != null && opConfig.InputPara.Count > 0) + //if (opConfig.InputPara != null && opConfig.InputPara.Count > 0) + //{ + // isToPause = opConfig.InputPara[0] == 1; + //} + if (opConfig.InputPara[0] == 10) { - isToPause = opConfig.InputPara[0] == 1; + isToPause = false; + } + else if (opConfig.InputPara[0] == 11) + { + isToPause = true; } if (isToPause == null) @@ -328,7 +376,7 @@ if (!_pauseHandle.WaitResult) { #region 鏉垮崱鏆傚仠鍔ㄤ綔 - motionDevice.StateChange(DeviceState.DSPause); + motionDevice.SetImmediatePause(); #endregion _pauseHandle.WaitHandle.Reset(); @@ -339,7 +387,7 @@ else if (!_pauseHandle.WaitResult) { #region 鏉垮崱鎭㈠鍔ㄤ綔 - motionDevice.StateChange(DeviceState.DSOpen); + motionDevice.ResetImmediatePause(); #endregion _pauseHandle.WaitHandle.Set(); @@ -354,7 +402,7 @@ if (!_pauseHandle.WaitResult) { #region 鏉垮崱鏆傚仠鍔ㄤ綔 - motionDevice.StateChange(DeviceState.DSPause); + motionDevice.SetImmediatePause(); #endregion _pauseHandle.WaitHandle.Reset(); @@ -367,7 +415,7 @@ if (!_pauseHandle.WaitResult) { #region 鏉垮崱鎭㈠鍔ㄤ綔 - motionDevice.StateChange(DeviceState.DSOpen); + motionDevice.ResetImmediatePause(); #endregion _pauseHandle.WaitHandle.Set(); @@ -553,7 +601,7 @@ private void MotionCardDefaultRun(string methodCode, ref IOperationConfig opConfig, ref IDevice invokeDevice) { IMonitorSet monitorSet = null; - if (opConfig == null) + if (opConfig == null || !(opConfig is MotionCardOperationConfigBase)) { monitorSet = Config.MonitorSetCollection.FirstOrDefault(u => u.MethodCode == methodCode); if (monitorSet == null) @@ -579,6 +627,15 @@ throw new ProcessException($"{motionCard.Name}寮傚父锛寋response.Message}", null, ExceptionLevel.Fatal); } } + } + + bool IsAllowedWork + { + get => !(IsSafetyBeamTrigged || IsSafetyDoorTrigged || IsEmergencyStopped); + } + string SafetyMsg + { + get => $"{(IsSafetyBeamTrigged ? "瀹夊叏鍏夊箷" : "")}{(IsSafetyDoorTrigged ? " 瀹夊叏闂�" : "")}{(IsEmergencyStopped ? " 鎬ュ仠鎸夐挳" : "")}瑙﹀彂涓�"; } #region 瀹夊叏闂� & 瀹夊叏鍏夌嚎 @@ -616,6 +673,9 @@ [ProcessMethod("", "SafetyBeamSignal", "瀹夊叏鍏夊箷淇″彿鐩戞帶锛屾甯窸N锛孫FF鏃舵姤璀�", InvokeType.TestInvoke)] public ProcessResponse SafetyBeamSignal(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) { + if (MachineState != MachineState.Running && MachineState != MachineState.Alarm) + return new ProcessResponse(true); + if (opConfig.InputPara == null || opConfig.InputPara.Count == 0) throw new ProcessException("瀹夊叏鍏夊箷鐩戞帶鏈厤缃緭鍏ヤ俊鍙�"); @@ -630,5 +690,43 @@ return new ProcessResponse(true); } #endregion + + #region 鎬ュ仠 + bool isEmergencyStopped = false; + bool isFullResetCovered = true; + public bool IsEmergencyStopped + { + get => isEmergencyStopped && isFullResetCovered; + set + { + if (value) + { + isFullResetCovered = false; + isEmergencyStopped = true; + } + else + { + isEmergencyStopped = false; + } + } + } + + [ProcessMethod("", "EmergencyStop", "鎬ュ仠鎸夐挳琚媿涓�", InvokeType.TestInvoke)] + public ProcessResponse EmergencyStop(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) + { + if (opConfig.InputPara == null || opConfig.InputPara.Count == 0) + throw new ProcessException("鎬ュ仠鎸夐挳鏈厤缃緭鍏ヤ俊鍙�"); + + IsEmergencyStopped = opConfig.InputPara[0] == 0; + + if (IsEmergencyStopped) + { + RaisedAlarm("鎬ュ仠鎸夐挳琚媿涓�"); + MachineState = MachineState.Alarm; + } + + return new ProcessResponse(true); + } + #endregion } } -- Gitblit v1.8.0