www.rkjava.de

de.rkjava.serial.rk512
Class DefaultS5Model

java.lang.Object
  extended byde.rkjava.serial.util.DefaultS5Model
      extended byde.rkjava.serial.rk512.DefaultS5Model
All Implemented Interfaces:
de.rkjava.serial.util.S5Model, S5Model

public class DefaultS5Model
extends de.rkjava.serial.util.DefaultS5Model
implements S5Model

This class is a simple S5Model to handle S5-data

Author:
Gerd Limbeck, www.rkjava.de

Constructor Summary
DefaultS5Model(int cpuNo, int dbNo, int firstWordNo, int ammountWords)
          Creates an object, that represents S5-data
 
Method Summary
 void addS5DataListener(S5DataListener listener)
          Adds a S5DataListener.
 int getAmmountWords()
          Returns the ammount of the datawords
 boolean getBit(int wordNo, int bitNo)
          Returns the value of a Bit as boolean.
 int getCpuNo()
          Returns the Cpu-Number
 int getDbNo()
          Returns the Number of the datablock
 int getFirstWordNo()
          Returns the Number of the first dataword in the datablock
 short[] getWords()
          Returns the datawords
 void removeS5DataListener(S5DataListener listener)
          Removes a S5DataListener
 void setBit(int wordNo, int bitNo, boolean value)
          Sets the value of a bit
 void setNewStructure(int cpuNo, int dbNo, int firstWordNo, int ammountWords)
          Sets a new structure.
 void setNewStructure(int cpuNo, int dbNo, int firstWordNo, short[] data)
          Sets a new structure together with new datawords
Every registered S5DataListener will be informed via s5StructureChanged()
 void setWords(short[] data)
          Sets new datawords
Attention: It must be valid: data.length = getAmmountWords()
 
Methods inherited from class de.rkjava.serial.util.DefaultS5Model
addS5DataListener, removeS5DataListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.rkjava.serial.util.S5Model
addS5DataListener, removeS5DataListener
 

Constructor Detail

DefaultS5Model

public DefaultS5Model(int cpuNo,
                      int dbNo,
                      int firstWordNo,
                      int ammountWords)
Creates an object, that represents S5-data

Parameters:
cpuNo - Number of the CPU
dbNo - Number of the datablock
firstWordNo - Number of the first dataword
ammountWords - Ammount of the datawords
Method Detail

addS5DataListener

public void addS5DataListener(S5DataListener listener)
Description copied from interface: S5Model
Adds a S5DataListener. Every registered S5DataListener will be informed about all changes at the data of this Model.

Specified by:
addS5DataListener in interface S5Model
Parameters:
listener - a S5DataListener

removeS5DataListener

public void removeS5DataListener(S5DataListener listener)
Description copied from interface: S5Model
Removes a S5DataListener

Specified by:
removeS5DataListener in interface S5Model
Parameters:
listener - a S5DataListener

getCpuNo

public int getCpuNo()
Description copied from interface: S5Model
Returns the Cpu-Number

Specified by:
getCpuNo in interface S5Model

setNewStructure

public void setNewStructure(int cpuNo,
                            int dbNo,
                            int firstWordNo,
                            int ammountWords)
Sets a new structure.

Every registered S5DataListener will be informed via s5StructureChanged()

Parameters:
cpuNo - new CPU-Np
dbNo - new Number of the datablock
firstWordNo - new Number of the first dataword
ammountWords - new ammount of the datawords

setNewStructure

public void setNewStructure(int cpuNo,
                            int dbNo,
                            int firstWordNo,
                            short[] data)
Description copied from interface: S5Model
Sets a new structure together with new datawords
Every registered S5DataListener will be informed via s5StructureChanged()

Specified by:
setNewStructure in interface S5Model

getDbNo

public int getDbNo()
Description copied from interface: S5Model
Returns the Number of the datablock

Specified by:
getDbNo in interface S5Model

getFirstWordNo

public int getFirstWordNo()
Description copied from interface: S5Model
Returns the Number of the first dataword in the datablock

Specified by:
getFirstWordNo in interface S5Model

getAmmountWords

public int getAmmountWords()
Description copied from interface: S5Model
Returns the ammount of the datawords

Specified by:
getAmmountWords in interface S5Model

getWords

public short[] getWords()
Description copied from interface: S5Model
Returns the datawords

Specified by:
getWords in interface S5Model

setWords

public void setWords(short[] data)
Description copied from interface: S5Model
Sets new datawords
Attention: It must be valid: data.length = getAmmountWords()

Specified by:
setWords in interface S5Model

getBit

public boolean getBit(int wordNo,
                      int bitNo)
Returns the value of a Bit as boolean.

Parameters:
wordNo - Number of the dataword. It must be valid: firstWordNo<=wordNo<= (firstWordNo+ammountWords-1)
bitNo - Number of the bit within the dataword. It must be valid: 0<=bitNr<=15
Returns:
value of the bit

setBit

public void setBit(int wordNo,
                   int bitNo,
                   boolean value)
Sets the value of a bit

Parameters:
wordNo - Number of the dataword. It must be valid: firstWordNo<=wordNo<= (firstWordNo+ammountWords-1)
bitNo - Number of the bit within the dataword. It must be valid: 0<=bitNr<=15
value - the value for the bit

www.rkjava.de