From 5bf1b91009a182188d6d2245aa71653801eea60b Mon Sep 17 00:00:00 2001 From: wells <123> Date: 星期日, 12 七月 2020 18:09:54 +0800 Subject: [PATCH] debug --- src/Bro.Device.GTSCard/GTSCardDriver.cs | 230 ++++++++++++-------- src/Bro.M071.Process/UI/M071_MainForm.cs | 190 ++++++++++------- src/Bro.Common.Device/DeviceBase/MotionCardBase.cs | 12 + src/Bro.Common.Model/Model/MonitorSet.cs | 43 ++- src/Bro.Common.Model/Model/IOItem.cs | 1 src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs | 12 src/Bro.M071.Process/M071Process_MotionCard.cs | 69 ++++- src/Bro.UI.Config/MainFrm.cs | 16 + src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs | 13 + src/Bro.Device.GTSCard/GTSCardConfig.cs | 2 src/Bro.M071.Process/M071Process.cs | 26 + src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs | 2 src/Bro.Device.Gocator/GocatorDriver.cs | 4 src/Bro.M071.Process/M071Models.cs | 4 src/Bro.M071.Process/UI/KeyIndicator.cs | 3 src/Bro.Common.Model/Model/MotionCardRelated.cs | 12 16 files changed, 405 insertions(+), 234 deletions(-) diff --git a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs index 103cc21..52e6582 100644 --- a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs +++ b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs @@ -183,6 +183,10 @@ [Editor(typeof(ComplexCollectionEditor<IODefinition>), typeof(UITypeEditor))] public List<IODefinition> IODefinitionCollection { get; set; } = new List<IODefinition>(); + [Category("IO閰嶇疆")] + [Description("true锛氳緭鍑哄彇鍙� false锛氳緭鍑轰笉鍙栧弽")] + public bool IsOutputReversed { get; set; } = true; + #region IMonitorConfig [Category("鐩戝惉璁剧疆")] [Description("MonitorSetCollection锛氱洃鍚搷浣滈厤缃泦鍚�")] @@ -306,6 +310,14 @@ [Editor(typeof(MovingOpsCollectionEditor), typeof(UITypeEditor))] public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>(); + [Category("3.杩愬姩寤舵椂")] + [Description("鎿嶄綔鍓嶅欢鏃讹紝鍗曚綅ms")] + public int DelayBefore { get; set; } = 0; + + [Category("3.杩愬姩寤舵椂")] + [Description("鎿嶄綔鍚庡欢鏃讹紝鍗曚綅ms")] + public int DelayAfter { get; set; } = 0; + public string MotionCardId = ""; //[Category("鏉垮崱杩愬姩閰嶇疆")] diff --git a/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs b/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs index d17062c..4ae9e2e 100644 --- a/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs +++ b/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs @@ -29,7 +29,7 @@ IOperationConfig backOpConfig = new OperationConfigBase(); List<IDevice> deviceList = null; IDevice currentDevice = null; - public FrmDeviceOpConfigEditor(DeviceOpBind bind) + public FrmDeviceOpConfigEditor(DeviceOpBind bind, bool isEnableSelectDevice = true) { InitializeComponent(); @@ -56,7 +56,15 @@ cboDevice.SelectedIndex = 0; } - cboDevice.SelectedIndexChanged += CboDevice_SelectedIndexChanged; + if (isEnableSelectDevice) + { + cboDevice.Enabled = true; + cboDevice.SelectedIndexChanged += CboDevice_SelectedIndexChanged; + } + else + { + cboDevice.Enabled = false; + } if (bind.OpConfig == null) { diff --git a/src/Bro.Common.Model/Model/IOItem.cs b/src/Bro.Common.Model/Model/IOItem.cs index 14a5754..5610aaf 100644 --- a/src/Bro.Common.Model/Model/IOItem.cs +++ b/src/Bro.Common.Model/Model/IOItem.cs @@ -109,6 +109,7 @@ Dictionary<IODefinition, string> itemDict = new Dictionary<IODefinition, string>(); public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { + itemDict.Clear(); if (context.Instance is IORefrenceItem item) { item.IOItemSource.ForEach(i => diff --git a/src/Bro.Common.Model/Model/MonitorSet.cs b/src/Bro.Common.Model/Model/MonitorSet.cs index 985da90..c666168 100644 --- a/src/Bro.Common.Model/Model/MonitorSet.cs +++ b/src/Bro.Common.Model/Model/MonitorSet.cs @@ -206,14 +206,14 @@ [DisplayName("瑙﹀彂鍊�")] public int TriggerValue { get; set; } = -1; - /// <summary> - /// 浼犲叆鏁版嵁鍦板潃鐨勭储寮� 鎸夌収鐩戝惉鍦板潃浠�0寮�濮嬬殑绱㈠紩闆嗗悎 - /// </summary> - [Category("鐩戝惉璁剧疆")] - [Description("浼犲叆鏁版嵁鍦板潃鐨勭储寮� 鎸夌収鐩戝惉鍦板潃浠�0寮�濮嬬殑绱㈠紩")] - [DisplayName("浼犲叆鏁版嵁绱㈠紩")] - [TypeConverter(typeof(SimpleCollectionConvert<int>))] - public List<int> InputDataIndex { get; set; } = new List<int>(); + ///// <summary> + ///// 浼犲叆鏁版嵁鍦板潃鐨勭储寮� 鎸夌収鐩戝惉鍦板潃浠�0寮�濮嬬殑绱㈠紩闆嗗悎 + ///// </summary> + //[Category("鐩戝惉璁剧疆")] + //[Description("浼犲叆鏁版嵁鍦板潃鐨勭储寮� 鎸夌収鐩戝惉鍦板潃浠�0寮�濮嬬殑绱㈠紩")] + //[DisplayName("浼犲叆鏁版嵁绱㈠紩")] + //[TypeConverter(typeof(SimpleCollectionConvert<int>))] + //public List<int> InputDataIndex { get; set; } = new List<int>(); /// <summary> /// 鐩戝惉鍥炰紶 @@ -255,18 +255,27 @@ } } - FrmOpConfigEdit frm = new FrmOpConfigEdit(ms.MethodCode, ms.Id, value as IOperationConfig) + FrmDeviceOpConfigEditor frmDeviceOpEditor = new FrmDeviceOpConfigEditor(new DeviceOpBind() { Device = ms.InvokeDevice, OpConfig = value as IOperationConfig }, false) { StartPosition = FormStartPosition.CenterScreen }; - if (frm.ShowDialog() == DialogResult.OK) - { - return frm.OpConfig; - } - else - { - return frm.BackupConfig; - } + frmDeviceOpEditor.ShowDialog(); + frmDeviceOpEditor.Bind.OpConfig.MonitorSetId = ms.Id; + frmDeviceOpEditor.Bind.OpConfig.DeviceId = ms.InvokeDevice; + + return frmDeviceOpEditor.Bind.OpConfig; + //FrmOpConfigEdit frm = new FrmOpConfigEdit(ms.MethodCode, ms.Id, value as IOperationConfig) + //{ + // StartPosition = FormStartPosition.CenterScreen + //}; + //if (frm.ShowDialog() == DialogResult.OK) + //{ + // return frm.OpConfig; + //} + //else + //{ + // return frm.BackupConfig; + //} } return base.EditValue(context, provider, value); diff --git a/src/Bro.Common.Model/Model/MotionCardRelated.cs b/src/Bro.Common.Model/Model/MotionCardRelated.cs index 7fd4136..1037012 100644 --- a/src/Bro.Common.Model/Model/MotionCardRelated.cs +++ b/src/Bro.Common.Model/Model/MotionCardRelated.cs @@ -138,12 +138,12 @@ [Category("閫熷害閰嶇疆")] [DisplayName("鍔犻�熷害")] [Description("Acc锛氬姞閫熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] - public double Acc { get; set; } = 1; + public double Acc { get; set; } = 0; [Category("閫熷害閰嶇疆")] [DisplayName("鍑忛�熷害")] [Description("鍑忛�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] - public double Dec { get; set; } = 1; + public double Dec { get; set; } = 0; } /// <summary> @@ -177,10 +177,10 @@ [Description("HighVelocity锛氶�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] public double HighVelocity { get; set; } = 50; - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鎼滅储璺濈")] - [Description("SearchHomeDistance锛氭悳绱㈣窛绂�")] - public int SearchHomeDistance { get; set; } = 9999999; + //[Category("鍥炲師鐐瑰弬鏁�")] + //[DisplayName("鎼滅储璺濈")] + //[Description("SearchHomeDistance锛氭悳绱㈣窛绂�")] + //public int SearchHomeDistance { get; set; } = 9999999; [Category("鍥炲師鐐瑰弬鏁�")] [DisplayName("鍋忕Щ璺濈")] diff --git a/src/Bro.Device.GTSCard/GTSCardConfig.cs b/src/Bro.Device.GTSCard/GTSCardConfig.cs index ddb8287..570b849 100644 --- a/src/Bro.Device.GTSCard/GTSCardConfig.cs +++ b/src/Bro.Device.GTSCard/GTSCardConfig.cs @@ -2,6 +2,7 @@ using Bro.Common.Helper; using Bro.Common.Interface; using Bro.UI.Device.Winform; +using System.ComponentModel; namespace Bro.Device.GTSCard { @@ -14,7 +15,6 @@ [Device("GTSCard", "鍥洪珮鏉垮崱", EnumHelper.DeviceAttributeType.InitialConfig)] public class GTSCardInitialConfig : MotionCardInitialConfigBase { - } [Device("GTSCard", "鍥洪珮鏉垮崱", EnumHelper.DeviceAttributeType.RunCtrl)] diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs index a09fda2..a917333 100644 --- a/src/Bro.Device.GTSCard/GTSCardDriver.cs +++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs @@ -118,11 +118,17 @@ { foreach (var operationSet in motionCardOperationConfig.OperationCollection) { + if (operationSet.DelayBefore > 0) + Thread.Sleep(operationSet.DelayBefore); + responseMessage = RunOperationSet(operationSet); if (!responseMessage.Result) { return responseMessage; } + + if (operationSet.DelayAfter > 0) + Thread.Sleep(operationSet.DelayAfter); } } return responseMessage; @@ -177,13 +183,16 @@ { foreach (var ioOutput in operationSet.IOOutputCollection) { - var ioData = MonitorValues.FirstOrDefault(u => u.IONum == ioOutput.IOItem.IONum && u.IOType == ioOutput.IOItem.IOType)?.Value;//IO 鏄紑銆佸叧 浠嶮onitorValues 鑾峰彇 - if (ioOutput.CheckValue != ioData) - { - responseMessage.Result = false; - responseMessage.Message = $"IO杈撳嚭涓嶉�氳繃锛岄厤缃細{ioOutput.GetDisplayText()}锛屽綋鍓嶅�硷細{ioData}"; - return responseMessage; - } + WriteOutput((short)ioOutput.IOItem.IONum, ioOutput.CheckValue); + + //var ioData = MonitorValues.FirstOrDefault(u => u.IONum == ioOutput.IOItem.IONum && u.IOType == ioOutput.IOItem.IOType)?.Value;//IO 鏄紑銆佸叧 浠嶮onitorValues 鑾峰彇 + + //if (ioOutput.CheckValue != ioData) + //{ + // responseMessage.Result = false; + // responseMessage.Message = $"IO杈撳嚭涓嶉�氳繃锛岄厤缃細{ioOutput.GetDisplayText()}锛屽綋鍓嶅�硷細{ioData}"; + // return responseMessage; + //} } } @@ -338,15 +347,22 @@ ResponseMessage responseMessage = new ResponseMessage(); if (opConfig is MotionOperationCollection gtsOperationCollection) { - List<Task<bool>> taskList = new List<Task<bool>>(); - foreach (var movingOp in gtsOperationCollection.MovingOps) + //List<Task<bool>> taskList = new List<Task<bool>>(); + //foreach (var movingOp in gtsOperationCollection.MovingOps) + //{ + // var task = SingleAxisMoving(movingOp); + // taskList.Add(task); + // task.Start(); + //} + //Task.WaitAll(taskList.ToArray()); + //responseMessage.Result = taskList.All(u => u.GetAwaiter().GetResult()); + + List<bool> resultList = new List<bool>(); + Parallel.ForEach(gtsOperationCollection.MovingOps, movingOp => { - var task = SingleAxisMoving(movingOp); - taskList.Add(task); - task.Start(); - } - Task.WaitAll(taskList.ToArray()); - responseMessage.Result = taskList.All(u => u.GetAwaiter().GetResult()); + resultList.Add(SingleAxisMoving(movingOp).Result); + }); + responseMessage.Result = resultList.All(u => u == true); if (!responseMessage.Result) { responseMessage.Message = $"鐐逛綅杩愬姩寮傚父"; @@ -368,11 +384,23 @@ resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, axisIndex)); resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm)); trapprm.smoothTime = 1; - trapprm.acc = optionPara.VelocityPara.Acc != 0 ? optionPara.VelocityPara.Acc : 1; - trapprm.dec = optionPara.VelocityPara.Dec != 0 ? optionPara.VelocityPara.Dec : 1; + + if (optionPara.VelocityPara.Acc != 0) + { + trapprm.acc = optionPara.VelocityPara.Acc; + } + + if (optionPara.VelocityPara.Dec != 0) + { + trapprm.dec = optionPara.VelocityPara.Dec; + } resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm)); - resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, axisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio)); + + if (optionPara.VelocityPara.Velocity != 0) + { + resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, axisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio)); + } var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK); if (!resultOK) @@ -389,7 +417,7 @@ /// <param name="optionPara">杩愬姩鍙傛暟瀵硅薄</param> public override Task<bool> SingleAxisMoving(MovingOption optionPara) { - return new Task<bool>(() => + return Task.Run(() => { axisImmediatePauseHandleDict[optionPara.AxisIndex].WaitOne(); bool isSuccessAndStop = false; @@ -397,10 +425,10 @@ { if (IConfig.AxisSettings.FirstOrDefault(a => a.AxisIndex == optionPara.AxisIndex)?.IsAxisEnabled ?? false) { - string _position = ""; + // string _position = ""; string motionType = optionPara.MoveMode == EnumHelper.MotionMode.Normal ? (optionPara.IsAbsolute ? "Abs" : "Rel") : optionPara.MoveMode.ToString(); - _position = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff},{optionPara.AxisIndex},{motionType},{GetPosition(optionPara.AxisIndex)},{GetPrfPosition(optionPara.AxisIndex)},{optionPara.Destination},"; + // _position = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff},{optionPara.AxisIndex},{motionType},{GetPosition(optionPara.AxisIndex)},{GetPrfPosition(optionPara.AxisIndex)},{optionPara.Destination},"; switch (optionPara.MoveMode) { @@ -435,9 +463,9 @@ } break; } - _position += $"{GetPosition(optionPara.AxisIndex)},"; - _position += $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}"; - LogAsync(DateTime.Now, "", _position); + //_position += $"{GetPosition(optionPara.AxisIndex)},"; + //_position += $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}"; + //LogAsync(DateTime.Now, "", _position); } } catch (Exception ex) @@ -680,7 +708,7 @@ short ret = 0; bool isSuccessSetAxisParam = false; int timeout = optionPara.MovingTimeout; - var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex).AxisRatio; + //var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex).AxisRatio; while (CurrentState == DeviceState.DSOpen && !_isPause) { //璁剧疆 杩愬姩鍙傛暟 @@ -774,63 +802,63 @@ var resultOK = taskList.All(u => u.GetAwaiter().GetResult()); } - /// <summary> - /// 鍥炲師鐐� - /// </summary> - /// <param name="movingOption">鍗″彿</param> - /// <param name="axisn">杞村彿</param> - /// <param name="homests">杞村洖鍘熺偣鐘舵��</param> - public bool GoHome(MovingOption movingOption) - { - try - { - PositionReset(movingOption.AxisIndex, 1); - GTSCardAPI.THomePrm thomeprm; - GTSCardAPI.THomeStatus homests; - // 鍚姩Home鎹曡幏 - short rtn = GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME); - // 鍒囨崲鍒扮偣浣嶈繍鍔ㄦā寮� - rtn = GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)movingOption.AxisIndex); - // 璇诲彇鐐逛綅妯″紡杩愬姩鍙傛暟 - rtn = GTSCardAPI.GT_GetHomePrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, out thomeprm); + ///// <summary> + ///// 鍥炲師鐐� + ///// </summary> + ///// <param name="movingOption">鍗″彿</param> + ///// <param name="axisn">杞村彿</param> + ///// <param name="homests">杞村洖鍘熺偣鐘舵��</param> + //public bool GoHome(MovingOption movingOption) + //{ + // try + // { + // PositionReset(movingOption.AxisIndex, 1); + // GTSCardAPI.THomePrm thomeprm; + // GTSCardAPI.THomeStatus homests; + // // 鍚姩Home鎹曡幏 + // short rtn = GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME); + // // 鍒囨崲鍒扮偣浣嶈繍鍔ㄦā寮� + // rtn = GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)movingOption.AxisIndex); + // // 璇诲彇鐐逛綅妯″紡杩愬姩鍙傛暟 + // rtn = GTSCardAPI.GT_GetHomePrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, out thomeprm); - thomeprm.mode = movingOption.GoHomePara.HomeMode;//鍥為浂鏂瑰紡 - thomeprm.moveDir = movingOption.GoHomePara.HomeDir;//鍥為浂鏂瑰悜 - thomeprm.edge = movingOption.GoHomePara.Edge; - thomeprm.velHigh = movingOption.GoHomePara.HighVelocity; - thomeprm.velLow = movingOption.GoHomePara.LowVelocity; - thomeprm.acc = movingOption.VelocityPara.Acc; - thomeprm.dec = movingOption.VelocityPara.Dec; - thomeprm.searchHomeDistance = movingOption.GoHomePara.SearchHomeDistance;//鎼滅储璺濈 - thomeprm.homeOffset = movingOption.GoHomePara.HomeOffset; //鍋忕Щ璺濈 - thomeprm.escapeStep = movingOption.GoHomePara.EscapeStep; - rtn = GTSCardAPI.GT_GoHome((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref thomeprm); //鍚姩鍥為浂 + // thomeprm.mode = movingOption.GoHomePara.HomeMode;//鍥為浂鏂瑰紡 + // thomeprm.moveDir = movingOption.GoHomePara.HomeDir;//鍥為浂鏂瑰悜 + // thomeprm.edge = movingOption.GoHomePara.Edge; + // thomeprm.velHigh = movingOption.GoHomePara.HighVelocity; + // thomeprm.velLow = movingOption.GoHomePara.LowVelocity; + // thomeprm.acc = movingOption.VelocityPara.Acc; + // thomeprm.dec = movingOption.VelocityPara.Dec; + // thomeprm.searchHomeDistance = movingOption.GoHomePara.SearchHomeDistance;//鎼滅储璺濈 + // thomeprm.homeOffset = movingOption.GoHomePara.HomeOffset; //鍋忕Щ璺濈 + // thomeprm.escapeStep = movingOption.GoHomePara.EscapeStep; + // rtn = GTSCardAPI.GT_GoHome((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref thomeprm); //鍚姩鍥為浂 - bool isStop = false; - int repeatTime = 1000; - do - { - Thread.Sleep(10); - GTSCardAPI.GT_GetHomeStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out homests); + // bool isStop = false; + // int repeatTime = 1000; + // do + // { + // Thread.Sleep(10); + // GTSCardAPI.GT_GetHomeStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out homests); - isStop = homests.run == 0; - if (isStop && homests.error == 0) - { - Thread.Sleep(200); - PositionReset(movingOption.AxisIndex, 1); - } - repeatTime--; - } while (!isStop && repeatTime > 0); + // isStop = homests.run == 0; + // if (isStop && homests.error == 0) + // { + // Thread.Sleep(200); + // PositionReset(movingOption.AxisIndex, 1); + // } + // repeatTime--; + // } while (!isStop && repeatTime > 0); - return isStop; - } - catch (Exception ex) - { - AllMoveStop(true); - OnExceptionOccured?.Invoke(DateTime.Now, ex); - return false; - } - } + // return isStop; + // } + // catch (Exception ex) + // { + // AllMoveStop(true); + // OnExceptionOccured?.Invoke(DateTime.Now, ex); + // return false; + // } + //} /// <summary> /// P2P鏂瑰紡鍥炲師鐐� @@ -840,8 +868,11 @@ { try { + StartCapture: + PositionReset(movingOption.AxisIndex, 1); ClearStatus(movingOption.AxisIndex, 1); + GTSCardAPI.TTrapPrm trapPrm; bool isStop = false; //鎼滅储璺濈 闃舵1 @@ -857,8 +888,9 @@ sRtn = GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref trapPrm); // 璁剧疆鐐逛綅妯″紡鐩爣閫熷害锛屽嵆鍥炲師鐐归�熷害 sRtn = GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.HighVelocity); + // 璁剧疆鐐逛綅妯″紡鐩爣浣嶇疆锛屽嵆鍘熺偣鎼滅储璺濈 - sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.SearchHomeDistance); + sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.HomeDir == 1 ? 99999999 : -99999999); // 鍚姩杩愬姩 sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1)); @@ -880,10 +912,19 @@ MoveStop((short)movingOption.AxisIndex, 0); throw new ProcessException($"杩愬姩杞磠movingOption.AxisIndex} 锛屽洖鍘熺偣瓒呮椂寮傚父"); } + if (isStop && capture != 1) { - ClearStatus((short)movingOption.AxisIndex, 1); + + var axisStatus = AxisStatusList.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex); + + if (((axisStatus.AxisStatus & 0x20) != 0) || ((axisStatus.AxisStatus & 0x40) != 0)) + { + movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1); + goto StartCapture; + } + throw new ProcessException($"杩愬姩杞磠movingOption.AxisIndex} 锛屽洖鍘熺偣瓒呮椂寮傚父"); } @@ -957,7 +998,7 @@ short outNum = (short)(index % 100 + 1); if ((int)value <= 1) { - GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPO, outNum, (short)value); + GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPO, outNum, IConfig.IsOutputReversed ? (short)(value == IOValue.TRUE ? 0 : 1) : (short)value); } else { @@ -1091,8 +1132,8 @@ if (newValues == null || newValues.Count == 0 || newAxisMovingStatus == null || newAxisMovingStatus.Count == 0) continue; - Stopwatch sw = new Stopwatch(); - sw.Start(); + //Stopwatch sw = new Stopwatch(); + //sw.Start(); if (MonitorValues.Count == newValues.Count) { //var tempNew = newValues.DeepSerializeClone();//clone @@ -1111,12 +1152,12 @@ AxisStatusList = new List<AxisMovingStatus>(newAxisMovingStatus); MonitorValues = new List<IOItem>(newValues); - sw.Stop(); + //sw.Stop(); - if (sw.ElapsedMilliseconds > 20) - { - LogAsync(DateTime.Now, $"{this.Name}杞鏃堕棿锛歿sw.ElapsedMilliseconds}", ""); - } + //if (sw.ElapsedMilliseconds > 20) + //{ + // LogAsync(DateTime.Now, $"{this.Name}杞鏃堕棿锛歿sw.ElapsedMilliseconds}", ""); + //} if (IConfig.MonitorInterval > 0) { @@ -1223,10 +1264,11 @@ monitorSet.OpConfig = new OperationConfigBase(); } - monitorSet.OpConfig.InputPara = monitorSet.InputDataIndex.ConvertAll(index => - { - return tempNew[index].Value == IOValue.TRUE ? 1 : 0; - }).ToList(); + //monitorSet.OpConfig.InputPara = monitorSet.InputDataIndex.ConvertAll(index => + //{ + // return tempNew[index].Value == IOValue.TRUE ? 1 : 0; + //}).ToList(); + monitorSet.OpConfig.InputPara = new List<int>() { (int)newIOItem.Value }; ExcuteMonitorInvoke(DateTime.Now, monitorSet.InvokeDevice, this, monitorSet); } @@ -1248,8 +1290,8 @@ { var rst = GTSCardAPI.GT_AxisOn((short)IConfig.CardNum, (short)axisSetting.AxisIndex); } - // 鎵�鏈変綅缃闆� - PositionReset(1, axisSettings.Count); + //// 鎵�鏈変綅缃闆� + //PositionReset(1, axisSettings.Count); // 姝f瀬闄愭姤璀� if ((axis_sts & 0x20) != 0) { diff --git a/src/Bro.Device.Gocator/GocatorDriver.cs b/src/Bro.Device.Gocator/GocatorDriver.cs index cfb5357..8e0bef5 100644 --- a/src/Bro.Device.Gocator/GocatorDriver.cs +++ b/src/Bro.Device.Gocator/GocatorDriver.cs @@ -109,12 +109,12 @@ if (imgSet != null) { imgSet.HImage = new HImage(); - imgSet.HImage.GenImage1("int2", (int)width, zoomHeight, zoomPtr); + imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); //imgSet.HImage = imgSet.HImage.ZoomImageSize((int)width, zoomHeight, "constant"); imgSet.HImage_2 = new HImage(); - imgSet.HImage_2.GenImage1("int2", (int)width, zoomHeight, zoomPtr); + imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); LaserScanParam para = new LaserScanParam() { diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs index 5ccaad2..beb5008 100644 --- a/src/Bro.M071.Process/M071Models.cs +++ b/src/Bro.M071.Process/M071Models.cs @@ -391,7 +391,9 @@ { if (valuePairs == null || valuePairs.Count == 0) { - IsDone = false; + IsDone = false; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDone")); + return; } foreach (KeyValuePair<string, double> pair in valuePairs) diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs index 5b63bbf..300a146 100644 --- a/src/Bro.M071.Process/M071Process.cs +++ b/src/Bro.M071.Process/M071Process.cs @@ -5,6 +5,7 @@ using Bro.M071.DBManager; using Bro.M071.Model; using Bro.M071.Model.Model; +using Bro.M071.Process.UI; using Bro.Process; using HalconDotNet; using Newtonsoft.Json; @@ -12,6 +13,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Text; @@ -59,6 +61,7 @@ Reset(null, null, null); FullReset(null); + } private void InitialMotionCardBaseAxisAlarm() @@ -72,7 +75,7 @@ private void MotionCard_OnAxisAlarmRaised(int axisIndex, string alarmMsg) { - RaisedAlarm(alarmMsg); + RaisedAlarm(alarmMsg); MachineState = MachineState.Alarm; } @@ -178,6 +181,11 @@ [ProcessMethod("", "StartJob", "寮�濮嬫壂鎻�", InvokeType.TestInvoke)] public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) { + if (!IsAllowedWork) + { + throw new ProcessException(SafetyMsg, null, ExceptionLevel.Fatal); + } + if (MachineState != MachineState.Ready) throw new ProcessException("鏈哄彴鏈氨缁紝璇峰嬁寮�濮嬫祴閲�", null, ExceptionLevel.Fatal); @@ -368,7 +376,9 @@ LogAsync(DateTime.Now, $"{m.GetDisplayText()}妫�娴嬬粨鏋�", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}"); - IShapeElement indicator = null; + KeyIndicator indicator = new KeyIndicator(m.Id, m.DisplayLocation); + indicator.Text = (m.Spec.ActualValue == null || m.Spec.ActualValue == -999) ? "NA" : m.Spec.ActualValue.Value.ToString("f2"); + indicator.ResultState = m.Spec.MeasureResult; pMeasure.ElementList.Add(indicator); //杈撳嚭鍥惧舰鍩哄厓鍒扮晫闈� OnElementUpdated?.BeginInvoke(indicator, null, null); @@ -404,10 +414,10 @@ { } - //Excel鎶ヨ〃杈撳嚭 锛堝崟涓骇鍝佺殑excel瀵煎嚭锛� - ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet); - //鏁版嵁搴撲繚瀛� - SaveProductionData(measurementUnitResultAndKeyUnitDataSet); + ////Excel鎶ヨ〃杈撳嚭 锛堝崟涓骇鍝佺殑excel瀵煎嚭锛� + //ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet); + ////鏁版嵁搴撲繚瀛� + //SaveProductionData(measurementUnitResultAndKeyUnitDataSet); SaveWholeImage(pMeasure); @@ -589,7 +599,7 @@ Directory.CreateDirectory(dir); } - map.Save(Path.Combine(dir, $"{pMeasure.Barcode}_{DateTime.Now.ToString("HHmmss")}.bmp")); + map.Save(Path.Combine(dir, $"{pMeasure.Barcode}_{pMeasure.PResult}_{DateTime.Now.ToString("HHmmss")}.png"), ImageFormat.Png); } catch (Exception ex) { @@ -718,7 +728,7 @@ { _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image; _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X; - _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z; + //_halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z; if (!_halconToolDict[keyToolKey].RunProcedure(out string error)) { LogAsync(DateTime.Now, $"{k.AliasName}妫�娴嬬畻娉曞紓甯革紝{error}", ""); diff --git a/src/Bro.M071.Process/M071Process_MotionCard.cs b/src/Bro.M071.Process/M071Process_MotionCard.cs index 70bb5c8..7a91ce4 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,9 +221,23 @@ // } //} + if (ResetTimer == null) + { + ResetTimer = new Timer(FullReset, null, -1, -1); + } + + if (opConfig?.InputPara != null && opConfig.InputPara.Count > 0) + { + //澶у浣嶄俊鍙� + ResetTimer.Change(opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1, -1); + + if (opConfig.InputPara[0] == 0) + return new ProcessResponse(true); + } + if (!IsAllowedWork) { - LogAsync(DateTime.Now, $"{(IsSafetyDoorTrigged ? "瀹夊叏闂�" : "")}{(IsSafetyBeamTrigged ? " 瀹夊叏鍏夌嚎" : "")}{(isEmergencyStopped ? " 鎬ュ仠鎸夐挳" : "")}瑙﹀彂涓紝澶嶄綅澶辫触", ""); + LogAsync(DateTime.Now, $"{SafetyMsg}锛屽浣嶅け璐�", ""); return new ProcessResponse(false); } @@ -224,16 +253,13 @@ MachineState = MachineState.Alarm; } - if (ResetTimer == null) - { - ResetTimer = new Timer(FullReset, null, -1, -1); - } - if (opConfig.InputPara.Count > 0) - { - //澶у浣嶄俊鍙� - ResetTimer.Change(-1, opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1); - } + + //if (opConfig.InputPara?.Count > 0) + //{ + // //澶у浣嶄俊鍙� + // ResetTimer.Change(-1, opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1); + //} //if (invokeDevice is MotionCardBase motionCard) //{ @@ -298,6 +324,8 @@ RaisedAlarm(""); MachineState = MachineState.Ready; + + GotoReadyPosition(null, null, null); return new ProcessResponse(true); } @@ -597,6 +625,10 @@ { get => !(IsSafetyBeamTrigged || IsSafetyDoorTrigged || IsEmergencyStopped); } + string SafetyMsg + { + get => $"{(IsSafetyBeamTrigged ? "瀹夊叏鍏夊箷" : "")}{(IsSafetyDoorTrigged ? " 瀹夊叏闂�" : "")}{(IsEmergencyStopped ? " 鎬ュ仠鎸夐挳" : "")}瑙﹀彂涓�"; + } #region 瀹夊叏闂� & 瀹夊叏鍏夌嚎 bool isSafetyDoorTrigged = false; @@ -633,6 +665,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("瀹夊叏鍏夊箷鐩戞帶鏈厤缃緭鍏ヤ俊鍙�"); @@ -674,7 +709,7 @@ if (opConfig.InputPara == null || opConfig.InputPara.Count == 0) throw new ProcessException("鎬ュ仠鎸夐挳鏈厤缃緭鍏ヤ俊鍙�"); - IsEmergencyStopped = opConfig.InputPara[0] == 1; + IsEmergencyStopped = opConfig.InputPara[0] == 0; if (IsEmergencyStopped) { diff --git a/src/Bro.M071.Process/UI/KeyIndicator.cs b/src/Bro.M071.Process/UI/KeyIndicator.cs index 8d43b6b..2565ee3 100644 --- a/src/Bro.M071.Process/UI/KeyIndicator.cs +++ b/src/Bro.M071.Process/UI/KeyIndicator.cs @@ -77,8 +77,9 @@ foreColor = Color.White; } + g.FillRectangle(new SolidBrush(Color.FromArgb(85, backColor)), rectFill); g.DrawString(Text, Font, new SolidBrush(foreColor), (float)(DisplayRect.X + DisplayRect.Width / 2.0 - txtSize.Width / 2.0), (float)(DisplayRect.Y + DisplayRect.Height / 2.0 - txtSize.Height / 2.0)); - g.FillRectangle(new SolidBrush(Color.FromArgb(55, backColor)), rectFill); + } } diff --git a/src/Bro.M071.Process/UI/M071_MainForm.cs b/src/Bro.M071.Process/UI/M071_MainForm.cs index 17b79c9..e875fd6 100644 --- a/src/Bro.M071.Process/UI/M071_MainForm.cs +++ b/src/Bro.M071.Process/UI/M071_MainForm.cs @@ -53,38 +53,44 @@ if (string.IsNullOrWhiteSpace(Config.BackgroundImagePath)) return; - this.Invoke(new Action(() => + try { - try - { - Bitmap image = (Bitmap)Image.FromFile(Config.BackgroundImagePath); - cvImage.LoadImage(image); - cvImage.SetScreenSize(); - } - catch (Exception ex) - { - LogAsync(new LogMsg(DateTime.Now, "杞藉叆鑳屾櫙鍥惧紓甯�", ex.Message)); - return; - } + this.Invoke(new Action(() => + { + try + { + Bitmap image = (Bitmap)Image.FromFile(Config.BackgroundImagePath); + cvImage.LoadImage(image); + cvImage.SetScreenSize(); + } + catch (Exception ex) + { + LogAsync(new LogMsg(DateTime.Now, "杞藉叆鑳屾櫙鍥惧紓甯�", ex.Message)); + return; + } - cvImage.Elements.Clear(); - lvMeasures.Items.Clear(); + cvImage.Elements.Clear(); + lvMeasures.Items.Clear(); - txtBarcode.Enabled = !Config.IsBarcodeManualInputBlocked; + txtBarcode.Enabled = !Config.IsBarcodeManualInputBlocked; - Config.MeasurementUnitCollection.ForEach(u => - { - if (!u.IsEnabled) - return; + Config.MeasurementUnitCollection.ForEach(u => + { + if (!u.IsEnabled) + return; - var ele = new KeyIndicator(u.Id, u.DisplayLocation); - cvImage.Elements.Add(ele); + var ele = new KeyIndicator(u.Id, u.DisplayLocation); + cvImage.Elements.Add(ele); - ListViewItem item = new ListViewItem(u.GetDisplayText()); - item.Tag = u.Id; - lvMeasures.Items.Add(item); - }); - })); + ListViewItem item = new ListViewItem(u.GetDisplayText()); + item.Tag = u.Id; + lvMeasures.Items.Add(item); + }); + })); + } + catch (Exception ex) + { + } Process_M071.OnClearBarcode -= M071_MainForm_OnClearBarcode; Process_M071.OnClearBarcode += M071_MainForm_OnClearBarcode; @@ -104,6 +110,9 @@ Config.PropertyChanged -= Config_PropertyChanged; Config.PropertyChanged += Config_PropertyChanged; + + Process_M071.OnElementUpdated -= Process_M071_OnElementUpdated; + Process_M071.OnElementUpdated += Process_M071_OnElementUpdated; } private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e) @@ -223,6 +232,26 @@ } #endregion + #region 鏍囩缁撴灉鏄剧ず + private async void Process_M071_OnElementUpdated(Common.Interface.IShapeElement obj) + { + if (obj is KeyIndicator keyIndicator) + { + this.Invoke(new Action(() => + { + var ele = cvImage.Elements.FirstOrDefault(u => u.ID == keyIndicator.ID); + + (ele as KeyIndicator).Text = keyIndicator.Text; + (ele as KeyIndicator).ResultState = keyIndicator.ResultState; + + this.Invalidate(); + })); + } + + await Task.Delay(100); + } + #endregion + #region 涓婃柟鐘舵�佸尯 #region 鏉$爜 @@ -261,46 +290,59 @@ #region 鏈哄彴鐘舵�� private async void M071_MainForm_MachineStateChanged(MachineState state) { - lblMachineState.BeginInvoke(new Action(() => + if (lblMachineState.IsHandleCreated) { - switch (state) + lblMachineState.BeginInvoke(new Action(() => { - case MachineState.Alarm: - btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Red; - btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.White; - lblMachineState.Text = "璀︽姤"; + switch (state) + { + case MachineState.Alarm: + btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Red; + btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.White; + lblMachineState.Text = "璀︽姤"; - btnStartMeasure.Enabled = false; - break; - case MachineState.Pause: - btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Yellow; - btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.Black; - lblMachineState.Text = "鏆傚仠"; + btnStartMeasure.Text = "寮�濮嬫祴閲�"; + btnStartMeasure.Enabled = false; + btnStartMeasure.BackColor = Color.Red; + break; + case MachineState.Pause: + btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Yellow; + btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.Black; + lblMachineState.Text = "鏆傚仠"; - //btnStartMeasure.Text = "鏆傚仠娴嬮噺"; - btnStartMeasure.Enabled = true; - break; - case MachineState.Ready: - btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime; - btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.White; - lblMachineState.Text = "灏辩华"; + btnStartMeasure.Text = "缁х画娴嬮噺"; + btnStartMeasure.Enabled = true; + btnStartMeasure.BackColor = Color.Lime; + break; + case MachineState.Ready: + btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime; + btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.White; + lblMachineState.Text = "灏辩华"; + + btnStartMeasure.Text = "寮�濮嬫祴閲�"; + btnStartMeasure.Enabled = true; + btnStartMeasure.BackColor = Color.Lime; + break; + case MachineState.Running: + btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime; + btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.DarkGreen; + lblMachineState.Text = "杩愯"; - btnStartMeasure.Enabled = true; - break; - case MachineState.Running: - btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime; - btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.DarkGreen; - lblMachineState.Text = "杩愯"; + btnStartMeasure.Text = "鏆傚仠娴嬮噺"; + btnStartMeasure.Enabled = true; + btnStartMeasure.BackColor = Color.Lime; + break; + case MachineState.Unknown: + btnStartMeasure.BackColor = lblMachineState.BackColor = SystemColors.Control; + btnStartMeasure.ForeColor = lblMachineState.ForeColor = SystemColors.ControlText; + lblMachineState.Text = "鏈煡"; - btnStartMeasure.Enabled = true; - break; - case MachineState.Unknown: - btnStartMeasure.BackColor = lblMachineState.BackColor = SystemColors.Control; - btnStartMeasure.ForeColor = lblMachineState.ForeColor = SystemColors.ControlText; - lblMachineState.Text = "鏈煡"; - break; - } - })); + btnStartMeasure.Enabled = false; + btnStartMeasure.BackColor = Color.Red; + break; + } + })); + } await Task.Delay(100); } @@ -333,7 +375,7 @@ lblProductionState.Text = "NG"; } - btnStartMeasure.Text = "寮�濮嬫祴閲�"; + //btnStartMeasure.Text = "寮�濮嬫祴閲�"; })); await Task.Delay(100); } @@ -347,6 +389,15 @@ lblProductionState.Text = "娴嬭瘯涓�"; lblCT.Text = ""; + + cvImage.Elements.ToList().ForEach(e => + { + if (e is KeyIndicator indicator) + { + indicator.Text = ""; + indicator.ResultState = null; + } + }); })); await Task.Delay(100); } @@ -356,9 +407,6 @@ private async void btnStartMeasure_Click(object sender, EventArgs e) { - btnStartMeasure.Enabled = false; - bool isBreak = false; - if (btnStartMeasure.Text == "寮�濮嬫祴閲�") { await Task.Run(() => @@ -369,31 +417,19 @@ } catch (Exception ex) { - isBreak = true; - LogAsync(DateTime.Now, "娴佺▼寮傚父", ex.Message); Process_M071.ExceptionRaisedInMonitor(ex); - - btnStartMeasure.Text = "寮�濮嬫祴閲�"; - } }); - - if (!isBreak) - btnStartMeasure.Text = "鏆傚仠娴嬮噺"; } else if (btnStartMeasure.Text == "缁х画娴嬮噺") { Process_M071.SwitchJobStatus(new OperationConfigBase() { InputPara = new List<int>() { 0 } }, null, null); - btnStartMeasure.Text = "鏆傚仠娴嬮噺"; } else { Process_M071.SwitchJobStatus(new OperationConfigBase() { InputPara = new List<int>() { 1 } }, null, null); - btnStartMeasure.Text = "缁х画娴嬮噺"; } - - btnStartMeasure.Enabled = true; } #region 澶嶄綅鎿嶄綔 @@ -414,7 +450,7 @@ Process_M071.Reset(null, null, null); } - Process_M071.ResetTimer.Change(-1, 1000 * 5); + Process_M071.ResetTimer.Change(1000 * 5, -1); } private void btnReset_MouseUp(object sender, MouseEventArgs e) diff --git a/src/Bro.UI.Config/MainFrm.cs b/src/Bro.UI.Config/MainFrm.cs index 39c3169..b2d717e 100644 --- a/src/Bro.UI.Config/MainFrm.cs +++ b/src/Bro.UI.Config/MainFrm.cs @@ -157,15 +157,21 @@ CloseAllDeviceFrm(); LoadDevices(); - foreach (var dock in dockPanelMain.Contents) + try { - MenuFrmBase m = dock as MenuFrmBase; - - if (m != null && m.Id != frmId) + foreach (var dock in dockPanelMain.Contents) { - m.DownloadProcess(process); + MenuFrmBase m = dock as MenuFrmBase; + + if (m != null && m.Id != frmId) + { + m.DownloadProcess(process); + } } } + catch (Exception ex) + { + } }); } diff --git a/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs b/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs index cef3b62..e47edce 100644 --- a/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs +++ b/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs @@ -67,7 +67,8 @@ if (ioInArray != null && ioInArray.Length == 1) { var ioIn = ioInArray[0] as IOIndicatorCtrl; - ioIn.IsOn = ioItem.Value == IOValue.FALSE; + + ioIn.IsOn = ioItem.Value == IOValue.TRUE; } } else @@ -76,7 +77,15 @@ if (ioOutArray != null && ioOutArray.Length == 1) { var ioOut = ioOutArray[0] as IOIndicatorCtrl; - ioOut.IsOn = ioItem.Value == IOValue.FALSE; + + if (MotionCard.IConfig.IsOutputReversed) + { + ioOut.IsOn = ioItem.Value == IOValue.TRUE; + } + else + { + ioOut.IsOn = ioItem.Value == IOValue.FALSE; + } } } } diff --git a/src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs b/src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs index aa8c728..b26aa01 100644 --- a/src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs +++ b/src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs @@ -76,7 +76,7 @@ private void btnStart_Click(object sender, EventArgs e) { - MotionCard.SingleAxisMoving(MotionCardMovingOption).Start(); + MotionCard.SingleAxisMoving(MotionCardMovingOption); } private void buttonSmoothStop_Click(object sender, EventArgs e) -- Gitblit v1.8.0