private bool TestOutputRanges(out MccDaq.Range DefaultRange) { short dataValue = 0; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; int configVal; 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."; DefaultRange = MccDaq.Range.NotUsed; TestRange = (MccDaq.Range)(-5); ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { ULStat = TestBoard.GetConfig(2, 0, 114, out configVal); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultRange = (MccDaq.Range)configVal; RangeFound = true; } } else { TestRange = MccDaq.Range.NotUsed; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } RangeFound = true; break; } else { if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) || (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse)) { System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use"); break; } } } } return(RangeFound); }
private void UpdateButton_Click(object sender, System.EventArgs e) /* Handles UpdateButton.Click */ { bool IsValidNumber = true; float EngUnits = 0.0f; try { EngUnits = float.Parse(txtVoltsToSet.Text); } catch (Exception ex) { MessageBox.Show(txtVoltsToSet.Text + " is not a valid voltage value", "Invalid Voltage ", MessageBoxButtons.OK, MessageBoxIcon.Error); IsValidNumber = false; } if (IsValidNumber) { // Parameters: // Chan :the D/A output channel // Range :ignored if board does not have programmable rage // DataValue :the value to send to Chan ushort DataValue = 0; MccDaq.ErrorInfo ULStat = DaqBoard.FromEngUnits(Range, EngUnits, out DataValue); ULStat = DaqBoard.AOut(Chan, Range, DataValue); lblValueSent.Text = "The count sent to DAC channel " + Chan.ToString("0") + " was:"; lblVoltage.Text = "The voltage at DAC channel " + Chan.ToString("0") + " is:"; lblShowValue.Text = DataValue.ToString("0"); lblShowVoltage.Text = EngUnits.ToString("0.0##") + " Volts"; } }
private void UpdateButton_Click(object sender, System.EventArgs e) { bool IsValidNumber = true; float EngUnits = 0.0f; IsValidNumber = float.TryParse(txtVoltsToSet.Text, out EngUnits); if (IsValidNumber) { // Parameters: // Chan :the D/A output channel // Range :ignored if board does not have programmable rage // DataValue :the value to send to Chan ushort DataValue = 0; float OutVal; MccDaq.ErrorInfo ULStat = DaqBoard.FromEngUnits(Range, EngUnits, out DataValue); ULStat = DaqBoard.AOut(Chan, Range, DataValue); lblValueSent.Text = "The count sent to DAC channel " + Chan.ToString("0") + " was:"; lblVoltage.Text = "The voltage at DAC channel " + Chan.ToString("0") + " is:"; lblShowValue.Text = DataValue.ToString("0"); OutVal = ConvertToVolts(DataValue); lblShowVoltage.Text = OutVal.ToString("0.0#####") + " Volts"; } }
private bool TestOutputRanges(out MccDaq.Range DefaultRange) { short dataValue = 0; MccDaq.ErrorInfo ULStat; MccDaq.Range TestRange; bool RangeFound = false; int configVal; DefaultRange = MccDaq.Range.NotUsed; TestRange = (MccDaq.Range)(-5); ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { ULStat = TestBoard.GetConfig(2, 0, 114, out configVal); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { DefaultRange = (MccDaq.Range)configVal; RangeFound = true; } } else { TestRange = MccDaq.Range.NotUsed; foreach (int i in Enum.GetValues(TestRange.GetType())) { TestRange = (MccDaq.Range)i; ULStat = TestBoard.AOut(0, TestRange, dataValue); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { if (DefaultRange == MccDaq.Range.NotUsed) { DefaultRange = TestRange; } RangeFound = true; break; } } } return(RangeFound); }
private void btnSendData_Click(object sender, System.EventArgs e) { float volts = 0.0F; ushort daCounts = 0; int chan = 0; foreach (TextBox box in _txtAOVolts) { if (chan <= MaxChan) { //get voltage to output volts = float.Parse(box.Text); // convert from voltage to binary counts DaqBoard.FromEngUnits(Range, volts, out daCounts); // load D/A DaqBoard.AOut(chan, Range, daCounts); ++chan; } } }
/// <summary> /// Output by a int value /// </summary> /// <param name="portNumber"></param> /// <param name="value"></param> public void AnalogOutut(int portNumber, short value) { DaqBoard.AOut(portNumber, Range.Bip5Volts, value); }