//关闭万用表连接 public void disposeNetWorkConnect() { if (m_msg != null || m_ioArbFG.IO != null) { m_msg = null; m_ioArbFG.IO = null; } Thread.Sleep(50); }
protected MessageSessionContext(MessageSessionContext context) { resourceName = context.resourceName; timeout = context.timeout; messageSession = context.messageSession; baseContext = context; checkScpiError = context.checkScpiError; ignoreWarnings = context.ignoreWarnings; }
/// <summary> /// Lock session /// </summary> /// <param name="session">VISA session to lock</param> /// <param name="lockResource">Use VISA resource lock if true</param> public SessionLocker(IMessageSession session, bool lockResource = false) { this.session = session; this.lockResource = lockResource; var nestedLock = Monitor.IsEntered(session); Monitor.Enter(session); if (lockResource && !nestedLock) { session.LockResource(); } }
//初始化并连接万用表设备 private bool ConnectDevice() { try { string conn_str = "TCPIP0::" + GlobalVar.gl_MultimetersIP + "::inst0::INSTR"; m_msg = m_rm.Open(conn_str, Ivi.Visa.Interop.AccessMode.NO_LOCK, 1000, "") as Ivi.Visa.Interop.IMessage; m_ioArbFG.IO = m_msg; GlobalVar.gl_UpperMonitor = true; return(true); } catch { GlobalVar.gl_UpperMonitor = false; MessageBox.Show("仪器连接时发生错误", "ERROR"); return(false); } }
private void m_setioButton_Click(object sender, System.EventArgs e) { this.rm = new ResourceManager(); try { this.msg = (rm.Open(this.m_gpibAddrTextBox.Text, Ivi.Visa.Interop.AccessMode.NO_LOCK, 2000, "")) as IMessage; ioArbFG.IO = msg; } catch (SystemException ex) { MessageBox.Show("Open failed on " + this.m_gpibAddrTextBox.Text + " " + ex.Source + " " + ex.Message, "AM Modulation", MessageBoxButtons.OK, MessageBoxIcon.Error); DisableControls(); ioArbFG.IO = null; return; } //Get the ID string of the instrument connected. m_idLabel.Text = GetInstrumentID(); }
private void Gpib_connect(object sender, RoutedEventArgs e) { rm = new ResourceManager(); try { msg = (rm.Open(GPIB_Address_Input.Text, AccessMode.NO_LOCK, 2000, "")) as Ivi.Visa.Interop.IMessage; ioArbFG.IO = msg; } catch (SystemException ex) { MessageBox.Show("Open failed on " + GPIB_Address_Input.Text + " " + ex.Source + " " + ex.Message, "ApplyBurst"); ioArbFG.IO = null; } Status_Output.Content = GetInstrumentID(); }
private void closeVisacomsesn() { if (this.sa_sesn!=null) { this.sa_sesn.Clear(); this.sa_sesn.Close(); this.sa_sesn = null; } if (this.sg_sesn != null) { this.sg_sesn.Clear(); this.sg_sesn.Close(); this.sg_sesn = null; } if (this.sg2_sesn != null) { this.sg2_sesn.Clear(); this.sg2_sesn.Close(); this.sg2_sesn = null; } if (this.rfbox_sesn != null) { this.rfbox_sesn.Clear(); this.rfbox_sesn.Close(); this.rfbox_sesn = null; } if (this.rfbox2_sesn != null) { this.rfbox2_sesn.Clear(); this.rfbox2_sesn.Close(); this.rfbox2_sesn = null; } if (this.is_sesn != null) { this.is_sesn.Clear(); this.is_sesn.Close(); this.is_sesn = null; } if (this.is2_sesn != null) { this.is2_sesn.Clear(); this.is2_sesn.Close(); this.is2_sesn = null; } if (this.dc5767a_sesn != null) { this.dc5767a_sesn.Clear(); this.dc5767a_sesn.Close(); this.dc5767a_sesn = null; } }
protected void SetMessageInterface(IMessageSession messageSession) { this.messageSession = messageSession; }