VppDisplayModel.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using PropertyGridLib.Controls;
  5. using TeamAAS.FlowEditor.Plugins;
  6. using TeamAAS.FlowEngine.FormulaData;
  7. using PropertyGridLib.Attributes;
  8. namespace Plugins.Vpp.Models
  9. {
  10. /// <summary>
  11. /// VP 图像显示节点模型:把上游输出的图层/图像显示到指定画面框(视觉窗体),
  12. /// 每个显示项可独立链接 OK/NG 结果(可不链接)驱动该画面框的状态圆点。
  13. /// </summary>
  14. [Serializable]
  15. public class VppDisplayModel : BasePluginModel
  16. {
  17. [Category("属性")]
  18. [DisplayName("1.显示项列表")]
  19. [Description("配置图层到画面框的显示映射,可添加多条;每项可独立链接 OK/NG(可不链接)")]
  20. [CollectionEditor(CanAdd = true, CanRemove = true, CanSort = true)]
  21. [FormulaEditor(typeof(InputSourceDataProvider))]
  22. public List<VppDisplayItem> DisplayItems { get; set; } = new List<VppDisplayItem>();
  23. }
  24. [Serializable]
  25. public class VppDisplayItem
  26. {
  27. /// <summary>目标画面序号(实际存储值,运行逻辑按 windows[FrameNo-1] 取窗体);UI 通过 FrameName 按名称选择</summary>
  28. [Browsable(false)]
  29. public int FrameNo { get; set; } = 1;
  30. /// <summary>
  31. /// 目标画面名称(属性网格中显示/选择的项):下拉项来自当前产品「画面列表」,
  32. /// 选择名称时映射为序号写入 <see cref="FrameNo"/>,读取时按序号还原名称。
  33. /// 计算属性,不参与序列化。
  34. /// </summary>
  35. [DisplayName("1.目标画面")]
  36. [Category("属性")]
  37. [Description("从当前产品的画面列表中选择目标画面,按名称选择、内部存储对应序号")]
  38. [TypeConverter(typeof(Plugins.Vpp.Core.FrameNameConverter))]
  39. [Newtonsoft.Json.JsonIgnore]
  40. public string FrameName
  41. {
  42. get => Plugins.Vpp.Core.FrameNameConverter.GetFrameName(
  43. Plugins.Vpp.Core.FrameNameConverter.GetFrames(), FrameNo);
  44. set
  45. {
  46. int no = Plugins.Vpp.Core.FrameNameConverter.ResolveFrameNo(value);
  47. if (no >= 1) FrameNo = no;
  48. }
  49. }
  50. [DisplayName("2.链接图层")]
  51. [Category("属性")]
  52. [Description("链接上游输出:图层(ICogRecord)/图像(ICogImage)/相机图像(GenImage)均可")]
  53. [FormulaEditor(typeof(InputSourceDataProvider))]
  54. public FormulaBound<object> Source { get; set; } = new FormulaBound<object>();
  55. [DisplayName("3.OK/NG 链接(可选)")]
  56. [Category("属性")]
  57. [Description("链接该画面的结果公式;为空 = 不链接(该画面框圆点保持原状)。非空时按真假把圆点刷成 绿/红")]
  58. [FormulaEditor(typeof(InputSourceDataProvider))]
  59. public FormulaBound<bool> OkNgBinding { get; set; } = new FormulaBound<bool>();
  60. public override string ToString()
  61. => $"{FrameName} ← {Source?.Formula ?? "(未链接)"}{(string.IsNullOrWhiteSpace(OkNgBinding?.Formula) ? "" : " | OK/NG")}";
  62. }
  63. }