| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using TeamAAS.FlowEditor.Execution;
- using TeamAAS.FlowEditor.Models;
- namespace TeamAAS.FlowEditor.Plugins
- {
- /// <summary>
- /// 插件接口 - 每个工具节点对应一个插件实现
- /// 参照 VisionKit 的 IVisionTool 接口
- /// </summary>
- public interface IFlowNodePlugin : IDisposable
- {
- /// <summary>获取/设置插件模型</summary>
- BasePluginModel GetModel
- {
- get;
- set;
- }
- /// <summary>所属流程绑定的结果注册表(运行态=Main,编辑/调试态=Debug;null 时回退 Debug)</summary>
- ResultRegistry Registry { get; set; }
- /// <summary>初始化插件(加载时调用)</summary>
- bool InitPlugin();
- /// <summary>执行插件逻辑</summary>
- NodeRunStatus PluginRun(CancellationToken token, out Dictionary<string, object> results);
- /// <summary>运行插件(封装计时+状态管理,内部调用PluginRun)</summary>
- NodeRunStatus Run(CancellationToken token);
- /// <summary>
- /// 初始化运行(每次运行前调用,内部调用InitPlugin),返回是否成功
- /// </summary>
- /// <returns></returns>
- bool InitRun();
- /// <summary>运行耗时(ms)</summary>
- int CostTime { get; }
- /// <summary>执行状态</summary>
- NodeRunStatus IsSuccess { get; set; }
- /// <summary>是否启用</summary>
- bool IsEnable { get; set; }
- /// <summary>最近一次运行的结果字典</summary>
- Dictionary<string, object> LastResults { get; }
- /// <summary>声明插件的输出字段(键名+类型),创建时即知输出 schema</summary>
- List<OutputField> DeclareOutputs();
- /// <summary>分支节点返回的下一个要执行的节点名列表(null=非分支节点)</summary>
- List<string> BranchTargets { get; }
- }
- /// <summary>
- /// 插件输出字段声明
- /// </summary>
- public class OutputField
- {
- public string Key { get; }
- public Type ValueType { get; }
- public OutputField(string key, Type valueType = null)
- {
- Key = key;
- ValueType = valueType;
- }
- }
- /// <summary>
- /// 插件描述符 - 插件加载后的元信息
- /// </summary>
- public class PluginDescriptor
- {
- public System.Type PluginType { get; set; }
- public PluginAttribute Attribute { get; set; }
- public string DisplayName => Attribute?.DisplayName;
- public PluginCategory Category => Attribute?.Category ?? PluginCategory.其他;
- public string IconGeometry => Attribute?.IconGeometry;
- public bool HasCustomView => Attribute?.ViewType != null;
- public NodeCategory NodeShape => Attribute?.NodeShape ?? NodeCategory.Normal;
- /// <summary>是否为子流程专用节点(不进主流程工具箱)。</summary>
- public bool IsSubFlowNode => Attribute?.IsSubFlowNode ?? false;
- /// <summary>子流程工具箱分组用的视觉类别(VisionPlugin 枚举)。</summary>
- public VisionPlugin VisionCategory => Attribute?.VisionCategory ?? VisionPlugin.其他;
- }
- /// <summary>
- /// 工具箱项信息(UI展示用,从PluginDescriptor生成)
- /// </summary>
- public class NodePluginInfo
- {
- public string PluginId { get; set; }
- public string DisplayName { get; set; }
- public NodeCategory Category { get; set; }
- public string IconGeometry { get; set; }
- public string Description { get; set; }
- public PluginCategory Group { get; set; }
- public string FlowPluginId { get; set; }
- /// <summary>是否为子流程专用节点(true=不进主流程工具箱,只在对应子流程编辑器中出现)。</summary>
- public bool IsSubFlowNode { get; set; }
- /// <summary>子流程工具箱分组类别(VisionPlugin 枚举)。</summary>
- public VisionPlugin VisionCategory { get; set; }
- }
- }
|