stella.jview
Class JRS485Simulator
java.lang.Object
util.PropertyContainer
util.PropertyResources
util.PropertyBundles
io.AbstractDriver
io.AbstractSerialDriver
stella.io.RS485Server
stella.io.CastingRS485Server
stella.io.WatchdogRS485Server
stella.io.PollingRS485Server
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

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.
|
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.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 |
| 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 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 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 |
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.
JRS485Simulator
public JRS485Simulator(Map prop)
- Constructs a new rs485 simulator. The actual gui is constructed when
the serial port is opened.
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