stella.roof
Class DomeReceiver

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.roof.AbstractShelter
                  extended by stella.roof.DomeReceiver
All Implemented Interfaces:
DriverDepending, Cloneable, ClusterDepending, DomeOperating, Sheltering, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, StatusProviding

public class DomeReceiver
extends AbstractShelter
implements DomeOperating, DriverDepending, ClusterDepending

The Dome receiver operates the Baader dome of RoboTel, but should be capable of dealing with similar dome designs.


Nested Class Summary
static class DomeReceiver.Follow
          A class for testing dome tracking.
static class DomeReceiver.Position
          A class for testing dome positioning.
private  class DomeReceiver.Slew
          This thread never switches motors on or off! This class acts as a thread to slew to a desired position.
private  class DomeReceiver.SolTrack
          A timer task that does the tracking of the anti-solar az.
static class DomeReceiver.Status
          A class for retrieving dome status
private  class DomeReceiver.Track
          A timer task that does the tracking of the dome.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Value altitude
          The value that has the height of the sky position tracked.
private  Value azimuth
          The value that has the azimuth of the sky position tracked.
private  DecTarget de
          The declination in the actual sky we have to follow.
private static double DEFALLOW
          We allow a maximum of 6 degrees on tracking.
private static double DEFDESIREDOFF
          Default property value.
private static long DEFFASTCOOL
          The time it takes the dome to stop after fast movement.
private static long DEFFASTJOIN
          Maximum time fast movement is allowed.
private static double DEFFASTPRE
          The fast positioning is done to that lavel.
private static double DEFHOMEPOSITION
          A home position.
private static int DEFMAXFAILS
          The default number of positiong retires .
private static double DEFMAXHEIGHT
          No need to go here.
private static int DEFMAXRETRIES
          The default number of positiong retires .
private static long DEFPOSITIONCACHE
          Position is invalid after 1000 ms.
private static String DEFSITE
          The default site.
private static long DEFSLEWSLEEP
          Sleep intervall during slews.
private static long DEFSLOWCOOL
          The time it takes the dome to stop after slow movement.
private static long DEFSLOWJOIN
          Maximum time slow movement is allowed.
private static double DEFSLOWPRE
          The slow positioning is done to that lavel.
private static long DEFTIMEOUT
          Maximum slit time for closing.
private static long DEFTRACKREPEAT
          During tracking, position is checked with this intervall.
private static double DEFTRAVELFAST
          If desired position is further than this, use fast speed.
private static double DEFVELOCITYTHRESHOLD
          Velocities below this deg per second are considered stopped.
private  DomeDriver dome
          The dome driver used for interfacing to the dome.
private  double domeaz
          And the azimuth.
private  long dometime
          The last time-stamp we retrieved the dome azimuth.
private  TimerTask follow
          The timer task that allows following the dome.
static String KEY_ALLOW
           
static String KEY_DESIREDOFF
           
static String KEY_DOMEDRIVER
          The name of the dome driver to use.
static String KEY_FASTCOOL
           
static String KEY_FASTJOIN
           
static String KEY_FASTPRE
           
static String KEY_HOMEPOSITION
          The azimuth of the home position.
static String KEY_LATITUDE
          If set, the name of the latitude parameter to use.
static String KEY_LONGITUDE
          If set, the name of the longitude parameter to use.
static String KEY_MAXFAILS
          The maximum number of go-to failures on position obtains.
static String KEY_MAXHEIGHT
           
static String KEY_MAXRETRIES
          The maximum number of retires for position obtains.
static String KEY_POSITIONCACHE
           
static String KEY_SITE
          If no explicit longitude or latitude, we use this site.
static String KEY_SLEWSLEEP
           
static String KEY_SLOWCOOL
           
static String KEY_SLOWJOIN
           
static String KEY_SLOWPRE
           
static String KEY_TIME
          If set, this time parameter should be used from the cluster.
static String KEY_TIMEOUT
           
static String KEY_TRACKREPEAT
           
static String KEY_TRAVELFAST
           
static String KEY_VELOCITYTHRESHOLD
           
private  double lastaz
          And the last azimuth.
private  ErrorEvent lasterror
          We store the last error generated for asynchroneous retrieval.
private  long lastopen
          The timestamp of the last opening of the roof.
private  long lastshut
          The timestamp of the last closing of the roof.
private  long lasttime
          Prior to the last get, this was the time of dome azimuth.
private  boolean motoron
          Indicates that we switched on the motors.
private  Thread moving
          A thread indicating a moving slit/hatch.
private  boolean movingannounced
          A boolean to avoid repeating messages.
private  RaTarget ra
          The right ascension in the actual sky we have to follow.
private  SolAzimuth solaz
          The azimuth of the sun to avoid direct blinding.
private  SolHeight solh
          The height of the sun to avoid direct blinding.
 
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
DomeReceiver(Map<String,String> prop)
          Constructs a new dome receiver used for operating the dome.
 
Method Summary
 boolean antiSun()
          Follows the anti-sun by positioning the slit always opposite to the sun position.
 void clearLastError()
          Clears the last error event.
 boolean close(boolean always)
          Closes the dome.
 boolean closeHatch()
          Directly closes the hatch, if possible.
 boolean closeSlit()
          Directly closes the slit, if possible.
static DomeReceiver createDomeReceiver(File props)
          Creates a dome receiver, initalizes the dome driver and all parameters.
 boolean follow(double ratel, double detel)
          Follows the object at the given ra and dec.
private  double getActualDomePosition()
          Returns the actual dome position if the cache-time is over, otherwise the cached position is returned.
private  Double getActualDomeVelocity()
          Checks the current and the last dome position and calculates a speed out of it, if both are valid, otherwise it returns null.
 Date getLastCloseTime()
          Returns the date of the last shut time if the roof is currently shut.
 ErrorEvent getLastError()
          Returns the last error that occured.
 Date getLastOpenTime()
          Returns the date of the last open time if the roof is currently open.
private  boolean go(double to, boolean forward, boolean fast, double within, long timeout, long cooldown)
          Goes to the indicated position, in the desired direction and speed.
private  boolean goTo(double azdeg)
          Goes to the indicated position.
 boolean home()
          Moves the dome to the home position.
 boolean isClosed()
          Returns true if the dome is fully open.
private  Boolean isMoving()
          We are moving, if our absolute speed is higher than the threshold.
 boolean isOpen()
          Returns true if the dome is fully open.
 boolean open(boolean auto)
          Opens the dome.
 boolean openHatch()
          Directly opens the hatch, if possible.
 boolean openSlit()
          Directly opens the slit, if possible.
 boolean position(double az)
          Moves the dome to the indicated position and stops there.
 boolean powerOff()
          Returns true if the dome driver is present.
 boolean powerOn()
          Returns true if the dome driver is present.
 Object provideStatus()
          Sends a status event back.
 void registerCluster(ParameterClustering set)
          Registers a parameter set to the roof.
 boolean registerDriver(Driver d)
          Registers the dome driver.
 boolean stop()
          Stops the azimuth moter, the slit mechanism cannot be stopped once initiated.
 
Methods inherited from class stella.roof.AbstractShelter
createShelter
 
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, init, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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
 
Methods inherited from interface util.Initializable
init
 

Field Detail

KEY_DOMEDRIVER

public static final String KEY_DOMEDRIVER
The name of the dome driver to use.

See Also:
Constant Field Values

KEY_HOMEPOSITION

public static final String KEY_HOMEPOSITION
The azimuth of the home position.

See Also:
Constant Field Values

KEY_MAXRETRIES

public static final String KEY_MAXRETRIES
The maximum number of retires for position obtains.

See Also:
Constant Field Values

KEY_MAXFAILS

public static final String KEY_MAXFAILS
The maximum number of go-to failures on position obtains.

See Also:
Constant Field Values

KEY_TIME

public static final String KEY_TIME
If set, this time parameter should be used from the cluster.

See Also:
Constant Field Values

KEY_LATITUDE

public static final String KEY_LATITUDE
If set, the name of the latitude parameter to use.

See Also:
Constant Field Values

KEY_LONGITUDE

public static final String KEY_LONGITUDE
If set, the name of the longitude parameter to use.

See Also:
Constant Field Values

KEY_SITE

public static final String KEY_SITE
If no explicit longitude or latitude, we use this site.

See Also:
Constant Field Values

KEY_DESIREDOFF

public static final String KEY_DESIREDOFF
See Also:
Constant Field Values

KEY_TRAVELFAST

public static final String KEY_TRAVELFAST
See Also:
Constant Field Values

KEY_FASTPRE

public static final String KEY_FASTPRE
See Also:
Constant Field Values

KEY_FASTJOIN

public static final String KEY_FASTJOIN
See Also:
Constant Field Values

KEY_FASTCOOL

public static final String KEY_FASTCOOL
See Also:
Constant Field Values

KEY_SLOWPRE

public static final String KEY_SLOWPRE
See Also:
Constant Field Values

KEY_SLOWJOIN

public static final String KEY_SLOWJOIN
See Also:
Constant Field Values

KEY_SLOWCOOL

public static final String KEY_SLOWCOOL
See Also:
Constant Field Values

KEY_POSITIONCACHE

public static final String KEY_POSITIONCACHE
See Also:
Constant Field Values

KEY_VELOCITYTHRESHOLD

public static final String KEY_VELOCITYTHRESHOLD
See Also:
Constant Field Values

KEY_SLEWSLEEP

public static final String KEY_SLEWSLEEP
See Also:
Constant Field Values

KEY_MAXHEIGHT

public static final String KEY_MAXHEIGHT
See Also:
Constant Field Values

KEY_ALLOW

public static final String KEY_ALLOW
See Also:
Constant Field Values

KEY_TIMEOUT

public static final String KEY_TIMEOUT
See Also:
Constant Field Values

KEY_TRACKREPEAT

public static final String KEY_TRACKREPEAT
See Also:
Constant Field Values

DEFSITE

private static final String DEFSITE
The default site.

See Also:
Constant Field Values

DEFHOMEPOSITION

private static final double DEFHOMEPOSITION
A home position.

See Also:
Constant Field Values

DEFMAXRETRIES

private static final int DEFMAXRETRIES
The default number of positiong retires .

See Also:
Constant Field Values

DEFMAXFAILS

private static final int DEFMAXFAILS
The default number of positiong retires .

See Also:
Constant Field Values

DEFDESIREDOFF

private static final double DEFDESIREDOFF
Default property value. Slit width 170cm, diameter 4.7m.

See Also:
Constant Field Values

DEFTRAVELFAST

private static final double DEFTRAVELFAST
If desired position is further than this, use fast speed.

See Also:
Constant Field Values

DEFFASTPRE

private static final double DEFFASTPRE
The fast positioning is done to that lavel.

See Also:
Constant Field Values

DEFSLOWPRE

private static final double DEFSLOWPRE
The slow positioning is done to that lavel.

See Also:
Constant Field Values

DEFFASTCOOL

private static final long DEFFASTCOOL
The time it takes the dome to stop after fast movement.

See Also:
Constant Field Values

DEFSLOWCOOL

private static final long DEFSLOWCOOL
The time it takes the dome to stop after slow movement.

See Also:
Constant Field Values

DEFFASTJOIN

private static final long DEFFASTJOIN
Maximum time fast movement is allowed.

See Also:
Constant Field Values

DEFSLOWJOIN

private static final long DEFSLOWJOIN
Maximum time slow movement is allowed.

See Also:
Constant Field Values

DEFPOSITIONCACHE

private static final long DEFPOSITIONCACHE
Position is invalid after 1000 ms.

See Also:
Constant Field Values

DEFVELOCITYTHRESHOLD

private static final double DEFVELOCITYTHRESHOLD
Velocities below this deg per second are considered stopped.

See Also:
Constant Field Values

DEFSLEWSLEEP

private static final long DEFSLEWSLEEP
Sleep intervall during slews.

See Also:
Constant Field Values

DEFMAXHEIGHT

private static final double DEFMAXHEIGHT
No need to go here.

See Also:
Constant Field Values

DEFALLOW

private static final double DEFALLOW
We allow a maximum of 6 degrees on tracking.

See Also:
Constant Field Values

DEFTIMEOUT

private static final long DEFTIMEOUT
Maximum slit time for closing.

See Also:
Constant Field Values

DEFTRACKREPEAT

private static final long DEFTRACKREPEAT
During tracking, position is checked with this intervall.

See Also:
Constant Field Values

dome

private DomeDriver dome
The dome driver used for interfacing to the dome.


solh

private SolHeight solh
The height of the sun to avoid direct blinding.


solaz

private SolAzimuth solaz
The azimuth of the sun to avoid direct blinding.


ra

private RaTarget ra
The right ascension in the actual sky we have to follow.


de

private DecTarget de
The declination in the actual sky we have to follow.


altitude

private Value altitude
The value that has the height of the sky position tracked.


azimuth

private Value azimuth
The value that has the azimuth of the sky position tracked.


motoron

private boolean motoron
Indicates that we switched on the motors.


dometime

private long dometime
The last time-stamp we retrieved the dome azimuth.


domeaz

private double domeaz
And the azimuth.


lasttime

private long lasttime
Prior to the last get, this was the time of dome azimuth.


lastaz

private double lastaz
And the last azimuth.


lasterror

private ErrorEvent lasterror
We store the last error generated for asynchroneous retrieval.


lastopen

private long lastopen
The timestamp of the last opening of the roof.


lastshut

private long lastshut
The timestamp of the last closing of the roof.


moving

private Thread moving
A thread indicating a moving slit/hatch.


movingannounced

private boolean movingannounced
A boolean to avoid repeating messages.


follow

private TimerTask follow
The timer task that allows following the dome.

Constructor Detail

DomeReceiver

public DomeReceiver(Map<String,String> prop)
Constructs a new dome receiver used for operating the dome.

Method Detail

registerDriver

public boolean registerDriver(Driver d)
Registers the dome driver.

Specified by:
registerDriver in interface DriverDepending
Returns:
True if registering at the driver was successful.

registerCluster

public void registerCluster(ParameterClustering set)
Registers a parameter set to the roof. If a time, longitude or latitude parameter was found, we grab it from the cluster, otherwise we construct default ones from our properties.

Specified by:
registerCluster in interface ClusterDepending

home

public boolean home()
Moves the dome to the home position. No extra limit/zero switches are needed, so we simply move the dome to the home azimuth position

Specified by:
home in interface DomeOperating

position

public boolean position(double az)
Moves the dome to the indicated position and stops there.

Specified by:
position in interface DomeOperating
Parameters:
az - The astronomical azimuth in degrees, S=0, W=+90.

antiSun

public boolean antiSun()
Follows the anti-sun by positioning the slit always opposite to the sun position.

Specified by:
antiSun in interface DomeOperating

follow

public boolean follow(double ratel,
                      double detel)
Follows the object at the given ra and dec.

Specified by:
follow in interface DomeOperating
Parameters:
ratel - Right ascension, degrees, apparent equinox.
detel - Declination, degress, apparent equinox.

stop

public boolean stop()
Stops the azimuth moter, the slit mechanism cannot be stopped once initiated.

Specified by:
stop in interface DomeOperating

open

public boolean open(boolean auto)
Opens the dome. Directly pipes it to our dome driver, but never throws an exception.

Specified by:
open in interface Sheltering
Parameters:
auto - True, if standard procedure (no emergency, like in automated mode).
Returns:
True if opening was successful.

close

public boolean close(boolean always)
Closes the dome. Directly pipes it to our dome driver, but never throws an exception.

Specified by:
close in interface Sheltering
Parameters:
always - True, if standard procedure (no emergency, like in automated mode).
Returns:
True if closing was successful

openHatch

public boolean openHatch()
Directly opens the hatch, if possible. Directly pipes it to our dome driver, but never throws an exception.

Specified by:
openHatch in interface DomeOperating
Returns:
True if opening was successful.

openSlit

public boolean openSlit()
Directly opens the slit, if possible. Directly pipes it to our dome driver, but never throws an exception.

Specified by:
openSlit in interface DomeOperating
Returns:
True if opening was successful.

closeHatch

public boolean closeHatch()
Directly closes the hatch, if possible. Directly pipes it to our dome driver, but never throws an exception.

Specified by:
closeHatch in interface DomeOperating
Returns:
True if opening was successful.

closeSlit

public boolean closeSlit()
Directly closes the slit, if possible. Directly pipes it to our dome driver, but never throws an exception.

Specified by:
closeSlit in interface DomeOperating
Returns:
True if opening was successful.

getLastCloseTime

public Date getLastCloseTime()
Returns the date of the last shut time if the roof is currently shut. If the roof is open, null should be retunred.

Specified by:
getLastCloseTime in interface Sheltering

getLastOpenTime

public Date getLastOpenTime()
Returns the date of the last open time if the roof is currently open. If the roof is shut, null should be retunred.

Specified by:
getLastOpenTime in interface Sheltering

isOpen

public boolean isOpen()
Returns true if the dome is fully open. This means that observing can commence.

Specified by:
isOpen in interface Sheltering

isClosed

public boolean isClosed()
Returns true if the dome is fully open. This means that observing can commence.

Specified by:
isClosed in interface Sheltering

powerOn

public boolean powerOn()
Returns true if the dome driver is present.

Specified by:
powerOn in interface DomeOperating
Returns:
True on success

powerOff

public boolean powerOff()
Returns true if the dome driver is present.

Specified by:
powerOff in interface DomeOperating
Returns:
True on success

provideStatus

public Object provideStatus()
Sends a status event back. The position of the roof and the state of the power switches is read and sent back.

Specified by:
provideStatus in interface StatusProviding

getLastError

public ErrorEvent getLastError()
Returns the last error that occured.

Specified by:
getLastError in interface DomeOperating

clearLastError

public void clearLastError()
Clears the last error event.

Specified by:
clearLastError in interface DomeOperating

goTo

private boolean goTo(double azdeg)
Goes to the indicated position. On RoboTel, we have two different slewing speeds available, which one we use depends on the distance we want to travel, decided by KEY_TRAVELFAST. Depending on the slewing speed chosen, we stop KEY_FASTPRE or KEY_SLOWPRE degrees before we reach the actual position. After the motor stopped moving, decided by #KEY_NOTMOVING, which is a value in degrees persecond, we check if we have reached the desired position within KEY_DESIREDOFF. If we are too far off, we are re-entrant into this method, but only to a certain depth of KEY_MAXRETRIES.


go

private boolean go(double to,
                   boolean forward,
                   boolean fast,
                   double within,
                   long timeout,
                   long cooldown)
Goes to the indicated position, in the desired direction and speed. Starts the motor, starts a surveilance thread, and stops the motor.


getActualDomePosition

private double getActualDomePosition()
Returns the actual dome position if the cache-time is over, otherwise the cached position is returned. If the driver is queried for a new position, the current one gets the last one. This information is then used to calculate the current speed.


getActualDomeVelocity

private Double getActualDomeVelocity()
Checks the current and the last dome position and calculates a speed out of it, if both are valid, otherwise it returns null.


isMoving

private Boolean isMoving()
We are moving, if our absolute speed is higher than the threshold.


createDomeReceiver

public static DomeReceiver createDomeReceiver(File props)
                                       throws IOException
Creates a dome receiver, initalizes the dome driver and all parameters. Mainly for testing purposes.

Throws:
IOException