From f52302d69d60ce15b0d5b100e30082c5a6e9caa1 Mon Sep 17 00:00:00 2001 From: xcd <834800634@qq.com> Date: 星期五, 03 七月 2020 18:38:44 +0800 Subject: [PATCH] merge --- src/Bro.Device.GTSCard/GTSCardDriver.cs | 58 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs index 5a562fe..0368c10 100644 --- a/src/Bro.Device.GTSCard/GTSCardDriver.cs +++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs @@ -18,12 +18,12 @@ namespace Bro.Device.GTSCard { [Device("GTSCard", "鍥洪珮鏉垮崱", EnumHelper.DeviceAttributeType.Device)] - public class GTSCardDriver : DeviceBase, IMonitor, IMotion + public class GTSCardDriver : MotionCardBase { // 寮傚父浜嬩欢 public Action<Exception> OnExceptionRaised; - public GTSCardInitialConfig IConfig + public GTSCardInitialConfig IIConfig { get { @@ -42,7 +42,7 @@ _isResetting = isReset; } - public List<AxisInfo> GetCurrentAxisInfo(params string[] axisName) + public override List<AxisInfo> GetCurrentAxisInfo(params string[] axisName) { throw new NotImplementedException(); } @@ -74,6 +74,14 @@ AllMoveStop(); AllAxisOff(); } + + public override ResponseMessage Run(IOperationConfig config) + { + ResponseMessage responseMessage = new ResponseMessage(); + + + return responseMessage; + } #endregion #region GTSCard @@ -93,6 +101,7 @@ throw new Exception("鏉垮崱杞藉叆閰嶇疆鏂囦欢寮傚父锛岄敊璇爜锛�" + res); } } + public bool AllAxisOn() { @@ -153,7 +162,7 @@ /// </summary> /// <param name="item">杩愬姩瀵硅薄</param> /// <returns>杩愬姩鎺у埗+鍋滄鍒ゆ柇</returns> - public bool MoveToPoint(IOperationConfig opConfig) + public override ResponseMessage MoveToPoint(IOperationConfig opConfig) { bool resultOK = false; var gtsOperationConfig = opConfig as GTSCardOperationConfig; @@ -172,7 +181,8 @@ Task.WaitAll(taskList.ToArray()); resultOK = taskList.All(u => u.GetAwaiter().GetResult()); - return resultOK; + //return resultOK; + throw new NotImplementedException(); } /// <summary> @@ -645,16 +655,17 @@ /// <param name="cardNum">鍗″彿</param> /// <param name="index">杈撳嚭鍙�,杩斿洖1-16</param> /// <param name="value">false琛ㄧず杈撳嚭锛宼rue琛ㄧず鍏抽棴</param> - public void WriteOut(short cardNum, short index, bool value) + public override void WriteOutput(short cardNum, short index, IOValue value) { short outNum = (short)(index % 100 + 1); - if (value) + if ((int)value <= 1) { - GTSCardAPI.GT_SetDoBit(cardNum, GTSCardAPI.MC_GPO, outNum, 0); + GTSCardAPI.GT_SetDoBit(cardNum, GTSCardAPI.MC_GPO, outNum, (short)value); } else { - GTSCardAPI.GT_SetDoBit(cardNum, GTSCardAPI.MC_GPO, outNum, 1); + var currentValue = (int)MonitorValues.FirstOrDefault(u => u.IONum == outNum && u.IOType == IOType.OUTPUT).Value; + GTSCardAPI.GT_SetDoBit(cardNum, GTSCardAPI.MC_GPO, outNum, (short)(currentValue == 1 ? 0 : 1)); } } @@ -679,10 +690,8 @@ #endregion #region IMonitor - public event Action<DateTime, string, IDevice, IMonitorSet> OnMonitorInvoke; - public event Action<DateTime, IDevice, IWarningSet> OnMonitorAlarm; - public List<IOItem> MonitorValues { get; set; } = new List<IOItem>(); + //public List<IOItem> MonitorValues { get; set; } = new List<IOItem>(); public List<IOItem> GetMonitorValues() @@ -701,14 +710,14 @@ IOItem inItem = new IOItem() { IONum = index, - Value = (inValue & (1 << index)) == 0 ? 1 : 0, - Model = IOModel.In + Value = (inValue & (1 << index)) == 0 ? IOValue.TRUE : IOValue.FALSE, + IOType = IOType.INPUT }; IOItem outItem = new IOItem() { IONum = index, - Value = (outValue & (1 << index)) == 0 ? 1 : 0, - Model = IOModel.Out + Value = (outValue & (1 << index)) == 0 ? IOValue.TRUE : IOValue.FALSE, + IOType = IOType.OUTPUT }; result.Add(inItem); result.Add(outItem); @@ -717,7 +726,7 @@ return result; } - public async void Monitor() + public async override void Monitor() { await Task.Run(() => { @@ -764,7 +773,7 @@ }); } - private void OnMethodInvoked(IAsyncResult ar) + public override void OnMethodInvoked(IAsyncResult ar) { MotionCardMonitorSet monitorSet = ar.AsyncState as MotionCardMonitorSet; ProcessResponse resValues = monitorSet.Response; @@ -779,7 +788,7 @@ foreach (var replyIOData in monitorSet.ReplyIODatas) { //鍐欏叆IO杈撳嚭 - if (replyIOData.Model == IOModel.Out) + if (replyIOData.IOType == IOType.OUTPUT) { GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPI, (short)replyIOData.IONum, (short)replyIOData.Value); } @@ -796,15 +805,14 @@ { MotionCardWarningSet warningSet = wSet as MotionCardWarningSet; - bool isOn = ((tempNew.FirstOrDefault(u => u.IONum == warningSet.TriggerIndex && u.Model == warningSet.WarningIOModel)?.Value >> warningSet.TriggerIndex) & 1) == (warningSet.TriggerValue ? 1 : 0); + bool isOn = (((int)((tempNew.FirstOrDefault(u => u.IONum == warningSet.TriggerIndex && u.IOType == warningSet.WarningIOModel)?.Value)) >> warningSet.TriggerIndex) & 1) == (warningSet.TriggerValue ? 1 : 0); if (warningSet.CurrentStatus != isOn) { warningSet.CurrentStatus = isOn; warningSet.TriggerTime = DateTime.Now; - warningSet.WarningDescription = $"璀︽姤锛歿warningSet.Name}-瑙﹀彂绱㈠紩锛歿warningSet.TriggerIndex}-{warningSet.WarningIOModel.GetEnumDescription()}:{warningSet.WarningCode}"; SaveAlarmCSVAsync(DateTime.Now, this.Name, warningSet); - OnMonitorAlarm?.BeginInvoke(DateTime.Now, this, warningSet, null, null); + ExcuteMonitorAlarm(DateTime.Now, this, warningSet); } }); #endregion @@ -823,7 +831,7 @@ if (newIOItem?.Value != oldIOItem?.Value) { - if (monitorSet.TriggerValue == -999 || newIOItem.Value == monitorSet.TriggerValue) + if (monitorSet.TriggerValue == -999 || (int)newIOItem.Value == monitorSet.TriggerValue) { if (monitorSet.OpConfig == null) { @@ -835,14 +843,14 @@ // return tempNew[index].Value; //}).ToList(); - OnMonitorInvoke?.BeginInvoke(DateTime.Now, monitorSet.InvokeDevice, this, monitorSet, OnMethodInvoked, monitorSet); + ExcuteMonitorInvoke(DateTime.Now, monitorSet.InvokeDevice, this, monitorSet); } } }); #endregion } - public void ResetAlarm() + public override void ResetAlarm() { int axis_sts; uint clk; -- Gitblit v1.8.0