public static int MeasMode(uint ascanNum, uint ascanPort, DGateType type, MeasMode mode) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].MeasMode; uint val = (uint)mode; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqSet(ascanNum, ascanPort, attr, val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Set measurement mode of double gate failed!", "错误:设置门的测量模式失败!"); } return(error_code); }
public static int TolMonitorSc(uint ascanNum, uint ascanPort, DGateType type, uint tolMonitorSc) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].TolMonitorSc; uint val = tolMonitorSc; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqSet(ascanNum, ascanPort, attr, val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Set tolerance monitor suppresser count of double gate failed!", "错误:设置门的容限误差计数失败!"); } return(error_code); }
public static int AlarmLevel(uint ascanNum, uint ascanPort, DGateType type, GateAlarmLevel level) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].AlarmLevel; uint val = 0; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqSet(ascanNum, ascanPort, attr, val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Set alarm level of double gate failed!", "错误:设置门的报警等级失败!"); } level = (GateAlarmLevel)val; return(error_code); }
//需要确定 //public static int AlarmMode(uint ascanNum, uint ascanPort, GateType type, GateAlarmActive active) //{ // int error_code; // int gateNum = (int)type; // uint attr = DaqAttrType.dGate[gateNum].AlarmActive; // uint val = 0; // if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) // { // error_code = -1; // return error_code; // } // if (type < gateTypeMin || type > gateTypeMax) // { // error_code = -1; // return error_code; // } // error_code = DAQ.daqSet(ascanNum, ascanPort, attr, ref val); // if (error_code != (int)PDAQ_ERR.GOOD) // { // MessageShow.show("Error:Get alarm active double gate failed!", "错误:获得门的报警使能失败!"); // } // active = (GateAlarmActive)val; // return error_code; //} public static int AlarmSignalLength(uint ascanNum, uint ascanPort, DGateType type, GateAlarmSignalLength length) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].AlarmSignalLength; uint val = (uint)length; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqSet(ascanNum, ascanPort, attr, val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Set alarm singal length of double gate failed!", "错误:设置门的报警信号长度失败!"); } return(error_code); }
public static int AlarmActive(uint ascanNum, uint ascanPort, DGateType type, GateAlarmActive active) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].AlarmActive; uint val = (uint)active; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqSet(ascanNum, ascanPort, attr, val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Get alarm active of double gate failed!", "错误:获得门的报警使能失败!"); } return(error_code); }
public static int TolMonitorMin(uint ascanNum, uint ascanPort, DGateType type, ref double tolMonitorMin) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].TolMonitorMin; double val = 0; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqGet(ascanNum, ascanPort, attr, ref val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Get tolerance monitor min of double gate failed!", "错误:获得门的最小容限误差失败!"); } tolMonitorMin = val; return(error_code); }
public static int MeasActive(uint ascanNum, uint ascanPort, DGateType type, MeasActive active) { int error_code; int gateNum = (int)type; uint attr = DaqAttrType.dGate[gateNum].MeasActive; uint val = 0; if (ascanNum < ascanNumMin || ascanNum > ascanNumMax) { error_code = -1; return(error_code); } if (type < gateTypeMin || type > gateTypeMax) { error_code = -1; return(error_code); } error_code = DAQ.daqGet(ascanNum, ascanPort, attr, ref val); if (error_code != (int)PDAQ_ERR.GOOD) { MessageShow.show("Error:Get measurement active of double gate failed!", "错误:获得门的测量使能失败!"); } active = (MeasActive)val; return(error_code); }
private void setTolMonitorMin(GateType gateType, DGateType dGateType, double tolMonitorMin) { if ((TolMonitorMode)tolMonitorMode1 == TolMonitorMode.Gate) { SetGateDAQ.TolMonitorMin(SelectAscan.sessionIndex, SelectAscan.port, gateType, tolMonitorMin); } else { SetDGateDAQ.TolMonitorMin(SelectAscan.sessionIndex, SelectAscan.port, dGateType, tolMonitorMin); } }
private void setTolMonitorSc(GateType gateType, DGateType dGateType, uint suppressCnt) { if ((TolMonitorMode)tolMonitorMode1 == TolMonitorMode.Gate) { SetGateDAQ.TolMonitorSc(SelectAscan.sessionIndex, SelectAscan.port, gateType, suppressCnt); } else { SetDGateDAQ.TolMonitorSc(SelectAscan.sessionIndex, SelectAscan.port, dGateType, suppressCnt); } }
private void setCheckBox(int tolMonitorIndex, GateType gateType, DGateType dGateType) { bool isCheckBoxChecked; isCheckBoxChecked = ((CheckBox)(Controls.Find("checkBox" + tolMonitorIndex + "ON", true)[0])).Checked; if (isCheckBoxChecked == true) { setControlsEnabled(tolMonitorIndex, true); ((RadioButton)(Controls.Find("dGate" + tolMonitorIndex, true)[0])).Checked = true;//Active double gate tolerance monitor defaultly } else { setControlsEnabled(tolMonitorIndex, false); SetGateDAQ.TolMonitorActive(SelectAscan.sessionIndex, SelectAscan.port, gateType, TMActive.OFF); SetDGateDAQ.TolMonitorActive(SelectAscan.sessionIndex, SelectAscan.port, dGateType, TMActive.OFF); } }
private void getGateTolMonitor(GateType gateType, DGateType dGatetType, int tolMonitorIndex) { int error_code; double min = 0; double max = 0; uint suppressCnt = 0; //Close double gate tolerance active error_code = SetDGateDAQ.TolMonitorActive(SelectAscan.sessionIndex, SelectAscan.port, dGatetType, TMActive.OFF); if (error_code != 0) { return; } //Open gate tolerance active error_code = SetGateDAQ.TolMonitorActive(SelectAscan.sessionIndex, SelectAscan.port, gateType, TMActive.ON); if (error_code != 0) { return; } error_code = GetGateDAQ.TolMonitorMax(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref max); if (error_code != 0) { return; } ((NumericUpDown)(Controls.Find("numUpDownMax" + tolMonitorIndex, true)[0])).Text = max.ToString(); error_code = GetGateDAQ.TolMonitorMin(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref min); if (error_code != 0) { return; } ((NumericUpDown)(Controls.Find("numUpDownMin" + tolMonitorIndex, true)[0])).Text = min.ToString(); error_code = GetGateDAQ.TolMonitorSc(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref suppressCnt); if (error_code != 0) { return; } ((NumericUpDown)(Controls.Find("numUpDownSc" + tolMonitorIndex, true)[0])).Text = suppressCnt.ToString(); }
/**Caculate tolMonitorMax and tolMonitorMin accordint to dGateType. * @param gateType1 and gateType2 accord to dGateType. * */ private void tolMonitorAccordToDGate(GateType gateType1, GateType gateType2, DGateType dGateType, int tolMonitorIndex) { int error_code; GateType gateType; double tolMonitorMax; double tolMonitorMin; int gate1 = 0; int gate2 = 1; double[] delay = new double[2] { 0, 0 }; //index=0,delay of gateType1;index=1,delay of gateType2 double[] width = new double[2] { 0, 0 }; double[] gateEnd = new double[2] { 0, 0 }; for (int i = 0; i < 2; i++) { if (i == 0) { gateType = gateType1; } else { gateType = gateType2; } error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref delay[i]); if (error_code != 0) { return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref width[i]); if (error_code != 0) { return; } gateEnd[i] = delay[i] + width[i]; } //caculate tolMonitorMax and tolMonitorMin if (delay[gate1] > delay[gate2]) { if (delay[gate1] > gateEnd[gate2]) { tolMonitorMax = gateEnd[gate1] - delay[gate2]; tolMonitorMin = delay[gate1] - gateEnd[gate2]; } else if (delay[gate1] <= gateEnd[gate2] && gateEnd[gate2] <= gateEnd[gate1]) { tolMonitorMax = gateEnd[gate1] - delay[gate2]; tolMonitorMin = 0; } else { tolMonitorMax = gateEnd[gate2] - delay[gate2]; tolMonitorMin = 0; } } else { if (delay[gate2] > gateEnd[gate1]) { tolMonitorMax = gateEnd[gate2] - delay[gate1]; tolMonitorMin = delay[gate2] - gateEnd[gate1]; } else if (delay[gate2] <= gateEnd[gate1] && gateEnd[gate1] <= gateEnd[gate2]) { tolMonitorMax = gateEnd[gate2] - delay[gate1]; tolMonitorMin = 0; } else { tolMonitorMax = gateEnd[gate1] - delay[gate1]; tolMonitorMin = 0; } } ((NumericUpDown)(Controls.Find("numUpDownMax" + tolMonitorIndex, true)[0])).Text = tolMonitorMax.ToString(); ((NumericUpDown)(Controls.Find("numUpDownMin" + tolMonitorIndex, true)[0])).Text = tolMonitorMin.ToString(); SetDGateDAQ.TolMonitorMax(SelectAscan.sessionIndex, SelectAscan.port, dGateType, tolMonitorMax); SetDGateDAQ.TolMonitorMin(SelectAscan.sessionIndex, SelectAscan.port, dGateType, tolMonitorMin); }