using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DevService.Dto; using Casic.Birmm.RbFreqStandMeasure.Tools; using System; using System.Reflection; namespace Casic.Birmm.RbFreqStandMeasure.R_DevService.Service.Impl { class SensitivityServiceImpl:SensitivityService { public void beginTest(string type, GPIBService gPIBService, GPIBService tcpService, CounterCheckParam counterCheckParam, out SensitivityContentParam sensitivityContentParam) { sensitivityContentParam = new SensitivityContentParam(); try { //启动output(一次)OUTPUT 0\OUTPUT 1 GPIB_TCPIP_OPERATIO.output(gPIBService); //设置周期/频率、电压GPIB if (type == "freq") GPIB_TCPIP_OPERATIO.setFreq(gPIBService, sensitivityContentParam.Freq); else if (type == "period") GPIB_TCPIP_OPERATIO.setPeriod(gPIBService, sensitivityContentParam.Period); bool lessTolerance = false; string currentVolTage = "0"; while (!lessTolerance) { //获取当前灵敏度 currentVolTage = getVOLTageValue(counterCheckParam, currentVolTage); //设置当前灵敏度 GPIB_TCPIP_OPERATIO.setVOLTage(gPIBService, currentVolTage, counterCheckParam.SoOutDelay); string checkResult = ""; //主动读取检测数据LAN if (type == "freq") checkResult = GPIB_TCPIP_OPERATIO.getFreq(tcpService); else if (type == "period") checkResult = GPIB_TCPIP_OPERATIO.getPeriod(tcpService); //检测数据是否在容差范围内 //返回满足容差的数据 lessTolerance = true; } } catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "beginTest:" + ex.Message); sensitivityContentParam = null; } } string getVOLTageValue(CounterCheckParam counterCheckParam,string currentValue) { if (currentValue == "0") return counterCheckParam.SoEleFrequency; else return (Convert.ToInt32(currentValue) + Convert.ToInt32(counterCheckParam.SoEleAddValue)).ToString(); } bool satisfyCheck(CounterCheckParam counterCheckParams, SensitivityContentParam sensitivityContentParam, string currentValue,string checkType) { bool satisfyResult = false; try { if (checkType == "freq") { } else if (checkType == "period") { } satisfyResult = true; } catch(Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"statisfyCheck:"+ex.Message); satisfyResult = false; } return satisfyResult; } /** * * GPIBService gPIBService=new GPIBServiceImpl(); * GPIBService tcpService=new TCPServiceImpl(); * gPIBService.open(); * for(datagridview.row) * { * SensitivityService.beginTest() * } * gPIBService.close(); * */ } }