public class Pilar3Socket extends AbstractPilarDriver implements TplListener
| Modifier and Type | Class and Description |
|---|---|
private class |
Pilar3Socket.Monitor
A class that takes a list of commands and checks incoming state changes
if all of the monitored commands are completed/acknowledged.
|
static class |
Pilar3Socket.PilarTest
Test class.
|
private class |
Pilar3Socket.TplHandler
A thread that permanently moitors the incoming stream for replies sent by
the socket.
|
| Modifier and Type | Field and Description |
|---|---|
private static long |
DEFACKNOWLEDGETIMEOUT
Time out on acknowledge of command.
|
private static long |
DEFCLOSETIMEOUT
Time out on listening-thread dead on close.
|
private static long |
DEFCOMPLETEDTIMEOUT
Default time out on completing of a command.
|
private static long |
DEFCOVERTIMEOUT
A general timeout for commands.
|
private static boolean |
DEFDEROTATOR
Default no derotator present.
|
private static double |
DEFDEROTATORACCURACY
The default offset setting accuracy.
|
private static int |
DEFDEROTATORAXIS
Default derotator axis.
|
private static int |
DEFDEROTATORRETRY
A retry maximum on derotator.
|
private static long |
DEFDEROTATORTIMEOUT
A general timeout for commands.
|
private static String |
DEFFATALERRORS
Default list of fatal errors.
|
private static double |
DEFFOCUSACCURACY
The default focus setting accuracy.
|
private static int |
DEFFOCUSRETRY
A retry maximum on focus.
|
private static long |
DEFFOCUSTIMEOUT
A general timeout for commands.
|
private static String |
DEFIGNOREERRORS
Default list of ignore errors.
|
private static int |
DEFINITPROBE
A retry maximum on init.
|
private static int |
DEFINITRETRY
A retry maximum on init.
|
private static long |
DEFINITTIMEOUT
A general timeout for commands.
|
private static int |
DEFMOVERETRY
A retry maximum on move.
|
private static long |
DEFMOVETIMEOUT
A general timeout for commands.
|
private static int |
DEFPARKPROBE
A retry maximum on park.
|
private static int |
DEFPARKRETRY
A retry maximum on park.
|
private static long |
DEFPARKTIMEOUT
A general timeout for commands.
|
private static long |
DEFQUERYSLEEP
A general timeout for sleeps .
|
private static int |
DEFRESETRETRY
A retry maximum on move.
|
private static long |
DEFRESETSLEEP
A general timeout for resets .
|
private static long |
DEFTIMEOUT
Time out on simple command.
|
private static String |
DEFTPLASSWORD
The default tpl password.
|
private static String |
DEFTPLHOST
The default hostname the TPL server runs on.
|
private static String |
DEFTPLLOGIN
The default tpl login name.
|
private static int |
DEFTPLPORT
The default TPL server port.
|
private static boolean |
DEFUSEDEROTATOR
Default we use the derotator, if present.
|
private List |
fatal
A string list of errors that cannot be cleared and stop operation.
|
private TplGet |
get
TPL get instance.
|
private List |
ignore
A string list of errors that do not interfere with operation.
|
private BufferedReader |
in
The input stream from the server as a buffered reader.
|
static String |
KEY_ACKNOWLEDGETIMEOUT
Time out on acknowledge of command.
|
static String |
KEY_AUTHOK
Points to the expected reply immediately after login.
|
static String |
KEY_CLOSETIMEOUT
Time out on listening-thread dead on close.
|
static String |
KEY_COMPLETEDTIMEOUT
Time out on completing of a command.
|
static String |
KEY_COVERTIMEOUT
A general timeout for commands.
|
static String |
KEY_DEROTATOR
If true, the current port is equipped with a derotator.
|
static String |
KEY_DEROTATORACCURACY
The maximum allowed deviation from the required derotator position.
|
static String |
KEY_DEROTATORAXIS
The axis index with a derotator.
|
static String |
KEY_DEROTATORRETRY
A retry maximum on derotator.
|
static String |
KEY_DEROTATORTIMEOUT
A general timeout for commands.
|
static String |
KEY_FATALERRORS
This is the list of errors that cannot be cleared.
|
static String |
KEY_FOCUSACCURACY
The maximum allowed deviation from the required focus position.
|
static String |
KEY_FOCUSRETRY
A retry maximum on focus.
|
static String |
KEY_FOCUSTIMEOUT
A general timeout for commands.
|
static String |
KEY_IGNOREERRORS
This is the list of errors that cannot may be ignored.
|
static String |
KEY_INITPROBE
A retry maximum on init.
|
static String |
KEY_INITRETRY
A retry maximum on init.
|
static String |
KEY_INITTIMEOUT
A general timeout for commands.
|
static String |
KEY_MOVERETRY
A retry maximum on move.
|
static String |
KEY_MOVETIMEOUT
A general timeout for commands.
|
static String |
KEY_PARKPROBE
A retry maximum on park.
|
static String |
KEY_PARKRETRY
A retry maximum on park.
|
static String |
KEY_PARKTIMEOUT
A general timeout for commands.
|
static String |
KEY_QUERYSLEEP
A sleep time between variable queries.
|
static String |
KEY_RESETRETRY
A retry maximum on park.
|
static String |
KEY_RESETSLEEP
A sleep time between reset tries .
|
static String |
KEY_TIMEOUT
A general timeout for commands.
|
static String |
KEY_TPLHOST
The host the TPL servers runs on.
|
static String |
KEY_TPLLOGIN
The user name how the client identifies itself at the server.
|
static String |
KEY_TPLPASSWORD
The password for identification.
|
static String |
KEY_TPLPORT
The port the TPL servers listens to.
|
static String |
KEY_USEDEROTATOR
If true, we steer the derotator on move, if present.
|
private Thread |
listen
The thread watching the input line for incoming replies.
|
private Collection |
monitors
The collection of monitors.
|
private BufferedWriter |
out
The output stream to the server as a buffered writer.
|
private Map |
sending
All active commands, those sending and those not processd.
|
private TplSet |
set
TPL set instance.
|
private double |
sumaltoff
For relative offsets, this double holds the currently applied h-off.
|
private double |
sumazoff
For relative offsets, this double holds the currently applied az-off.
|
private Socket |
tpl
The socket connection to the server.
|
DEFDRIVERNAME, KEY_AVERAGEPRESS, KEY_AVERAGETEMP, KEY_COMMANDID, KEY_PRESSURE, KEY_TEMPERATUREKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
Pilar3Socket(Map prop)
Constructs a new pilar3 driver.
|
| Modifier and Type | Method and Description |
|---|---|
private boolean |
afterDisconnect()
This method is called after a disconnect has been commenced or if the
initial open fails.
|
private boolean |
applyOffset(double dazenc,
double dz)
Applies an encoder difference in azimuth and zenith distance to the
current azimuth and height.
|
private boolean |
checkForFatalErrors(List errs)
We compare a list of errors found to be present on the telescope with a
list of fatal errors described by the
KEY_FATALERRORS property. |
private boolean |
checkForIgnoreErrors(List errs)
We compare a list of errors found to be present on the telescope with a
list of ignorable errors described by the
KEY_IGNOREERRORS
property. |
boolean |
close()
Closes the connection by sending disconnect.
|
boolean |
commenceAbort()
Aborts all telescope operation.
|
boolean |
commenceAbsoluteOffset(double azoff,
double altoff)
Applies an AZ-ALT offset to the current telescope position.
|
boolean |
commenceAbsoluteOffset(double azoff,
double altoff,
double h)
Applies an AZ-ALT offset to the current telescope position.
|
boolean |
commenceClear()
Try to clear the telescope errors.
|
boolean |
commenceDerotator(double position)
Sets the absolut position of the telescope derotator and disables
tracking adjustment.
|
boolean |
commenceDerotatorOffset(double position)
Sets the offset of the telescope derotator and prepares the telescope for
derotator tracking adjustment.
|
boolean |
commenceFocus(double position)
Sets the absolut position of the telescope primary focus (in mm).
|
boolean |
commenceFocusOffset(double dpos)
Sets the offset position of the telescope primary focus (in mm).
|
boolean |
commenceGuiding(boolean start)
Starts/stops telescope tracking.
|
boolean |
commenceInit()
Initializes the telescope.
|
boolean |
commenceMove(double radeg,
double dedeg)
Moves the telescope into a new RA-DE position.
|
boolean |
commenceMove(double radeg,
double dedeg,
double off,
boolean fol)
Moves the telescope into a new RA-DE position.
|
boolean |
commenceMove(double radeg,
double dedeg,
double off,
boolean follow,
boolean use)
Moves the telescope into a new RA-DE position.
|
boolean |
commenceMoveAzAlt(double azdeg,
double altdeg)
Moves the telescope into a new AZ-ALT position and stops tracking.
|
boolean |
commencePark()
Brings the telescope into its park position.
|
boolean |
commenceRelativeOffset(double azoff,
double altoff)
Adds an AZ-ALT offset to the current telescope position.
|
boolean |
commenceRelativeOffset(double azoff,
double altoff,
double h)
Adds an AZ-ALT offset to the current telescope position.
|
boolean |
commenceSetCovers(boolean close)
Sets the position of the mirror covers.
|
private TplAbort |
commenceTplAbort(boolean killit,
int what)
Sends a new TPL abort command with the default command completition
timeout.
|
private TplAbort |
commenceTplAbort(boolean killit,
int what,
long timeout)
Sends a new TPL abort command.
|
private TplGet |
commenceTplGet(String request)
Sends a new get command with the default command completition timeout.
|
private TplGet |
commenceTplGet(String request,
long timeout)
Sends a new get command.
|
private TplSet |
commenceTplSet(String request)
Sends a new set command with the default command completition timeout.
|
private TplSet |
commenceTplSet(String request,
long timeout)
Sends a new set command.
|
boolean |
commenceTracking(boolean start)
Starts/stops telescope tracking.
|
boolean |
commenceUsePort(int portnum)
Optical port, specifies used derotator and filter and will also rotate M3
(if supported by the telescope hardware).
|
void |
exit()
Always closes the connection on exit.
|
Collection<TsiError> |
getErrors()
Reads the error list.
|
private double |
getHorizontalHeight()
Returns the current height as returned by the telescope or throws an
error.
|
Object |
getValue(String name)
Returns the value of a TSI variable as a java Object.
|
void |
init()
Initializes the driver by instantiating monitor tables.
|
boolean |
isOpen()
Returns true if the connection is open.
|
boolean |
open()
Opens a new connection to the TSI server (Pilar3).
|
void |
processData(TplEvent reply)
Processes a
TplEvent. |
void |
rebuild()
A way to rebuild the error base.
|
private boolean |
send(TplCommand command)
Sends the specified command to the server socket and puts the command to
the
sending lookup table. |
boolean |
setValue(String name,
String to)
Sets the value of a TSI varibale.
|
private void |
stateChanged(TplCommand changed)
An event signaled that the state on a command has changed.
|
boolean |
updateEnvironment()
Writes the actual ambient temperature and pressure to Pilar3 to make use
it in the refraction correction.
|
private boolean |
waitCommandCompleted(TplCommand command,
long timeout)
Waits for a given TPL command gets completed.
|
boolean |
waitForValue(String variable,
String value,
String notvalue,
long timeout)
Waits until (monitors) a TSI variable gets a specified value.
|
getNextId, getPressure, getTemperature, registerParametercreateDriver, equals, getDriverName, hashCodeaugment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitgetDriverNamepublic static final String KEY_TPLHOST
public static final String KEY_TPLPORT
public static final String KEY_TPLLOGIN
public static final String KEY_TPLPASSWORD
public static final String KEY_AUTHOK
public static final String KEY_TIMEOUT
public static final String KEY_ACKNOWLEDGETIMEOUT
public static final String KEY_COMPLETEDTIMEOUT
public static final String KEY_CLOSETIMEOUT
public static final String KEY_DEROTATORACCURACY
public static final String KEY_DEROTATORAXIS
public static final String KEY_FOCUSACCURACY
public static final String KEY_INITTIMEOUT
public static final String KEY_PARKTIMEOUT
public static final String KEY_DEROTATORTIMEOUT
public static final String KEY_FOCUSTIMEOUT
public static final String KEY_MOVETIMEOUT
public static final String KEY_COVERTIMEOUT
public static final String KEY_QUERYSLEEP
public static final String KEY_RESETSLEEP
public static final String KEY_FOCUSRETRY
public static final String KEY_DEROTATORRETRY
public static final String KEY_MOVERETRY
public static final String KEY_INITPROBE
public static final String KEY_PARKPROBE
public static final String KEY_INITRETRY
public static final String KEY_PARKRETRY
public static final String KEY_RESETRETRY
public static final String KEY_FATALERRORS
public static final String KEY_IGNOREERRORS
public static final String KEY_DEROTATOR
public static final String KEY_USEDEROTATOR
private static final String DEFTPLHOST
private static final int DEFTPLPORT
private static final String DEFTPLLOGIN
private static final String DEFTPLASSWORD
private static final long DEFTIMEOUT
private static final long DEFACKNOWLEDGETIMEOUT
private static final long DEFCOMPLETEDTIMEOUT
private static final long DEFCLOSETIMEOUT
private static final double DEFFOCUSACCURACY
private static final double DEFDEROTATORACCURACY
private static final long DEFINITTIMEOUT
private static final long DEFPARKTIMEOUT
private static final long DEFFOCUSTIMEOUT
private static final long DEFDEROTATORTIMEOUT
private static final long DEFMOVETIMEOUT
private static final long DEFCOVERTIMEOUT
private static final long DEFQUERYSLEEP
private static final long DEFRESETSLEEP
private static final int DEFDEROTATORRETRY
private static final int DEFFOCUSRETRY
private static final int DEFMOVERETRY
private static final int DEFINITPROBE
private static final int DEFPARKPROBE
private static final int DEFINITRETRY
private static final int DEFPARKRETRY
private static final int DEFRESETRETRY
private static final String DEFFATALERRORS
private static final String DEFIGNOREERRORS
private static final int DEFDEROTATORAXIS
private static final boolean DEFDEROTATOR
private static final boolean DEFUSEDEROTATOR
private double sumazoff
private double sumaltoff
private List fatal
private List ignore
private TplSet set
private TplGet get
private Socket tpl
private BufferedReader in
private BufferedWriter out
private Collection monitors
private Map sending
private Thread listen
public Pilar3Socket(Map prop)
public void init()
init in interface Initializablepublic void exit()
public boolean open()
throws IOException
open in interface Driverhost - IP address of the TSI server.port - communication port of the TSI server.IOExceptionpublic boolean isOpen()
public boolean close()
throws IOException
close in interface DriverIOExceptionpublic boolean commenceAbort()
throws IOException,
TsiTimeoutException
commenceAbort in interface TelescopeDriverIOExceptionTsiTimeoutExceptionpublic void rebuild()
rebuild in interface PilarDriverpublic boolean commenceClear()
throws IOException,
TsiTimeoutException
commenceClear in interface PilarDriverIOExceptionTsiTimeoutExceptionpublic boolean commenceFocus(double position)
throws IOException,
TsiTimeoutException
commenceFocus in interface FocusAccessibleposition - the new focusposition in mm.IOExceptionTsiTimeoutExceptionpublic boolean commenceFocusOffset(double dpos)
throws IOException,
TsiTimeoutException
commenceFocusOffset in interface FocusAccessibledpos - The focus offset that should be applyied.IOExceptionTsiTimeoutExceptionpublic boolean commenceDerotator(double position)
throws IOException,
TsiTimeoutException
KEY_DEROTATORAXIS. This method sets the absolute
position of the derotator as the syncmode 1 plus offset, compare
commenceDerotatorOffset(double).commenceDerotator in interface DerotatorAccessibleposition - the new derotator position in degrees.IOExceptionTsiTimeoutExceptionpublic boolean commenceDerotatorOffset(double position)
throws IOException,
TsiTimeoutException
KEY_DEROTATORAXIS. This method sets the
offset position of the derotator as the syncmode 3 plus offset, compare
commenceDerotator(double).commenceDerotatorOffset in interface DerotatorAccessibleposition - the new derotator position in degrees.IOExceptionTsiTimeoutExceptionpublic boolean commenceInit()
throws IOException,
TsiTimeoutException
commenceInit in interface TelescopeDriverIOExceptionTsiTimeoutExceptionpublic boolean commenceMove(double radeg,
double dedeg)
throws IOException,
TsiTimeoutException
commenceMove in interface PointingAccessiblera - new right ascension to move in degree.de - new declination to move in degree.IOExceptionTsiTimeoutExceptionpublic boolean commenceMove(double radeg,
double dedeg,
double off,
boolean fol)
throws IOException,
TsiTimeoutException
commenceMove in interface PointingAccessibleradeg - new right ascension to move in degree.dedeg - new declination to move in degree.off - The derotator offset in degressfol - If true, the derotator follows the tracking.IOExceptionTsiTimeoutExceptionpublic boolean commenceMove(double radeg,
double dedeg,
double off,
boolean follow,
boolean use)
throws IOException,
TsiTimeoutException
ra - new right ascension to move in degree.de - new declination to move in degree.off - The derotator offset in degressfollow - If true, the derotator follows the tracking.use - If true, the derotator is used if present.IOExceptionTsiTimeoutExceptionpublic boolean commenceMoveAzAlt(double azdeg,
double altdeg)
throws IOException,
TsiTimeoutException
commenceMoveAzAlt in interface PointingAccessibleazdeg - Astronomical azimuth of desired telescope position.altdeg - Height of target of desired telescope positionIOExceptionTsiTimeoutExceptionprivate double getHorizontalHeight()
throws IOException,
TsiTimeoutException
IOExceptionTsiTimeoutExceptionprivate boolean applyOffset(double dazenc,
double dz)
throws IOException,
TsiTimeoutException
IOExceptionTsiTimeoutExceptionpublic boolean commenceAbsoluteOffset(double azoff,
double altoff)
throws IOException,
TsiTimeoutException
commenceAbsoluteOffset in interface OffsetAccessibleazoff - AZ offset in degrees (will be corrected with the actual
telescope altitude).altoff - ALT offset in degrees.IOExceptionTsiTimeoutExceptionpublic boolean commenceAbsoluteOffset(double azoff,
double altoff,
double h)
throws IOException,
TsiTimeoutException
commenceAbsoluteOffset in interface OffsetAccessibleazoff - AZ offset in degrees (will be corrected with the actual
telescope altitude).altoff - ALT offset in degrees.h - Height of telescope in degrees.IOExceptionTsiTimeoutExceptionpublic boolean commenceRelativeOffset(double azoff,
double altoff)
throws IOException,
TsiTimeoutException
commenceRelativeOffset in interface OffsetAccessibleazoff - AZ offset in degrees (will be corrected with the actual
telescope altitude).altoff - ALT offset in degrees.IOExceptionTsiTimeoutExceptionpublic boolean commenceRelativeOffset(double azoff,
double altoff,
double h)
throws IOException,
TsiTimeoutException
commenceRelativeOffset in interface OffsetAccessibleazoff - AZ offset in degrees (will be corrected with the actual
telescope altitude).altoff - ALT offset in degrees.h - Height of telescope.IOExceptionTsiTimeoutExceptionpublic boolean commencePark()
throws IOException,
TsiTimeoutException
commencePark in interface TelescopeDriverIOExceptionTsiTimeoutExceptionpublic boolean commenceSetCovers(boolean close)
throws IOException,
TsiTimeoutException
commenceSetCovers in interface PilarDriverclose - true for closing, false for opening.IOExceptionTsiTimeoutExceptionpublic boolean commenceTracking(boolean start)
throws IOException,
TsiTimeoutException
commenceTracking in interface PointingAccessiblestart - boolean to start or stop telescope tracking.IOExceptionTsiTimeoutExceptionpublic boolean commenceGuiding(boolean start)
throws IOException,
TsiTimeoutException
commenceGuiding in interface OffsetAccessiblestart - boolean to start or stop telescope tracking.IOExceptionTsiTimeoutExceptionpublic boolean commenceUsePort(int portnum)
throws IOException,
TsiTimeoutException
commenceUsePort in interface PilarDriverportnumber - id of the optical port.IOExceptionTsiTimeoutExceptionpublic Object getValue(String name) throws IOException, TsiTimeoutException
getValue in interface PilarDrivername - TSI variable to query.IOExceptionTsiTimeoutExceptionpublic boolean setValue(String name, String to) throws IOException, TsiTimeoutException
setValue in interface PilarDrivername - The TSI variable to setto - The value the variable should be set to.IOExceptionTsiTimeoutExceptionpublic boolean waitForValue(String variable, String value, String notvalue, long timeout) throws TsiTimeoutException, IOException
waitForValue in interface PilarDrivervariable - TSI variable to be monitored.value - the TSI variable must get.notvalue - If the TSI variable get this value, return with falsetimeout - maximum time (ms) until the variable must get the given value.TsiTimeoutException;TsiTimeoutExceptionIOExceptionpublic boolean updateEnvironment()
throws IOException,
TsiTimeoutException
IOExceptionTsiTimeoutExceptionpublic Collection<TsiError> getErrors() throws IOException, TsiTimeoutException
getErrors in interface PilarDriverIOExceptionTsiTimeoutExceptionprivate boolean checkForFatalErrors(List errs)
KEY_FATALERRORS property.
If any of the fatal errors is recognized (true error has identical
starting string), true is returned. If all errors present on the
telescope, we return false.private boolean checkForIgnoreErrors(List errs)
KEY_IGNOREERRORS
property. If all of the errors are recognized (true error has identical
starting string), true is returned.private TplGet commenceTplGet(String request, long timeout) throws TsiTimeoutException, IOException
request - TSI command string.timeout - time out for the command completition.TsiTimeoutExceptionIOExceptionprivate TplGet commenceTplGet(String request) throws TsiTimeoutException, IOException
request - TSI command string.TsiTimeoutExceptionIOExceptionprivate TplSet commenceTplSet(String request, long timeout) throws TsiTimeoutException, IOException
request - TSI command string.timeout - time out for the command completition.TsiTimeoutExceptionIOExceptionprivate TplSet commenceTplSet(String request) throws TsiTimeoutException, IOException
request - TSI command string.TsiTimeoutExceptionIOExceptionprivate TplAbort commenceTplAbort(boolean killit, int what, long timeout) throws TsiTimeoutException, IOException
killit - if running command is to be killed (or aborted)what - command ID of the command to be killed/aborted. If it is set
to 0, then all the running commands are going to be
killed/aborted.TsiTimeoutExceptionIOExceptionprivate TplAbort commenceTplAbort(boolean killit, int what) throws TsiTimeoutException, IOException
TsiTimeoutExceptionIOExceptionprivate boolean waitCommandCompleted(TplCommand command, long timeout) throws TsiTimeoutException
command - the TPL command to be waited.timeout - timeout for the command complete.TsiTimeoutExceptionprivate boolean afterDisconnect()
throws IOException
IOExceptionprivate boolean send(TplCommand command) throws IOException
sending lookup table.IOExceptionpublic void processData(TplEvent reply)
TplEvent. If we have a command listening for the
incoming event, we interpret it using the
TplCommand.parseTplEvent(stella.net.tpl.TplEvent). If the acknowledge/complete state of
the command changed, we also test if someone is waiting for notification.processData in interface TplListenerprivate void stateChanged(TplCommand changed)