www.rkjava.de

de.rkjava.serial.rk512
Class DefaultS7Model

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

public class DefaultS7Model
extends de.rkjava.serial.util.DefaultS7Model
implements S7Model

This class is a simple S7Model to handle S7-data

Author:
Gerd Limbeck, www.rkjava.de

Constructor Summary
DefaultS7Model(int cpuNo, int dbNo, int firstByteNo, int ammountBytes)
          Creates an object, that represents S7-data
 
Method Summary
 void addS7DataListener(S7DataListener l)
          Adds a S7DataListener
 int getAmmountBytes()
          Returns the ammount of the databytes
 boolean getBit(int byteNo, int bitNo)
          Returns the value of a Bit as boolean.
 byte[] getBytes()
          Returns the databytes
 int getCpuNo()
          Returns the Cpu-No
 int getDbNo()
          Returns the Number of the datablock
 int getFirstByteNo()
          Returns the Number of the first databyte in the datablock
 void removeS7DataListener(S7DataListener l)
          Removes a S7DataListener
 void setBit(int byteNo, int bitNo, boolean value)
          Sets the value of a bit
 void setBytes(byte[] data)
          Sets new databytes
Attention: It must be valid: data.length = getAmmountbytes()
 void setNewStructure(int cpuNo, int dbNo, int firstByteNo, int ammountBytes)
          Sets a new structure.
 void setNewStructure(int cpuNo, int dbNo, int firstByteNo, int ammountBytes, byte[] data)
          Sets a new structure together with new databytes.
 
Methods inherited from class de.rkjava.serial.util.DefaultS7Model
addS7DataListener, removeS7DataListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.rkjava.serial.util.S7Model
addS7DataListener, removeS7DataListener
 

Constructor Detail

DefaultS7Model

public DefaultS7Model(int cpuNo,
                      int dbNo,
                      int firstByteNo,
                      int ammountBytes)
Creates an object, that represents S7-data

Parameters:
cpuNo - Number of the CPU
dbNo - Number of the datablock
firstByteNo - Number of the first databyte
ammountBytes - Ammount of the databytes
Method Detail

addS7DataListener

public void addS7DataListener(S7DataListener l)
Description copied from interface: S7Model
Adds a S7DataListener

Specified by:
addS7DataListener in interface S7Model
Parameters:
l - a S7DataListener

removeS7DataListener

public void removeS7DataListener(S7DataListener l)
Description copied from interface: S7Model
Removes a S7DataListener

Specified by:
removeS7DataListener in interface S7Model
Parameters:
l - a S7DataListener

getCpuNo

public int getCpuNo()
Description copied from interface: S7Model
Returns the Cpu-No

Specified by:
getCpuNo in interface S7Model

setNewStructure

public void setNewStructure(int cpuNo,
                            int dbNo,
                            int firstByteNo,
                            int ammountBytes)
Sets a new structure. Every registered S7DataListener will be informed via s7StructureChanged()

Parameters:
cpuNo - new CPU-No
dbNo - new Number of the datablock
firstByteNo - new Number of the first databyte
ammountBytes - new ammount of the databytes
See Also:
S7DataListener.s7StructureChanged(EventObject)

setNewStructure

public void setNewStructure(int cpuNo,
                            int dbNo,
                            int firstByteNo,
                            int ammountBytes,
                            byte[] data)
Description copied from interface: S7Model
Sets a new structure together with new databytes.
Every registered S7DataListener will be informed via s7StructureChanged()

Specified by:
setNewStructure in interface S7Model

getDbNo

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

Specified by:
getDbNo in interface S7Model

getFirstByteNo

public int getFirstByteNo()
Description copied from interface: S7Model
Returns the Number of the first databyte in the datablock

Specified by:
getFirstByteNo in interface S7Model

getAmmountBytes

public int getAmmountBytes()
Description copied from interface: S7Model
Returns the ammount of the databytes

Specified by:
getAmmountBytes in interface S7Model

getBytes

public byte[] getBytes()
Description copied from interface: S7Model
Returns the databytes

Specified by:
getBytes in interface S7Model

setBytes

public void setBytes(byte[] data)
Description copied from interface: S7Model
Sets new databytes
Attention: It must be valid: data.length = getAmmountbytes()

Specified by:
setBytes in interface S7Model

getBit

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

Parameters:
byteNo - Number of the databyte. It must be valid: firstByteNo<=byteNo<= (firstByteNo+ammountBytes-1)
bitNo - Number of the bit within the databyte. It must be valid: 0<=bitNr<=7
Returns:
the value for the bit

setBit

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

Parameters:
byteNo - Number of the databyte. It must be valid: firstByteNo<=byteNo<= (firstByteNo+ammountBytes-1)
bitNo - Number of the bit within the databyte. It must be valid: 0<=bitNr<=7
value - the value for the bit

www.rkjava.de