From 3cba54c4ee8d29d33ed21a2c749a9d2f2d03e22d Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期五, 03 七月 2020 18:33:30 +0800
Subject: [PATCH] 板卡IO定义修改。板卡预定义操作功能实现
---
src/Bro.Device.GTSCard/GTSCardDriver.cs | 22 +-
/dev/null | 13 --
src/Bro.Common.Device/DeviceBase/MotionCardBase.cs | 20 +++
src/Bro.M071.Process/M071Process.cs | 37 -----
src/Bro.Common.Model/Model/IOItem.cs | 15 +-
src/Bro.M071.Process/M071Process_MotionCard.cs | 217 ++++++++++++++++++++++++++++++++++++
src/Bro.M071.Process/Bro.M071.Process.csproj | 2
src/Bro.M071.Process/M071Config.cs | 3
src/Bro.M071.Process/M071Models.cs | 4
src/Bro.Common.Model/Helper/EnumHelper.cs | 19 +++
10 files changed, 281 insertions(+), 71 deletions(-)
diff --git a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
index dce4dcd..d7d1a41 100644
--- a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
+++ b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
@@ -12,6 +12,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using static Bro.Common.Helper.EnumHelper;
namespace Bro.Common.Base
{
@@ -26,7 +27,7 @@
public abstract void ResetAlarm();
public abstract ResponseMessage Run(IOperationConfig config);
- public void ExcuteMonitorInvok(DateTime dateTime, string invokeDevice, IDevice device, IMonitorSet monitorSet)
+ public void ExcuteMonitorInvoke(DateTime dateTime, string invokeDevice, IDevice device, IMonitorSet monitorSet)
{
OnMonitorInvoke?.BeginInvoke(dateTime, invokeDevice, device, monitorSet, null, null);
}
@@ -43,6 +44,10 @@
return InitialConfig as MotionCardInitialConfigBase;
}
}
+
+ public List<IOItem> MonitorValues { get; set; } = new List<IOItem>();
+
+ public abstract void WriteOutput(short cardNum, short index, IOValue value);
}
public class MotionCardInitialConfigBase : InitialConfigBase, IMonitorConfig
@@ -126,6 +131,7 @@
#endregion
}
+ [Device("MotionCardBase", "鏉垮崱鎿嶄綔閰嶇疆鍩虹被", EnumHelper.DeviceAttributeType.OperationConfig)]
public class MotionCardOperationConfigBase : OperationConfigBase, IComplexDisplay
{
[Category("IO鎿嶄綔閰嶇疆")]
@@ -179,7 +185,7 @@
IOConfirmCollection.ForEach(i =>
{
confirm += i.GetDisplayText() + " ";
- });
+ });
if (confirm != "")
{
confirm = " 纭锛�" + confirm;
@@ -199,6 +205,16 @@
}
}
+ [Device("MotionCardOperationConfigCollection", "鏉垮崱鎿嶄綔閰嶇疆鍩虹被闆嗗悎", EnumHelper.DeviceAttributeType.OperationConfig)]
+ public class MotionCardOperationConfigCollection : OperationConfigBase
+ {
+ [Category("澶嶄綅鎿嶄綔")]
+ [Description("鏉垮崱鎿嶄綔閰嶇疆鍩虹被闆嗗悎锛屼緷娆℃墽琛�")]
+ [TypeConverter(typeof(CollectionCountConvert))]
+ [Editor(typeof(ComplexCollectionEditor<MotionCardOperationConfigBase>), typeof(UITypeEditor))]
+ public List<MotionCardOperationConfigBase> MotionCardOpsCollection { get; set; } = new List<MotionCardOperationConfigBase>();
+ }
+
public class IORefrenceItemCollectionEditor : CollectionEditor
{
protected override CollectionForm CreateCollectionForm()
diff --git a/src/Bro.Common.Model/Helper/EnumHelper.cs b/src/Bro.Common.Model/Helper/EnumHelper.cs
index 52c5349..703be4a 100644
--- a/src/Bro.Common.Model/Helper/EnumHelper.cs
+++ b/src/Bro.Common.Model/Helper/EnumHelper.cs
@@ -577,6 +577,16 @@
OUTPUT = 1
}
+ public enum IOValue
+ {
+ [Description("鍏抽棴")]
+ FALSE = 0,
+ [Description("寮�鍚�")]
+ TRUE = 1,
+ [Description("鍙嶈浆")]
+ REVERSE = 2,
+ }
+
/// <summary>
/// PubSubCenter浜嬩欢涓績鐨勬秷鎭被鍨�
/// </summary>
@@ -593,5 +603,14 @@
//[Description("鏇存柊鏁版嵁")]
//UpdateData,
}
+
+ public enum MachineState
+ {
+ Unknown,
+ Ready,
+ Running,
+ Alarm,
+ Pause,
+ }
}
}
diff --git a/src/Bro.Common.Model/Model/IOItem.cs b/src/Bro.Common.Model/Model/IOItem.cs
index 147880e..653cdb2 100644
--- a/src/Bro.Common.Model/Model/IOItem.cs
+++ b/src/Bro.Common.Model/Model/IOItem.cs
@@ -22,8 +22,9 @@
/// IO鐐圭殑鍊�
/// </summary>
[Category("IO閰嶇疆")]
- [Description("IO鏁板��")]
- public virtual int Value { get; set; }
+ [Description("IO鐘舵��")]
+ [TypeConverter(typeof(EnumDescriptionConverter<IOValue>))]
+ public virtual IOValue Value { get; set; }
/// <summary>
/// IO鐐规槸in杩樻槸out
@@ -44,7 +45,7 @@
public virtual string GetDisplayText()
{
- return $"{IOType.GetEnumDescription()}-{IONum}-{Value}";
+ return $"{IOType.GetEnumDescription()}-{IONum}-{Value.GetEnumDescription()}";
}
public int GetHashCode(object obj)
@@ -70,7 +71,7 @@
[Browsable(false)]
[JsonIgnore]
- public override int Value { get; set; }
+ public override IOValue Value { get; set; }
public override string GetDisplayText()
{
@@ -86,8 +87,8 @@
public IODefinition IOItem { get; set; } = new IODefinition();
[Category("IO鎿嶄綔閰嶇疆")]
- [Description("闇�瑕佹搷浣滅殑IO鐨勬暟鍊�")]
- public int CheckValue
+ [Description("闇�瑕佹搷浣滅殑IO鐨勭姸鎬�")]
+ public IOValue CheckValue
{
get => IOItem.Value;
set => IOItem.Value = value;
@@ -99,7 +100,7 @@
public string GetDisplayText()
{
- return IOItem.IODesc + "-" + CheckValue;
+ return IOItem.IODesc + "-" + CheckValue.GetEnumDescription();
}
}
diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs
index b9bc5de..5b60b6d 100644
--- a/src/Bro.Device.GTSCard/GTSCardDriver.cs
+++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -652,16 +652,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));
}
}
@@ -687,7 +688,7 @@
#region IMonitor
- public List<IOItem> MonitorValues { get; set; } = new List<IOItem>();
+ //public List<IOItem> MonitorValues { get; set; } = new List<IOItem>();
public List<IOItem> GetMonitorValues()
@@ -706,13 +707,13 @@
IOItem inItem = new IOItem()
{
IONum = index,
- Value = (inValue & (1 << index)) == 0 ? 1 : 0,
+ 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,
+ Value = (outValue & (1 << index)) == 0 ? IOValue.TRUE : IOValue.FALSE,
IOType = IOType.OUTPUT
};
result.Add(inItem);
@@ -801,13 +802,12 @@
{
MotionCardWarningSet warningSet = wSet as MotionCardWarningSet;
- bool isOn = ((tempNew.FirstOrDefault(u => u.IONum == warningSet.TriggerIndex && u.IOType == 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);
ExcuteMonitorAlarm(DateTime.Now, this, warningSet);
}
@@ -828,7 +828,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)
{
@@ -840,7 +840,7 @@
// return tempNew[index].Value;
//}).ToList();
- ExcuteMonitorInvok(DateTime.Now, monitorSet.InvokeDevice, this, monitorSet);
+ ExcuteMonitorInvoke(DateTime.Now, monitorSet.InvokeDevice, this, monitorSet);
}
}
});
diff --git a/src/Bro.M071.Process/Bro.M071.Process.csproj b/src/Bro.M071.Process/Bro.M071.Process.csproj
index ebc097e..08b6346 100644
--- a/src/Bro.M071.Process/Bro.M071.Process.csproj
+++ b/src/Bro.M071.Process/Bro.M071.Process.csproj
@@ -110,7 +110,7 @@
<Compile Include="M071Config.cs" />
<Compile Include="M071Models.cs" />
<Compile Include="M071Process.cs" />
- <Compile Include="M071Process_IO.cs" />
+ <Compile Include="M071Process_MotionCard.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\KeyIndicator.cs" />
<Compile Include="UI\M071Node.cs" />
diff --git a/src/Bro.M071.Process/M071Config.cs b/src/Bro.M071.Process/M071Config.cs
index b3ae3f3..84af1e8 100644
--- a/src/Bro.M071.Process/M071Config.cs
+++ b/src/Bro.M071.Process/M071Config.cs
@@ -44,18 +44,21 @@
[Category("鑳屾櫙鍥剧墖璁剧疆")]
[Description("杩愯鑳屾櫙鍥剧墖璺緞")]
[Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
+ [DisplayName("鑳屾櫙鍥剧墖")]
public string BackgroundImagePath { get; set; }
[Category("妫�娴嬭缃�")]
[Description("鎷嶆憚鐐逛綅璁剧疆闆嗗悎")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(ComplexCollectionEditor<SnapshotPoint>), typeof(UITypeEditor))]
+ [DisplayName("鎷嶆憚鐐逛綅")]
public List<SnapshotPoint> SnapshotPointCollection { get; set; } = new List<SnapshotPoint>();
[Category("妫�娴嬭缃�")]
[Description("瑙嗚妫�娴嬪崟閿厤缃泦鍚�")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(ComplexCollectionEditor<KeyUnit>), typeof(UITypeEditor))]
+ [DisplayName("鍗曢敭閰嶇疆")]
public List<KeyUnit> KeyUnitCollection { get; set; } = new List<KeyUnit>();
[Category("妫�娴嬭缃�")]
diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs
index 8c15fde..a5c4137 100644
--- a/src/Bro.M071.Process/M071Models.cs
+++ b/src/Bro.M071.Process/M071Models.cs
@@ -312,7 +312,7 @@
[Category("鍗曢敭閰嶇疆")]
[Description("鍗曢敭缁撴灉閰嶇疆")]
[TypeConverter(typeof(KeyUnitResultConverter))]
- public string KeyResult { get; set; } = "";
+ public string KeyResultId { get; set; } = "";
public List<HImage> KeyImages = new List<HImage>();
@@ -342,7 +342,7 @@
{
string msg = Key;
- msg += string.IsNullOrWhiteSpace(KeyResult) ? "" : $"-{KeyResult}";
+ msg += string.IsNullOrWhiteSpace(KeyResultId) ? "" : $"-{KeyResultId}";
return msg;
}
diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs
index 68b79c6..b5235b2 100644
--- a/src/Bro.M071.Process/M071Process.cs
+++ b/src/Bro.M071.Process/M071Process.cs
@@ -110,7 +110,7 @@
if (keyRespone.Count == 0)
throw new ProcessException($"{u.GetDisplayText()}瀵瑰簲鐨勫崟閿笉瀛樺湪鎴栦笉鍙敤");
- if (b.KeyResult == "All")
+ if (b.KeyResultId == "All")
{
keyRespone.SelectMany(kr => kr.KeyResultList).ToList().ForEach(r =>
{
@@ -119,7 +119,7 @@
}
else
{
- b.MeasureValueDict[b.KeyResult] = null;
+ b.MeasureValueDict[b.KeyResultId] = null;
}
});
});
@@ -236,39 +236,6 @@
BarCode = "";
return new ProcessResponse(true);
- }
-
- /// <summary>
- /// 鏆傚仠鏍囧織
- /// WaitHandle 鏆傚仠鍙ユ焺 榛樿涓洪潪闃诲 鍙墽琛�
- /// WaitResult 鏆傚仠鏍囧織 true 姝e父鎵ц false 鏆傚仠涓�
- /// </summary>
- ManualWaitConfirm _pauseHandle = new ManualWaitConfirm()
- {
- WaitHandle = new ManualResetEvent(true),
- WaitResult = true,
- };
-
- [ProcessMethod("", "PauseJob", "鏆傚仠娴佺▼", InvokeType.TestInvoke)]
- public ProcessResponse PauseJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
- {
- if (_pauseHandle.WaitResult)
- {
- #region 鏉垮崱鏆傚仠鍔ㄤ綔
- #endregion
-
- _pauseHandle.WaitHandle.Reset();
- }
- else
- {
- #region 鏉垮崱鎭㈠鍔ㄤ綔
- #endregion
-
- _pauseHandle.WaitHandle.Set();
- }
-
- _pauseHandle.WaitResult = !_pauseHandle.WaitResult;
- return new ProcessResponse(_pauseHandle.WaitResult);
}
#region 绉佹湁鏂规硶
diff --git a/src/Bro.M071.Process/M071Process_IO.cs b/src/Bro.M071.Process/M071Process_IO.cs
deleted file mode 100644
index 3a0dd4f..0000000
--- a/src/Bro.M071.Process/M071Process_IO.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Bro.M071.Process
-{
- public partial class M071Process
- {
-
- }
-}
diff --git a/src/Bro.M071.Process/M071Process_MotionCard.cs b/src/Bro.M071.Process/M071Process_MotionCard.cs
new file mode 100644
index 0000000..a0f31eb
--- /dev/null
+++ b/src/Bro.M071.Process/M071Process_MotionCard.cs
@@ -0,0 +1,217 @@
+锘縰sing Bro.Common.Base;
+using Bro.Common.Helper;
+using Bro.Common.Interface;
+using Bro.Common.Model;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing.Design;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using static Bro.Common.Helper.EnumHelper;
+
+namespace Bro.M071.Process
+{
+ public partial class M071Process
+ {
+ Timer _resetTimer = null;
+ const int FULLRESETTIME = 5;
+
+ MachineState machineState = MachineState.Unknown;
+ MachineState MachineState
+ {
+ get => machineState;
+ set
+ {
+ machineState = value;
+
+ switch (machineState)
+ {
+ case MachineState.Ready:
+ break;
+ case MachineState.Running:
+ break;
+ case MachineState.Alarm:
+ break;
+ case MachineState.Pause:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ [ProcessMethod("MotionCardBase", "Reset", "绠�鍗曞浣嶆搷浣�", InvokeType.TestInvoke)]
+ public ProcessResponse Reset(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ //if (opConfig == null)
+ //{
+ // var monitorSet = Config.MonitorSetCollection.FirstOrDefault(u => u.MethodCode == "Reset");
+ // if (monitorSet == null)
+ // throw new ProcessException("鏈厤缃粯璁ゅ浣嶆搷浣�");
+
+ // opConfig = monitorSet.OpConfig;
+ // if (opConfig == null)
+ // throw new ProcessException("鏈厤缃浣嶆搷浣滃叿浣撻厤缃姩浣�");
+
+ // if (invokeDevice == null)
+ // {
+ // invokeDevice = DeviceCollection.FirstOrDefault(u => u.Id == monitorSet.InvokeDevice);
+ // if (invokeDevice == null)
+ // throw new ProcessException("鏈厤缃浣嶆搷浣滄墽琛岃澶�");
+ // }
+ //}
+
+ MotionCardDefaultRun("Reset", ref opConfig, ref invokeDevice);
+
+ 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 (invokeDevice is MotionCardBase motionCard)
+ //{
+ // motionCard.Run(opConfig);
+ //}
+
+ return new ProcessResponse(true);
+ }
+
+ private void FullReset(object state)
+ {
+ FullReset(null, null, null);
+ }
+
+ [ProcessMethod("MotionCardOperationConfigCollection", "FullReset", "澶у浣嶆搷浣�", InvokeType.TestInvoke)]
+ public ProcessResponse FullReset(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ //if (opConfig == null)
+ //{
+ // var monitorSet = Config.MonitorSetCollection.FirstOrDefault(u => u.MethodCode == "FullReset");
+ // if (monitorSet == null)
+ // throw new ProcessException("鏈厤缃粯璁ゅぇ澶嶄綅鎿嶄綔");
+
+ // opConfig = monitorSet.OpConfig;
+ // if (opConfig == null)
+ // throw new ProcessException("鏈厤缃ぇ澶嶄綅鎿嶄綔鍏蜂綋閰嶇疆鍔ㄤ綔");
+
+ // if (invokeDevice == null)
+ // {
+ // invokeDevice = DeviceCollection.FirstOrDefault(u => u.Id == monitorSet.InvokeDevice);
+ // if (invokeDevice == null)
+ // throw new ProcessException("鏈厤缃ぇ澶嶄綅鎿嶄綔鎵ц璁惧");
+ // }
+ //}
+
+ //if (invokeDevice is MotionCardBase motionCard)
+ //{
+ // motionCard.Run(opConfig);
+ //}
+
+ MotionCardDefaultRun("FullReset", ref opConfig, ref invokeDevice);
+
+ return new ProcessResponse(true);
+ }
+
+ /// <summary>
+ /// 鏆傚仠鏍囧織
+ /// WaitHandle 鏆傚仠鍙ユ焺 榛樿涓洪潪闃诲 鍙墽琛�
+ /// WaitResult 鏆傚仠鏍囧織 true 姝e父鎵ц false 鏆傚仠涓�
+ /// </summary>
+ ManualWaitConfirm _pauseHandle = new ManualWaitConfirm()
+ {
+ WaitHandle = new ManualResetEvent(true),
+ WaitResult = true,
+ };
+
+ [ProcessMethod("", "PauseJob", "鏆傚仠娴佺▼", InvokeType.TestInvoke)]
+ public ProcessResponse PauseJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ if (_pauseHandle.WaitResult)
+ {
+ #region 鏉垮崱鏆傚仠鍔ㄤ綔
+ #endregion
+
+ _pauseHandle.WaitHandle.Reset();
+ }
+ else
+ {
+ #region 鏉垮崱鎭㈠鍔ㄤ綔
+ #endregion
+
+ _pauseHandle.WaitHandle.Set();
+ }
+
+ _pauseHandle.WaitResult = !_pauseHandle.WaitResult;
+ return new ProcessResponse(_pauseHandle.WaitResult);
+ }
+
+ [ProcessMethod("MotionCardBase", "SwitchLightRed", "鍒囨崲鎸囩ず鐏�-绾�", InvokeType.TestInvoke)]
+ public ProcessResponse SwitchLightRed(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ MotionCardDefaultRun("SwitchLightRed", ref opConfig, ref invokeDevice);
+ return new ProcessResponse(true);
+ }
+
+ [ProcessMethod("MotionCardBase", "SwitchLightYellow", "鍒囨崲鎸囩ず鐏�-榛�", InvokeType.TestInvoke)]
+ public ProcessResponse SwitchLightYellow(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ return new ProcessResponse(true);
+ }
+
+ [ProcessMethod("MotionCardBase", "SwitchLightGreen", "鍒囨崲鎸囩ず鐏�-缁�", InvokeType.TestInvoke)]
+ public ProcessResponse SwitchLightGreen(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ return new ProcessResponse(true);
+ }
+
+ [ProcessMethod("MotionCardBase", "SwitchBeep", "鍒囨崲铚傞福鍣�", InvokeType.TestInvoke)]
+ public ProcessResponse SwitchBeep(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ return new ProcessResponse(true);
+ }
+
+ [ProcessMethod("MotionCardBase", "SwitchNormalLight", "鍒囨崲鏃ュ厜鐏�", InvokeType.TestInvoke)]
+ public ProcessResponse SwitchNormalLight(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ MotionCardDefaultRun("SwitchNormalLight", ref opConfig, ref invokeDevice);
+
+ return new ProcessResponse(true);
+ }
+
+ private void MotionCardDefaultRun(string methodCode, ref IOperationConfig opConfig, ref IDevice invokeDevice)
+ {
+ IMonitorSet monitorSet = null;
+ if (opConfig == null)
+ {
+ monitorSet = Config.MonitorSetCollection.FirstOrDefault(u => u.MethodCode == methodCode);
+ if (monitorSet == null)
+ throw new ProcessException("鏈厤缃粯璁ゆ搷浣�");
+
+ opConfig = monitorSet.OpConfig;
+ if (opConfig == null)
+ throw new ProcessException("鏈厤缃叿浣撻厤缃姩浣�");
+ }
+
+ if (invokeDevice == null)
+ {
+ invokeDevice = DeviceCollection.FirstOrDefault(u => u.Id == monitorSet.InvokeDevice);
+ if (invokeDevice == null)
+ throw new ProcessException("鏈厤缃搷浣滄墽琛岃澶�");
+ }
+
+ if (invokeDevice is MotionCardBase motionCard)
+ {
+ motionCard.Run(opConfig);
+ }
+ }
+ }
+}
--
Gitblit v1.8.0