public class RoofReceiver extends AbstractShelter implements GlobalDepending, RoofOperating, DriverDepending
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.
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.
KEY_LEFTOPEN: Maps to the string that should be sent to the
serial port as the open-left command.KEY_LEFTUNOPEN: Maps to the string that should be sent to the
serial port after opening of the left roofs is finished.KEY_RIGHTOPEN: Maps to the string that should be sent to the
serial port as the open-right command.KEY_RIGHTUNOPEN: Maps to the string that should be sent to the
serial port after opening of the right roofs is finished.KEY_LEFTCLOSE: Maps to the string that should be sent to the
serial port to initiate closing of the left roof.KEY_LEFTUNCLOSE: Maps to the string that should be sent to the
serial port after closing of the left roof has successfully been completed.
KEY_RIGHTCLOSE: Maps to the string that should be sent to the
serial port to initiate closing of the left roof.KEY_RIGHTUNCLOSE: Maps to the string that should be sent to the
serial port after closing of the left roof has successfully been completed.
KEY_POWER_ON: Maps to the string that should be sent to
the serial line to enable power.KEY_POWER_OFF: Maps to the string that should be sent to
the serial line to power down the roof system.KEY_CONCURRENTOPENDELAY: The delay between initiating
the opening of the first
and the second roof half. Introduced to pet the UPS power drain.KEY_CONCURRENTCLOSEDELAY The delay between initiating the
closing of the first
and the second roof half. Introduced to pet the UPS power drain.<:KEY_OPENONFAIL:KEY_MOVETIME: Maps to the maximal time the roofs need to
finish their movement. At open this is the time between release of the
closed limit-switches until the open limit-switches
are set.KEY_LAUNCHTIME: Maps to the maximal time the roofs need to
start their movement. At open this is the time between sending of the
open command and the release of the closed
limit-switches.KEY_RESETTIME: Maps to the time-out between power on/off
commands on limit switch resets.KEY_PAUSETIME: Maps to the time-out after power has been
re-established to the roof. Needed to avoid faulty readings on the motor
protection.KEY_OPENTRIGGER: Maps to the properties of the open roof
trigger.KEY_POWERTRIGGER: Maps to the properties of the power on
trigger.KEY_CLOSETRIGGER: Maps to the properties of the roof-closed
trigger.KEY_LIMITFAIL: Maps to the properties of the limit switch
failure triggers.KEY_MOTORFAIL: Maps to the properties of the motor protection
triggers.KEY_OPENONFAIL: If this property is true, opening of the
roof is also allowed in case of limit switch failures.KEY_CLOSEONFAIL: If this property is true, closing of the
roof is also allowed in case of limit switch failures.RoofReceiver.OpenThread. The second roof half opening is initiated after the
KEY_CONCURRENTOPENDELAY time has passed. Both threads are joined
and true is returned if both threads return successfully.
RoofReceiver.CloseThread. The second roof half opening is initiated after the
KEY_CONCURRENTCLOSEDELAY time has passed. Both threads are joined
and true is returned if both threads return successfully.KEY_OPENPOWERALLOW points to true. Now, the limit switches
are checked. If the KEY_OPENONFAIL property is set and the limit
switches indicate a failure, their reading is reset with a call to the
resetLimit() method. On success, this method proceeds normally. Now,
the motor protection is checked. If everything works out, opening of the
roof
starts with a blinking period. After the blinking, to avoid deadlocks from
unrecognived close commands, the closing command is reset by sending the
KEY_LEFTUNCLOSE command. Now, opening of the roof is initiated by
sending the KEY_LEFTOPEN command. A timer watches for release of
the
roof by checking the isclosed-trigger of the left roof half. If the roof
releases on time, a new timer is started watching for the isopened-trigger.
If this trigger releases, this method returns true, if anything fails in
this
cycle false is returned. Note that prior to returning from this method, the
KEY_LEFTUNOPEN command is sent.KEY_RESETTIME and the KEY_PAUSETIME conduct the timing
of the on/off commands.
| Modifier and Type | Class and Description |
|---|---|
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.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
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.
|
KEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Constructor and Description |
|---|
RoofReceiver(Map<String,String> qualify)
The constructor for a roof receiver.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
String |
conciseStatus() |
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.
|
Object |
extendedStatus()
Sends a status event back.
|
Date |
getLastCloseTime()
If we are open, we return the last Date all roofs have been opened.
|
ErrorEvent |
getLastError(CommandEvent dummy)
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.
|
boolean |
registerDriver(Driver driver)
Initializes the serial server.
|
void |
registerGlobals(GlobalGrouping set)
Registers a parameter set to the roof.
|
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.
|
createShelterclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, 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, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultBoolean, 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, stringPropertiespublic static final String KEY_CONCURRENTOPENDELAY
public static final String KEY_CONCURRENTCLOSEDELAY
public static final String KEY_OPENONFAIL
public static final String KEY_CLOSEONFAIL
public static final String KEY_OPENPOWERALLOW
public static final String KEY_CLOSEPOWERALLOW
public static final String KEY_LEFTOPEN
public static final String KEY_LEFTUNOPEN
public static final String KEY_LEFTCLOSE
public static final String KEY_LEFTUNCLOSE
public static final String KEY_RIGHTOPEN
public static final String KEY_RIGHTUNOPEN
public static final String KEY_RIGHTCLOSE
public static final String KEY_RIGHTUNCLOSE
public static final String KEY_POWER_ON
public static final String KEY_POWER_OFF
public static final String KEY_LIGHTSWITCH
public static final String KEY_POWERTRIGGER
public static final String KEY_OPENTRIGGER
public static final String KEY_CLOSETRIGGER
public static final String KEY_LIMITFAIL
public static final String KEY_MOTORFAIL
public static final String KEY_MOVETIME
public static final String KEY_LAUNCHTIME
public static final String KEY_RESETTIME
public static final String KEY_PAUSETIME
public static final String KEY_RETRYMAXIMUM
public static final String KEY_RETRYINTERVALL
public static final String KEY_RETRYSWITCHES
public static final String KEY_RETRYOPENAIM
public static final String KEY_RETRYCLOSEAIM
public static final String KEY_ENSURE
public static final String KEY_STATUSDATUM
public static final String KEY_VALIDOPEN
public static final String KEY_VALIDSHUT
private static final boolean DEFOPENPOWERALLOW
private static final boolean DEFCLOSEPOWERALLOW
private static final boolean DEFOPENONFAIL
private static final boolean DEFCLOSEONFAIL
private static final String DEFLEFTOPEN
private static final String DEFLEFTUNOPEN
private static final String DEFLEFTCLOSE
private static final String DEFLEFTUNCLOSE
private static final String DEFRIGHTOPEN
private static final String DEFRIGHTUNOPEN
private static final String DEFRIGHTCLOSE
private static final String DEFRIGHTUNCLOSE
private static final String DEFPOWERON
private static final String DEFPOWEROFF
private static final String DEFRESET
private static final String DEFUNRESET
private static final String DEFERRORREPLY
private static final long DEFCONCURRENTOPENDELAY
private static final long DEFCONCURRENTCLOSEDELAY
private static final long DEFMOVETIME
private static final long DEFLAUNCHTIME
private static final long DEFRESETTIME
private static final long DEFPAUSETIME
private static final int DEFRETRYMAXIMUM
private static final long DEFRETRYINTERVALL
private static final String DEFLIGHTSWITCH
private static final String DEFRETRYSWITCHES
private static final String DEFRETRYOPENAIM
private static final String DEFRETRYCLOSEAIM
private static final int DEFENSURE
private static final String DEFSTATUSDATUM
private static final boolean DEFVALIDOPEN
private static final boolean DEFVALIDSHUT
private Blinker flashing
private OneReadTrigger power
private SwitchTrigger[] openRoof
private SwitchTrigger[] shutRoof
private SwitchTrigger[] limitFail
private SwitchTrigger[] motorFail
private final SimpleTrigger[] opening
private final SimpleTrigger[] closing
private final SimpleTrigger[] cancelOpen
private final SimpleTrigger[] cancelClose
private long lastOpenSuccess
private long lastOpenReceive
private long lastCloseSuccess
private long lastCloseReceive
private final Timer repeater
private RoofReceiver.RetryTask retry
private static final String OPENRETRY
private static final String SHUTRETRY
private ErrorEvent wentwrong
private long timetag
private final boolean[] highpoll
private final Object[] lock
protected static transient PollingRS485Server serial
public RoofReceiver(Map<String,String> qualify) throws RemoteException, InitException
At construct a timer task reading in the status of all roofs is started and the roof receiver registers itself as a status handler.
InitExceptionRemoteExceptionpublic boolean isOpen()
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.isOpen in interface Shelteringpublic boolean isClosed()
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;isClosed in interface Shelteringpublic void registerGlobals(GlobalGrouping set)
registerGlobals in interface GlobalDependingpublic boolean registerDriver(Driver driver)
registerDriver in interface DriverDependingpublic ErrorEvent getLastError(CommandEvent dummy)
RoofOperating method.
If this methods return true, there may still be an error event here
which will then be a status event.getLastError in interface RoofOperatingpublic void clearLastError()
clearLastError in interface RoofOperatingpublic boolean open(boolean auto)
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.
open in interface Shelteringauto - True, if standard procedure (no emergency, like in automated
mode).preOpen()public boolean openLeft()
openLeft in interface RoofOperatingpublic boolean openRight()
openRight in interface RoofOperatingpublic boolean close(boolean auto)
KEY_CONCURRENTCLOSEDELAYclose in interface Shelteringauto - True, if standard procedure (no emergency, like in automated
mode).preClose()public boolean closeLeft()
closeLeft in interface RoofOperatingpublic boolean closeRight()
closeRight in interface RoofOperatingpublic Object extendedStatus()
extendedStatus in interface StatusProvidingpublic String conciseStatus()
conciseStatus in interface StatusProvidingpublic Date getLastOpenTime()
getLastOpenTime in interface Shelteringpublic Date getLastCloseTime()
getLastCloseTime in interface Shelteringpublic boolean resetLimit()
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.
resetLimit in interface RoofOperatingpublic boolean powerOn()
powerOn in interface RoofOperatingpublic boolean powerOff()
powerOff in interface RoofOperatingprivate boolean preOpen()
KEY_OPENPOWERALLOW property is
checked.
If true, power is switched on, if false, a power-off error is generated
and false is returned.KEY_OPENONFAIL property is checked. If true, both
limit switches are reset by a call to resetLimit(), otherwise
a limit-switch-failurte error is generated and false is
returned.private boolean preClose()
KEY_CLOSEPOWERALLOW property is
checked.
If true, power is switched on, if false, a power-off error is generated
and false is returned.KEY_CLOSEONFAIL property is checked. If true, both
limit switches are reset by a call to resetLimit(), otherwise
a limit-switch-failurte error is generated and false is
returned.private boolean doOpen(int roofnr)
direct - True if invoked directly, false if in
command-receive phase.private boolean doClose(int roofnr)
roofnr - The roof number to close.private boolean openBlink()
private boolean closeBlink()
private boolean openRoofLaunch(int roofnr)
private boolean openRoofMove(int roofnr)
private boolean shutRoofLaunch(int roofnr)
private boolean shutRoofMove(int roofnr)
private boolean defect(int roofnr)