/// <summary> /// 返回数组 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual double[] VisaReads(string command) { double[] dtmp; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); string res = ""; AgVisa32.viRead(_Session, out res, 1000000); string[] tmp = res.Split(','); dtmp = new double[tmp.Length]; try { for (int i = 0; i < tmp.Length; i++) { dtmp[i] = double.Parse(tmp[i]); } } catch { Console.WriteLine(); } return(dtmp); }
public static double ReadDB(string addr, string window, string m1) { int resourceManager = 0, viError; int session = 0; viError = AgVisa32.viOpenDefaultRM(out resourceManager); viError = AgVisa32.viOpen(resourceManager, addr.ToString(), AgVisa32.VI_NO_LOCK, AgVisa32.VI_TMO_IMMEDIATE, out session); System.Threading.Thread.Sleep(100); viError = AgVisa32.viPrintf(session, "CALC:PAR:SEL '" + window + "'" + "\n"); viError = AgVisa32.viPrintf(session, "CALC:" + m1 + ":Y?" + "\n"); string res = ""; AgVisa32.viRead(session, out res, 100); System.Threading.Thread.Sleep(100); AgVisa32.viClose(session); AgVisa32.viClose(resourceManager); double dtmp = double.Parse(res.ToString().Split(',')[0]); return(dtmp); }
public override double[] VisaReads(string command) { double[] dtmp; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); if (_ViError != 0) { OnchildThreadException("error:" + _InstrNick + _InstrAddr); } string res = ""; AgVisa32.viRead(_Session, out res, 100000); string[] tmp = res.Split(','); dtmp = new double[tmp.Length]; try { for (int i = 0; i < tmp.Length; i++) { dtmp[i] = double.Parse(tmp[i]); } } catch { Console.WriteLine(); } return(dtmp); }
/// <summary> /// 返回数组 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual double[] VisaReads(string command) { double[] dtmp; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); if (_ViError != 0) { OnchildThreadException("error:" + _InstrNick + _InstrAddr); } string res = ""; AgVisa32.viRead(_Session, out res, 8020); string[] tmp = res.Split(','); dtmp = new double[tmp.Length]; for (int i = 0; i < tmp.Length; i++) { dtmp[i] = double.Parse(tmp[i]); } return(dtmp); }
/// <summary> /// 返回数值 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual double VisaRead_double(string command) { double dtmp; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); if (_ViError != 0) { OnchildThreadException("error:" + _InstrNick + _InstrAddr); } string res = ""; try { AgVisa32.viRead(_Session, out res, 15); //string[] resa = res.Split(','); //res = resa[0]; dtmp = double.Parse(res); return(dtmp); } catch (Exception) { OnchildThreadException("error:" + _InstrNick + ":数据采集失败"); return(0); } }
/// <summary> /// 返回字符串结果 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual string VisaRead(string command) { _ViError = AgVisa32.viPrintf(_Session, command + "\r\n"); if (_ViError != 0) { OnchildThreadException("error:" + _InstrNick + _InstrAddr); } string res = ""; Thread.Sleep(100); try { AgVisa32.viRead(_Session, out res, 15); //string[] resa = res.Split(','); //res = resa[0]; double dtmp = double.Parse(res); return(dtmp.ToString("f2")); } catch (Exception) { OnchildThreadException("error:" + _InstrNick + ":数据采集失败"); return(""); } }
public string VisaRead_STR(string command) { viError = AgVisa32.viPrintf(session, command + "\n"); string res = ""; AgVisa32.viRead(session, out res, 100); return(res); }
/// <summary> /// 返回绝对值结果 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual string VisaRead_Abs(string command) { _ViError = AgVisa32.viPrintf(_Session, command + "\n"); string res = ""; AgVisa32.viRead(_Session, out res, 10000); string[] resa = res.Split(','); res = resa[0]; double dtmp = Math.Abs(double.Parse(res)); return(dtmp.ToString("f1")); }
public override string VisaRead(string command) { string res = ""; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); AgVisa32.viRead(_Session, out res, 1000); double dtmp = double.Parse(res) * 1000; return(dtmp.ToString("f0")); }
/// <summary> /// 返回字符串结果 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual string VisaRead(string command) { _ViError = AgVisa32.viPrintf(_Session, command + "\r\n"); string res = ""; Thread.Sleep(100); AgVisa32.viRead(_Session, out res, 100); string[] resa = res.Split(','); res = resa[0]; double dtmp = double.Parse(res); return(dtmp.ToString("f2")); }
/// <summary> /// 返回数值 /// </summary> /// <param name="command"></param> /// <returns></returns> public virtual double VisaRead_double(string command) { double dtmp; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); string res = ""; AgVisa32.viRead(_Session, out res, 100); string[] resa = res.Split(','); res = resa[0]; dtmp = double.Parse(res); return(dtmp); }
public virtual string VisaOriginRead(string command) { _ViError = AgVisa32.viPrintf(_Session, command + "\r\n"); if (_ViError != 0) { OnchildThreadException("error:" + _InstrNick + _InstrAddr); } string res = ""; Thread.Sleep(100); try { AgVisa32.viRead(_Session, out res, 100000); return(res); } catch (Exception) { OnchildThreadException("error:" + _InstrNick + ":数据采集失败"); return(""); } }
public override double VisaRead_double(string command) { double dtmp; _ViError = AgVisa32.viPrintf(_Session, command + "\n"); if (_ViError != 0) { OnchildThreadException("error:" + _InstrNick + _InstrAddr); } string res = ""; try { AgVisa32.viRead(_Session, out res, 17); dtmp = double.Parse(res); return(dtmp); } catch (Exception) { OnchildThreadException("error:" + _InstrNick + ":数据采集失败"); return(0); } }