예제 #1
0
        /// <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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        /// <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);
            }
        }
예제 #6
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);
        }
예제 #8
0
        /// <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"));
        }
예제 #9
0
        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"));
        }
예제 #10
0
        /// <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"));
        }
예제 #11
0
        /// <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);
        }
예제 #12
0
        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("");
            }
        }
예제 #13
0
        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);
            }
        }