|
@@ -0,0 +1,94 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Forms;
|
|
|
+using PowerTestDemo.com;
|
|
|
+using AppLibs.Devices;
|
|
|
+using System.Threading;
|
|
|
+
|
|
|
+namespace PowerTestDemo.models
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 增益测试测试模板,继承自指标测试模板基类
|
|
|
+ /// </summary>
|
|
|
+ public class OutputVoltage : BaseModel
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 测试模板名称,测试指标配置表中的模板名称源自这个参数
|
|
|
+ /// </summary>
|
|
|
+ public OutputVoltage()
|
|
|
+ {
|
|
|
+ //首先要定义模板名称,excel 自动测试项总表中的指标测试模板的名称要和这个名称一致
|
|
|
+ TemplateName = "输出电压模板";
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 重写的Run方法,当执行到这个测试指标项时,Run会被调用
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="parameters"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public override bool Run(TestNode parameters)
|
|
|
+ {
|
|
|
+ //检查当前指标需要的仪器是否OK,
|
|
|
+ //var sig = this.tps.GetDevice("信号源1");
|
|
|
+ //var spe = this.tps.GetDevice("频谱仪");
|
|
|
+ //if(sig == null || spe == null)
|
|
|
+ //{
|
|
|
+ // ShowMessage(MsgType.Error, string.Format("仪器不齐全,{0}/{1}无法运行",parameters.Channel,parameters.Name));
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+
|
|
|
+ int ch = parameters.Parameters.GetParameter<int>("板卡通道");
|
|
|
+ double[] ratedThreshold= parameters.Parameters.GetParameterToArray<double>("+15V1空载阈值");
|
|
|
+ double[] downThreshold = parameters.Parameters.GetParameterToArray<double>("下拉偏阈值");
|
|
|
+ double[] upThreshold = parameters.Parameters.GetParameterToArray<double>("上拉偏阈值");
|
|
|
+
|
|
|
+ if (ratedThreshold == null)
|
|
|
+ {
|
|
|
+ ShowMessage(MsgType.Error, string.Format("配置文件中频率参数为空,{0}/{1}无法运行",parameters.Channel,parameters.Name));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始测试
|
|
|
+ Thread.Sleep(50);
|
|
|
+ Random rd = new Random();
|
|
|
+ double result = 0;
|
|
|
+ result = rd.NextDouble();
|
|
|
+ result = double.Parse(String.Format("{0:F2}", result));
|
|
|
+ if (parameters.Channel == "+15V1")
|
|
|
+ this.tps.SetTestTableCellValue(6, 1, true, result + 14.5);
|
|
|
+ else if (parameters.Channel == "-15V1")
|
|
|
+ this.tps.SetTestTableCellValue(6, 2, true, result - 15.5);
|
|
|
+ else if (parameters.Channel == "+5V1")
|
|
|
+ this.tps.SetTestTableCellValue(6, 3, true, result + 4.5);
|
|
|
+ else if (parameters.Channel == "-5V")
|
|
|
+ this.tps.SetTestTableCellValue(6, 4, true, result - 5.5);
|
|
|
+ else if (parameters.Channel == "+12V")
|
|
|
+ this.tps.SetTestTableCellValue(6, 5, true, result + 11.5);
|
|
|
+ else if (parameters.Channel == "+15V2")
|
|
|
+ this.tps.SetTestTableCellValue(6, 6, true, result + 14.5);
|
|
|
+ else if (parameters.Channel == "-15V2")
|
|
|
+ this.tps.SetTestTableCellValue(6, 7, true, result - 15.5);
|
|
|
+ else if (parameters.Channel == "+5V2")
|
|
|
+ this.tps.SetTestTableCellValue(6, 8, true, result + 4.5);
|
|
|
+ else if (parameters.Channel == "+50V")
|
|
|
+ this.tps.SetTestTableCellValue(6, 9, true, result + 49.5);
|
|
|
+ else if (parameters.Channel == "+25V")
|
|
|
+ this.tps.SetTestTableCellValue(6, 10, true, result + 24.5);
|
|
|
+ else if (parameters.Channel == "+28V")
|
|
|
+ this.tps.SetTestTableCellValue(6, 11, true, result + 27.5);
|
|
|
+
|
|
|
+ //当测试过程比较久时,要走合适的地方检测IsRuning
|
|
|
+ if (IsRuning == false)
|
|
|
+ {
|
|
|
+ //过程中如果IsRunning为false,表示按了停止测试按钮,要退出程序运行
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|