stella.telescope
Class Pilar3Socket

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by io.AbstractDriver
                  extended by stella.telescope.AbstractPilarDriver
                      extended by stella.telescope.Pilar3Socket
All Implemented Interfaces:
Driver, Cloneable, EventListener, PilarDriver, TplListener, ParameterDepending, TelescopeDriver, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
OpenPilarSocket.PilarTest, Pilar3Socket.PilarTest

public class Pilar3Socket
extends AbstractPilarDriver
implements TplListener

Case implementation of the pilar3 driver.


Nested Class Summary
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.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
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.
 
Fields inherited from class stella.telescope.AbstractPilarDriver
DEFDRIVERNAME, KEY_AVERAGEPRESS, KEY_AVERAGETEMP, KEY_COMMANDID, KEY_PRESSURE, KEY_TEMPERATURE
 
Fields inherited from class io.AbstractDriver
KEY_DRIVERNAME
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
Pilar3Socket(Map prop)
          Constructs a new pilar3 driver.
 
Method Summary
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.
 
Methods inherited from class stella.telescope.AbstractPilarDriver
getNextId, getPressure, getTemperature, registerParameter
 
Methods inherited from class io.AbstractDriver
createDriver, equals, getDriverName, hashCode
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, 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, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface io.Driver
getDriverName
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_TPLHOST

public static final String KEY_TPLHOST
The host the TPL servers runs on.

See Also:
Constant Field Values

KEY_TPLPORT

public static final String KEY_TPLPORT
The port the TPL servers listens to.

See Also:
Constant Field Values

KEY_TPLLOGIN

public static final String KEY_TPLLOGIN
The user name how the client identifies itself at the server.

See Also:
Constant Field Values

KEY_TPLPASSWORD

public static final String KEY_TPLPASSWORD
The password for identification.

See Also:
Constant Field Values

KEY_AUTHOK

public static final String KEY_AUTHOK
Points to the expected reply immediately after login. Can be null.

See Also:
Constant Field Values

KEY_TIMEOUT

public static final String KEY_TIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_ACKNOWLEDGETIMEOUT

public static final String KEY_ACKNOWLEDGETIMEOUT
Time out on acknowledge of command.

See Also:
Constant Field Values

KEY_COMPLETEDTIMEOUT

public static final String KEY_COMPLETEDTIMEOUT
Time out on completing of a command.

See Also:
Constant Field Values

KEY_CLOSETIMEOUT

public static final String KEY_CLOSETIMEOUT
Time out on listening-thread dead on close.

See Also:
Constant Field Values

KEY_DEROTATORACCURACY

public static final String KEY_DEROTATORACCURACY
The maximum allowed deviation from the required derotator position.

See Also:
Constant Field Values

KEY_DEROTATORAXIS

public static final String KEY_DEROTATORAXIS
The axis index with a derotator.

See Also:
Constant Field Values

KEY_FOCUSACCURACY

public static final String KEY_FOCUSACCURACY
The maximum allowed deviation from the required focus position.

See Also:
Constant Field Values

KEY_INITTIMEOUT

public static final String KEY_INITTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_PARKTIMEOUT

public static final String KEY_PARKTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_DEROTATORTIMEOUT

public static final String KEY_DEROTATORTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_FOCUSTIMEOUT

public static final String KEY_FOCUSTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_MOVETIMEOUT

public static final String KEY_MOVETIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_COVERTIMEOUT

public static final String KEY_COVERTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

KEY_QUERYSLEEP

public static final String KEY_QUERYSLEEP
A sleep time between variable queries.

See Also:
Constant Field Values

KEY_RESETSLEEP

public static final String KEY_RESETSLEEP
A sleep time between reset tries .

See Also:
Constant Field Values

KEY_FOCUSRETRY

public static final String KEY_FOCUSRETRY
A retry maximum on focus.

See Also:
Constant Field Values

KEY_DEROTATORRETRY

public static final String KEY_DEROTATORRETRY
A retry maximum on derotator.

See Also:
Constant Field Values

KEY_MOVERETRY

public static final String KEY_MOVERETRY
A retry maximum on move.

See Also:
Constant Field Values

KEY_INITPROBE

public static final String KEY_INITPROBE
A retry maximum on init.

See Also:
Constant Field Values

KEY_PARKPROBE

public static final String KEY_PARKPROBE
A retry maximum on park.

See Also:
Constant Field Values

KEY_INITRETRY

public static final String KEY_INITRETRY
A retry maximum on init.

See Also:
Constant Field Values

KEY_PARKRETRY

public static final String KEY_PARKRETRY
A retry maximum on park.

See Also:
Constant Field Values

KEY_RESETRETRY

public static final String KEY_RESETRETRY
A retry maximum on park.

See Also:
Constant Field Values

KEY_FATALERRORS

public static final String KEY_FATALERRORS
This is the list of errors that cannot be cleared.

See Also:
Constant Field Values

KEY_IGNOREERRORS

public static final String KEY_IGNOREERRORS
This is the list of errors that cannot may be ignored.

See Also:
Constant Field Values

KEY_DEROTATOR

public static final String KEY_DEROTATOR
If true, the current port is equipped with a derotator.

See Also:
Constant Field Values

KEY_USEDEROTATOR

public static final String KEY_USEDEROTATOR
If true, we steer the derotator on move, if present.

See Also:
Constant Field Values

DEFTPLHOST

private static final String DEFTPLHOST
The default hostname the TPL server runs on.

See Also:
Constant Field Values

DEFTPLPORT

private static final int DEFTPLPORT
The default TPL server port.

See Also:
Constant Field Values

DEFTPLLOGIN

private static final String DEFTPLLOGIN
The default tpl login name.

See Also:
Constant Field Values

DEFTPLASSWORD

private static final String DEFTPLASSWORD
The default tpl password.

See Also:
Constant Field Values

DEFTIMEOUT

private static final long DEFTIMEOUT
Time out on simple command.

See Also:
Constant Field Values

DEFACKNOWLEDGETIMEOUT

private static final long DEFACKNOWLEDGETIMEOUT
Time out on acknowledge of command.

See Also:
Constant Field Values

DEFCOMPLETEDTIMEOUT

private static final long DEFCOMPLETEDTIMEOUT
Default time out on completing of a command.

See Also:
Constant Field Values

DEFCLOSETIMEOUT

private static final long DEFCLOSETIMEOUT
Time out on listening-thread dead on close.

See Also:
Constant Field Values

DEFFOCUSACCURACY

private static final double DEFFOCUSACCURACY
The default focus setting accuracy.

See Also:
Constant Field Values

DEFDEROTATORACCURACY

private static final double DEFDEROTATORACCURACY
The default offset setting accuracy.

See Also:
Constant Field Values

DEFINITTIMEOUT

private static final long DEFINITTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

DEFPARKTIMEOUT

private static final long DEFPARKTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

DEFFOCUSTIMEOUT

private static final long DEFFOCUSTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

DEFDEROTATORTIMEOUT

private static final long DEFDEROTATORTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

DEFMOVETIMEOUT

private static final long DEFMOVETIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

DEFCOVERTIMEOUT

private static final long DEFCOVERTIMEOUT
A general timeout for commands.

See Also:
Constant Field Values

DEFQUERYSLEEP

private static final long DEFQUERYSLEEP
A general timeout for sleeps .

See Also:
Constant Field Values

DEFRESETSLEEP

private static final long DEFRESETSLEEP
A general timeout for resets .

See Also:
Constant Field Values

DEFDEROTATORRETRY

private static final int DEFDEROTATORRETRY
A retry maximum on derotator.

See Also:
Constant Field Values

DEFFOCUSRETRY

private static final int DEFFOCUSRETRY
A retry maximum on focus.

See Also:
Constant Field Values

DEFMOVERETRY

private static final int DEFMOVERETRY
A retry maximum on move.

See Also:
Constant Field Values

DEFINITPROBE

private static final int DEFINITPROBE
A retry maximum on init.

See Also:
Constant Field Values

DEFPARKPROBE

private static final int DEFPARKPROBE
A retry maximum on park.

See Also:
Constant Field Values

DEFINITRETRY

private static final int DEFINITRETRY
A retry maximum on init.

See Also:
Constant Field Values

DEFPARKRETRY

private static final int DEFPARKRETRY
A retry maximum on park.

See Also:
Constant Field Values

DEFRESETRETRY

private static final int DEFRESETRETRY
A retry maximum on move.

See Also:
Constant Field Values

DEFFATALERRORS

private static final String DEFFATALERRORS
Default list of fatal errors. Only first tokens.

See Also:
Constant Field Values

DEFIGNOREERRORS

private static final String DEFIGNOREERRORS
Default list of ignore errors. Only first tokens.

See Also:
Constant Field Values

DEFDEROTATORAXIS

private static final int DEFDEROTATORAXIS
Default derotator axis.

See Also:
Constant Field Values

DEFDEROTATOR

private static final boolean DEFDEROTATOR
Default no derotator present.

See Also:
Constant Field Values

DEFUSEDEROTATOR

private static final boolean DEFUSEDEROTATOR
Default we use the derotator, if present.

See Also:
Constant Field Values

sumazoff

private double sumazoff
For relative offsets, this double holds the currently applied az-off.


sumaltoff

private double sumaltoff
For relative offsets, this double holds the currently applied h-off.


fatal

private List fatal
A string list of errors that cannot be cleared and stop operation.


ignore

private List ignore
A string list of errors that do not interfere with operation.


set

private TplSet set
TPL set instance.


get

private TplGet get
TPL get instance.


tpl

private Socket tpl
The socket connection to the server.


in

private BufferedReader in
The input stream from the server as a buffered reader.


out

private BufferedWriter out
The output stream to the server as a buffered writer.


monitors

private Collection monitors
The collection of monitors.


sending

private Map sending
All active commands, those sending and those not processd.


listen

private Thread listen
The thread watching the input line for incoming replies.

Constructor Detail

Pilar3Socket

public Pilar3Socket(Map prop)
Constructs a new pilar3 driver.

Method Detail

init

public void init()
Initializes the driver by instantiating monitor tables.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

exit

public void exit()
Always closes the connection on exit.


open

public boolean open()
             throws IOException
Opens a new connection to the TSI server (Pilar3).

Specified by:
open in interface Driver
Parameters:
host - IP address of the TSI server.
port - communication port of the TSI server.
Returns:
if successfull.
Throws:
IOException

isOpen

public boolean isOpen()
Returns true if the connection is open.

Specified by:
isOpen in interface Driver
Returns:
True, if a previous initialization was successful

close

public boolean close()
              throws IOException
Closes the connection by sending disconnect.

Specified by:
close in interface Driver
Returns:
True if clean-up was successful.
Throws:
IOException

commenceAbort

public boolean commenceAbort()
                      throws IOException,
                             TsiTimeoutException
Aborts all telescope operation. All running commands are stopped. Guiding and tracking is deactivated. NOT going to the park position.

Specified by:
commenceAbort in interface TelescopeDriver
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

rebuild

public void rebuild()
A way to rebuild the error base.

Specified by:
rebuild in interface PilarDriver

commenceClear

public boolean commenceClear()
                      throws IOException,
                             TsiTimeoutException
Try to clear the telescope errors. If the errors reported by the underlying softand/or hardware are not resolved, this will not be able to clear the errors. Only resolved errors will be removed from the error list.

Specified by:
commenceClear in interface PilarDriver
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceFocus

public boolean commenceFocus(double position)
                      throws IOException,
                             TsiTimeoutException
Sets the absolut position of the telescope primary focus (in mm). Method returns after new focus position has reached. TODO: check if this works. TG: Method has to be redone, this might work, but not a clear implementation

Specified by:
commenceFocus in interface TelescopeDriver
Parameters:
position - the new focusposition in mm.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceFocusOffset

public boolean commenceFocusOffset(double dpos)
                            throws IOException,
                                   TsiTimeoutException
Sets the offset position of the telescope primary focus (in mm). Method returns immediately. Offset are not cummulative. TG: Method has to be redone, this might work, but not a clear implementation from the Pilar side.

Specified by:
commenceFocusOffset in interface TelescopeDriver
Parameters:
dpos - The focus offset that should be applyied.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceDerotator

public boolean commenceDerotator(double position)
                          throws IOException,
                                 TsiTimeoutException
Sets the absolut position of the telescope derotator and disables tracking adjustment. This method should be mainly used on a non-tracking mode, e.g. if taking sky flats. The axis where the derotator is located is set in KEY_DEROTATORAXIS. This method sets the absolute position of the derotator as the syncmode 1 plus offset, compare commenceDerotatorOffset(double).

Specified by:
commenceDerotator in interface TelescopeDriver
Parameters:
position - the new derotator position in degrees.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceDerotatorOffset

public boolean commenceDerotatorOffset(double position)
                                throws IOException,
                                       TsiTimeoutException
Sets the offset of the telescope derotator and prepares the telescope for derotator tracking adjustment. This method should be mainly used on science observations. The method only prepares the offset, it does not wait for the offset position to be reached. The axis where the derotator is located is set in KEY_DEROTATORAXIS. This method sets the offset position of the derotator as the syncmode 3 plus offset, compare commenceDerotator(double).

Specified by:
commenceDerotatorOffset in interface TelescopeDriver
Parameters:
position - the new derotator position in degrees.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceInit

public boolean commenceInit()
                     throws IOException,
                            TsiTimeoutException
Initializes the telescope.

Specified by:
commenceInit in interface TelescopeDriver
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceMove

public boolean commenceMove(double radeg,
                            double dedeg)
                     throws IOException,
                            TsiTimeoutException
Moves the telescope into a new RA-DE position.

Specified by:
commenceMove in interface TelescopeDriver
Parameters:
ra - new right ascension to move in degree.
de - new declination to move in degree.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceMove

public boolean commenceMove(double radeg,
                            double dedeg,
                            double off,
                            boolean fol)
                     throws IOException,
                            TsiTimeoutException
Moves the telescope into a new RA-DE position.

Specified by:
commenceMove in interface TelescopeDriver
Parameters:
radeg - new right ascension to move in degree.
dedeg - new declination to move in degree.
off - The derotator offset in degress
fol - If true, the derotator follows the tracking.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceMove

public boolean commenceMove(double radeg,
                            double dedeg,
                            double off,
                            boolean follow,
                            boolean use)
                     throws IOException,
                            TsiTimeoutException
Moves the telescope into a new RA-DE position.

Parameters:
ra - new right ascension to move in degree.
de - new declination to move in degree.
off - The derotator offset in degress
follow - If true, the derotator follows the tracking.
use - If true, the derotator is used if present.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceMoveAzAlt

public boolean commenceMoveAzAlt(double azdeg,
                                 double altdeg)
                          throws IOException,
                                 TsiTimeoutException
Moves the telescope into a new AZ-ALT position and stops tracking.

Specified by:
commenceMoveAzAlt in interface TelescopeDriver
Parameters:
azdeg - Astronomical azimuth of desired telescope position.
altdeg - Height of target of desired telescope position
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

getHorizontalHeight

private double getHorizontalHeight()
                            throws IOException,
                                   TsiTimeoutException
Returns the current height as returned by the telescope or throws an error. Used for correcting offsets if the height is not provided.

Throws:
IOException
TsiTimeoutException

applyOffset

private boolean applyOffset(double dazenc,
                            double dz)
                     throws IOException,
                            TsiTimeoutException
Applies an encoder difference in azimuth and zenith distance to the current azimuth and height. The offset sums are not altered.

Throws:
IOException
TsiTimeoutException

commenceAbsoluteOffset

public boolean commenceAbsoluteOffset(double azoff,
                                      double altoff)
                               throws IOException,
                                      TsiTimeoutException
Applies an AZ-ALT offset to the current telescope position. Azimuthal component will be corrected with the actual telescope altitude (ie. az_corrected = azoff * cos (alt_current)). The offset sums are reset to the new values.

Specified by:
commenceAbsoluteOffset in interface TelescopeDriver
Parameters:
azoff - AZ offset in degrees (will be corrected with the actual telescope altitude).
altoff - ALT offset in degrees.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceAbsoluteOffset

public boolean commenceAbsoluteOffset(double azoff,
                                      double altoff,
                                      double h)
                               throws IOException,
                                      TsiTimeoutException
Applies an AZ-ALT offset to the current telescope position. Azimuthal component will be corrected with the actual telescope altitude (ie. az_corrected = azoff * cos (alt_current)). The offset sums are reset to the new values.

Specified by:
commenceAbsoluteOffset in interface TelescopeDriver
Parameters:
azoff - AZ offset in degrees (will be corrected with the actual telescope altitude).
altoff - ALT offset in degrees.
h - Height of telescope in degrees.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceRelativeOffset

public boolean commenceRelativeOffset(double azoff,
                                      double altoff)
                               throws IOException,
                                      TsiTimeoutException
Adds an AZ-ALT offset to the current telescope position. Azimuthal component will be corrected with the actual telescope altitude (ie. az_corrected = azoff * cos (alt_current)). The offset sums reflect the new total offsets.

Specified by:
commenceRelativeOffset in interface TelescopeDriver
Parameters:
azoff - AZ offset in degrees (will be corrected with the actual telescope altitude).
altoff - ALT offset in degrees.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceRelativeOffset

public boolean commenceRelativeOffset(double azoff,
                                      double altoff,
                                      double h)
                               throws IOException,
                                      TsiTimeoutException
Adds an AZ-ALT offset to the current telescope position. Azimuthal component will be corrected with the actual telescope altitude (ie. az_corrected = azoff * cos (alt_current)). The offset sums reflect the new total offsets.

Specified by:
commenceRelativeOffset in interface TelescopeDriver
Parameters:
azoff - AZ offset in degrees (will be corrected with the actual telescope altitude).
altoff - ALT offset in degrees.
h - Height of telescope.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commencePark

public boolean commencePark()
                     throws IOException,
                            TsiTimeoutException
Brings the telescope into its park position. Closes the mirror covers. Powers-down the telescope.

Specified by:
commencePark in interface TelescopeDriver
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceSetCovers

public boolean commenceSetCovers(boolean close)
                          throws IOException,
                                 TsiTimeoutException
Sets the position of the mirror covers.

Specified by:
commenceSetCovers in interface PilarDriver
Parameters:
close - true for closing, false for opening.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceTracking

public boolean commenceTracking(boolean start)
                         throws IOException,
                                TsiTimeoutException
Starts/stops telescope tracking.

Specified by:
commenceTracking in interface TelescopeDriver
Parameters:
start - boolean to start or stop telescope tracking.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceGuiding

public boolean commenceGuiding(boolean start)
                        throws IOException,
                               TsiTimeoutException
Starts/stops telescope tracking.

Specified by:
commenceGuiding in interface TelescopeDriver
Parameters:
start - boolean to start or stop telescope tracking.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

commenceUsePort

public boolean commenceUsePort(int portnum)
                        throws IOException,
                               TsiTimeoutException
Optical port, specifies used derotator and filter and will also rotate M3 (if supported by the telescope hardware).

Specified by:
commenceUsePort in interface PilarDriver
Parameters:
portnumber - id of the optical port.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

getValue

public Object getValue(String name)
                throws IOException,
                       TsiTimeoutException
Returns the value of a TSI variable as a java Object.

Specified by:
getValue in interface PilarDriver
Parameters:
name - TSI variable to query.
Returns:
if successfull.
Throws:
IOException
TsiTimeoutException

setValue

public boolean setValue(String name,
                        String to)
                 throws IOException,
                        TsiTimeoutException
Sets the value of a TSI varibale. If strings are set, they must include the quotes!

Specified by:
setValue in interface PilarDriver
Parameters:
name - The TSI variable to set
to - The value the variable should be set to.
Throws:
IOException
TsiTimeoutException

waitForValue

public boolean waitForValue(String variable,
                            String value,
                            String notvalue,
                            long timeout)
                     throws TsiTimeoutException,
                            IOException
Waits until (monitors) a TSI variable gets a specified value. Maximum timeout must also be given.

Specified by:
waitForValue in interface PilarDriver
Parameters:
variable - TSI variable to be monitored.
value - the TSI variable must get.
notvalue - If the TSI variable get this value, return with false
timeout - maximum time (ms) until the variable must get the given value.
Returns:
true if the operation was successful.
Throws:
TsiTimeoutException;
TsiTimeoutException
IOException

updateEnvironment

public boolean updateEnvironment()
                          throws IOException,
                                 TsiTimeoutException
Writes the actual ambient temperature and pressure to Pilar3 to make use it in the refraction correction.

Returns:
true if successfull.
Throws:
IOException
TsiTimeoutException

getErrors

public Collection<TsiError> getErrors()
                               throws IOException,
                                      TsiTimeoutException
Reads the error list.

Specified by:
getErrors in interface PilarDriver
Throws:
IOException
TsiTimeoutException

checkForFatalErrors

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. 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.


checkForIgnoreErrors

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. If all of the errors are recognized (true error has identical starting string), true is returned.


commenceTplGet

private TplGet commenceTplGet(String request,
                              long timeout)
                       throws TsiTimeoutException,
                              IOException
Sends a new get command. The command is provided with a new command id and put into the sending lookup table. For locking access, the command actually sent is returned.

Parameters:
request - TSI command string.
timeout - time out for the command completition.
Returns:
the original TPL command if command is completed or null.
Throws:
TsiTimeoutException
IOException

commenceTplGet

private TplGet commenceTplGet(String request)
                       throws TsiTimeoutException,
                              IOException
Sends a new get command with the default command completition timeout.

Parameters:
request - TSI command string.
Returns:
the original TPL command if command is completed or null.
Throws:
TsiTimeoutException
IOException

commenceTplSet

private TplSet commenceTplSet(String request,
                              long timeout)
                       throws TsiTimeoutException,
                              IOException
Sends a new set command. The command is provided with a new command id and put into the sending lookup table. For locking access, the command actually sent is returned.

Parameters:
request - TSI command string.
timeout - time out for the command completition.
Returns:
the original TPL command if command is completed or null.
Throws:
TsiTimeoutException
IOException

commenceTplSet

private TplSet commenceTplSet(String request)
                       throws TsiTimeoutException,
                              IOException
Sends a new set command with the default command completition timeout.

Parameters:
request - TSI command string.
Returns:
the original TPL command if command is completed or null.
Throws:
TsiTimeoutException
IOException

commenceTplAbort

private TplAbort commenceTplAbort(boolean killit,
                                  int what,
                                  long timeout)
                           throws TsiTimeoutException,
                                  IOException
Sends a new TPL abort command. The command is provided with a new command id and put into the sending lookup table. For locking access, the command actually sent is returned.

Parameters:
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.
Throws:
TsiTimeoutException
IOException

commenceTplAbort

private TplAbort commenceTplAbort(boolean killit,
                                  int what)
                           throws TsiTimeoutException,
                                  IOException
Sends a new TPL abort command with the default command completition timeout.

Throws:
TsiTimeoutException
IOException

waitCommandCompleted

private boolean waitCommandCompleted(TplCommand command,
                                     long timeout)
                              throws TsiTimeoutException
Waits for a given TPL command gets completed.

Parameters:
command - the TPL command to be waited.
timeout - timeout for the command complete.
Throws:
TsiTimeoutException

afterDisconnect

private boolean afterDisconnect()
                         throws IOException
This method is called after a disconnect has been commenced or if the initial open fails.

Throws:
IOException

send

private boolean send(TplCommand command)
              throws IOException
Sends the specified command to the server socket and puts the command to the sending lookup table.

Returns:
True if sending was successful.
Throws:
IOException

processData

public void processData(TplEvent reply)
Processes a 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.

Specified by:
processData in interface TplListener

stateChanged

private void stateChanged(TplCommand changed)
An event signaled that the state on a command has changed. We go through the list of all monitors and check the new state.