|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiCaster
stella.sensor.AbstractSensor
stella.sensor.TimerTaskSensor
stella.sensor.DataSensor
stella.sensor.CumulativeSensor
stella.sensor.PredictiveSensor
stella.sensor.SmoothingSensor
stella.sensor.DerivativeSensor
stella.sensor.WeatherSensor
stella.sensor.Ups
public abstract class Ups
A class to represent an ups. This requires the following things to be set up:
KEY_PORT, which should alwys be
DEFPORTKEY_UPSNAMEKEY_LOGIN
should point to true.KEY_USER and KEY_PASSWORD should be present
in the properties. Note that the password will be given in plain ASCII.KEY_REQUEST key. The answer retrieved is
passed to the abstract method processAnswer(java.lang.String) which should
return a double that equals the current sensor value. If the answer is
connected with a weather-event, the resolution must also be done within
this method.RmiErrorCaster functionality. These errors can be
trapped by an appropriate error handler.
KEY_LOGIN property is true.KEY_HOST is
established, using the port name specified with the KEY_PORT
key. This port should always be DEFPORT. The host key should
point to a valid host name.processAnswer(java.lang.String) method.cancel() method performs a logout from
the upsd if the KEY_LOGIN property is set and login was
completed successfully at the sensor's construction.processAnswer(java.lang.String) method. Any weather-event related issues must also
be solved within this method. This is particularily true for delayed
weather events. To not interfere with this weather-event generation, the
standard methods used by the weather sensor will always return true.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class stella.sensor.TimerTaskSensor |
|---|
TimerTaskSensor.SensorRead |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
private static String |
ANS_ERROR
The leading string for error-replies. |
private static String |
ANS_LOGIN
The correct answer for login processes. |
private static String |
ANS_REQUEST
The correct answer for request processes. |
private static String |
CMD_LOGIN
The login command. |
private static String |
CMD_LOGOUT
The logout command. |
private static String |
CMD_PASSWORD
The password command. |
private static String |
CMD_REQUEST
The request command. |
private static String |
CMD_USER
The username command. |
private static String |
DEFCR
The default end-of-line string. |
private static String |
DEFHOST
The default host name where the server is running. |
private static boolean |
DEFLOGIN
The default port number for the communication to the server. |
private static int |
DEFPORT
The default port number for the communication to the server. |
private BufferedReader |
in
The socket reader, a wrapped socket-input stream. |
private boolean |
islogin
True, if sensor logged in at upsd as a power-drawing unit. |
static String |
KEY_CR
The key pointing to the end-of-line string sent/received. |
static String |
KEY_HOST
The key to the host name of the ups-server. |
static String |
KEY_LOGIN
The key pointing to the end-of-line string sent/received. |
static String |
KEY_PASSWORD
The key pointing to the end-of-line string sent/received. |
static String |
KEY_PORT
The key to the communications port to the ups-server. |
static String |
KEY_REQUEST
The key pointing to the end-of-line string sent/received. |
static String |
KEY_UPSNAME
Key to the UPS-name. |
static String |
KEY_USER
The key pointing to the end-of-line string sent/received. |
private BufferedWriter |
out
The socket writer, a wrapped socket-output stream. |
private Socket |
upsd
The communication socket. |
| Fields inherited from class stella.sensor.DerivativeSensor |
|---|
DEFRAWDERIVATIVE, derive, KEY_DERIVATIVEADVISE, KEY_DERIVE, KEY_PATH, KEY_RAWDERIVATIVE, z |
| Fields inherited from class stella.sensor.SmoothingSensor |
|---|
f, g, KEY_SMOOTH, KEY_SMOOTHADVISE |
| Fields inherited from class stella.sensor.PredictiveSensor |
|---|
KEY_BASE, KEY_CHI, KEY_EXTRAPOLATE, KEY_FUTURE, KEY_PREDICTADVISE, predict |
| Fields inherited from class stella.sensor.CumulativeSensor |
|---|
KEY_AVERAGE, KEY_MEMORY, KEY_PACK |
| Fields inherited from class stella.sensor.DataSensor |
|---|
DEFRAWFORMAT, DEFREPORT, DEFSIGMAFORMAT, KEY_RAWFORMAT, KEY_REPORT, KEY_SIGMAFORMAT |
| Fields inherited from class stella.sensor.TimerTaskSensor |
|---|
KEY_RESPAWN |
| Fields inherited from class stella.sensor.AbstractSensor |
|---|
KEY_BIND, KEY_BINDNAME, KEY_CONVERT, KEY_DESCRIPTION, KEY_SENSORNAME |
| Fields inherited from class util.rmi.AbstractRmiCaster |
|---|
ALTERNATEHOST, ALTERNATEPORT, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT |
| 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 stella.rmi.RmiDataCaster |
|---|
NAMING_EXTENSION |
| Fields inherited from interface util.PropertySupplying |
|---|
CONFIG, KEY_CLASS |
| Fields inherited from interface util.ResourceSupplying |
|---|
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME |
| Constructor Summary | |
|---|---|
protected |
Ups(Map prop)
Constructs a new ups-sensor. |
| Method Summary | |
|---|---|
void |
cancel()
Cancels this sensor reading thread. |
private boolean |
closeSocket()
Closes a client-socket to the ups server. |
protected void |
errorReceived(String error)
Treats incoming error replies. |
TimerTask |
initSensorTimerTask()
Initializes the thread the ups-sensor should run in. |
private boolean |
openSocket()
Opens a client-socket to the ups-server. |
protected abstract double |
processAnswer(String answer)
Subclasses must provide a body for this method. |
protected double |
readSensor()
Reads the sensor. |
private String |
send(String command)
Writes to the socket writer. |
private String |
sendToSocket(String command)
Opens a socket to the ups-server, writes out a specified command, reads in the response and closes the socket before returning. |
| Methods inherited from class stella.sensor.WeatherSensor |
|---|
addWeatherListener, conductOneMeasure, currentlyClear, currentlyRetarding, generateDataEvent, getMinClearUpTime, getSensorInitInfo, goodFromDerivative, goodFromPredict, goodFromRaw, goodFromSmooth, isDerivativeRetard, isPredictRetard, isRawRetard, isSmoothRetard, judgeWeather, notifyWeatherListener, removeWeatherListener, status |
| Methods inherited from class stella.sensor.DerivativeSensor |
|---|
deriveAt, getDerivativeFormat, getDerivativeToggleInfo, getDerivator, getLastDerivative, isDerivativeAdvise, isDeriving, newData, regetDerive, registerDerivator |
| Methods inherited from class stella.sensor.SmoothingSensor |
|---|
getLastSmooth, getSmoother, getSmoothToggleInfo, isSmoothAdvise, isSmoothing, regetSmooth, registerSmoother, smoothOne |
| Methods inherited from class stella.sensor.PredictiveSensor |
|---|
getExtrapolation, getLastPredict, getPredictToggleInfo, isPredictAdvise, isPredicting, isReliable, predictFrom, regetPredict |
| Methods inherited from class stella.sensor.CumulativeSensor |
|---|
cumulateOne, getLastRaw, getLastTime, getMaxSize, getMemory, getSize |
| Methods inherited from class stella.sensor.DataSensor |
|---|
addDataListener, addRmiDataListener, exit, getRawFormat, getSigmaFormat, removeDataListener, removeRmiDataListener, report |
| Methods inherited from class stella.sensor.TimerTaskSensor |
|---|
equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, isReady, regetRaw, setTimeOfRead, validReading |
| Methods inherited from class stella.sensor.AbstractSensor |
|---|
addRmiErrorListener, createSensor, getBindName, getConvert, getSensorDescription, getSensorName, init, notifyErrorListener, removeRmiErrorListener, setConvert, toString |
| Methods inherited from class util.rmi.AbstractRmiCaster |
|---|
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, isValid, unbindFromRegistry, unbindFromRegistry |
| Methods inherited from class util.rmi.RmiPropertyContainer |
|---|
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty |
| 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, 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 |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface stella.sensor.Cumulating |
|---|
cumulateOne, getLastRaw, getLastTime, getMaxSize, getSize, getTimeOfRead, regetRaw |
| Methods inherited from interface util.rmi.RmiCaster |
|---|
bindToRegistry, isValid, unbindFromRegistry |
| Methods inherited from interface stella.sensor.Telemetering |
|---|
validReading |
| 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.ResourceSupplying |
|---|
getResource, getResourceAsStream, getResources |
| Field Detail |
|---|
public static final String KEY_UPSNAME
public static final String KEY_HOST
public static final String KEY_PORT
public static final String KEY_CR
public static final String KEY_LOGIN
public static final String KEY_USER
public static final String KEY_PASSWORD
public static final String KEY_REQUEST
private static final String DEFHOST
private static final int DEFPORT
private static final boolean DEFLOGIN
private static final String DEFCR
private static final String CMD_LOGIN
private static final String CMD_LOGOUT
private static final String CMD_USER
private static final String CMD_PASSWORD
private static final String CMD_REQUEST
private static final String ANS_LOGIN
private static final String ANS_REQUEST
private static final String ANS_ERROR
private boolean islogin
private Socket upsd
private BufferedReader in
private BufferedWriter out
| Constructor Detail |
|---|
protected Ups(Map prop)
throws RemoteException
IllegalArgumentException - If no KEY_REQUEST property
is given.
RemoteException| Method Detail |
|---|
public TimerTask initSensorTimerTask()
KEY_LOGIN property is true, this sensor logs in at the
upsd-server.
initSensorTimerTask in interface TelemeteringinitSensorTimerTask in class TimerTaskSensorTelemetering.getRespawn()public void cancel()
CMD_LOGIN command,
a logout is performed prior to stopping this thread.
cancel in interface Telemeteringcancel in class TimerTaskSensorprotected double readSensor()
KEY_REQUEST) to the upsd. The incomming reply is stripped
from the confirmation part and only the variable value is passed to
the processAnswer(java.lang.String) method.
readSensor in class TimerTaskSensorConvertToPhysicalprotected abstract double processAnswer(String answer)
WeatherJudging methods should be overridn.
private boolean openSocket()
private boolean closeSocket()
private String send(String command)
errorReceived(java.lang.String) method, after the leading
ANS_ERROR code has been stripped from the response.This method expects the streams to be open, no further checks are made.
private String sendToSocket(String command)
protected void errorReceived(String error)
error - The error message without the leading ANS_ERROR.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||