
Chapter 3
159
Programming Examples
Using Java Programming Over Socket LAN
scpiCommand.setFont(font);
scpiResponse.appendText("SCPI Demo Program: Response messages\n");
scpiResponse.appendText("--------------------------------------------\n");
}
// This routine is called whenever the applet is actived
public void start() {
// Open the sockets if not already opened
sck.OpenSockets();
// Start a response thread
StartResponseThread(true);
}
// This routine is called whenever the applet is out of scope
// i.e. minize browser
public void stop() {
// Close all local sockets
sck.CloseSockets();
// Kill the response thread
StartResponseThread(false);
}
// Action for sending out scpi commands
// This routine is called whenever a command is received from the
// SCPI command panel.
public boolean action(Event evt, Object what) {
// If this is the correct target
if (evt.target == scpiCommand) {
// Get the scpi command
String str = scpiCommand.getText();
// Send it out to the Scpi socket
sck.ScpiWriteLine(str);
String tempStr = str.toLowerCase();
// If command str is "syst:err?", don't need to send another one.
if ( (tempStr.indexOf("syst") == -1) ||
(tempStr.indexOf("err") == -1) ) {
// Query for any error
sck.ScpiWriteLine("syst:err?");
}
return true;
}
return false;
}
// Start/Stop a Response thread to display the response strings
private void StartResponseThread(boolean start) {
if (start) {
// Start a response thread
responseThread = new Thread(this);
responseThread.start();
}
else {
// Kill the response thread
Содержание E4406A VSA Series
Страница 4: ...4 ...
Страница 59: ...59 2 Programming Fundamentals ...
Страница 76: ...76 Chapter2 Programming Fundamentals Using the Instrument Status Registers Overall Status Register System ...
Страница 124: ...124 Chapter2 Programming Fundamentals Using the LAN to Control the Analyzer ...
Страница 125: ...125 3 Programming Examples ...
Страница 164: ...164 Chapter3 Programming Examples Using Java Programming Over Socket LAN ...
Страница 165: ...165 4 Programming Command Cross References ...
Страница 379: ...379 6 Error Messages ...
Страница 412: ...412 Chapter6 Error Messages Error Message Descriptions ...