hades.models.io
Class RemoteIpin

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

public class RemoteIpin
extends SimObject

RemoteIpin - read N bits of data from a remote server and generate the corresponding output events on output ports YN-1..Y0. This class waits for a rising edge (0-1 transition) on the "sample" input port to contact the remote server specified by the "urlBase" and "userID" values. It then reads the remote server simulation time and 24 (N_OUTPUTS) StdLogic1164 data values in ASCII representation and converts this information into events on the YN..Y0 ouptut ports.

If the remote server cannot be reached or its response is invalid, the "error" output signal is asserted.

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

See Also:
Serialized Form

Field Summary
protected  PortStdLogic1164 port_error
           
protected  PortStdLogic1164 port_sample
           
(package private)  java.lang.String urlBase
           
(package private)  java.lang.String userID
           
protected  PortStdLogic1164[] yports
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
RemoteIpin()
          RemoteIpin():
 
Method Summary
 void configure()
          configure:
 SimObject copy()
          create a copy of this RemoteIpin 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 constructs the URL used to contact the server
 void evaluate(java.lang.Object arg)
          evaluate: called from the simulation kernel when the sample input changes.
 int getNumberOfOutputs()
           
 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 parseURLData()
          parse the data returned by the URL connection.
 void readFromRemoteServer()
           
 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 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
 

Field Detail

urlBase

java.lang.String urlBase

userID

java.lang.String userID

yports

protected PortStdLogic1164[] yports

port_sample

protected PortStdLogic1164 port_sample

port_error

protected PortStdLogic1164 port_error
Constructor Detail

RemoteIpin

public RemoteIpin()
RemoteIpin():

Method Detail

getNumberOfOutputs

public int getNumberOfOutputs()

createPorts

public void createPorts()

encodeURL

public java.lang.String encodeURL()
this method constructs the URL used to contact the server

Currently, the output format is as follows: "urlBase" + "?" + "userID" + ":" + "simTime" where userID : a String (which should not contain ':') simTime : simulation time encoded as hex-formatted double value


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


parseURLData

public void parseURLData()
parse the data returned by the URL connection.


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 class: SimObject
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 when the sample input changes. On a rising edge (0-1 transition) of the "sample" input, we contact the remote server and try to decode and convert its response into the corresponding events on the YN..Y0 output ports.

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

readFromRemoteServer

public void readFromRemoteServer()

copy

public SimObject copy()
create a copy of this RemoteIpin 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