SX1 User Manual
18
M-SX1-001-01
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 SX1 runs SCPI commands asynchronously. To check if an operation is complete, it is required to poll
the status bit via the query “
STAT:OPER:COND?
”. If the return value is 0, the
SX1 has completed its
operation.
Try
Write
(
"Close"
+
cCommand.SChannel.ToString
+
vbLf
)
While
(
iResponse
<>
0
)
strSwitchResponse
=
Query
(
":STAT:OPER:COND?"
+
vbLf
)
If
Not
Integer.TryParse
(
strSwitchResponse
,
iResponse
)
Then
iResponse
=
-
1
End
if
System.Threading.Thread.Sleep
(
10
)
iCycles
+=
1
If
iCycles
>
300
Then
Throw
New
System.TimeoutException
(
"Switch did not complete its
operation"
)
End
If
End
While
Catch
ex
As
Exception
MsgBox
(
ex.Message
)
End
Try