private bool TestInputRanges(out MccDaq.Range DefaultRange) { short dataValue; int dataHRValue, Options, index; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; string ConnectionConflict; ConnectionConflict = "This network device is in use by another process or user." + System.Environment.NewLine + System.Environment.NewLine + "Check for other users on the network and close any applications " + System.Environment.NewLine + "(such as Instacal) that may be accessing the network device."; ValidRanges = new MccDaq.Range[49]; DefaultRange = MccDaq.Range.NotUsed; TestRange = MccDaq.Range.NotUsed; Options = 0; index = 0; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; if (ADRes > 16) { ULStat = TestBoard.AIn32(0, TestRange, out dataHRValue, Options); } else { ULStat = TestBoard.AIn(0, TestRange, out dataValue); } if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } ValidRanges.SetValue(TestRange, index); index = index + 1; RangeFound = true; } else { if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) || (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse)) { System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use"); break; } } } Array.Resize(ref ValidRanges, index); return(RangeFound); }
private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs) { float EngUnits; double HighResEngUnits; MccDaq.ErrorInfo ULStat; System.UInt16 DataValue; System.UInt32 DataValue32; int Chan; int Options = 0; tmrConvert.Stop(); // Collect the data by calling AIn member function of MccBoard object // Parameters: // Chan :the input channel number // Range :the Range for the board. // DataValue :the name for the value collected // set input channel bool ValidChan = int.TryParse(txtNumChan.Text, out Chan); if (ValidChan) { if (Chan > HighChan) { Chan = HighChan; } txtNumChan.Text = Chan.ToString(); } if (ADResolution > 16) { ULStat = DaqBoard.AIn32(Chan, Range, out DataValue32, Options); // Convert raw data to Volts by calling ToEngUnits // (member function of MccBoard class) ULStat = DaqBoard.ToEngUnits32(Range, DataValue32, out HighResEngUnits); lblShowData.Text = DataValue32.ToString(); // print the counts lblShowVolts.Text = HighResEngUnits.ToString("F5") + " Volts"; // print the voltage } else { ULStat = DaqBoard.AIn(Chan, Range, out DataValue); // Convert raw data to Volts by calling ToEngUnits // (member function of MccBoard class) ULStat = DaqBoard.ToEngUnits(Range, DataValue, out EngUnits); lblShowData.Text = DataValue.ToString(); // print the counts lblShowVolts.Text = EngUnits.ToString("F4") + " Volts"; // print the voltage } tmrConvert.Start(); }
public string AnalogInput(int portNumber) { if (ADResolution > 16) { ULStat = DaqBoard.AIn32(portNumber, AcutalRange, out DataValue32, Options); return(DataValue32.ToString()); } else { ULStat = DaqBoard.AIn(portNumber, AcutalRange, out DataValue); return(DataValue.ToString()); } }
private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs) /* Handles tmrConvert.Tick */ { float EngUnits; double HighResEngUnits; MccDaq.ErrorInfo ULStat; UInt16 DataValue; UInt32 DataValue32; MccDaq.Range Range; int Chan; int Options = 0; tmrConvert.Stop(); // Parameters: // Chan :the input channel number // Range :the range for the board. // DataValue :the name for the value collected Chan = int.Parse(txtNumChan.Text); Range = (MccDaq.Range)(int.Parse(lblGainCodeVal.Text)); if (HighResAD) { ULStat = DaqBoard.AIn32(Chan, Range, out DataValue32, Options); // ******* CONVERT RAW DATA VALUES TO VOLTAGES ******** ULStat = DaqBoard.ToEngUnits32(Range, DataValue32, out HighResEngUnits); lblShowData.Text = DataValue32.ToString("D"); lblShowCalcResults.Text = HighResEngUnits.ToString("0.00000") + " Volts"; } else { ULStat = DaqBoard.AIn(Chan, Range, out DataValue); // ******* CONVERT RAW DATA VALUES TO VOLTAGES ******** ULStat = DaqBoard.ToEngUnits(Range, DataValue, out EngUnits); lblShowData.Text = DataValue.ToString("D"); lblShowCalcResults.Text = EngUnits.ToString("0.000") + " Volts"; } tmrConvert.Start(); }
private bool TestInputRanges(out MccDaq.Range DefaultRange) { short dataValue; int dataHRValue, Options, index; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; ValidRanges = new MccDaq.Range[49]; DefaultRange = MccDaq.Range.NotUsed; TestRange = MccDaq.Range.NotUsed; Options = 0; index = 0; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; if (ADRes > 16) { ULStat = TestBoard.AIn32(0, TestRange, out dataHRValue, Options); } else { ULStat = TestBoard.AIn(0, TestRange, out dataValue); } if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } ValidRanges.SetValue(TestRange, index); index = index + 1; RangeFound = true; } } Array.Resize(ref ValidRanges, index); return(RangeFound); }