コード例 #1
0
ファイル: ScpiIO.cs プロジェクト: ZHJEE/OpenTAP
        public ScpiIOResult Open(string visaAddress, bool exclusiveLock)
        {
            if (instrument != Visa.VI_NULL)
            {
                throw new Exception("IO is already open");
            }
            var res2 = Visa.viOpenDefaultRM(out rm);

            if (res2 < 0)
            {
                return(MakeError(res2));
            }

            var res = Visa.viOpen(ScpiInstrument.GetResourceManager(), visaAddress, exclusiveLock ? Visa.VI_EXCLUSIVE_LOCK : Visa.VI_NO_LOCK, IOTimeoutMS, out instrument);

            // Use sensible defaults
            sendEnd     = true;
            useTermChar = false;

            if (res >= 0)
            {
                SyncSettings();
            }
            else
            {
                instrument = Visa.VI_NULL;
            }

            return(MakeError(res));
        }
コード例 #2
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
 /// <summary>
 /// 仪表识别
 /// </summary>
 /// <param name="inInstrumentAddress">仪表地址</param>
 /// <param name="outConnected"> 是否连接</param>
 /// <returns></returns>
 public string TryIdentifyInstrument(string inInstrumentAddress, out bool outConnected)
 {
     outConnected = true;
     try
     {
         ScpiInstrument tmpInstr = new ScpiInstrument(inInstrumentAddress, true);
         return(tmpInstr.Identity);
     }
     catch (Exception ex)
     {
         outConnected = false;
         return("");
     }
 }
コード例 #3
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <summary>
        /// 更新设备信息
        /// </summary>
        /// <param name="tmpInstrumentInfo"></param>
        private static void UpdateInstrumentInfo(InstrumentInfo tmpInstrumentInfo)
        {
            try
            {
                GlobalStatusReport.Report(string.Format("UpdateInstrumentInfo 仪表名称:{0} 地址:{1},开始连接", tmpInstrumentInfo.InstrumentName, tmpInstrumentInfo.IpAddress));
                tmpInstrumentInfo.DevInfoState = devState.ischeck;
                string Identity   = "";
                string ModelNo    = "";
                string InstSN     = "";
                string Firmware   = "";
                string Options    = "";
                string Manufactor = "";
                ModelNo = ScpiInstrument.DetermineInstrumentInfo(tmpInstrumentInfo.IpAddress, out Identity, out InstSN, out Options, out Firmware, out Manufactor);
                if ((ModelNo == null) || (ModelNo == string.Empty))
                {
                    tmpInstrumentInfo.ConnectOK    = devState.error;
                    tmpInstrumentInfo.DevInfoState = devState.error;
#if Simulate
                    tmpInstrumentInfo.ConnectOK    = devState.connect;
                    tmpInstrumentInfo.DevInfoState = devState.connect;
#endif
                }
                else
                {
                    tmpInstrumentInfo.ConnectOK    = devState.connect;
                    tmpInstrumentInfo.DevInfoState = devState.connect;

                    tmpInstrumentInfo.ModelNo    = ModelNo;
                    tmpInstrumentInfo.Identity   = Identity;
                    tmpInstrumentInfo.SN         = InstSN;
                    tmpInstrumentInfo.OptionList = Options;
                    tmpInstrumentInfo.Manufacter = Manufactor;
                }
                GlobalStatusReport.Report(string.Format("UpdateInstrumentInfo 仪表名称:{0} 地址:{1},连接结束!", tmpInstrumentInfo.InstrumentName, tmpInstrumentInfo.IpAddress));
            }
            catch (Exception ex)
            {
                tmpInstrumentInfo.ConnectOK = devState.error;
            }
        }
コード例 #4
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        private static bool IfNeedUpdateCtrlObj(string tmpNewAddress, ScpiInstrument tmpCtrlObj)
        {
            bool bNeedUpdateCtrlObj = (tmpCtrlObj == null) || (tmpCtrlObj.ResourceName != tmpNewAddress);

            return(bNeedUpdateCtrlObj);
        }