hades.models.special
Class SerialTerminal

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.special.SerialTerminal
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable, Wakeable

public class SerialTerminal
extends SimObject
implements Simulatable, Wakeable

SerialTerminal - a text-terminal (VT-100 style) with two-wire RX/TX serial RS-232 I/O. Output and input go to a separate Swing JFrame window.

See Also:
Serialized Form

Nested Class Summary
 class SerialTerminal.JConfigDialog
           
 
Field Summary
protected  int baud_rate
           
protected  double bit_time
           
(package private)  javax.swing.JPanel buttonPanel
           
(package private)  javax.swing.JButton clearButton
           
(package private)  javax.swing.JButton closeButton
           
(package private)  javax.swing.JButton configButton
           
(package private)  SerialTerminal.JConfigDialog configDialog
           
protected  boolean enable_log
           
(package private)  javax.swing.JCheckBox enableLogCB
           
 int EVEN_PARITY
           
protected  double lastSendTime
           
protected  int n_databits
           
protected  int n_rx_bits
           
protected  int n_stopbits
           
 int NO_PARITY
           
 int ODD_PARITY
           
protected  int parity_mode
           
protected  PortStdLogic1164 port_RX
           
protected  PortStdLogic1164 port_TX
           
(package private)  javax.swing.JLabel receiveHexTF
           
(package private)  javax.swing.JLabel receiveTF
           
protected  boolean[] rx_samples
           
protected  int rx_state
           
protected  boolean rx_waiting
           
(package private)  java.awt.Image theIcon
           
(package private)  javax.swing.JFrame topFrame
           
(package private)  javax.swing.JLabel transmitHexTF
           
(package private)  javax.swing.JLabel transmitTF
           
protected  StdLogic1164 value_0
           
protected  StdLogic1164 value_1
           
protected  StdLogic1164 value_X
           
(package private)  VT52Canvas vt52Canvas
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
SerialTerminal()
          SerialTerminal(): simple constructor
 
Method Summary
(package private)  void buildButtonPanel()
           
(package private)  void buildGUI()
           
(package private)  void buildGUICallbacks()
           
 void changeName()
           
 void configure()
          create and display a 'ConfigDialog' to set the parameters for a SimObject.
 SimObject copy()
          copy(): create a clone of the current SerialTerminal, including its color
(package private)  void decode(boolean[] receivedBits)
           
 void elaborate(java.lang.Object arg)
          elaborate(): Set the TX line to '1' (idle)
 void evaluate(java.lang.Object arg)
          evaluate(): react to events on the RX input.
 java.lang.String getCommString()
           
 boolean[] getDataBits(char c, int n_databits)
           
 boolean getParityBit(boolean[] databits, boolean even_parity)
           
 java.awt.Component getPropertySheet()
          return a reference to the 'property sheet' or configuration window for this SimObject.
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (short) tool tip message for a SimObject.
 boolean initialize(java.lang.String s)
          initialize a SimObject from a String.
static void main(java.lang.String[] argv)
          main(): simple selftest of the SerialTerminal's GUI
 void mousePressed(java.awt.event.MouseEvent me)
          react to a MouseEvent.
(package private)  void scheduleInteractive(Signal signal, Port port, double time, StdLogic1164 value)
           
 void setCommunication(int baud_rate, int data_bits, int stop_bits, int parity_mode)
           
 void setName(java.lang.String name)
          set the name of this SimObject.
 void setSymbol(Symbol s)
           
(package private)  void startReceive()
           
 java.lang.String toString()
          toString() - the usual info method
 void transmitOneCharacter(char c)
          transmitOneCharacter generates all simulation events to propagate the RS232 bit pattern corresponding to char 'c' on the signal connected to port_TX (if any).
 void wakeup(java.lang.Object arg)
          called as a reaction to our wakeup-events once a start bit has been detected.
 void write(java.io.PrintWriter ps)
           
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setParent, setPorts, setSimulator, setVersionId, setVisible, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hades.simulator.Simulatable
message
 

Field Detail

port_RX

protected PortStdLogic1164 port_RX

port_TX

protected PortStdLogic1164 port_TX

value_0

protected StdLogic1164 value_0

value_1

protected StdLogic1164 value_1

value_X

protected StdLogic1164 value_X

NO_PARITY

public final int NO_PARITY
See Also:
Constant Field Values

ODD_PARITY

public final int ODD_PARITY
See Also:
Constant Field Values

EVEN_PARITY

public final int EVEN_PARITY
See Also:
Constant Field Values

baud_rate

protected int baud_rate

n_databits

protected int n_databits

n_stopbits

protected int n_stopbits

parity_mode

protected int parity_mode

bit_time

protected double bit_time

n_rx_bits

protected int n_rx_bits

rx_state

protected int rx_state

rx_waiting

protected boolean rx_waiting

rx_samples

protected boolean[] rx_samples

lastSendTime

protected double lastSendTime

enable_log

protected boolean enable_log

topFrame

javax.swing.JFrame topFrame

buttonPanel

javax.swing.JPanel buttonPanel

clearButton

javax.swing.JButton clearButton

closeButton

javax.swing.JButton closeButton

configButton

javax.swing.JButton configButton

vt52Canvas

VT52Canvas vt52Canvas

receiveTF

javax.swing.JLabel receiveTF

receiveHexTF

javax.swing.JLabel receiveHexTF

transmitTF

javax.swing.JLabel transmitTF

transmitHexTF

javax.swing.JLabel transmitHexTF

enableLogCB

javax.swing.JCheckBox enableLogCB

configDialog

SerialTerminal.JConfigDialog configDialog

theIcon

java.awt.Image theIcon
Constructor Detail

SerialTerminal

public SerialTerminal()
SerialTerminal(): simple constructor

Method Detail

setSymbol

public void setSymbol(Symbol s)
Overrides:
setSymbol in class SimObject

setName

public void setName(java.lang.String name)
Description copied from class: SimObject
set the name of this SimObject. If there is a Symbol for this SimObject, we also try to set the InstanceLabel in the Symbol.

To avoid consistency problems, when the user changes a SimObject's name interactively, we also try to enforce a unique name.

Overrides:
setName in class SimObject

buildButtonPanel

void buildButtonPanel()

buildGUI

void buildGUI()

buildGUICallbacks

void buildGUICallbacks()

setCommunication

public void setCommunication(int baud_rate,
                             int data_bits,
                             int stop_bits,
                             int parity_mode)

changeName

public void changeName()

write

public void write(java.io.PrintWriter ps)
Overrides:
write in class SimObject

initialize

public boolean initialize(java.lang.String s)
Description copied from class: SimObject
initialize a SimObject from a String. The method returns true once all required data has been read. Until then, you should repeatedly call initialize() with additional Strings.

Overrides:
initialize in class SimObject

getPropertySheet

public java.awt.Component getPropertySheet()
Description copied from class: SimObject
return a reference to the 'property sheet' or configuration window for this SimObject. We cast the return value to an AWT Component, but typically you can expect either a hades.gui.PropertySheet or an java.awt.Window (Dialog or Frame).

Overrides:
getPropertySheet in class SimObject

configure

public void configure()
Description copied from class: SimObject
create and display a 'ConfigDialog' to set the parameters for a SimObject. The default ConfigDialog for the base class (SimObject) itself is empty except for the 'instance name' of the SimObject.

Overrides:
configure in class SimObject

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Description copied from class: SimObject
react to a MouseEvent. The base SimObject ignores MouseEvents.

Note that the HADES schematic editor will also deliver jfig.canvas.FigCanvasEvent object, which also include the world-coordinates of the Event.

Overrides:
mousePressed in class SimObject

elaborate

public void elaborate(java.lang.Object arg)
elaborate(): Set the TX line to '1' (idle)

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject
Parameters:
arg - This parameter is ignored by SerialTerminal

evaluate

public void evaluate(java.lang.Object arg)
evaluate(): react to events on the RX input. The RS-232 receiver uses a simple state-machine to decode a RS-232 transmitted character. It remains in state "rx_waiting" until a first event on the RX line occurs at time t. The receiver will then sample the RX input at times "t + 1/2 bit_time", "t + 3/2 bit_time" ... "t + 2n+1/2 bit_time" for the start, data, parity, and stop bits.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - An arbitrary and unused object

wakeup

public void wakeup(java.lang.Object arg)
called as a reaction to our wakeup-events once a start bit has been detected.

Specified by:
wakeup in interface Wakeable
Parameters:
arg - An arbitrary and unused object

startReceive

void startReceive()

decode

void decode(boolean[] receivedBits)

transmitOneCharacter

public void transmitOneCharacter(char c)
transmitOneCharacter generates all simulation events to propagate the RS232 bit pattern corresponding to char 'c' on the signal connected to port_TX (if any).

Because this method is called in reaction to an (asynchronous) user input event, we have to use the scheduleInteractiveEvent() calls to keep the simulator data structures consistent.


scheduleInteractive

void scheduleInteractive(Signal signal,
                         Port port,
                         double time,
                         StdLogic1164 value)

getDataBits

public boolean[] getDataBits(char c,
                             int n_databits)

getParityBit

public boolean getParityBit(boolean[] databits,
                            boolean even_parity)

copy

public SimObject copy()
copy(): create a clone of the current SerialTerminal, including its color

Overrides:
copy in class SimObject

getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
Description copied from class: SimObject
construct a (short) tool tip message for a SimObject. This method should be overridden as needed.

Specified by:
getToolTip in interface ContextToolTip
Overrides:
getToolTip in class SimObject

getCommString

public java.lang.String getCommString()

toString

public java.lang.String toString()
toString() - the usual info method

Overrides:
toString in class SimObject

main

public static void main(java.lang.String[] argv)
main(): simple selftest of the SerialTerminal's GUI