com.shabarshin.jemul
Class jeComponent

java.lang.Object
  |
  +--com.shabarshin.jemul.jeComponent
Direct Known Subclasses:
jeGate

public abstract class jeComponent
extends java.lang.Object

Class of abstract component for jEmul (universal emulator of discrete schemes in Java).


Field Summary
protected  boolean flag_pullup
          Flag that indicates pull up feature switched on.
protected  java.lang.String name
          Name of the component.
protected  char[] pin
          Array that defines types of pins.
static char PIN_GND
          The constant indicates ground type of the pin and equals 'G' character.
static char PIN_INPUT
          The constant indicates input type of the pin and equals 'I' character.
static char PIN_NC
          The constant indicates not-connected type of the pin and equals 'N' character.
static char PIN_OPEN
          The constant indicates open-drain (or open-collector) type of the pin and equals 'D' character.
static char PIN_OUTPUT
          The constant indicates output type of the pin and equals 'O' character.
static char PIN_UNKNOWN
          The constant indicates unknown type of the pin and equals 'U' character.
static char PIN_VCC
          The constant indicates power supply type of the pin and equals 'V' character.
protected  char[] val
          Array that defines values of pins.
static char VAL_FALSE
          The constant indicates low-level value of the pin and equals 'F' character.
static char VAL_TRUE
          The constant indicates high-level value of the pin and equals 'T' character.
static char VAL_UNKNOWN
          The constant indicates unknown value of the pin and equals 'U' character.
static char VAL_ZSTATE
          The constant indicates Z-state value of the pin and equals 'Z' character.
 
Constructor Summary
jeComponent(java.lang.String nam, int number)
          Constructor of the abstract component.
 
Method Summary
 void error(java.lang.String s)
          Print error message to console.
 boolean getBool(int n)
          Get pin boolean value.
 int getInputs()
          Get number of inputs.
 char getLogic(int n)
          Get pin logic value.
 java.lang.String getName()
          Get name of the component.
 int getOutputs()
          Get number of outputs.
 char getPin(int n)
          Get pin type.
 int getPins()
          Get number of pins.
 char getVal(int n)
          Get pin value.
 boolean isInput(int n)
          Test pin for input by number.
 boolean isOutput(int n)
          Test pin for output by number.
 void pullUp(boolean p)
          Switch on or switch off flag of pull-up feature.
 void setBool(int n, boolean v)
          Set pin boolean value.
 void setLogic(int n, char v)
          Set pin logic value.
 void setPin(int n, char t)
          Set pin type.
 void setVal(int n, char v)
          Set pin value.
abstract  int step()
          Do step of emulation.
 java.lang.String toString()
          Convert object to string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Name of the component.


flag_pullup

protected boolean flag_pullup
Flag that indicates pull up feature switched on. Deafault value is true so all unconnected inputs will be "1"


pin

protected char[] pin
Array that defines types of pins. pin[0] is number of pins, so array has length pin[0]+1 and usually pin[0] must be equal val[0]

See Also:
PIN_UNKNOWN, PIN_INPUT, PIN_OUTPUT, PIN_OPEN, PIN_VCC, PIN_GND, PIN_NC

PIN_UNKNOWN

public static final char PIN_UNKNOWN
The constant indicates unknown type of the pin and equals 'U' character.

See Also:
Constant Field Values

PIN_INPUT

public static final char PIN_INPUT
The constant indicates input type of the pin and equals 'I' character.

See Also:
Constant Field Values

PIN_OUTPUT

public static final char PIN_OUTPUT
The constant indicates output type of the pin and equals 'O' character.

See Also:
Constant Field Values

PIN_OPEN

public static final char PIN_OPEN
The constant indicates open-drain (or open-collector) type of the pin and equals 'D' character.

See Also:
Constant Field Values

PIN_VCC

public static final char PIN_VCC
The constant indicates power supply type of the pin and equals 'V' character.

See Also:
Constant Field Values

PIN_GND

public static final char PIN_GND
The constant indicates ground type of the pin and equals 'G' character.

See Also:
Constant Field Values

PIN_NC

public static final char PIN_NC
The constant indicates not-connected type of the pin and equals 'N' character.

See Also:
Constant Field Values

val

protected char[] val
Array that defines values of pins. val[0] is number of values, so array has length val[0]+1 and usually val[0] must be equal pin[0]

See Also:
VAL_UNKNOWN, VAL_TRUE, VAL_FALSE, VAL_ZSTATE

VAL_UNKNOWN

public static final char VAL_UNKNOWN
The constant indicates unknown value of the pin and equals 'U' character.

See Also:
Constant Field Values

VAL_TRUE

public static final char VAL_TRUE
The constant indicates high-level value of the pin and equals 'T' character.

See Also:
Constant Field Values

VAL_FALSE

public static final char VAL_FALSE
The constant indicates low-level value of the pin and equals 'F' character.

See Also:
Constant Field Values

VAL_ZSTATE

public static final char VAL_ZSTATE
The constant indicates Z-state value of the pin and equals 'Z' character.

See Also:
Constant Field Values
Constructor Detail

jeComponent

public jeComponent(java.lang.String nam,
                   int number)
Constructor of the abstract component.

Parameters:
nam - a name of the component.
number - a quantity of all pins of the component.
Method Detail

error

public void error(java.lang.String s)
Print error message to console.

Parameters:
s - a message for printing.

pullUp

public void pullUp(boolean p)
Switch on or switch off flag of pull-up feature.

Parameters:
p - true or false value.
See Also:
flag_pullup

getName

public java.lang.String getName()
Get name of the component.

Returns:
String with name.
See Also:
name

getPins

public int getPins()
Get number of pins.

Returns:
number of pins.
See Also:
pin

setPin

public void setPin(int n,
                   char t)
Set pin type.

Parameters:
n - pin number (starts from 1)
t - pin type char
See Also:
pin, PIN_UNKNOWN, PIN_INPUT, PIN_OUTPUT, PIN_OPEN, PIN_VCC, PIN_GND, PIN_NC

getPin

public char getPin(int n)
Get pin type.

Parameters:
n - pin number (starts from 1)
Returns:
pin type char
See Also:
pin, PIN_UNKNOWN, PIN_INPUT, PIN_OUTPUT, PIN_OPEN, PIN_VCC, PIN_GND, PIN_NC

setVal

public void setVal(int n,
                   char v)
Set pin value.

Parameters:
n - pin number (starts from 1)
v - pin value char
See Also:
val, VAL_UNKNOWN, VAL_TRUE, VAL_FALSE, VAL_ZSTATE

setLogic

public void setLogic(int n,
                     char v)
Set pin logic value. Pullup feature is used (if set).

Parameters:
n - pin number (starts from 1)
v - pin logic value char
See Also:
val, VAL_UNKNOWN, VAL_TRUE, VAL_FALSE, VAL_ZSTATE

setBool

public void setBool(int n,
                    boolean v)
Set pin boolean value.

Parameters:
n - pin number (starts from 1)
v - pin boolean value
See Also:
val

getVal

public char getVal(int n)
Get pin value.

Parameters:
n - pin number (starts from 1)
Returns:
pin value char
See Also:
val, VAL_UNKNOWN, VAL_TRUE, VAL_FALSE, VAL_ZSTATE

getLogic

public char getLogic(int n)
Get pin logic value. Pullup feature is used (if set).

Parameters:
n - pin number (starts from 1)
Returns:
pin logic value char
See Also:
val, VAL_TRUE, VAL_FALSE

getBool

public boolean getBool(int n)
Get pin boolean value.

Parameters:
n - pin number (starts from 1)
Returns:
pin boolean value
See Also:
val

getInputs

public int getInputs()
Get number of inputs.

Returns:
number of input pins
See Also:
pin

getOutputs

public int getOutputs()
Get number of outputs.

Returns:
number of output pins
See Also:
pin

isInput

public boolean isInput(int n)
Test pin for input by number.

Parameters:
n - pin number (starts from 1)
Returns:
true if pin is input
See Also:
pin

isOutput

public boolean isOutput(int n)
Test pin for output by number.

Parameters:
n - pin number (starts from 1)
Returns:
true if pin is output or open-drain (open-collector)
See Also:
pin

toString

public java.lang.String toString()
Convert object to string.

Overrides:
toString in class java.lang.Object
Returns:
String with object description

step

public abstract int step()
Do step of emulation.

Returns:
0 if Ok or Error code