diff --git a/Library.Core/FlipflopContext.cs b/Library.Core/FlipflopContext.cs
index a9e6862..cabf969 100644
--- a/Library.Core/FlipflopContext.cs
+++ b/Library.Core/FlipflopContext.cs
@@ -71,7 +71,7 @@ namespace Serein.Library.Core
{
public FlipflopStateType State { get; set; }
- public TriggerType Type { get; set; }
+ public TriggerDescription Type { get; set; }
public TResult Value { get; set; }
public FlipflopContext(FlipflopStateType ffState)
diff --git a/Library.Framework/FlipflopContext.cs b/Library.Framework/FlipflopContext.cs
index b1be1a5..c3fa51a 100644
--- a/Library.Framework/FlipflopContext.cs
+++ b/Library.Framework/FlipflopContext.cs
@@ -63,7 +63,7 @@ namespace Serein.Library.Framework.NodeFlow
{
public FlipflopStateType State { get; set; }
- public TriggerType Type { get; set; }
+ public TriggerDescription Type { get; set; }
public TResult Value { get; set; }
public FlipflopContext(FlipflopStateType ffState)
diff --git a/Library/Api/IFlipflopContext.cs b/Library/Api/IFlipflopContext.cs
index 288d2f5..10be21e 100644
--- a/Library/Api/IFlipflopContext.cs
+++ b/Library/Api/IFlipflopContext.cs
@@ -17,7 +17,7 @@ namespace Serein.Library.Api
///
/// 触发类型
///
- TriggerType Type { get; set; }
+ TriggerDescription Type { get; set; }
///
/// 触发时传递的数据
///
diff --git a/Library/Api/IFlowTrigger.cs b/Library/Api/IFlowTrigger.cs
new file mode 100644
index 0000000..33b07bb
--- /dev/null
+++ b/Library/Api/IFlowTrigger.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Serein.Library.Api
+{
+ ///
+ /// 触发器接口
+ ///
+ ///
+ public interface IFlowTrigger
+ {
+ ///
+ /// 等待信号触发并指定超时时间
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> WaitTriggerWithTimeoutAsync(TSignal signal, TimeSpan outTime);
+ ///
+ /// 等待信号触发
+ ///
+ /// 预期的返回值类型
+ ///
+ ///
+ Task> WaitTriggerAsync(TSignal signal);
+ ///
+ /// 调用触发器
+ ///
+ /// 预期的返回值类型
+ /// 信号
+ /// 返回值
+ ///
+ Task InvokeTriggerAsync(TSignal signal, TResult value);
+ ///
+ /// 取消所有触发器
+ ///
+ void CancelAllTrigger();
+ }
+
+}
diff --git a/Library/Enums/NodeType.cs b/Library/Enums/NodeType.cs
index 44b472b..90f211e 100644
--- a/Library/Enums/NodeType.cs
+++ b/Library/Enums/NodeType.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -72,6 +73,9 @@ namespace Serein.Library
///
public enum NodeControlType
{
+ ///
+ /// 预料之外的情况
+ ///
None,
///
/// 动作节点
@@ -81,25 +85,31 @@ namespace Serein.Library
/// 触发器节点
///
Flipflop,
+
///
/// 表达式操作节点
///
+ [Description("base")]
ExpOp,
///
/// 表达式操作节点
///
+ [Description("base")]
ExpCondition,
///
/// 条件节点区域
///
+ [Description("base")]
ConditionRegion,
///
/// 全局数据
///
+ [Description("base")]
GlobalData,
///
/// 脚本节点
///
+ [Description("base")]
Script,
}
diff --git a/Library/FlowNode/NodeModelBaseFunc.cs b/Library/FlowNode/NodeModelBaseFunc.cs
index ee5a643..ef01b3a 100644
--- a/Library/FlowNode/NodeModelBaseFunc.cs
+++ b/Library/FlowNode/NodeModelBaseFunc.cs
@@ -38,7 +38,6 @@ namespace Serein.Library
}
-
///
/// 保存自定义信息
///
@@ -155,7 +154,7 @@ namespace Serein.Library
AssemblyName = MethodDetails.AssemblyName,
MethodName = MethodDetails?.MethodName,
Label = MethodDetails?.MethodAnotherName,
- Type = this.GetType().ToString(),
+ Type = ControlType.ToString() , //this.GetType().ToString(),
TrueNodes = trueNodes.ToArray(),
FalseNodes = falseNodes.ToArray(),
UpstreamNodes = upstreamNodes.ToArray(),
diff --git a/Library/Utils/ChannelFlowTrigger.cs b/Library/Utils/ChannelFlowTrigger.cs
index 34a5d5e..d65e1d6 100644
--- a/Library/Utils/ChannelFlowTrigger.cs
+++ b/Library/Utils/ChannelFlowTrigger.cs
@@ -1,5 +1,6 @@
+using Serein.Library.Api;
using System;
using System.Collections.Concurrent;
using System.Threading;
@@ -12,18 +13,22 @@ namespace Serein.Library.Utils
- public class ChannelFlowTrigger
+ public class ChannelFlowTrigger : IFlowTrigger
{
// 使用并发字典管理每个枚举信号对应的 Channel
- private readonly ConcurrentDictionary> _channels = new ConcurrentDictionary>();
+ private readonly ConcurrentDictionary>> _channels = new ConcurrentDictionary>>();
///
- /// 创建信号并指定超时时间,到期后自动触发(异步方法)
+ /// 获取或创建指定信号的 Channel
///
/// 枚举信号标识符
- /// 超时时间
- /// 等待任务
- public async Task<(TriggerType, TResult)> WaitDataWithTimeoutAsync(TSignal signal, TimeSpan outTime)
+ /// 对应的 Channel
+ private Channel> GetOrCreateChannel(TSignal signal)
+ {
+ return _channels.GetOrAdd(signal, _ => Channel.CreateUnbounded>());
+ }
+
+ public async Task> WaitTriggerWithTimeoutAsync(TSignal signal, TimeSpan outTime)
{
var channel = GetOrCreateChannel(signal);
var cts = new CancellationTokenSource();
@@ -34,7 +39,11 @@ namespace Serein.Library.Utils
try
{
await Task.Delay(outTime, cts.Token);
- await channel.Writer.WriteAsync((TriggerType.Overtime, null));
+ var outResult = new TriggerResult