|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--misim.PortMapper
The port mapper class provides a convenient way to map a set of port data to a set of inputs, with a simple mapping string. This allows the user of a plugin to wire the various inputs of a complex device into whichever port pins they wish.
Note that a PortMapper is expensive to create, and not especially fast. Plugin writers should only use it where complex wiring is required, and then re-use PortMappers where at all possible.
Constructor Summary | |
PortMapper(MachineState machineState,
java.lang.String mapping,
java.lang.String required)
Create a new PortMapper. |
Method Summary | |
int |
getBitmask(int portId)
Returnt the bitmask of the bits we're interested in for the given port |
int |
getPortBits(char aBit)
Return the bitmask for this port bit |
int |
getPortCount()
Return the number of ports that are mapped |
int |
getPortData(java.lang.String bits,
int data,
int portId)
Prepare data to write the following bits to a given port. |
Port |
getPortFor(char aBit)
Return the name of the port that maps this bit. |
int |
getPortMask(java.lang.String bits,
int portId)
Prepare a mask to write the following bits to a given port This returns a value with bits set to one where the mapped bits exist on this port. |
java.lang.String |
getPortName(int index)
Return the name of the given mapped port |
java.util.Vector |
getPortNames()
Return the names of all mapped ports. |
java.util.Vector |
getPortsFor(java.lang.String bits)
Return a vector of the ports that the following bits are mapped to |
void |
prepare(int portId,
int data)
Update the port mapper's view of the port, so that data can be read from it with the read or readBit methods. |
int |
read(java.lang.String bits)
Read the data from the port mapper for the given set of characters. |
boolean |
readBit(char bit)
Return the bit value for a single mapped character Note that characters that have no mapping defined are read as '0'. |
void |
writeToPort(Port aPort,
java.lang.String bits,
int data)
Write the given data to this port, mapping only the supplied bits. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PortMapper(MachineState machineState, java.lang.String mapping, java.lang.String required) throws MiSimException
The mapping parameter is a string of port mappings, each separated by a comma. A port mapping is a port name and a set of characters, separated by a colon. The set of characters correspond to bits on the port. The last character in the set corresponds to bit 0, the next to last corresponds to bit 1 and so on. A character 'x' is ignored.
For example: "Port A:DNxxx, Port B:3210"
This maps Bit 3 of Port A to the character 'N' and Bit 4 of Port A to the character 'D'. Bits 3-0 of Port B are mapped to the characters '3', '2','1' and '0' All other port bits are ignored.
machineState
- The machine who's ports we are to mapmapping
- The mapping String, as defined aboverequired
- A list of required mapping characters that must be definedMiSimException
- If the mapping is not well formed.Method Detail |
public int getPortCount()
public java.lang.String getPortName(int index)
index
- The index of the mapped portpublic java.util.Vector getPortNames()
public Port getPortFor(char aBit)
aBit
- A Mapped bitpublic java.util.Vector getPortsFor(java.lang.String bits)
bits
- The bits that are mappedpublic int getPortBits(char aBit)
aBit
- A Mapped bitpublic int getBitmask(int portId)
portId
- The port we're interested inpublic void writeToPort(Port aPort, java.lang.String bits, int data)
aPort
- The port to be written tobits
- The bits to be written, in order they appear in data (MSB first)data
- The data to be writtenpublic int getPortMask(java.lang.String bits, int portId)
bits
- The bits to be mapped.portId
- The port that a mask is to be prepared forpublic int getPortData(java.lang.String bits, int data, int portId)
bits
- The bits to be mapped, in order they appear in data (MSB first)data
- The data to be mappedportId
- The Id of the port that we shall be writing topublic void prepare(int portId, int data)
portId
- The Id of the port that is being writtendata
- The data on the portpublic int read(java.lang.String bits)
bits
- A string of mapped characterspublic boolean readBit(char bit)
bit
- The mapped character to read
|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |