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 { /// /// 增益测试测试模板,继承自指标测试模板基类 /// public class InOutDelay : BaseModel { /// /// 测试模板名称,测试指标配置表中的模板名称源自这个参数 /// public InOutDelay() { //首先要定义模板名称,excel 自动测试项总表中的指标测试模板的名称要和这个名称一致 TemplateName = "输入输出延时模板"; } /// /// 重写的Run方法,当执行到这个测试指标项时,Run会被调用 /// /// /// 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; //} double[] threshold = parameters.Parameters.GetParameterToArray("+15V1阈值"); int delay = parameters.Parameters.GetParameter("通道延迟"); if (threshold == 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 = 13 + rd.NextDouble() * 8; result = double.Parse(String.Format("{0:F2}", result)); if (parameters.Channel == "+15V1") this.tps.SetTestTableCellValue(10, 1, true, result ); else if (parameters.Channel == "-15V1") this.tps.SetTestTableCellValue(10, 2, true, result ); else if (parameters.Channel == "+5V1") this.tps.SetTestTableCellValue(10, 3, true, result ); else if (parameters.Channel == "-5V") this.tps.SetTestTableCellValue(10, 4, true, result ); else if (parameters.Channel == "+12V") this.tps.SetTestTableCellValue(10, 5, true, result ); else if (parameters.Channel == "+15V2") this.tps.SetTestTableCellValue(10, 6, true, result ); else if (parameters.Channel == "-15V2") this.tps.SetTestTableCellValue(10, 7, true, result ); else if (parameters.Channel == "+5V2") this.tps.SetTestTableCellValue(10, 8, true, result ); else if (parameters.Channel == "+50V") this.tps.SetTestTableCellValue(10, 9, true, result ); else if (parameters.Channel == "+25V") this.tps.SetTestTableCellValue(10, 10, true, result); else if (parameters.Channel == "+28V") this.tps.SetTestTableCellValue(10, 11, true, result); //当测试过程比较久时,要走合适的地方检测IsRuning if (IsRuning == false) { //过程中如果IsRunning为false,表示按了停止测试按钮,要退出程序运行 return false; } return true; } } }