你好! 我正在努力让安捷伦34972A通过IP连接进行温度采集:_4通道使用_C#软件代码主要是由离开公司的人编写的,他给我们留下了一些错误(Lucky Us)它 尝试读取温度数据,但有时:_fail配置(MyAgilent34972.FResistance.Configure通过MyAgilent34972.Scan.Initiate),错误-401查询中断_fail读取值(MyAgilent34972.Scan.Fetch),错误-401查询中断ou“ 来自仪器的意外反应“为了使事情变得更糟,它通常可以正常工作,但有时会产生这个错误-401。 我想也许,安捷伦设备没有足够的时间来处理命令,所以我尝试在命令之间添加System.Threading.Thread.Sleep。 没有好处,因为它仍然得到相同的错误,但有一个新的:timedout。 我在互联网上寻找了一个安捷伦34972A API C#参考,但没有找到可用的东西(我发现这个http://www.element14.com/communi ... ogrammers-reference - 帮助SCPI编程,这个http://www.keysight.com/upload/c ... 90009_quick_ref.pdf也没有关于C#的事情)我很确定我做错了但没有C#参考 ,我不知道我做错了什么。 有任何线索吗? 提前致谢代码:使用Ivi.Driver.Interop; 使用Agilent.Agilent34970.Interop; IAgilent34970 MyAgilent34972; string [] Channel34972A = new string [] {“102”,“103”,“104”,“105”,}; bool b_Connected; b_Connected = false; string standardInitOptions =“Cache = true,InterchangeCheck = false,QueryInstrStatus = true,RangeCheck = true,RecordCoercions = false,Simulate = false”; 试试{MyAgilent34972 = new Agilent34970(); MyAgilent34972.Initialize(“TCPIP0 :: 192.168.0.11 :: INSTR”,false,false,standardInitOptions); b_Connected = MyAgilent34972.Initialized; } catch(异常错误){MessageBox.Show(error.ToString(),“Agilent 34972A”); } if(b_Connected == true){string str_channelList = Channel34972A [0] +“:”+ Channel34972A [Channel34972A.Count() - 1]; 试试{MyAgilent34972.FResistance.Configure(str_channelList,10,0.001); MyAgilent34972.Scan.SweepCount = 1; MyAgilent34972.Scan.IntervalScanSetup(str_channelList,1,1); MyAgilent34972.Scan.Initiate(); } catch(Exception exc){int errorCode = 0; string errorString =“”; MyAgilent34972.Utility.ErrorQuery(ref errorCode,ref errorString); MessageBox.Show(“config:”+ errorCode.ToString()+“,”+ errorString); string [] str_value = new string [Channel34972A.Count()]; string [] str_valueDegC = new string [Channel34972A.Count()]; if(b_Connected == true){try {MyAgilent34972.Scan.Initiate(); MyAgilent34972.System.WaitForOperationComplete(10000); str_value = MyAgilent34972.Scan.Fetch(); for(int i = 0; i {double d_value = Convert.ToDouble(str_value .Replace('。',',')); str_valueDegC = d_value.ToString();}} catch(异常错误) ){MessageBox.Show(“读取安捷伦:”+ error.ToString());}}
以上来自于谷歌翻译
以下为原文
Hello!
I'm trying to get an Agilent 34972A working on a temperature acquisition through IP connexion: _4 channels used _C# software
The code has been primarily written by someone who left the company and he left us some bugs to work on (Lucky Us) It tries to read the temperature data but sometimes: _fail on configuration (MyAgilent34972.FResistance.Configure through MyAgilent34972.Scan.Initiate) with error -401 query interrupted _fail on values read (MyAgilent34972.Scan.Fetch) with error -401 query interrupted ou "Unexpected response from instrument" To make things worse, it usually works fine but sometimes it make this error -401.
I thought that maybe, the Agilent device didn't have enough time to handle the commands so I try adding System.Threading.Thread.Sleep between commands. No good, as it still get the same error but had a new one: timedout.
I looked for an Agilent 34972A API C# Reference on the Internet but didn't find something usable (I found this http://www.element14.com/communi ... mers-reference-help on SCPI programming, thishttp://www.keysight.com/upload/c ... 90009_quick_ref.pdfalso but nothing on C#)
I'm pretty sure I'm doing something wrong but without a C# reference, I don't know the thing(s) I'm doing wrong.
Any clue(s)?
Thanks in advance
Code: using Ivi.Driver.Interop; using Agilent.Agilent34970.Interop;
IAgilent34970 MyAgilent34972; string[] Channel34972A = new string[] { "102", "103", "104", "105", }; bool b_Connected;
b_Connected = false; string standardInitOptions = "Cache=true, InterchangeCheck=false, QueryInstrStatus=true, RangeCheck=true, RecordCoercions=false, Simulate=false"; try { MyAgilent34972 = new Agilent34970(); MyAgilent34972.Initialize("TCPIP0::192.168.0.11::INSTR", false, false, standardInitOptions); b_Connected = MyAgilent34972.Initialized;
} catch (Exception error) { MessageBox.Show(error.ToString(), "Agilent 34972A"); } if (b_Connected == true) { string str_channelList = Channel34972A[0] + ":" + Channel34972A[Channel34972A.Count() - 1];
try { MyAgilent34972.FResistance.Configure(str_channelList, 10, 0.001); MyAgilent34972.Scan.SweepCount = 1; MyAgilent34972.Scan.IntervalScanSetup(str_channelList, 1, 1); MyAgilent34972.Scan.Initiate(); } catch (Exception exc) { int errorCode=0; string errorString=""; MyAgilent34972.Utility.ErrorQuery(ref errorCode,ref errorString); MessageBox.Show("config :" + errorCode.ToString()+", "+errorString);
} } string[] str_value = new string[Channel34972A.Count()]; string[] str_valueDegC = new string[Channel34972A.Count()];
if (b_Connected == true) { try { MyAgilent34972.Scan.Initiate(); MyAgilent34972.System.WaitForOperationComplete(10000);
str_value = MyAgilent34972.Scan.Fetch(); for (int i = 0; i < str_value.Count(); i++) { double d_value = Convert.ToDouble(str_value.Replace('.', ',')); str_valueDegC = d_value.ToString(); } } catch (Exception error) { MessageBox.Show("reading from agilent: " + error.ToString()); }
}
0
|