public class WatchdogRS485Server extends CastingRS485Server
KEY_WATCHDOG
is matched to it's safety state pointed to by the KEY_SAFETY
key. The order of the addresses in KEY_WATCHDOG must match the
KEY_SAFETY order.
The watchdog is set once, during the CastingRS485Server.init() phase. The
KEY_HOSTOK command is sent via a fixed-delay timer task. The
time-out of the watchdog is given with the KEY_WATCHTIME key.
The frequency of the host-ok writes is stated as a multipl of the
watchdog time, regulated with the KEY_OKTIME key. Note that the
watchdog time is given in milliseconds, but the resolution as supported by
the NuDam modules restricts it to multiples of 100ms, at max 25.5 sec.
Since writing the host-ok to the serial line does not return any
answer from the modules, writing of the host-ok delays the execution for
a KEY_COOLDOWN-time. This should prevent too-early releases on the
serial-lock that may happen if a CastingRS485Server.writeCommand(java.lang.String) is concurrently
writing to the serial line.
RS485Server.Checksum, RS485Server.Command, RS485Server.Info, RS485Server.ScanAbstractSerialDriver.Available| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DEFCASTOK
The default casting behavior for host-ok.
|
private static long |
DEFCOOLDOWN
The default cool-down time.
|
private static String |
DEFHOSTOK
The default host-ok string.
|
private static int |
DEFINCREMENT
The default watchdog timeout.
|
private static double |
DEFOKTIME
The default multiplier to the watchdog time for host-ok sends.
|
private static boolean |
DEFRESETONCLOSE
The default watchdog reset on normal close.
|
private static int |
DEFWATCHTIME
The default watchdog timeout.
|
protected static Timer |
hosttimer
The timer associated with scheduling the host-ok sends.
|
private TimerTask |
isok
The timer task of sending host-ok.
|
static String |
KEY_CASTOK
The key whether to cast host-ok to the listeners.
|
static String |
KEY_COOLDOWN
The key to the cool-down time after a no-result write.
|
static String |
KEY_HOSTOK
The host-ok string.
|
static String |
KEY_INCREMENT
The key to the watchdog time-out increase per module, in ms.
|
static String |
KEY_OKTIME
A multiplier to the watchdog time-out for host-ok sends.
|
static String |
KEY_RESETONCLOSE
True if watchdog should be reset on normal close.
|
static String |
KEY_SAFETY
The modules safety values.
|
static String |
KEY_WATCHDOG
The key to the module address where watchdogs should be enabled.
|
static String |
KEY_WATCHTIME
The key to the watchdog time-out, in ms.
|
private boolean |
watchon
If true, watchdogs are running.
|
KEY_BINDKEY_CHECKCHAR, KEY_CHECKSUM, KEY_CLOSE, KEY_CR, KEY_ECHO, KEY_FAILTIME, KEY_FAILURES, KEY_INVALID, KEY_MAXBUFFER, KEY_MAXBUSY, KEY_QUERYTIME, KEY_REINIT, KEY_RESPONDTIME, KEY_STARTUP, KEY_TIMEBUSY, lockinport, KEY_BAUDRATE, KEY_CLOSETIMEOUT, KEY_DATABIT, KEY_FLOWCONTROL, KEY_INBUFFER, KEY_NOTIFYCOOLDOWN, KEY_OUTBUFFER, KEY_PARITYBIT, KEY_PORTNAME, KEY_RECEIVEFRAMING, KEY_RECEIVETHRESHOLD, KEY_RECEIVETIMEOUT, KEY_STOPBIT, KEY_TIMEOUT, LOCK, outport, STATICLOCKKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONCONFIG, KEY_CLASS| Constructor and Description |
|---|
WatchdogRS485Server(Map prop)
Constructs a new watchdog-enabled RS485-server.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
close()
Closes the serial server.
|
private static String |
hexTime(int timeout)
Convert a time in ms into the hex-string used for the watchdog timeout.
|
boolean |
resetWatchdog()
Resets the watchdog functionality of the modules.
|
boolean |
startWatchdog()
Stars the watch-dog functionality on modules listed in
KEY_WATCHDOG key. |
addRmiSerialListener, bindToRegistry, exit, init, isValid, notifyListeners, removeRmiSerialListener, unbindFromRegistry, writeCommand, writeCommand, writeStringdeferCommand, ensureCommand, getCheckSum, getCheckSumming, isReading, open, readString, setCheckSumming, toString, writeStringcreatePortEventListener, createPortEventListener, deregisterSoleEventListener, disableEvent, enableEvent, getDriverName, isOpen, registerSoleEventListener, resetOriginalParameterscreateDriver, equals, hashCodeaugment, augment, augment, augment, augment, clone, 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, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiespublic static final String KEY_WATCHDOG
public static final String KEY_SAFETY
public static final String KEY_WATCHTIME
public static final String KEY_INCREMENT
public static final String KEY_OKTIME
public static final String KEY_HOSTOK
public static final String KEY_RESETONCLOSE
public static final String KEY_COOLDOWN
public static final String KEY_CASTOK
private static final int DEFWATCHTIME
private static final int DEFINCREMENT
private static final double DEFOKTIME
private static final String DEFHOSTOK
private static final boolean DEFRESETONCLOSE
private static final long DEFCOOLDOWN
private static final boolean DEFCASTOK
protected static Timer hosttimer
private TimerTask isok
private boolean watchon
public WatchdogRS485Server(Map prop)
CastingRS485Server.init() method is called. Use of this constructer sets default
values for the KEY_WATCHTIME, KEY_OKTIME, and the
KEY_HOSTOK, if these keys are not present in the properties
handed over to this constructor.public boolean startWatchdog()
KEY_WATCHDOG key. If at least one module was found, a timer
is constructed and a timer-task sending host-ok is scheduled for
fixed-delay execution at a period defined with the
KEY_WATCHTIME and the KEY_OKTIME keys.public boolean resetWatchdog()
close()
if the KEY_RESETONCLOSE property is true.public boolean close()
throws IOException
KEY_RESETONCLOSE key points
to true, the watchdog functionality is reset on close.close in interface Driverclose in class AbstractSerialDriverIOExceptionprivate static final String hexTime(int timeout)