ScpiFuncs_Measure.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Uestc.Auto6.Dso.Core;
  8. using Uestc.Auto6.Dso.ComModel;
  9. using UESTC.Auto.SCPIManager;
  10. namespace Uestc.Auto6.Dso.Scpi
  11. {
  12. partial class StubFunc
  13. {
  14. /// <summary>
  15. /// 设置或查询指示器
  16. /// </summary>
  17. /// <param name="analyResult"></param>
  18. /// <returns></returns>
  19. public static bool scpiSet_MeasureIndicator(SCPICommandProcessFuncParam analyResult)
  20. {
  21. if (Presenter == null || analyResult.Tag is not ScpiTagObj tagObj
  22. || !scpiSet_ParamCheck(analyResult, out string paraStr))
  23. {
  24. return false;
  25. }
  26. var measure = Presenter.Measure;
  27. if (shortCMD(paraStr) == "OFF")
  28. {
  29. Presenter.Measure.Indicator = 0;
  30. }
  31. else if ((!int.TryParse(paraStr.Replace("P", ""), out int index)) || !(index < 1 || index > measure.Length))
  32. {
  33. Presenter.Measure.Indicator = index;
  34. }
  35. else
  36. {
  37. return false;
  38. }
  39. return true;
  40. }
  41. /// <summary>
  42. /// 设置或查询指示器
  43. /// </summary>
  44. /// <param name="analyResult"></param>
  45. /// <param name="sendMessage"></param>
  46. /// <returns></returns>
  47. public static bool scpiQuy_MeasureIndicator(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
  48. {
  49. if (Presenter == null || analyResult.Tag is not ScpiTagObj tagObj)
  50. {
  51. return false;
  52. }
  53. var indicator = Presenter.Measure.Indicator;
  54. string returnStr;
  55. if (indicator <= 0)
  56. {
  57. returnStr = "OFF";
  58. }
  59. else
  60. {
  61. returnStr = $"P{indicator}";
  62. }
  63. sendMessage.SendData = decodeStr(returnStr);
  64. return true;
  65. }
  66. /// <summary>
  67. /// 设置快速采集类型。
  68. /// </summary>
  69. /// <param name="analyResult"></param>
  70. /// <returns></returns>
  71. public static bool scpiSet_MeasureUltraAcq(SCPICommandProcessFuncParam analyResult)
  72. {
  73. if (Presenter == null || analyResult.Tag is not ScpiTagObj tagObj
  74. || !scpiSet_ParamCheck(analyResult, out string paraStr))
  75. {
  76. return false;
  77. }
  78. paraStr = shortCMD(paraStr);
  79. var measure = Presenter.Measure;
  80. switch (paraStr)
  81. {
  82. case "VERT":
  83. for (Int32 i = 0; i < measure.Length; i++)
  84. {
  85. measure[i].Name = _StdVertItems[i];
  86. measure[i].Source = measure.SnapshotSource;
  87. measure[i].Source2nd = null;
  88. measure[i].Active = true;
  89. measure.ResetStat(i);
  90. }
  91. break;
  92. case "HORI":
  93. for (Int32 i = 0; i < measure.Length; i++)
  94. {
  95. measure[i].Name = _StdHorzItems[i];
  96. measure[i].Source = measure.SnapshotSource;
  97. measure[i].Source2nd = null;
  98. measure[i].Active = true;
  99. measure.ResetStat(i);
  100. }
  101. break;
  102. default:
  103. return false;
  104. }
  105. return true;
  106. }
  107. /// <summary>
  108. /// 设置所有测量项是否激活
  109. /// </summary>
  110. /// <param name="analyResult"></param>
  111. /// <returns></returns>
  112. public static bool scpiSet_MeasureAllActive(SCPICommandProcessFuncParam analyResult)
  113. {
  114. if (Presenter == null || analyResult.Tag is not ScpiTagObj tagObj
  115. || !scpiSet_ParamCheck(analyResult, out string paraStr))
  116. {
  117. return false;
  118. }
  119. paraStr = shortCMD(paraStr);
  120. var measure = Presenter.Measure;
  121. switch (paraStr)
  122. {
  123. case "ON":
  124. measure.SetAllActive(true);
  125. break;
  126. case "OFF":
  127. measure.SetAllActive(false);
  128. break;
  129. default:
  130. return false;
  131. }
  132. return true;
  133. }
  134. /// <summary>
  135. /// 设置或查询测量项类型。
  136. /// </summary>
  137. /// <param name="analyResult"></param>
  138. /// <returns></returns>
  139. public static bool scpiSet_MeasureItemType(SCPICommandProcessFuncParam analyResult)
  140. {
  141. if (Presenter == null || analyResult.Tag is not ScpiTagObj tagObj
  142. || !checkMEAItemNO(analyResult, out MeasItemPrsnt itemPrsnt)
  143. || !scpiSet_ParamCheck(analyResult, out string paraStr)
  144. )
  145. {
  146. return false;
  147. }
  148. MeasPrsnt measure = Presenter.Measure;
  149. if (!measure.ScpiNameTable.TryGetValue(shortCMD(paraStr), out string setValue))
  150. {
  151. return false;
  152. }
  153. itemPrsnt.Name = setValue;
  154. measure.ResetStat(analyResult.ChannelIndex - 1);
  155. return true;
  156. }
  157. /// <summary>
  158. /// 设置或查询测量项类型。
  159. /// </summary>
  160. /// <param name="analyResult"></param>
  161. /// <param name="sendMessage"></param>
  162. /// <returns></returns>
  163. public static bool scpiQuy_MeasureItemType(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
  164. {
  165. if (Presenter == null || !checkMEAItemNO(analyResult, out MeasItemPrsnt itemPrsnt)
  166. || analyResult.Tag is not ScpiTagObj tagObj)
  167. {
  168. return false;
  169. }
  170. MeasPrsnt measure = Presenter.Measure;
  171. string itemName = itemPrsnt.Name;
  172. var keyValue = measure.ScpiNameTable.FirstOrDefault(data => data.Value == itemName);
  173. if (string.IsNullOrWhiteSpace(keyValue.Key))
  174. {
  175. return false;
  176. }
  177. sendMessage.SendData = decodeStr(keyValue.Key);
  178. return true;
  179. }
  180. }
  181. }
  182. //================= 共8个方法 =