stella.roof
Class RoofReceiver

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

public class RoofReceiver
extends AbstractShelter
implements ClusterDepending, RoofOperating, DriverDepending

The class serving open/close roof, power on/off, status and reset limit switches. For the individual commands, refer to OpenLeftRoof, OpenRightRoof, OpenRoof, CloseLeftRoof, CloseRightRoof, CloseRoof, PowerOnRoof, PowerOffRoof, ResetLimitSwitch , and StatusEnvironment. Five SwitchTriggers, power, openRoof, shutRoof, limitFail, and motorFail are provided by this class, where all except the first one come in pair for each roof-half.
This class is intended for basic-access. No time-out or re-do routines are implemented, these should be done by a scheduler on the command caster edge. This server provides access to the roof via the RoofOperating interface. If this roof receiver is used in the primary command/acknowledge/done message cycle, it must be incorporated with a ReceiverTorso desendantas like a EnvironmentMaster.

The following properties are used by the roof receiver. Note that commands sent to the serial port are stripped from the carriage return char(s), see the RS485Server.KEY_CR key.

The main commands served by the roof receiver are treated in the following way.


Nested Class Summary
protected  class RoofReceiver.CloseThread
          To open both halfes synchroningly, create an open thread for each half.
protected  class RoofReceiver.OpenThread
          To open both halfes synchroningly, create an open thread for each half.
protected  class RoofReceiver.RetryTask
          The timer task responsible for retries of open/close of the roof.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  SimpleTrigger[] cancelClose
          A trigger indicating that the close-movement should be canceled.
private  SimpleTrigger[] cancelOpen
          A trigger indicating that the open-movement should be canceled.
private  SimpleTrigger[] closing
          A trigger indicating that the roof is closing.
private static boolean DEFCLOSEONFAIL
          The default overruling for close.
private static boolean DEFCLOSEPOWERALLOW
          The default power-allowance for close.
private static long DEFCONCURRENTCLOSEDELAY
          The default delay time for concurrent closing of roof halfes, 5 sec.
private static long DEFCONCURRENTOPENDELAY
          The default delay time for concurrent opening of roof halfes, 5 sec.
private static int DEFENSURE
          The default resending of crucial commands.
private static String DEFERRORREPLY
          The default erronous-command starting string.
private static long DEFLAUNCHTIME
          The default timeout on launch, 10sec.
private static String DEFLEFTCLOSE
          The default close string.
private static String DEFLEFTOPEN
          The default open string.
private static String DEFLEFTUNCLOSE
          The default close string.
private static String DEFLEFTUNOPEN
          The default open string.
private static String DEFLIGHTSWITCH
          The default name of the light switch.
private static long DEFMOVETIME
          The default timeout on total move, 4 min.
private static boolean DEFOPENONFAIL
          The default overruling for open.
private static boolean DEFOPENPOWERALLOW
          The default power-allowance for open.
private static long DEFPAUSETIME
          The default limit switch reset power-off time, 2 sec.
private static String DEFPOWEROFF
          The default power-off string.
private static String DEFPOWERON
          The default power-on string.
private static String DEFRESET
          The default reset limit switches command.
private static long DEFRESETTIME
          The default limit switch reset power-off time, 0.5 sec.
private static String DEFRETRYCLOSEAIM
          The default aim values of the limit switches on close retries.
private static long DEFRETRYINTERVALL
          The default intervall between retries.
private static int DEFRETRYMAXIMUM
          The default maximum number of close/open retries on failure.
private static String DEFRETRYOPENAIM
          The default aim values of the limit switches on open retries.
private static String DEFRETRYSWITCHES
          The default limit switches to match on retries.
private static String DEFRIGHTCLOSE
          The default close string.
private static String DEFRIGHTOPEN
          The default open string.
private static String DEFRIGHTUNCLOSE
          The default close string.
private static String DEFRIGHTUNOPEN
          The default open string.
private static String DEFSTATUSDATUM
          The default simple-data format for the status datum.
private static String DEFUNRESET
          The default unreset limit switches command.
private static boolean DEFVALIDOPEN
          The default valid only state.
private static boolean DEFVALIDSHUT
          The default valid only state.
private  Blinker flashing
          The blinker for flashing light prior to roof movement.
private  boolean[] highpoll
          To allow the poller to be on high long enough.
static String KEY_CLOSEONFAIL
          The key to overrule limit switch failures on close.
static String KEY_CLOSEPOWERALLOW
          The key to allow powering up the roof on open, if power is off.
static String KEY_CLOSETRIGGER
          The key to the properties of the roofOpen remote trigger.
static String KEY_CONCURRENTCLOSEDELAY
          The key for a delay of opening the second half.
static String KEY_CONCURRENTOPENDELAY
          The key for a delay of opening the second half.
static String KEY_ENSURE
          For faulty serials, this key should point to a number bigger one.
static String KEY_LAUNCHTIME
          The key for the launching phase timeout (ms).
static String KEY_LEFTCLOSE
          The key linked to the string sent to the serial port for close.
static String KEY_LEFTOPEN
          The key linked to the string sent to the serial port for open.
static String KEY_LEFTUNCLOSE
          The key linked to the string sent to the serial port for close.
static String KEY_LEFTUNOPEN
          The key linked to the string sent to the serial port for open.
static String KEY_LIGHTSWITCH
          The key to the blinker name.
static String KEY_LIMITFAIL
          The key to the properties of the limit switch fail trigger.
static String KEY_MOTORFAIL
          The key to the properties of the motor fail trigger.
static String KEY_MOVETIME
          The key for the whole moving phase timeout (ms).
static String KEY_OPENONFAIL
          The key to overrule limit switch failures on open.
static String KEY_OPENPOWERALLOW
          The key to allow powering up the roof on open, if power is off.
static String KEY_OPENTRIGGER
          The key to the properties of the roofOpen remote trigger.
static String KEY_PAUSETIME
          The time required for limit switch reset pause after on.
static String KEY_POWER_OFF
          The key linked to the string sent to the serial port for power off.
static String KEY_POWER_ON
          The key linked to the string sent to the serial port for power on.
static String KEY_POWERTRIGGER
          The key to the start-up power state.
static String KEY_RESETTIME
          The time required for limit switch reset pause between off-on.
static String KEY_RETRYCLOSEAIM
          The aim values of the limit switches to match on close retries.
static String KEY_RETRYINTERVALL
          The intervall between retries.
static String KEY_RETRYMAXIMUM
          The maximum number of close/open retries on failure.
static String KEY_RETRYOPENAIM
          The aim values of the limit switches to match on open retries.
static String KEY_RETRYSWITCHES
          The limit switches to match on retries.
static String KEY_RIGHTCLOSE
          The key linked to the string sent to the serial port for close.
static String KEY_RIGHTOPEN
          The key linked to the string sent to the serial port for open.
static String KEY_RIGHTUNCLOSE
          The key linked to the string sent to the serial port for close.
static String KEY_RIGHTUNOPEN
          The key linked to the string sent to the serial port for open.
static String KEY_STATUSDATUM
          The keys to the simple-date format string for status messages.
static String KEY_VALIDOPEN
          If true, the open state is determined by valid reads only.
static String KEY_VALIDSHUT
          If true, the shut state is determined by valid reads only.
private  long lastCloseReceive
          The ms-time of the last received close command.
private  long lastCloseSuccess
          The ms-time of the last successful close command.
private  long lastOpenReceive
          The ms-time of the last received open command.
private  long lastOpenSuccess
          The ms-time of the last successful open command.
private  SwitchTrigger[] limitFail
          This triggers get true if the limit-switch check signals a failure.
private  Object[] lock
          To allow synchronizing.
private  SwitchTrigger[] motorFail
          This triggers get true if the motor protection signals a failure.
private  SimpleTrigger[] opening
          A trigger indicating that the roof is opening.
private static String OPENRETRY
          The retry-task identifier for open.
private  SwitchTrigger[] openRoof
          The actual open state, true for roof(s) open.
private  OneReadTrigger power
          The actual power state, true for power on.
private  Timer repeater
          The timer for repetitive tries to open/close of roof.
private  RoofReceiver.RetryTask retry
          The timer task for repetitive open roof.
protected static PollingRS485Server serial
          The serial port server.
private static String SHUTRETRY
          The retry-task identifier for close.
private  SwitchTrigger[] shutRoof
          This triggers get true if the roofs are entirely closed.
private  long timetag
          For occasional time-tagging.
private  ErrorEvent wentwrong
          An error event to return.
 
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
RoofReceiver(Map<String,String> qualify)
          The constructor for a roof receiver.
 
Method Summary
 void clearLastError()
          Clears the last error event.
 boolean close(boolean auto)
          Processes an entire close cycle for both roof halfes.
private  boolean closeBlink()
          Does blinking phase on open roof.
 boolean closeLeft()
          Closes the left roof, regardless of its current state.
 boolean closeRight()
          Closes the right roof, regardless of its current state.
private  boolean defect(int roofnr)
          Checks the status of the limit switches.
private  boolean doClose(int roofnr)
          Processes an entire close-roof cycle.
private  boolean doOpen(int roofnr)
          Processes an entire open-roof cycle.
private  String ensure(String command, int retries)
          For convenience, we catch IOExceptions.
 Date getLastCloseTime()
          If we are open, we return the last Date all roofs have been opened.
 ErrorEvent getLastError()
          Returns the last error event generated during a command subroutine.
 Date getLastOpenTime()
          If we are open, we return the last Date all roofs have been opened.
 boolean isClosed()
          Returns the combined status of all open-roof switches.
 boolean isOpen()
          Returns the combined status of all open-roof switches.
 boolean open(boolean auto)
          Processes an entire open cycle for both roof halfes.
private  boolean openBlink()
          Does blinking phase on open roof.
 boolean openLeft()
          Opens the left roof, regardless of its current state.
 boolean openRight()
          Opens the right roof, regardless of its current state.
private  boolean openRoofLaunch(int roofnr)
          Opens the roof, first stage.
private  boolean openRoofMove(int roofnr)
          Opens the roof, second stage.
 boolean powerOff()
          Powers down the roof.
 boolean powerOn()
          Powers the roof on.
private  boolean preClose()
          Things that are done prior to any close command.
private  boolean preOpen()
          Things that are done prior to any open command.
 Object provideStatus()
          Sends a status event back.
 void registerCluster(ParameterClustering set)
          Registers a parameter set to the roof.
 boolean registerDriver(Driver driver)
          Initializes the serial server.
 boolean resetLimit()
          Resets the limit switch failure indicator.
private  boolean shutRoofLaunch(int roofnr)
          Closes the roof, first stage.
private  boolean shutRoofMove(int roofnr)
          Closes the roof, second stage.
 
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_CONCURRENTOPENDELAY

public static final String KEY_CONCURRENTOPENDELAY
The key for a delay of opening the second half.

See Also:
Constant Field Values

KEY_CONCURRENTCLOSEDELAY

public static final String KEY_CONCURRENTCLOSEDELAY
The key for a delay of opening the second half.

See Also:
Constant Field Values

KEY_OPENONFAIL

public static final String KEY_OPENONFAIL
The key to overrule limit switch failures on open.

See Also:
Constant Field Values

KEY_CLOSEONFAIL

public static final String KEY_CLOSEONFAIL
The key to overrule limit switch failures on close.

See Also:
Constant Field Values

KEY_OPENPOWERALLOW

public static final String KEY_OPENPOWERALLOW
The key to allow powering up the roof on open, if power is off.

See Also:
Constant Field Values

KEY_CLOSEPOWERALLOW

public static final String KEY_CLOSEPOWERALLOW
The key to allow powering up the roof on open, if power is off.

See Also:
Constant Field Values

KEY_LEFTOPEN

public static final String KEY_LEFTOPEN
The key linked to the string sent to the serial port for open.

See Also:
Constant Field Values

KEY_LEFTUNOPEN

public static final String KEY_LEFTUNOPEN
The key linked to the string sent to the serial port for open.

See Also:
Constant Field Values

KEY_LEFTCLOSE

public static final String KEY_LEFTCLOSE
The key linked to the string sent to the serial port for close.

See Also:
Constant Field Values

KEY_LEFTUNCLOSE

public static final String KEY_LEFTUNCLOSE
The key linked to the string sent to the serial port for close.

See Also:
Constant Field Values

KEY_RIGHTOPEN

public static final String KEY_RIGHTOPEN
The key linked to the string sent to the serial port for open.

See Also:
Constant Field Values

KEY_RIGHTUNOPEN

public static final String KEY_RIGHTUNOPEN
The key linked to the string sent to the serial port for open.

See Also:
Constant Field Values

KEY_RIGHTCLOSE

public static final String KEY_RIGHTCLOSE
The key linked to the string sent to the serial port for close.

See Also:
Constant Field Values

KEY_RIGHTUNCLOSE

public static final String KEY_RIGHTUNCLOSE
The key linked to the string sent to the serial port for close.

See Also:
Constant Field Values

KEY_POWER_ON

public static final String KEY_POWER_ON
The key linked to the string sent to the serial port for power on.

See Also:
Constant Field Values

KEY_POWER_OFF

public static final String KEY_POWER_OFF
The key linked to the string sent to the serial port for power off.

See Also:
Constant Field Values

KEY_LIGHTSWITCH

public static final String KEY_LIGHTSWITCH
The key to the blinker name.

See Also:
Constant Field Values

KEY_POWERTRIGGER

public static final String KEY_POWERTRIGGER
The key to the start-up power state.

See Also:
Constant Field Values

KEY_OPENTRIGGER

public static final String KEY_OPENTRIGGER
The key to the properties of the roofOpen remote trigger.

See Also:
Constant Field Values

KEY_CLOSETRIGGER

public static final String KEY_CLOSETRIGGER
The key to the properties of the roofOpen remote trigger.

See Also:
Constant Field Values

KEY_LIMITFAIL

public static final String KEY_LIMITFAIL
The key to the properties of the limit switch fail trigger.

See Also:
Constant Field Values

KEY_MOTORFAIL

public static final String KEY_MOTORFAIL
The key to the properties of the motor fail trigger.

See Also:
Constant Field Values

KEY_MOVETIME

public static final String KEY_MOVETIME
The key for the whole moving phase timeout (ms).

See Also:
Constant Field Values

KEY_LAUNCHTIME

public static final String KEY_LAUNCHTIME
The key for the launching phase timeout (ms).

See Also:
Constant Field Values

KEY_RESETTIME

public static final String KEY_RESETTIME
The time required for limit switch reset pause between off-on.

See Also:
Constant Field Values

KEY_PAUSETIME

public static final String KEY_PAUSETIME
The time required for limit switch reset pause after on.

See Also:
Constant Field Values

KEY_RETRYMAXIMUM

public static final String KEY_RETRYMAXIMUM
The maximum number of close/open retries on failure.

See Also:
Constant Field Values

KEY_RETRYINTERVALL

public static final String KEY_RETRYINTERVALL
The intervall between retries.

See Also:
Constant Field Values

KEY_RETRYSWITCHES

public static final String KEY_RETRYSWITCHES
The limit switches to match on retries.

See Also:
Constant Field Values

KEY_RETRYOPENAIM

public static final String KEY_RETRYOPENAIM
The aim values of the limit switches to match on open retries.

See Also:
Constant Field Values

KEY_RETRYCLOSEAIM

public static final String KEY_RETRYCLOSEAIM
The aim values of the limit switches to match on close retries.

See Also:
Constant Field Values

KEY_ENSURE

public static final String KEY_ENSURE
For faulty serials, this key should point to a number bigger one.

See Also:
Constant Field Values

KEY_STATUSDATUM

public static final String KEY_STATUSDATUM
The keys to the simple-date format string for status messages.

See Also:
Constant Field Values

KEY_VALIDOPEN

public static final String KEY_VALIDOPEN
If true, the open state is determined by valid reads only. Dangerous!

See Also:
Constant Field Values

KEY_VALIDSHUT

public static final String KEY_VALIDSHUT
If true, the shut state is determined by valid reads only. Dangerous!

See Also:
Constant Field Values

DEFOPENPOWERALLOW

private static final boolean DEFOPENPOWERALLOW
The default power-allowance for open.

See Also:
Constant Field Values

DEFCLOSEPOWERALLOW

private static final boolean DEFCLOSEPOWERALLOW
The default power-allowance for close.

See Also:
Constant Field Values

DEFOPENONFAIL

private static final boolean DEFOPENONFAIL
The default overruling for open.

See Also:
Constant Field Values

DEFCLOSEONFAIL

private static final boolean DEFCLOSEONFAIL
The default overruling for close.

See Also:
Constant Field Values

DEFLEFTOPEN

private static final String DEFLEFTOPEN
The default open string.

See Also:
Constant Field Values

DEFLEFTUNOPEN

private static final String DEFLEFTUNOPEN
The default open string.

See Also:
Constant Field Values

DEFLEFTCLOSE

private static final String DEFLEFTCLOSE
The default close string.

See Also:
Constant Field Values

DEFLEFTUNCLOSE

private static final String DEFLEFTUNCLOSE
The default close string.

See Also:
Constant Field Values

DEFRIGHTOPEN

private static final String DEFRIGHTOPEN
The default open string.

See Also:
Constant Field Values

DEFRIGHTUNOPEN

private static final String DEFRIGHTUNOPEN
The default open string.

See Also:
Constant Field Values

DEFRIGHTCLOSE

private static final String DEFRIGHTCLOSE
The default close string.

See Also:
Constant Field Values

DEFRIGHTUNCLOSE

private static final String DEFRIGHTUNCLOSE
The default close string.

See Also:
Constant Field Values

DEFPOWERON

private static final String DEFPOWERON
The default power-on string.

See Also:
Constant Field Values

DEFPOWEROFF

private static final String DEFPOWEROFF
The default power-off string.

See Also:
Constant Field Values

DEFRESET

private static final String DEFRESET
The default reset limit switches command.

See Also:
Constant Field Values

DEFUNRESET

private static final String DEFUNRESET
The default unreset limit switches command.

See Also:
Constant Field Values

DEFERRORREPLY

private static final String DEFERRORREPLY
The default erronous-command starting string.

See Also:
Constant Field Values

DEFCONCURRENTOPENDELAY

private static final long DEFCONCURRENTOPENDELAY
The default delay time for concurrent opening of roof halfes, 5 sec.

See Also:
Constant Field Values

DEFCONCURRENTCLOSEDELAY

private static final long DEFCONCURRENTCLOSEDELAY
The default delay time for concurrent closing of roof halfes, 5 sec.

See Also:
Constant Field Values

DEFMOVETIME

private static final long DEFMOVETIME
The default timeout on total move, 4 min.

See Also:
Constant Field Values

DEFLAUNCHTIME

private static final long DEFLAUNCHTIME
The default timeout on launch, 10sec.

See Also:
Constant Field Values

DEFRESETTIME

private static final long DEFRESETTIME
The default limit switch reset power-off time, 0.5 sec.

See Also:
Constant Field Values

DEFPAUSETIME

private static final long DEFPAUSETIME
The default limit switch reset power-off time, 2 sec.

See Also:
Constant Field Values

DEFRETRYMAXIMUM

private static final int DEFRETRYMAXIMUM
The default maximum number of close/open retries on failure.

See Also:
Constant Field Values

DEFRETRYINTERVALL

private static final long DEFRETRYINTERVALL
The default intervall between retries.

See Also:
Constant Field Values

DEFLIGHTSWITCH

private static final String DEFLIGHTSWITCH
The default name of the light switch.

See Also:
Constant Field Values

DEFRETRYSWITCHES

private static final String DEFRETRYSWITCHES
The default limit switches to match on retries.

See Also:
Constant Field Values

DEFRETRYOPENAIM

private static final String DEFRETRYOPENAIM
The default aim values of the limit switches on open retries.

See Also:
Constant Field Values

DEFRETRYCLOSEAIM

private static final String DEFRETRYCLOSEAIM
The default aim values of the limit switches on close retries.

See Also:
Constant Field Values

DEFENSURE

private static final int DEFENSURE
The default resending of crucial commands.

See Also:
Constant Field Values

DEFSTATUSDATUM

private static final String DEFSTATUSDATUM
The default simple-data format for the status datum.

See Also:
Constant Field Values

DEFVALIDOPEN

private static final boolean DEFVALIDOPEN
The default valid only state.

See Also:
Constant Field Values

DEFVALIDSHUT

private static final boolean DEFVALIDSHUT
The default valid only state.

See Also:
Constant Field Values

flashing

private Blinker flashing
The blinker for flashing light prior to roof movement.


power

private OneReadTrigger power
The actual power state, true for power on.


openRoof

private SwitchTrigger[] openRoof
The actual open state, true for roof(s) open.


shutRoof

private SwitchTrigger[] shutRoof
This triggers get true if the roofs are entirely closed.


limitFail

private SwitchTrigger[] limitFail
This triggers get true if the limit-switch check signals a failure.


motorFail

private SwitchTrigger[] motorFail
This triggers get true if the motor protection signals a failure.


opening

private SimpleTrigger[] opening
A trigger indicating that the roof is opening.


closing

private SimpleTrigger[] closing
A trigger indicating that the roof is closing.


cancelOpen

private SimpleTrigger[] cancelOpen
A trigger indicating that the open-movement should be canceled.


cancelClose

private SimpleTrigger[] cancelClose
A trigger indicating that the close-movement should be canceled.


lastOpenSuccess

private long lastOpenSuccess
The ms-time of the last successful open command.


lastOpenReceive

private long lastOpenReceive
The ms-time of the last received open command.


lastCloseSuccess

private long lastCloseSuccess
The ms-time of the last successful close command.


lastCloseReceive

private long lastCloseReceive
The ms-time of the last received close command.


repeater

private Timer repeater
The timer for repetitive tries to open/close of roof.


retry

private RoofReceiver.RetryTask retry
The timer task for repetitive open roof.


OPENRETRY

private static final String OPENRETRY
The retry-task identifier for open.

See Also:
Constant Field Values

SHUTRETRY

private static final String SHUTRETRY
The retry-task identifier for close.

See Also:
Constant Field Values

wentwrong

private ErrorEvent wentwrong
An error event to return.


timetag

private long timetag
For occasional time-tagging.


highpoll

private boolean[] highpoll
To allow the poller to be on high long enough.


lock

private Object[] lock
To allow synchronizing.


serial

protected static transient PollingRS485Server serial
The serial port server.

Constructor Detail

RoofReceiver

public RoofReceiver(Map<String,String> qualify)
             throws RemoteException
The constructor for a roof receiver. Additionally to the standard receiver properties the following quantities may be specified in the properties, default values are in paranthesis: Note that the property files of the roofs to control must be included in a comma-separated list in the properties otherwise an IllegalStateException is thrown.

At construct a timer task reading in the status of all roofs is started and the roof receiver registers itself as a status handler.

Throws:
RemoteException
Method Detail

isOpen

public boolean isOpen()
Returns the combined status of all open-roof switches. If the KEY_VALIDOPEN switch is false, true is returned only, if all open-roof switches are true. If this switch is true, only valid readings are considered, meaning that invalid states are ignored. This is a dangerous setting and should only be used in emergencies, when one of the two roof-state modules is broken. If no open-roof switches are associated with this roof receiver, false is returned.

Specified by:
isOpen in interface Sheltering

isClosed

public boolean isClosed()
Returns the combined status of all open-roof switches. If the KEY_VALIDSHUT switch is false, true is returned only, if all shut-roof switches are true. If this switch is true, only valid readings are considered, meaning that invalid states are ignored. This is a dangerous setting and should only be used in emergencies, when one of the two roof-state modules is broken. If no shut trigger are asociated, we return false;

Specified by:
isClosed in interface Sheltering

registerCluster

public void registerCluster(ParameterClustering set)
Registers a parameter set to the roof. If a parameter is found, the roof receiver grabs it to issue blinking lights prior to roof open.

Specified by:
registerCluster in interface ClusterDepending

registerDriver

public boolean registerDriver(Driver driver)
Initializes the serial server. The serial server is responsible for communication to the serial port. It provides stream-I/O access to the serial port. If the serial port is not yet opened this method tries to open it.

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

getLastError

public ErrorEvent getLastError()
Returns the last error event generated during a command subroutine. If a command fails for any reason it generates a new error event which is retrieved with this method. Command failure is indicated by returning false from any of the RoofOperating method. If this methods return true, there may still be an error event here which will then be a status event.

Specified by:
getLastError in interface RoofOperating

clearLastError

public void clearLastError()
Clears the last error event.

Specified by:
clearLastError in interface RoofOperating

open

public boolean open(boolean auto)
Processes an entire open cycle for both roof halfes. The launch of the second roof open command is delayed for the sake of the UPS by the time specified in KEY_CONCURRENTOPENDELAY.

For all open/close action, a limit-switch failure may be overruled using the appropriate KEY_OPENONFAIL switch. Because limit switch resets are done with power on/off, both limit switch failure indicators are reset at the same time. This requires the limit switch check to be moved to the appropriate open... methods rather to reside within the doOpen(int) method.

Another note: Power is needed for the operation of the roofs, but may be off at method call. Power may be turned on if the KEY_OPENPOWERALLOW property is true. In this case, limit switches are reset for sure.

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

openLeft

public boolean openLeft()
Opens the left roof, regardless of its current state. It is essentiall that this method is only called by applications that know what they are doing.

Specified by:
openLeft in interface RoofOperating
Returns:
True if opening was successful.

openRight

public boolean openRight()
Opens the right roof, regardless of its current state. It is essentiall that this method is only called by applications that know what they are doing.

Specified by:
openRight in interface RoofOperating
Returns:
True if opening was successful.

close

public boolean close(boolean auto)
Processes an entire close cycle for both roof halfes. The launch of the second roof close command is delayed for the sake of the UPS by the time specified in KEY_CONCURRENTCLOSEDELAY

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

closeLeft

public boolean closeLeft()
Closes the left roof, regardless of its current state. It is essentiall that this method is only called by applications that know what they are doing.

Specified by:
closeLeft in interface RoofOperating
Returns:
True if closing was successful

closeRight

public boolean closeRight()
Closes the right roof, regardless of its current state. It is essentiall that this method is only called by applications that know what they are doing.

Specified by:
closeRight in interface RoofOperating
Returns:
True if closing was successful

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

getLastOpenTime

public Date getLastOpenTime()
If we are open, we return the last Date all roofs have been opened. Otherwise null is returned.

Specified by:
getLastOpenTime in interface Sheltering

getLastCloseTime

public Date getLastCloseTime()
If we are open, we return the last Date all roofs have been opened. Otherwise null is returned.

Specified by:
getLastCloseTime in interface Sheltering

resetLimit

public boolean resetLimit()
Resets the limit switch failure indicator. This is done by sending power-off followed by power-on. Between those two commands, a pause specified by KEY_RESETTIME is inserted. Reset is always done simultaneously for both roofs.

Note that the power on/off cycle initially also resets the motor protection, but this will immediately be restored because the motor protection is a temperature-sensitive switch and will not release until the motors have cooled down.

Specified by:
resetLimit in interface RoofOperating

powerOn

public boolean powerOn()
Powers the roof on. If the roof has power already this method immediately returns true.

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

powerOff

public boolean powerOff()
Powers down the roof. If the roof is powerless already this method immedialtely returns true.

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

ensure

private String ensure(String command,
                      int retries)
For convenience, we catch IOExceptions.


preOpen

private boolean preOpen()
Things that are done prior to any open command. This includes:


preClose

private boolean preClose()
Things that are done prior to any close command. This includes:


doOpen

private boolean doOpen(int roofnr)
Processes an entire open-roof cycle. Depending on the direct flag, error/status messages are either piped to the System streams or to an error listener. Additionally, if direct is true, the roofs are powered on if necessarry.

Parameters:
direct - True if invoked directly, false if in command-receive phase.
Returns:
True on success

doClose

private boolean doClose(int roofnr)
Processes an entire close-roof cycle. Depending on the direct flag, error/status messages are either piped to the System streams or to an error listener. Additionally, if direct is true, the roofs are powered on if necessarry.

Parameters:
roofnr - The roof number to close.
Returns:
True on success.

openBlink

private boolean openBlink()
Does blinking phase on open roof. Fails when no blinking instance is available. Returns immediately if the blinking phase is still on or if the desired duration is zero.


closeBlink

private boolean closeBlink()
Does blinking phase on open roof. Fails when no blinking instance is available. Returns immediately if the blinking phase is still on or if the desired duration is zero.


openRoofLaunch

private boolean openRoofLaunch(int roofnr)
Opens the roof, first stage. Sends the open command to the serial server and sets the moving boolean to true. Sets the timetag to the actual time. The roof switches are read until the roof-closed switches release. This ends this part of the command.


openRoofMove

private boolean openRoofMove(int roofnr)
Opens the roof, second stage. The roof switches are read until the roof-open switches ring. The unopen (unset the open) command is sent to the serial server. The time it took for opening the roof is returned. The moving flag is unset. The lastOpenSuccess is set to the current time.


shutRoofLaunch

private boolean shutRoofLaunch(int roofnr)
Closes the roof, first stage. Sends the close command to the serial server and sets the moving boolean to true. Sets the timetag to the actual time. The roof switches are read until the roof-opened switches release. This end this part of the command.


shutRoofMove

private boolean shutRoofMove(int roofnr)
Closes the roof, second stage. The roof switches are read until the roof-close switches ring. The unclose (unset the close) command is sent to the serial server. The time it took for closing the roof is returned. The moving flag is unset. The lastCloseSuccess is set to the current time.


defect

private boolean defect(int roofnr)
Checks the status of the limit switches. If any pair says the roof is open and closed at the same time there is probably something wrong.