public class Session extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Session.ConnType
Public constants.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
OPTN_KEEP_ALIVE |
| Constructor and Description |
|---|
Session(int options,
String sessnPrompt,
String unamePrompt,
String passwdPrompt,
String exitCommand,
Ascii.Terminator terminator)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkReplyLength(String[] reply,
int count)
Checks whether a reply size is valid
|
void |
close()
Closes the connection
|
String |
getPrompt()
Gets the prompt
|
boolean |
isOpen()
Tests whether the device connection is open.
|
void |
open(Session.ConnType connType,
String ident,
int baudRate,
int runTimeout)
Opens a connection.
|
void |
open(Session.ConnType connType,
String ident,
int baudRate,
String username,
String password,
int logTimeout,
int runTimeout)
Opens a connection and logs in.
|
String[] |
receive()
Receives a response
|
String[] |
receive(String command)
Sends a command and receives the response
|
static void |
responseError(String resp)
Generates an invalid response exception
|
void |
send(String command)
Sends a command
|
void |
setCharTimeout(int timeout)
Sets the response inter-character timeout.
|
void |
setConnTimeout(int timeout)
Sets the network connection timeout.
|
void |
setDebug(boolean on)
Sets the debug option.
|
void |
setTimeout(int timeout)
Sets the response timeout.
|
public static final int OPTN_KEEP_ALIVE
public Session(int options,
String sessnPrompt,
String unamePrompt,
String passwdPrompt,
String exitCommand,
Ascii.Terminator terminator)
options - Options wordsessnPrompt - The expected session promptunamePrompt - The expected username promptpasswdPrompt - The expected password promptexitCommand - The exit commandterminator - The Ascii command/response terminatorpublic void open(Session.ConnType connType, String ident, int baudRate, String username, String password, int logTimeout, int runTimeout) throws org.lsst.ccs.drivers.commons.DriverException
connType - The enumerated connection type: TELNET, FTDI or SERIALident - The host name (TELNET), USB ID (FTDI) or port name (SERIAL)baudRate - The baud rate for FTDI and Serialusername - The user namepassword - The passwordlogTimeout - The character timeout when logging in (msec)runTimeout - The character timeout when running (msec)org.lsst.ccs.drivers.commons.DriverExceptionpublic void open(Session.ConnType connType, String ident, int baudRate, int runTimeout) throws org.lsst.ccs.drivers.commons.DriverException
connType - The enumerated connection type: FTDI or SERIALident - The USB ID (FTDI) or port name (SERIAL)baudRate - The baud rate for FTDI and SerialrunTimeout - The character timeout when running (msec)org.lsst.ccs.drivers.commons.DriverExceptionpublic void close()
throws org.lsst.ccs.drivers.commons.DriverException
org.lsst.ccs.drivers.commons.DriverExceptionpublic boolean isOpen()
public void send(String command) throws org.lsst.ccs.drivers.commons.DriverException
command - The command to sendorg.lsst.ccs.drivers.commons.DriverExceptionpublic String[] receive() throws org.lsst.ccs.drivers.commons.DriverException
org.lsst.ccs.drivers.commons.DriverExceptionpublic String[] receive(String command) throws org.lsst.ccs.drivers.commons.DriverException
command - The command to sendorg.lsst.ccs.drivers.commons.DriverExceptionpublic void setConnTimeout(int timeout)
timeout - The timeout (ms). 0 means no timeout.public void setTimeout(int timeout)
throws org.lsst.ccs.drivers.commons.DriverException
timeout - The timeout (ms)org.lsst.ccs.drivers.commons.DriverExceptionpublic void setCharTimeout(int timeout)
throws org.lsst.ccs.drivers.commons.DriverException
timeout - The timeout (ms)org.lsst.ccs.drivers.commons.DriverExceptionpublic String getPrompt()
public void setDebug(boolean on)
on - Whether to turn debugging onpublic static void checkReplyLength(String[] reply, int count) throws org.lsst.ccs.drivers.commons.DriverException
reply - The array of reply linescount - The expected line countorg.lsst.ccs.drivers.commons.DriverException - if unequalpublic static void responseError(String resp) throws org.lsst.ccs.drivers.commons.DriverException
resp - The response stringorg.lsst.ccs.drivers.commons.DriverException - alwaysCopyright © 2020 LSST. All rights reserved.