Agilent Technologies E4406A VSA Satellite Radio User Manual


 
174 Chapter 3
Programming Examples
Using Java Programming Over Socket LAN
// Clear the error queue before starting the thread
// in case if theres any error messages from the previous actions
while ( str.indexOf("No error") == -1 ) {
sck.ScpiWriteLine("syst:err?");
str = sck.ScpiReadLine();
}
// Start receiving response or error messages
while(true) {
str = sck.ScpiReadLine();
if ( str != null ) {
// If response messages is "No error", do no display it,
// replace it with "OK" instead.
if ( str.equals("+0,\"No error\"") ) {
str = "OK";
}
// Display any response messages in the Response panel
scpiResponse.appendText(str+"\n");
}
}
}
// Set up and open the SCPI sockets
private void SetupSockets() {
// Get server url
appletBase = (URL)getCodeBase();
// Open the sockets
sck = new Socks(appletBase);
}
// Set up the SCPI command and response panels
private void SetupPanels() {
// Set up SCPI command panel
southPanel.setLayout(new GridLayout(1, 1));
p = new Panel();
p.setLayout(new BorderLayout());