PT1 User Manual
25
M-PT1-001-01
Public
Overrides
Function
GetAllAddresses
()
As
String
()
Try
Dim
nameList
As
New
List
(
Of
String
)
nameList
=
GlobalResourceManager.Find
(
“USB
?*
INSTR”
)
Return
nameList.ToArray
()
Catch
ex
As
Exception
Return
Nothing
End
Try
End
Function
5.
Open an
IMessageBasedSession
to the desired device using an address from the
nameList
in the
previous step:
Private
visa
As
IMessageBasedSession
visa
=
GlobalResourceManager.Open
(
addr
)
6.
Use the
Write
method to send SCPI commands and the
Read
method to retrieve results:
Public
Overrides
Function
Read
(
ByVal
readableOnly
As
Boolean
)
As
String
Dim
response
As
String
=
String.Empty
response
=
visa.RawIO.ReadString
()
If
response
=
String.Empty
Then
Throw
New
Exception
(
"Read from device failed"
)
End
If
Return
response
End
Function
Public
Overrides
Sub
Write
(
ByVal
strCommand
As
String
)
visa.RawIO.Write
(
strCommand
)
End
Sub
Write
commands require termination with the linefeed character
\n
.
Note
The PT1 runs SCPI commands asynchronously. To check if an operation is complete, it is required to poll
the s
tatus bit via the query “
STAT:OPER:COND?
”. If the return value is 0, the PT1 has completed its
operation.
Try
Write
(
"Test:Res?"
+
vbLf
)
While
(
iResponse
<>
0
)
strPolarityResponse
=
Query
(
":STAT:OPER:COND?"
+
vbLf
)
If
Not
Integer.TryParse
(
strPolarityResponse
,
iResponse
)
Then
iResponse
=
-
1
End
if
System.Threading.Thread.Sleep
(
10
)