stella.parameter
Class SwitchStub

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.ParameterStub
                      extended by stella.parameter.TriggerStub
                          extended by stella.parameter.SwitchStub
All Implemented Interfaces:
Cloneable, Runnable, Remote, Parameter, Switch, Trigger, CancelRunnable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying, RmiListener

public class SwitchStub
extends TriggerStub
implements Switch

The stub representation for a remote switch. The remote value bound to is normally a RS485Switch or a OneWireSwitch. This class provides local access to the turning the switch. This classes should always set the blocking property to true, as we first try to get the switch's state before we turn.


Nested Class Summary
 
Nested classes/interfaces inherited from class stella.parameter.ParameterStub
ParameterStub.Finger
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
 
Fields inherited from class stella.parameter.TriggerStub
KEY_UNCONNECTED
 
Fields inherited from class stella.parameter.ParameterStub
KEY_BLOCK, KEY_FORMATCLASS, KEY_FORMATPATTERN, KEY_INITTRY, KEY_REMOTENAME, KEY_RETRY, KEY_SERVERDELAY, KEY_WAIT, sensor
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
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.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
SwitchStub(Map prop)
          Constructs a new switch stub.
SwitchStub(String remotename)
          For convenience, we support a constructor with only the remote name.
 
Method Summary
 boolean turnOff()
          If the remote parameter we are registered to is a RemoteSwitch, we try to turn it.
 boolean turnOn(long timeout)
          If the remote parameter we are registered to is a RemoteSwitch, we try to turn it.
 
Methods inherited from class stella.parameter.TriggerStub
get, getElapsedToggleTime, getLastToggleTime, getTrigger, isTrue, setTrigger, toggleTrigger
 
Methods inherited from class stella.parameter.ParameterStub
cancel, disconnect, exit, getAsociatedThread, getFormatted, init, isConnected, maxTimeToCancel, rebind, rescanned, run, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, getFormatted, getName, getPreserveFile, getString, getString, register, setName, toString
 
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, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Trigger
getElapsedToggleTime, getLastToggleTime, getTrigger, isTrue, setTrigger, toggleTrigger
 
Methods inherited from interface stella.Parameter
get, getFormatted, getName, getString, set
 
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
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Constructor Detail

SwitchStub

public SwitchStub(String remotename)
           throws RemoteException
For convenience, we support a constructor with only the remote name.

Throws:
RemoteException

SwitchStub

public SwitchStub(Map prop)
           throws RemoteException
Constructs a new switch stub. This parameter connects to a remote switch.

Throws:
RemoteException
Method Detail

turnOn

public boolean turnOn(long timeout)
If the remote parameter we are registered to is a RemoteSwitch, we try to turn it. To ensure a proper handle to the remote parameter, we first try to get the value, which ensures proper binding if the ParameterStub.KEY_BLOCK property is true.

Specified by:
turnOn in interface Switch
Parameters:
timeout - The maximum time the switch should be on (ms), zero for unlimited.
Returns:
True, if switch was successfully turned on.

turnOff

public boolean turnOff()
If the remote parameter we are registered to is a RemoteSwitch, we try to turn it. To ensure a proper handle to the remote parameter, we first try to get the value, which ensures proper binding if the ParameterStub.KEY_BLOCK property is true.

Specified by:
turnOff in interface Switch
Returns:
True, if switch was successfully turned off.