private int initGatePositionPara() { int error_code; double delay = 0; double width = 0; double threshold = 0; error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref delay); if (error_code != 0) { return(error_code); } numUpDownDelay.Text = delay.ToString(); error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref width); if (error_code != 0) { return(error_code); } numUpDownWidth.Text = width.ToString(); error_code = GetGateDAQ.Threshold(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref threshold); if (error_code != 0) { return(error_code); } numUpDownThreshold.Text = threshold.ToString(); return(error_code); }
private void tolMonitorAccordToGate(GateType gateType, int tolMonitorIndex) { int error_code; double delay = 0; double width = 0; double tolMonitorMax; double tolMonitorMin; error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref delay); if (error_code != 0) { return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gateType, ref width); if (error_code != 0) { return; } tolMonitorMin = delay; tolMonitorMax = delay + width; ((NumericUpDown)(Controls.Find("numUpDownMax" + tolMonitorIndex, true)[0])).Text = tolMonitorMax.ToString(); ((NumericUpDown)(Controls.Find("numUpDownMin" + tolMonitorIndex, true)[0])).Text = tolMonitorMin.ToString(); }
public static bool setTofMode(uint sessionIndex, uint port, GateType gateNum, TofMode tofMode) { int error_code; bool isSetPre = false; AscanWaveDectionMode waveMode = AscanWaveDectionMode.Rf; IFActive iFGate = IFActive.OFF; error_code = GetGateDAQ.IFActive(SelectAscan.sessionIndex, SelectAscan.port, GateType.I, ref iFGate); if (error_code != 0) { return(isSetPre = true); } error_code = GetAsacnVideoDAQ.DetectionWaveMode(SelectAscan.sessionIndex, SelectAscan.port, ref waveMode); if (error_code != 0) { return(isSetPre = true); } if (tofMode == TofMode.ZeroAfter || tofMode == TofMode.ZeroBefore) { if (waveMode != AscanWaveDectionMode.Rf) { MessageShow.show("Warn:TOF Mode = Zero Befor,Need to set Wave Mode->RF Mode!", "警告:TOF模式为Zero Befor,必须设置检波模式为RF模式"); return(isSetPre = true); } else if ((gateNum == GateType.I) && (iFGate == IFActive.ON)) { MessageShow.show("Warn:The function of IF Gate or IF Start has opened, can't Set!", "警告:IF Gate 或 IF Start功能开启,不能设置!"); return(isSetPre = true); } } else if (tofMode == TofMode.Peak) { if ((gateNum == GateType.I) && (iFGate == IFActive.ON)) { MessageShow.show("Warn:The function of IF Gate or IF Start has opened, can't Set!", "警告:IF Gate 或 IF Start功能开启,不能设置!"); return(isSetPre = true); } } error_code = SetGateDAQ.tofMode(SelectAscan.sessionIndex, SelectAscan.port, gateNum, tofMode); if (error_code != 0) { return(isSetPre = true); } return(isSetPre); }
private int initRadioButttonOfGateLogic() { int error_code; GateAlarmLogic gateLogic = GateAlarmLogic.Negative; GateAlarmActive alarmActive = GateAlarmActive.OFF; error_code = GetGateDAQ.AlarmActive(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref alarmActive); if (error_code != 0) { return(error_code); } if (alarmActive == GateAlarmActive.OFF) { radioButtonOff.Checked = true; return(error_code); } else if (alarmActive == GateAlarmActive.ON) { error_code = GetGateDAQ.AlarmLogic(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref gateLogic); if (error_code != 0) { return(error_code); } switch (gateLogic) { case GateAlarmLogic.Negative: radioButtonNegative.Checked = true; break; case GateAlarmLogic.Positive: radioButtonPositive.Checked = true; break; default: error_code = -1; MessageShow.show("Warn:Bind the controls of gate logic failed!", "警告:绑定Gate logic 的控件失败!"); break; } return(error_code); } else { MessageShow.show("Warn:Get the testing of gate logic!", "警告:获取Gate logic 的测试模式!"); return(error_code = -1); } }
private int initNumUpDownSupressCount() { int error_code; uint supressCount = 0; error_code = GetGateDAQ.ScCounter(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref supressCount); if (error_code != 0) { checkBoxOn.Checked = false; numUpDownSupressCount.Enabled = false; } else { numUpDownSupressCount.Value = supressCount; } return(error_code); }
private void CalTchartY_D(GateType gate1, GateType gate2) { double delay1 = 0, delay2 = 0, width1 = 0, width2 = 0; int error_code; error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gate1, ref delay1); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); lineRecord.Clear(); return; } error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gate2, ref delay2); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); lineRecord.Clear(); return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gate1, ref width1); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); lineRecord.Clear(); return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gate2, ref width2); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); lineRecord.Clear(); return; } if ((width1 + delay1) > (width2 + delay2)) { this.tChartA_y2 = (width1 + delay1) - delay2 + 5; } else { this.tChartA_y2 = (width2 + delay2) - delay1 + 5; } this.tChartA_y1 = 0; }
private void CalTchartY_D(GateType gate1, GateType gate2) { double delay1 = 0, delay2 = 0, width1 = 0, width2 = 0; int error_code; error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gate1, ref delay1); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); start = false; //制成false 后就画不了图了,怎么办 return; } error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, gate2, ref delay2); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); start = false; return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gate1, ref width1); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); start = false; return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, gate2, ref width2); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); start = false; return; } if ((width1 + delay1) > (width2 + delay2)) { this.tChart_y2 = (width1 + delay1) - delay2; } else { this.tChart_y2 = (width2 + delay2) - delay1; } this.tChart_y1 = 0; }
/**Set wave mode to Positive、Negative、Full Wave acocording to tofMode.*/ public static bool WaveMode(uint ascanNum, uint ascanPort, AscanWaveDectionMode waveMode) { int error_code; int gateTotNum = 4; GateType gateNum; int gateI = (int)GateType.I; int gateA = (int)GateType.A; int gateB = (int)GateType.B; int gateC = (int)GateType.C; bool isSetPre = true; TofMode[] tofMode = new TofMode[gateTotNum]; TofMode tofModeFlank = TofMode.Flank; for (int i = 0; i < gateTotNum; i++) { gateNum = (GateType)i; error_code = GetGateDAQ.TofMode(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref tofMode[i]); if (error_code != 0) { return(isSetPre); } } if (waveMode == AscanWaveDectionMode.SemiPositve || waveMode == AscanWaveDectionMode.SemiNegtive || waveMode == AscanWaveDectionMode.Full) { if (tofMode[gateI] > tofModeFlank || tofMode[gateA] > tofModeFlank || tofMode[gateB] > tofModeFlank || tofMode[gateC] > tofModeFlank) //Tof Mode are Zero Before or Zero After { MessageShow.show("Tof Mode = Zero Before or Zero After, need to set Receiver->RF!", "Tof Mode = Zero Before or Zero After,必须设置Receiver->RF!"); return(isSetPre); } } error_code = SetAscanVideoDAQ.DetectionWaveMode(ascanNum, ascanPort, waveMode); if (error_code != 0) { return(isSetPre); } return(isSetPre = false); }
public static int getTOfMode(uint sessionIndex, GateType gateNum, List <TofMode> list) { int error_code = 0; TofMode tofMode = TofMode.Flank; for (int i = 0; i < batchSessionsInfo.Count; i++) { if (batchSessionsInfo[i].sessionIndex == sessionIndex) { error_code = GetGateDAQ.TofMode(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref tofMode); if (error_code != 0) { break; } list.Add(tofMode); } } return(error_code); }
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(); }
private int initGateIf() { int error_code = 0; if (gateNum != GateType.I) { checkBoxIF.Checked = false; return(error_code); } else { IFActive ifActive = IFActive.OFF; error_code |= GetGateDAQ.IFActive(SelectAscan.sessionIndex, SelectAscan.port, GateType.I, ref ifActive); if (ifActive == IFActive.ON) { checkBoxIF.Checked = true; } return(error_code); } }
private void initTolerance() { int error_code; TMActive gateActive = TMActive.OFF; TMActive dGateActive = TMActive.OFF; for (int tolMonitorIndex = 0; tolMonitorIndex < 4; tolMonitorIndex++) { error_code = GetGateDAQ.TolMonitorActive(SelectAscan.sessionIndex, SelectAscan.port, (GateType)tolMonitorIndex, ref gateActive); if (error_code != 0) { return; } error_code = GetDGateDAQ.TolMonitorActive(SelectAscan.sessionIndex, SelectAscan.port, (DGateType)tolMonitorIndex, ref dGateActive); if (error_code != 0) { return; } if (gateActive == TMActive.ON && dGateActive == TMActive.ON) { MessageShow.show("Warn:Gate and double gate tolerance monitor are all active,need to select one to active!", "警告:门容限误差和双门容限误差都打开,只能选择一种容限误差模式!"); } else if (gateActive == TMActive.ON) { ((CheckBox)(Controls.Find("check" + tolMonitorIndex + 1 + "ON", true)[0])).Checked = true; ((RadioButton)(Controls.Find("gate" + tolMonitorIndex + 1, true)[0])).Checked = true; } else if (dGateActive == TMActive.ON) { ((CheckBox)(Controls.Find("check" + tolMonitorIndex + 1 + "ON", true)[0])).Checked = true; ((RadioButton)(Controls.Find("dGate" + tolMonitorIndex + 1, true)[0])).Enabled = true; } else { setControlsEnabled(tolMonitorIndex + 1, false); } } }
private void checkBoxOn_Click(object sender, EventArgs e) { int error_code; uint supressCount = 0; if (checkBoxOn.Checked == true) { if (SetBatchDAQ.isOn) { error_code = SetBatchDAQ.ScActive(SelectAscan.sessionIndex, gateNum, SuppressCounterActive.ON); } else { error_code = SetGateDAQ.ScActive(SelectAscan.sessionIndex, SelectAscan.port, gateNum, SuppressCounterActive.ON); } error_code |= GetGateDAQ.ScCounter(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref supressCount); if (SetBatchDAQ.isOn) { error_code = SetBatchDAQ.ScCounter(SelectAscan.sessionIndex, gateNum, supressCount); } if (error_code != 0) { checkBoxOn.Checked = false; return; } numUpDownSupressCount.Enabled = true; numUpDownSupressCount.Value = Convert.ToDecimal(supressCount); } else { error_code = SetGateDAQ.ScActive(SelectAscan.sessionIndex, SelectAscan.port, gateNum, SuppressCounterActive.OFF); if (error_code != 0) { checkBoxOn.Checked = true; return; } numUpDownSupressCount.Enabled = false; } }
private int initRadioButttonOfTofMode() { int error_code; TofMode tofMode = TofMode.Peak; error_code = GetGateDAQ.TofMode(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref tofMode); if (error_code != 0) { return(error_code); } switch (tofMode) { case TofMode.Peak: radioButtonPeak.Checked = true; preRdo = radioButtonPeak; break; case TofMode.Flank: radioButtonFlank.Checked = true; preRdo = radioButtonFlank; break; case TofMode.ZeroBefore: radioButtonZeroB.Checked = true; preRdo = radioButtonZeroB; break; case TofMode.ZeroAfter: radioButtonZeroA.Checked = true; preRdo = radioButtonZeroA; break; default: error_code = -1; MessageShow.show("Warn:Bind controls of tof mode failed!", "警告:绑定Tof mode的控件失败!"); break; } return(error_code); }
private void CalTchartY_S(GateType selectedGate) { double delay = 0, width = 0; int error_code; error_code = GetGateDAQ.Delay(SelectAscan.sessionIndex, SelectAscan.port, selectedGate, ref delay); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); lineRecord.Clear(); return; } error_code = GetGateDAQ.Width(SelectAscan.sessionIndex, SelectAscan.port, selectedGate, ref width); if (error_code != 0) { MessageBox.Show("WARNING:gate data error"); lineRecord.Clear();; return; } this.tChartA_y1 = delay - 1; this.tChartA_y2 = delay + width + 2; }
private int initCheckBoxOfSuppressCount() { int error_code; SuppressCounterActive scActive = SuppressCounterActive.OFF; error_code = GetGateDAQ.ScActive(SelectAscan.sessionIndex, SelectAscan.port, gateNum, ref scActive); if (error_code != 0) { return(error_code); } if (scActive == SuppressCounterActive.ON) { checkBoxOn.Checked = true; numUpDownSupressCount.Enabled = true; error_code = initNumUpDownSupressCount(); } else { checkBoxOn.Checked = false; numUpDownSupressCount.Enabled = false; } return(error_code); }
/**Get Gate DAQ*/ private static int getGate(uint ascanNum, uint ascanPort, GateType gateType, ref PGate param) { int error_code; error_code = GetGateDAQ.Delay(ascanNum, ascanPort, gateType, ref param.Delay); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.Width(ascanNum, ascanPort, gateType, ref param.Width); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.Threshold(ascanNum, ascanPort, gateType, ref param.Threshold); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.IFActive(ascanNum, ascanPort, gateType, ref param.IF); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.TofMode(ascanNum, ascanPort, gateType, ref param.TofMode); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DnsActive(ascanNum, ascanPort, gateType, ref param.DnsActive); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DnsBw(ascanNum, ascanPort, gateType, ref param.DnsBw); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DnsStart(ascanNum, ascanPort, gateType, ref param.DnsStart); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DnsStep(ascanNum, ascanPort, gateType, ref param.DnsStep); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.AlarmLogic(ascanNum, ascanPort, gateType, ref param.AlarmLogic); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.ScActive(ascanNum, ascanPort, gateType, ref param.ScActive); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.ScCounter(ascanNum, ascanPort, gateType, ref param.ScCounter); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DtsActive(ascanNum, ascanPort, gateType, ref param.DtsActive); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DtsBand(ascanNum, ascanPort, gateType, ref param.DtsBand); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DtsStart(ascanNum, ascanPort, gateType, ref param.DtsStart); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.DtsStep(ascanNum, ascanPort, gateType, ref param.DtsStep); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.TolMonitorActive(ascanNum, ascanPort, gateType, ref param.TolMonitorActive); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.TolMonitorMax(ascanNum, ascanPort, gateType, ref param.TolMonitorMax); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.TolMonitorMin(ascanNum, ascanPort, gateType, ref param.TolMonitorMin); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.TolMonitorSc(ascanNum, ascanPort, gateType, ref param.TolMonitorSc); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.AlarmActive(ascanNum, ascanPort, gateType, ref param.AlarmActive); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.AlarmMode(ascanNum, ascanPort, gateType, ref param.AlarmMode); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.AlarmSignalLength(ascanNum, ascanPort, gateType, ref param.AlarmSignalLength); if (error_code != 0) { return(error_code); } //error_code = SetGateDAQ.AlarmTimeLength(ascanNum, gateType, param.); //if (error_code != 0) // return error_code; error_code = GetGateDAQ.AlarmActiveLevel(ascanNum, ascanPort, gateType, ref param.AlarmActiveLevel); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.MeasActive(ascanNum, ascanPort, gateType, ref param.MeasActive); if (error_code != 0) { return(error_code); } error_code = GetGateDAQ.MeasMode(ascanNum, ascanPort, gateType, ref param.MeasMode); if (error_code != 0) { return(error_code); } return(error_code); }
//使得筛选的通道和当前显示通道所有参数变得一样 public static int Param(uint sessionIndex, uint selPort) { int error_code = 0; bool isSetPre = false; double delay = 0; double range = 0; double gain = 0; uint envlopDecay = 0; AscanWaveDectionMode waveMode = AscanWaveDectionMode.SemiPositve; RecieverType type = RecieverType.Pc; AscanEnvelopActive envelopActive = AscanEnvelopActive.OFF; int gateTol = 4; TofMode tofMode = TofMode.Flank; TofMode[] tofModeArr = new TofMode[gateTol]; GateAlarmLogic[] gateAlarmLogic = new GateAlarmLogic[gateTol]; GateAlarmActive[] gateAlarmActive = new GateAlarmActive[gateTol]; double[] gateDelay = new double[gateTol]; double[] gateWidth = new double[gateTol]; double[] threshold = new double[gateTol]; SuppressCounterActive[] scActive = new SuppressCounterActive[gateTol]; uint[] scCount = new uint[gateTol]; IFActive ifActive = IFActive.OFF; AscanIFActive ascanIfActive = AscanIFActive.OFF; //取得当前通道的所有参数 error_code = GetAsacnVideoDAQ.Delay(sessionIndex, selPort, ref delay); error_code |= GetAsacnVideoDAQ.Range(sessionIndex, selPort, ref range); error_code |= GetAsacnVideoDAQ.Range(sessionIndex, selPort, ref range); error_code |= GetRecieverDAQ.AnalogGain(sessionIndex, selPort, ref gain); error_code |= GetAsacnVideoDAQ.EnvlopDecayFactor(sessionIndex, selPort, ref envlopDecay); error_code |= GetAsacnVideoDAQ.DetectionWaveMode(sessionIndex, selPort, ref waveMode); error_code |= GetPulserTransmitDAQ.RecieverMode(sessionIndex, selPort, ref type); error_code |= GetAsacnVideoDAQ.EnvlopActive(sessionIndex, selPort, ref envelopActive); error_code |= GetGateDAQ.IFActive(sessionIndex, selPort, GateType.I, ref ifActive); error_code |= GetAsacnVideoDAQ.IFActive(sessionIndex, selPort, ref ascanIfActive); for (int i = 0; i < gateTol; i++) { GateType gateIndex = (GateType)i; error_code |= GetGateDAQ.TofMode(sessionIndex, selPort, gateIndex, ref tofModeArr[i]); error_code |= GetGateDAQ.AlarmLogic(sessionIndex, selPort, gateIndex, ref gateAlarmLogic[i]); error_code |= GetGateDAQ.AlarmActive(sessionIndex, selPort, gateIndex, ref gateAlarmActive[i]); error_code |= GetGateDAQ.Delay(sessionIndex, selPort, gateIndex, ref gateDelay[i]); error_code |= GetGateDAQ.Width(sessionIndex, selPort, gateIndex, ref gateWidth[i]); error_code |= GetGateDAQ.Threshold(sessionIndex, selPort, gateIndex, ref threshold[i]); error_code |= GetGateDAQ.ScActive(sessionIndex, selPort, gateIndex, ref scActive[i]); error_code |= GetGateDAQ.ScCounter(sessionIndex, selPort, gateIndex, ref scCount[i]); } if (error_code != 0) { return(error_code); } //赋值 for (int i = 0; i < batchSessionsInfo.Count; i++) { uint port = (uint)batchSessionsInfo[i].port; uint seIndex = (uint)batchSessionsInfo[i].sessionIndex; //第二种情况||batchSessionsInfo[i].sessionIndex != sessionIndex //if (batchSessionsInfo[i].sessionIndex == sessionIndex && port != selPort )//以selPort号为依据配置同一块板卡的其他虚拟通道的参数 { error_code = SetAscanVideoDAQ.Delay(seIndex, port, delay); error_code |= SetAscanVideoDAQ.Range(seIndex, port, range); error_code |= SetReceiverDAQ.AnalogGain(seIndex, port, gain); error_code |= SetAscanVideoDAQ.EnvlopDecayFactor(seIndex, port, envlopDecay); isSetPre = SetAscanVideoDAQ.WaveMode(seIndex, port, waveMode); error_code |= SetPulserTransmitDAQ.RecieverMode(seIndex, port, type); error_code |= SetAscanVideoDAQ.EnvlopActive(seIndex, port, envelopActive); for (int j = 0; j < gateTol; j++) { GateType gateIndex = (GateType)j; isSetPre |= SetGateDAQ.setTofMode(seIndex, port, gateIndex, tofModeArr[j]); error_code |= SetGateDAQ.AlarmLogic(seIndex, port, gateIndex, gateAlarmLogic[j]); error_code |= SetGateDAQ.AlarmActive(seIndex, port, gateIndex, gateAlarmActive[j]); error_code |= SetGateDAQ.Delay(seIndex, port, gateIndex, gateDelay[j]); error_code |= SetGateDAQ.Width(seIndex, port, gateIndex, gateWidth[j]); error_code |= SetGateDAQ.Threshold(seIndex, port, gateIndex, threshold[j]); error_code |= SetGateDAQ.ScActive(seIndex, port, gateIndex, scActive[j]); error_code |= SetGateDAQ.ScCounter(seIndex, port, gateIndex, scCount[j]); if (error_code != 0) { return(error_code); } } error_code |= GetGateDAQ.TofMode(seIndex, port, GateType.I, ref tofMode); if (ifActive == IFActive.ON && ascanIfActive == AscanIFActive.ON) { if (tofMode != TofMode.Flank) { MessageShow.show("Warning:" + seIndex + port + "The TOF Mode GateI must select Flank mode!", "警告:" + sessionIndex + port + "门模式门I未选择Flank模式!"); return(error_code = -1); } else { error_code |= SetGateDAQ.iFActive(seIndex, port, GateType.I, IFActive.ON); error_code |= SetAscanVideoDAQ.IFActive(seIndex, port, AscanIFActive.ON); } } else { error_code |= SetGateDAQ.iFActive(seIndex, port, GateType.I, IFActive.OFF); error_code |= SetAscanVideoDAQ.IFActive(seIndex, port, AscanIFActive.OFF); } if (error_code != 0) { return(error_code); } } } return(error_code); }
/* * private void FormGatePosition_Paint(object sender, PaintEventArgs e) * { * e.Graphics.DrawLine(new Pen(SystemColors.GradientActiveCaption, 3), 1, 0, 1, this.Height); * } */ private void checkBoxIF_Click(object sender, EventArgs e) { if ((int)gateNum == 0) { int error_code = 0; TofMode tofMode = TofMode.Flank; List <TofMode> list = new List <TofMode>(); list.Clear(); if (checkBoxIF.Checked) { if (SetBatchDAQ.isOn) { error_code = SetBatchDAQ.getTOfMode(SelectAscan.sessionIndex, GateType.I, list); for (int i = 0; i < list.Count; i++) { if (list[i] != TofMode.Flank) { MessageShow.show("Warning:The TOF Mode GateI must select Flank mode!", "警告:门模式门I未选择Flank模式!"); checkBoxIF.Checked = false; return; } } error_code |= SetBatchDAQ.GateIFActive(SelectAscan.sessionIndex, GateType.I, IFActive.ON); error_code |= SetBatchDAQ.AscanVideoIFActive(SelectAscan.sessionIndex, GateType.I, AscanIFActive.ON); if (error_code != 0) { return; } } else { error_code = GetGateDAQ.TofMode(SelectAscan.sessionIndex, SelectAscan.port, GateType.I, ref tofMode); if (tofMode != TofMode.Flank) { MessageShow.show("Warning:The TOF Mode GateI must select Flank mode!", "警告:门模式门I未选择Flank模式!"); checkBoxIF.Checked = false; return; } error_code |= SetGateDAQ.iFActive(SelectAscan.sessionIndex, SelectAscan.port, GateType.I, IFActive.ON); error_code |= SetAscanVideoDAQ.IFActive(SelectAscan.sessionIndex, SelectAscan.port, AscanIFActive.ON); if (error_code != 0) { return; } } } else { if (SetBatchDAQ.isOn) { error_code = SetGateDAQ.iFActive(SelectAscan.sessionIndex, SelectAscan.port, GateType.I, IFActive.OFF); error_code |= SetAscanVideoDAQ.IFActive(SelectAscan.sessionIndex, SelectAscan.port, AscanIFActive.OFF); } { error_code = SetGateDAQ.iFActive(SelectAscan.sessionIndex, SelectAscan.port, GateType.I, IFActive.OFF); error_code |= SetAscanVideoDAQ.IFActive(SelectAscan.sessionIndex, SelectAscan.port, AscanIFActive.OFF); } if (error_code != 0) { return; } FormList.MDIChild.drawGateIWhenIfStartDisabled(); } } if ((int)gateNum == 1) { MessageShow.show("Warning:The Gate must select GateI!", "警告:门模式未选择门I!"); checkBoxIF.Checked = false; return; } if ((int)gateNum == 2) { MessageShow.show("Warning:The Gate must select GateI!", "警告:门模式未选择门I!"); checkBoxIF.Checked = false; return; } if ((int)gateNum == 3) { MessageShow.show("Warning:The Gate must select GateI!", "警告:门模式未选择门I!"); checkBoxIF.Checked = false; return; } }
/**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); }