IToolInfo.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. namespace CommonMethods
  8. {
  9. [Serializable]
  10. public class IToolInfo
  11. {
  12. /// <summary>
  13. /// 工具是否启用
  14. /// </summary>
  15. public bool enable { get; set; }
  16. /// <summary>
  17. /// 工具名称
  18. /// </summary>
  19. public string toolName { get; set; }
  20. /// <summary>
  21. /// 工具类型
  22. /// </summary>
  23. public ToolType toolType { get; set; }
  24. /// <summary>
  25. /// 工具对象
  26. /// </summary>
  27. public object tool { get; set; }
  28. /// <summary>
  29. /// 工具窗体,由于无法对Form进行序列化,所以作为静态变量
  30. /// </summary>
  31. [NonSerialized]
  32. public Form FormTool = new Form();
  33. /// <summary>
  34. /// 工具窗体名
  35. /// </summary>
  36. public string FormToolName { get; set; }
  37. /// <summary>
  38. /// 工具描述信息
  39. /// </summary>
  40. public string toolTipInfo { get; set; }
  41. /// <summary>
  42. /// 工具输入字典集合
  43. /// </summary>
  44. public List<ToolIO> toolInput { get; set; }
  45. /// <summary>
  46. /// 工具输出字典集合
  47. /// </summary>
  48. public List<ToolIO> toolOutput { get; set; }
  49. /// <summary>
  50. /// 工具作用描述
  51. /// </summary>
  52. public string toolDescription { get; set; }
  53. /// <summary>
  54. /// 工具运行结果
  55. /// </summary>
  56. public ToolRunStatu toolRunStatu { get; set; }
  57. /// <summary>
  58. /// 绑定的JOB名称
  59. /// </summary>
  60. public string bingingJobName { get; set; }
  61. public IToolInfo()
  62. {
  63. enable = true;
  64. toolType = ToolType.None;
  65. toolName = string.Empty;
  66. bingingJobName = string.Empty;
  67. tool = new object();
  68. toolInput = new List<ToolIO>();
  69. toolOutput = new List<ToolIO>();
  70. }
  71. /// <summary>
  72. /// 以IO名获取IO对象
  73. /// </summary>
  74. /// <param name="IOName"></param>
  75. /// <returns></returns>
  76. public ToolIO GetInput(string IOName)
  77. {
  78. for (int i = 0; i < toolInput.Count; i++)
  79. {
  80. if (toolInput[i].IOName == IOName)
  81. return toolInput[i];
  82. }
  83. return new ToolIO();
  84. }
  85. /// <summary>
  86. /// 以IO名获取IO对象
  87. /// </summary>
  88. /// <param name="IOName"></param>
  89. /// <returns></returns>
  90. public ToolIO GetOutput(string IOName)
  91. {
  92. for (int i = 0; i < toolOutput.Count; i++)
  93. {
  94. if (toolOutput[i].IOName == IOName)
  95. return toolOutput[i];
  96. }
  97. return new ToolIO();
  98. }
  99. /// <summary>
  100. /// 移除工具输入项
  101. /// </summary>
  102. /// <param name="IOName"></param>
  103. public void RemoveInputIO(string IOName)
  104. {
  105. for (int i = 0; i < toolInput.Count; i++)
  106. {
  107. if (toolInput[i].IOName == toolName)
  108. toolInput.RemoveAt(i);
  109. }
  110. }
  111. /// <summary>
  112. /// 移除工具输出项
  113. /// </summary>
  114. /// <param name="IOName"></param>
  115. public void RemoveOutputIO(string IOName)
  116. {
  117. for (int i = 0; i < toolOutput.Count; i++)
  118. {
  119. if (toolOutput[i].IOName == toolName)
  120. toolOutput.RemoveAt(i);
  121. }
  122. }
  123. public Form GetFormTool()
  124. {
  125. return FormTool;
  126. }
  127. public void SetFormTool(Form myForm)
  128. {
  129. FormTool = myForm;
  130. }
  131. }
  132. /// <summary>
  133. /// 工具的输入输出类
  134. /// </summary>
  135. [Serializable]
  136. public class ToolIO
  137. {
  138. public string IOName;
  139. public object value;
  140. public DataType ioType;
  141. public ToolIO() { }
  142. public ToolIO(string IOName1, object value1, DataType ioType1)
  143. {
  144. this.IOName = IOName1;
  145. this.value = value1;
  146. this.ioType = ioType1;
  147. }
  148. }
  149. }