stella.roof
Class RoofReceiver.RetryTask

java.lang.Object
  extended by java.util.TimerTask
      extended by stella.roof.RoofReceiver.RetryTask
All Implemented Interfaces:
Runnable
Enclosing class:
RoofReceiver

protected class RoofReceiver.RetryTask
extends TimerTask

The timer task responsible for retries of open/close of the roof. Prior to running it checks if its internal retry counter has not reached its maximum, whether the last open/close has been successful, whether the last close/open receive is valid and whether the limit switch state is not the desired reading. To query this task if its is scheduled for opening or closing, use the isOpen() and isShut() method, respectively.


Field Summary
private  int retries
          The number of retries.
private  String type
          The type of this retry task.
 
Constructor Summary
protected RoofReceiver.RetryTask(String openclose)
          Constructs a new retry-task.
 
Method Summary
 boolean isOpen()
          Queries the retry type for open.
 boolean isShut()
          Queries the retry type for shut.
 void run()
          The run method of the repetitive open/shut task.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private String type
The type of this retry task. Either open or shut.


retries

private int retries
The number of retries.

Constructor Detail

RoofReceiver.RetryTask

protected RoofReceiver.RetryTask(String openclose)
Constructs a new retry-task. Its internal retries counter is set to zero. The type of the retry is determined.

Method Detail

isOpen

public boolean isOpen()
Queries the retry type for open. Returns true if this task is intended for opening.


isShut

public boolean isShut()
Queries the retry type for shut. Returns true if this task is intended for closinging.


run

public void run()
The run method of the repetitive open/shut task. Prior to running it checks for the following conditions:
  1. The number of actual retries must be below RoofReceiver.KEY_RETRYMAXIMUM. If this number is zero, this task will never run.
  2. Depending on its type, it checks if the lastXXXSuccess is earlier than the corresponding lastXXXReceive. In this case, this timer task is canceled.
  3. On e.g. opening, if the lastCloseReceive is earlier than the lastOpenReceive, this timer task is canceled.
  4. The switch state, as determined by RoofReceiver.KEY_RETRYSWITCHES is compared to the aim value, either RoofReceiver.KEY_RETRYOPENAIM or RoofReceiver.KEY_RETRYCLOSEAIM. If the current switch state already reads as this aim value, this timer task is canceled.
  5. If the switch state is null, this thread dies without performing any task, but may be rescheduled later.
If all this conditions are fulfilled, the main class's RoofReceiver.open(boolean) or RoofReceiver.close(boolean) method is called. No further checks are made after the call to this method.

Specified by:
run in interface Runnable
Specified by:
run in class TimerTask