private void cmdStartBgnd_Click(System.Object eventSender, System.EventArgs eventArgs) { int CurIndex; int CurCount; short Status; MccDaq.ErrorInfo ULStat; int Rate; MccDaq.ScanOptions Options; int Count; int PretrigCount; cmdStartBgnd.Enabled = false; cmdStartBgnd.Visible = false; cmdStopConvert.Enabled = true; cmdStopConvert.Visible = true; cmdQuit.Enabled = false; UserTerm = 0; // initialize user terminate flag MccDaq.DigitalPortDirection Direction; MccDaq.DigitalPortType PortNum; //configure FirstPortA for digital input PortNum = (MccDaq.DigitalPortType)ChanArray[1]; Direction = MccDaq.DigitalPortDirection.DigitalIn; ULStat = DaqBoard.DConfigPort(PortNum, Direction); // Collect the values with cbDaqInScan() // Parameters: // BoardNum :the number used by CB.CFG to describe this board // ChanArray[] :array of channel values // ChanTypeArray[] : array of channel types // GainArray[] :array of gain values // ChansCount :the number of elements in the arrays (0=disable queue) // PretrigCount :number of pre-trigger A/D samples to collect // Count :the total number of A/D samples to collect // Rate :sample rate in samples per second // ADData[] :the array for the collected data values // Options :data collection options PretrigCount = 0; Count = NumElements; // Number of data points to collect Options = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.Background | MccDaq.ScanOptions.Continuous; Rate = 100; // Acquire data at 100 Hz ULStat = DaqBoard.DaqInScan(ChanArray, ChanTypeArray, GainArray, ChanCount, ref Rate, ref PretrigCount, ref Count, MemHandle, Options); ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqiFunction); if (Status == MccDaq.MccBoard.Running) { lblShowStat.Text = "Running"; lblShowCount.Text = CurCount.ToString("D"); lblShowIndex.Text = CurIndex.ToString("D"); } tmrCheckStatus.Enabled = true; }
private void cmdStartBgnd_Click(System.Object eventSender, System.EventArgs eventArgs) { int CurIndex; int CurCount; short Status; MccDaq.ErrorInfo ULStat; int CBRate; object Options; int CBCount; int PretrigCount; MccDaq.TriggerSource TrigSource; MccDaq.TriggerSensitivity TrigSense; int TrigChan; MccDaq.ChannelType ChanType; MccDaq.Range Gain; float Variance; float Level; MccDaq.TriggerEvent TrigEvent; int Direction; int PortNum; cmdStartBgnd.Enabled = false; cmdStartBgnd.Visible = false; cmdStopConvert.Enabled = true; cmdStopConvert.Visible = true; cmdQuit.Enabled = false; UserTerm = 0; // initialize user terminate flag lblADData[0].Text = ""; lblADData[1].Text = ""; lblADData[2].Text = ""; //configure FirstPortA for digital input PortNum = ChanArray[1]; Direction = System.Convert.ToInt32(MccDaq.DigitalPortDirection.DigitalIn); ULStat = DaqBoard.DConfigPort((MccDaq.DigitalPortType)PortNum, (MccDaq.DigitalPortDirection)Direction); //Set Triggers //Parameters: //BoardNum :the number used by CB.CFG to describe this board //TrigSource :trigger source //TrigSense :trigger sensitivity //TrigChan :trigger channel //ChanType :trigger channel type //Gain :trigger channel gain //Level :trigger Level //Variance :trigger Variance //TrigEvent :trigger event type //Start trigger settings // AD conversions are enabled when analog channel 0 makes a transition from below 2 V to above.*/ TrigSource = MccDaq.TriggerSource.TrigAnalogSW; TrigSense = MccDaq.TriggerSensitivity.RisingEdge; TrigChan = ChanArray[0]; ChanType = ChanTypeArray[0]; Gain = GainArray[0]; Level = 2; Variance = 0; TrigEvent = MccDaq.TriggerEvent.Start; //Set start trigger ULStat = DaqBoard.DaqSetTrigger(TrigSource, TrigSense, TrigChan, ChanType, Gain, Level, Variance, TrigEvent); //Stop trigger settings // AD conversions are terminated when counter 0 reaches 100 counts.*/ TrigSource = MccDaq.TriggerSource.TrigCounter; TrigSense = MccDaq.TriggerSensitivity.AboveLevel; TrigChan = ChanArray[2]; ChanType = ChanTypeArray[2]; Gain = GainArray[2]; Level = 100; Variance = 0; TrigEvent = MccDaq.TriggerEvent.Stop; //Set stop trigger ULStat = DaqBoard.DaqSetTrigger(TrigSource, TrigSense, TrigChan, ChanType, Gain, Level, Variance, TrigEvent); // Collect the values with cbDaqInScan() // Parameters: // BoardNum :the number used by CB.CFG to describe this board // ChanArray[] :array of channel values // ChanTypeArray[] : array of channel types // GainArra[] :array of gain values // ChansCount :the number of elements in the arrays (0=disable queue) // PretrigCount :number of pre-trigger A/D samples to collect // CBCount :the total number of A/D samples to collect // CBRate :sample rate in samples per second // ADData[] :the array for the collected data values // Options :data collection options PretrigCount = 0; CBCount = NumElements; // Number of data points to collect Options = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.Background | MccDaq.ScanOptions.Continuous | MccDaq.ScanOptions.ExtTrigger; CBRate = 100; // Acquire data at 100 Hz ULStat = DaqBoard.DaqInScan(ChanArray, ChanTypeArray, GainArray, ChanCount, ref CBRate, ref PretrigCount, ref CBCount, MemHandle, (MccDaq.ScanOptions)Options); ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqiFunction); if (Status == MccDaq.MccBoard.Running) { lblShowStartTrig.Text = "Waiting for trigger..."; lblShowStopTrig.Text = ""; lblShowStat.Text = "Running"; lblShowCount.Text = CurCount.ToString("D"); lblShowIndex.Text = CurIndex.ToString("D"); } tmrCheckStatus.Enabled = true; }