| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using PropertyGridLib.Controls;
- using TeamAAS.FlowEditor.Plugins;
- using TeamAAS.FlowEngine.FormulaData;
- using PropertyGridLib.Attributes;
- namespace Plugins.Vpp.Models
- {
- /// <summary>
- /// VP 图像显示节点模型:把上游输出的图层/图像显示到指定画面框(视觉窗体),
- /// 每个显示项可独立链接 OK/NG 结果(可不链接)驱动该画面框的状态圆点。
- /// </summary>
- [Serializable]
- public class VppDisplayModel : BasePluginModel
- {
- [Category("属性")]
- [DisplayName("1.显示项列表")]
- [Description("配置图层到画面框的显示映射,可添加多条;每项可独立链接 OK/NG(可不链接)")]
- [CollectionEditor(CanAdd = true, CanRemove = true, CanSort = true)]
- [FormulaEditor(typeof(InputSourceDataProvider))]
- public List<VppDisplayItem> DisplayItems { get; set; } = new List<VppDisplayItem>();
- }
- [Serializable]
- public class VppDisplayItem
- {
- /// <summary>目标画面序号(实际存储值,运行逻辑按 windows[FrameNo-1] 取窗体);UI 通过 FrameName 按名称选择</summary>
- [Browsable(false)]
- public int FrameNo { get; set; } = 1;
- /// <summary>
- /// 目标画面名称(属性网格中显示/选择的项):下拉项来自当前产品「画面列表」,
- /// 选择名称时映射为序号写入 <see cref="FrameNo"/>,读取时按序号还原名称。
- /// 计算属性,不参与序列化。
- /// </summary>
- [DisplayName("1.目标画面")]
- [Category("属性")]
- [Description("从当前产品的画面列表中选择目标画面,按名称选择、内部存储对应序号")]
- [TypeConverter(typeof(Plugins.Vpp.Core.FrameNameConverter))]
- [Newtonsoft.Json.JsonIgnore]
- public string FrameName
- {
- get => Plugins.Vpp.Core.FrameNameConverter.GetFrameName(
- Plugins.Vpp.Core.FrameNameConverter.GetFrames(), FrameNo);
- set
- {
- int no = Plugins.Vpp.Core.FrameNameConverter.ResolveFrameNo(value);
- if (no >= 1) FrameNo = no;
- }
- }
- [DisplayName("2.链接图层")]
- [Category("属性")]
- [Description("链接上游输出:图层(ICogRecord)/图像(ICogImage)/相机图像(GenImage)均可")]
- [FormulaEditor(typeof(InputSourceDataProvider))]
- public FormulaBound<object> Source { get; set; } = new FormulaBound<object>();
- [DisplayName("3.OK/NG 链接(可选)")]
- [Category("属性")]
- [Description("链接该画面的结果公式;为空 = 不链接(该画面框圆点保持原状)。非空时按真假把圆点刷成 绿/红")]
- [FormulaEditor(typeof(InputSourceDataProvider))]
- public FormulaBound<bool> OkNgBinding { get; set; } = new FormulaBound<bool>();
- public override string ToString()
- => $"{FrameName} ← {Source?.Formula ?? "(未链接)"}{(string.IsNullOrWhiteSpace(OkNgBinding?.Formula) ? "" : " | OK/NG")}";
- }
- }
|