stella.jview
Class JRS485Simulator

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by io.AbstractDriver
                  extended by io.AbstractSerialDriver
                      extended by stella.io.RS485Server
                          extended by stella.io.CastingRS485Server
                              extended by stella.io.WatchdogRS485Server
                                  extended by stella.io.PollingRS485Server
                                      extended by stella.jview.JRS485Simulator
All Implemented Interfaces:
Driver, ActionListener, Cloneable, Remote, EventListener, Displayable, CacheChangedCaster, PollerQuery, RmiSerialCaster, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster

public class JRS485Simulator
extends PollingRS485Server
implements ActionListener, Displayable

A graphical simulator for RS485-attached devices. This class extends the PollingRS485Server class and is used to simulate the behaviour for classes that use an PollingRS485Serveras a driver. All cached channels are represented as textfields where the user can change its contents. The typical RS485 simulator should look like

JRS485Simulator

As soon as the user approves a change in one of the textfields the appropriate cache value is updated.
Note that in the simple version the writeCommand(java.lang.String, int, boolean) returns an arbitrary string.


Nested Class Summary
static class JRS485Simulator.Test
          Test purpose only.
 
Nested classes/interfaces inherited from class stella.io.PollingRS485Server
PollingRS485Server.CacheDump, PollingRS485Server.ConcurrentTest, PollingRS485Server.Interleave, PollingRS485Server.Poller
 
Nested classes/interfaces inherited from class stella.io.RS485Server
RS485Server.Checksum, RS485Server.Command, RS485Server.Info, RS485Server.Scan
 
Nested classes/interfaces inherited from class io.AbstractSerialDriver
AbstractSerialDriver.Available
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  JLabel[] cachekey
          The labels bound to the input text fields recorded for action events
static String KEY_DEF
          The prefix for default commando readings.
private  JStatusPanel status
          The status panel.
private  JTextField[] tf
          The input text fields recorded for action events
 
Fields inherited from class stella.io.PollingRS485Server
cache, cachelisten, KEY_ACTIVEDROP, KEY_ACTIVEREAD, KEY_CASTPOLL, KEY_PASSIVEDROP, KEY_PASSIVEREAD, KEY_POLLBASE, KEY_RESPONDMAX, KEY_STARTOPEN, timecurrent, timemax, timemin, validcache
 
Fields inherited from class stella.io.WatchdogRS485Server
hosttimer, KEY_CASTOK, KEY_COOLDOWN, KEY_HOSTOK, KEY_INCREMENT, KEY_OKTIME, KEY_RESETONCLOSE, KEY_SAFETY, KEY_WATCHDOG, KEY_WATCHTIME
 
Fields inherited from class stella.io.CastingRS485Server
KEY_BIND
 
Fields inherited from class stella.io.RS485Server
KEY_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, lock
 
Fields inherited from class io.AbstractSerialDriver
inport, 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, outport, staticlock
 
Fields inherited from class io.AbstractDriver
KEY_DRIVERNAME
 
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.RmiSerialCaster
NAMING_EXTENSION
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
JRS485Simulator(Map prop)
          Constructs a new rs485 simulator.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          The action-event receiving method.
 String blockChannel(String cmd)
          Evades block-reads detection of non-polling.
 Icon getIcon()
          Might return an icon, if one was stated in the properties
 Component getRepresentation()
          Returns a JPanel consiting of input fields for the cached rs485 channel values and a status panel at the bottom.
 boolean open()
          Initializes the driver.
 boolean open(String port, String name, int block)
          Overrides the open method.
 String writeCommand(String cmd, int count, boolean flag)
          Writes a command to the simulator.
 String writeString(String towrite)
          To override host-okay sends.
 
Methods inherited from class stella.io.PollingRS485Server
addCacheChangedListener, close, exit, getPollerCache, init, initCache, interleaveCommand, isActive, isPolling, readChannel, removeCacheChangedListener, setActive, setPassive, startPolling, stopPolling, toString, validChannel
 
Methods inherited from class stella.io.WatchdogRS485Server
resetWatchdog, startWatchdog
 
Methods inherited from class stella.io.CastingRS485Server
addRmiSerialListener, bindToRegistry, isValid, notifyListeners, removeRmiSerialListener, unbindFromRegistry, writeCommand, writeCommand, writeString
 
Methods inherited from class stella.io.RS485Server
deferCommand, ensureCommand, getCheckSum, getCheckSumming, isReading, readString, setCheckSumming
 
Methods inherited from class io.AbstractSerialDriver
createPortEventListener, createPortEventListener, deregisterSoleEventListener, disableEvent, enableEvent, getDriverName, isOpen, registerSoleEventListener, resetOriginalParameters
 
Methods inherited from class io.AbstractDriver
createDriver, equals, hashCode
 
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 util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
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
 

Field Detail

KEY_DEF

public static final String KEY_DEF
The prefix for default commando readings.

See Also:
Constant Field Values

tf

private JTextField[] tf
The input text fields recorded for action events


cachekey

private JLabel[] cachekey
The labels bound to the input text fields recorded for action events


status

private JStatusPanel status
The status panel.

Constructor Detail

JRS485Simulator

public JRS485Simulator(Map prop)
Constructs a new rs485 simulator. The actual gui is constructed when the serial port is opened.

Method Detail

open

public boolean open(String port,
                    String name,
                    int block)
Overrides the open method. This is a serial server simulator, so the actual opening of the port is skipped. The name of the serial port that should be opened, though, is echoed to the status panel.


open

public boolean open()
             throws IOException
Initializes the driver. For this simulator a GUI is constructed where all cachable values are exposed to the user and may be altered at any time. The default value for all cached values is determined from the #blocklength hashtable. A frame is displayed displaying the cache, the input text fields are action-wise registered to this simulator.

Specified by:
open in interface Driver
Overrides:
open in class PollingRS485Server
Returns:
True if initialization was successful.
Throws:
IOException

getIcon

public Icon getIcon()
Might return an icon, if one was stated in the properties

Specified by:
getIcon in interface Displayable

getRepresentation

public Component getRepresentation()
Returns a JPanel consiting of input fields for the cached rs485 channel values and a status panel at the bottom.

Specified by:
getRepresentation in interface Displayable

actionPerformed

public void actionPerformed(ActionEvent ae)
The action-event receiving method. It looks up the label of the associated JLabel and changes the content of the cache accordingly.

Specified by:
actionPerformed in interface ActionListener

blockChannel

public String blockChannel(String cmd)
Evades block-reads detection of non-polling. Returns the cache value instead.

Overrides:
blockChannel in class PollingRS485Server
Returns:
The valid channel reading.

writeCommand

public String writeCommand(String cmd,
                           int count,
                           boolean flag)
Writes a command to the simulator. It is passed to the status panel as a command.

Returns:
'!' If count equals zero otherwise '!' followed by '0'.

writeString

public String writeString(String towrite)
To override host-okay sends.

Overrides:
writeString in class RS485Server
Returns:
The entire string writtn to the port, including chksum and CR