hades.models.io
Class RemoteOpin

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.io.RemoteOpin
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable, Wakeable
Direct Known Subclasses:
RemoteOpin8

public class RemoteOpin
extends SimObject
implements Wakeable

RemoteOpin - transfer input events to a remote server using a simple URL protocol encoding and generate a trigger pulse. This simulation model waits for input events on its N data inputs, encodes the input values into a simple text-only URL representation, and contacts the server specified by "urlBase". In combination with a corresponding server (cgi-script or servlet), this allows to access remote simulation models from a standard Hades simulation setup.

To improve efficiency and to reduce network load, multiple events occuring at the same time are encoded as a single output value change. Internally, this is realized using a Wakeup-Event.

Also, a short 1nsec. pulse is generated on the "trigger" output pin for each network transaction. One use of this trigger pulse is to activate a RemoteIpin component to sample the remote circuit's response.

See the code and class documentation for the encodeURL() method for the protocol details.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable _wakeupTable
           
protected  double DELTA
           
protected  PortStdLogic1164[] dports
           
protected  PortStdLogic1164 port_error
           
protected  PortStdLogic1164 port_trigger
           
(package private)  java.lang.String urlBase
           
(package private)  java.lang.String userID
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
RemoteOpin()
          RemoteOpin():
 
Method Summary
 void configure()
          configure:
 SimObject copy()
          create a copy of this RemoteOpin with the same urlBase and userID
 void createPorts()
           
 void elaborate(java.lang.Object arg)
          elaborate(): This method is called by the simulation engine to initialize the simulation object.
 java.lang.String encodeTime(double time)
          convert a simulation time into ASCII: the bit-pattern into a hex string
 java.lang.String encodeURL()
          this method collects the current simulation data and constructs the output URL.
 void evaluate(java.lang.Object arg)
          evaluate: called from the simulation kernel for external input events on the D15..D0 input ports.
 int getNumberOfInputs()
           
 double getSimTimeOr0()
          return the current simulation time or 0.0D if no simulator
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (short) tool tip message for a SimObject.
 java.lang.String getUrlBase()
           
 java.lang.String getUserID()
           
 boolean initialize(java.lang.String s)
          initialize from a String that contains the following data: "versionID urlBase userID", e.g.
 void setUrlBase(java.lang.String s)
           
 void setUserID(java.lang.String s)
           
 java.lang.String toString()
          toString: generate a text description for this SimObject.
 void wakeup(java.lang.Object arg)
          wakeup(): This method is called by the simulation engine to wakeup the simulation object.
 void write(java.io.PrintWriter ps)
          write "versionId urlBase userID" using NameMangler
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getPropertySheet, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, mousePressed, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setSymbol, 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

urlBase

java.lang.String urlBase

userID

java.lang.String userID

dports

protected PortStdLogic1164[] dports

port_trigger

protected PortStdLogic1164 port_trigger

port_error

protected PortStdLogic1164 port_error

DELTA

protected final double DELTA
See Also:
Constant Field Values

_wakeupTable

protected java.util.Hashtable _wakeupTable
Constructor Detail

RemoteOpin

public RemoteOpin()
RemoteOpin():

Method Detail

getNumberOfInputs

public int getNumberOfInputs()

createPorts

public void createPorts()

encodeURL

public java.lang.String encodeURL()
this method collects the current simulation data and constructs the output URL.

Currently, the output format is as follows: "urlBase" + "?" + "userID" + ":" + "simTime" + ":" + "D15"+"D14"+...+"D0" where userID : a String (which should not contain ':') simTime : simulation time encoded as hex-formatted double value D[i] : a 1-bit StdLogic1164 value, 'U', 'X', '0', ... 'D'

With small changes, the encoding could also be used for raw IP or TCP transfers instead of http/URL based transactions.


encodeTime

public java.lang.String encodeTime(double time)
convert a simulation time into ASCII: the bit-pattern into a hex string


getSimTimeOr0

public double getSimTimeOr0()
return the current simulation time or 0.0D if no simulator


getUrlBase

public java.lang.String getUrlBase()

setUrlBase

public void setUrlBase(java.lang.String s)

getUserID

public java.lang.String getUserID()

setUserID

public void setUserID(java.lang.String s)

elaborate

public void elaborate(java.lang.Object arg)
Description copied from interface: Simulatable
elaborate(): This method is called by the simulation engine to initialize the simulation object.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject

evaluate

public void evaluate(java.lang.Object arg)
evaluate: called from the simulation kernel for external input events on the D15..D0 input ports. In order to reduce network traffic when multiple inputs change at the same time, this method doesn't directly contact the remote server. Instead, we retrieve the current simulation time and check whether this is the first input change at the simulation time. If so, we generate a wakeup event a (simTime+delta) and return. If not, we do nothing, because the previous wakeup event will already handle things.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - an arbitrary object argument

wakeup

public void wakeup(java.lang.Object arg)
Description copied from interface: Wakeable
wakeup(): This method is called by the simulation engine to wakeup the simulation object.

Specified by:
wakeup in interface Wakeable

copy

public SimObject copy()
create a copy of this RemoteOpin with the same urlBase and userID

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

toString

public java.lang.String toString()
Description copied from class: SimObject
toString: generate a text description for this SimObject. This method currently combines the class name for the SimObject (or subclass) and its full name in the current Hades Design, e.g. "hades.models.gates.And2: /uut/adder16/adder1/i3".

Overrides:
toString in class SimObject

write

public void write(java.io.PrintWriter ps)
write "versionId urlBase userID" using NameMangler

Overrides:
write in class SimObject

initialize

public boolean initialize(java.lang.String s)
initialize from a String that contains the following data: "versionID urlBase userID", e.g. "1001 http://www.dummy.org/cgi-bin/adder bill.g"

Overrides:
initialize in class SimObject

configure

public void configure()
configure:

Overrides:
configure in class SimObject