OutputOvershoot.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. using PowerTestDemo.com;
  8. using AppLibs.Devices;
  9. using System.Threading;
  10. namespace PowerTestDemo.models
  11. {
  12. /// <summary>
  13. /// 增益测试测试模板,继承自指标测试模板基类
  14. /// </summary>
  15. public class OutputOvershoot : BaseModel
  16. {
  17. /// <summary>
  18. /// 测试模板名称,测试指标配置表中的模板名称源自这个参数
  19. /// </summary>
  20. public OutputOvershoot()
  21. {
  22. //首先要定义模板名称,excel 自动测试项总表中的指标测试模板的名称要和这个名称一致
  23. TemplateName = "输出过冲模板";
  24. }
  25. /// <summary>
  26. /// 重写的Run方法,当执行到这个测试指标项时,Run会被调用
  27. /// </summary>
  28. /// <param name="parameters"></param>
  29. /// <returns></returns>
  30. public override bool Run(TestNode parameters)
  31. {
  32. //检查当前指标需要的仪器是否OK,
  33. //var sig = this.tps.GetDevice("信号源1");
  34. //var spe = this.tps.GetDevice("频谱仪");
  35. //if(sig == null || spe == null)
  36. //{
  37. // ShowMessage(MsgType.Error, string.Format("仪器不齐全,{0}/{1}无法运行",parameters.Channel,parameters.Name));
  38. // return false;
  39. //}
  40. double[] threshold = parameters.Parameters.GetParameterToArray<double>("阈值");
  41. int delay = parameters.Parameters.GetParameter<int>("通道延迟");
  42. if (threshold == null)
  43. {
  44. ShowMessage(MsgType.Error, string.Format("配置文件中频率参数为空,{0}/{1}无法运行", parameters.Channel, parameters.Name));
  45. return false;
  46. }
  47. //开始测试
  48. Thread.Sleep(50);
  49. Random rd = new Random();
  50. double result = 0;
  51. result = 3 + rd.NextDouble() * 5;
  52. result = double.Parse(String.Format("{0:F2}", result));
  53. if (parameters.Channel == "+15V1")
  54. this.tps.SetTestTableCellValue(8, 1, true, result );
  55. else if (parameters.Channel == "-15V1")
  56. this.tps.SetTestTableCellValue(8, 2, true, result );
  57. else if (parameters.Channel == "+5V1")
  58. this.tps.SetTestTableCellValue(8, 3, true, result );
  59. else if (parameters.Channel == "-5V")
  60. this.tps.SetTestTableCellValue(8, 4, true, result );
  61. else if (parameters.Channel == "+12V")
  62. this.tps.SetTestTableCellValue(8, 5, true, result );
  63. else if (parameters.Channel == "+15V2")
  64. this.tps.SetTestTableCellValue(8, 6, true, result );
  65. else if (parameters.Channel == "-15V2")
  66. this.tps.SetTestTableCellValue(8, 7, true, result );
  67. else if (parameters.Channel == "+5V2")
  68. this.tps.SetTestTableCellValue(8, 8, true, result );
  69. else if (parameters.Channel == "+50V")
  70. this.tps.SetTestTableCellValue(8, 9, true, result );
  71. else if (parameters.Channel == "+25V")
  72. this.tps.SetTestTableCellValue(8, 10, true, result);
  73. else if (parameters.Channel == "+28V")
  74. this.tps.SetTestTableCellValue(8, 11, true, result);
  75. //当测试过程比较久时,要走合适的地方检测IsRuning
  76. if (IsRuning == false)
  77. {
  78. //过程中如果IsRunning为false,表示按了停止测试按钮,要退出程序运行
  79. return false;
  80. }
  81. return true;
  82. }
  83. }
  84. }