modsim
Class SimulatedProcessImage

java.lang.Object
  extended by modsim.SimulatedProcessImage
All Implemented Interfaces:
net.wimpi.modbus.procimg.ProcessImage, net.wimpi.modbus.procimg.ProcessImageImplementation

public class SimulatedProcessImage
extends java.lang.Object
implements net.wimpi.modbus.procimg.ProcessImageImplementation

Create a simulated process image. This uses the configuration file to set the addresses and data types.

Author:
bburch 16 July 2008
See Also:
ProcessImageImplementation

Field Summary
 
Fields inherited from interface net.wimpi.modbus.procimg.ProcessImageImplementation
DIG_FALSE, DIG_INVALID, DIG_TRUE
 
Constructor Summary
SimulatedProcessImage(java.io.File file)
          Constructor to build the simulated ProcessImage.
 
Method Summary
 void addDigitalIn(net.wimpi.modbus.procimg.DigitalIn di)
           
 void addDigitalOut(net.wimpi.modbus.procimg.DigitalOut digout)
           
 void addInputRegister(net.wimpi.modbus.procimg.InputRegister reg)
           
 void addRegister(net.wimpi.modbus.procimg.Register reg)
           
 net.wimpi.modbus.procimg.DigitalIn getDigitalIn(int ref)
          Return the digital input register corresponding to the address.
 int getDigitalInCount()
           
 net.wimpi.modbus.procimg.DigitalIn[] getDigitalInRange(int ref, int count)
          Return the digital input registers in the range.
 net.wimpi.modbus.procimg.DigitalOut getDigitalOut(int ref)
          Return the digital out register that matches the address.
 int getDigitalOutCount()
           
 net.wimpi.modbus.procimg.DigitalOut[] getDigitalOutRange(int ref, int count)
           
 net.wimpi.modbus.procimg.InputRegister getInputRegister(int ref)
          Return the input register at the modbus memory address.
 int getInputRegisterCount()
           
 net.wimpi.modbus.procimg.InputRegister[] getInputRegisterRange(int ref, int count)
          Return the input registers in a range.
 java.lang.String getIpAddress()
          Return the extracted IP address.
 int getPortNumber()
          Return the Modbus port number.
 net.wimpi.modbus.procimg.Register getRegister(int ref)
          Return the register at the given address.
 int getRegisterCount()
           
 net.wimpi.modbus.procimg.Register[] getRegisterRange(int ref, int count)
          Return the registers in the range given.
 java.lang.String getUnitName()
          Return the unit name.
 void removeDigitalIn(net.wimpi.modbus.procimg.DigitalIn di)
           
 void removeDigitalOut(net.wimpi.modbus.procimg.DigitalOut digout)
           
 void removeInputRegister(net.wimpi.modbus.procimg.InputRegister reg)
           
 void removeRegister(net.wimpi.modbus.procimg.Register reg)
           
 void setDigitalIn(int ref, net.wimpi.modbus.procimg.DigitalIn di)
          Create a digital input at the address given.
 void setDigitalOut(int ref, net.wimpi.modbus.procimg.DigitalOut digout)
          Create a digital output at the address given.
 void setInputRegister(int ref, net.wimpi.modbus.procimg.InputRegister reg)
          Create an input register at the address.
 void setRegister(int ref, net.wimpi.modbus.procimg.Register reg)
          Create a register at the address.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimulatedProcessImage

public SimulatedProcessImage(java.io.File file)
Constructor to build the simulated ProcessImage. Reads in the configuration file and constructs the memory map.

Parameters:
file - File - the configuration file to be read in
Method Detail

addDigitalIn

public void addDigitalIn(net.wimpi.modbus.procimg.DigitalIn di)
Specified by:
addDigitalIn in interface net.wimpi.modbus.procimg.ProcessImageImplementation

addDigitalOut

public void addDigitalOut(net.wimpi.modbus.procimg.DigitalOut digout)
Specified by:
addDigitalOut in interface net.wimpi.modbus.procimg.ProcessImageImplementation

addInputRegister

public void addInputRegister(net.wimpi.modbus.procimg.InputRegister reg)
Specified by:
addInputRegister in interface net.wimpi.modbus.procimg.ProcessImageImplementation

addRegister

public void addRegister(net.wimpi.modbus.procimg.Register reg)
Specified by:
addRegister in interface net.wimpi.modbus.procimg.ProcessImageImplementation

getDigitalIn

public net.wimpi.modbus.procimg.DigitalIn getDigitalIn(int ref)
Return the digital input register corresponding to the address.

Specified by:
getDigitalIn in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - modbus address
Returns:
DigitalIn - the digital input register, or null if no match to address

getDigitalInCount

public int getDigitalInCount()
Specified by:
getDigitalInCount in interface net.wimpi.modbus.procimg.ProcessImage

getDigitalInRange

public net.wimpi.modbus.procimg.DigitalIn[] getDigitalInRange(int ref,
                                                              int count)
Return the digital input registers in the range.

Specified by:
getDigitalInRange in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - starting modbus address
count - int - number of digitals in range
Returns:
Digital[] - array of digital input registers in range

getDigitalOut

public net.wimpi.modbus.procimg.DigitalOut getDigitalOut(int ref)
Return the digital out register that matches the address.

Specified by:
getDigitalOut in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - modbus address
Returns:
DigitalOut - matchin register

getDigitalOutCount

public int getDigitalOutCount()
Specified by:
getDigitalOutCount in interface net.wimpi.modbus.procimg.ProcessImage

getDigitalOutRange

public net.wimpi.modbus.procimg.DigitalOut[] getDigitalOutRange(int ref,
                                                                int count)
Specified by:
getDigitalOutRange in interface net.wimpi.modbus.procimg.ProcessImage

getInputRegister

public net.wimpi.modbus.procimg.InputRegister getInputRegister(int ref)
Return the input register at the modbus memory address.

Specified by:
getInputRegister in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - the modbus memory map address
Returns:
InputRegister - the input register at the address, or null.

getInputRegisterCount

public int getInputRegisterCount()
Specified by:
getInputRegisterCount in interface net.wimpi.modbus.procimg.ProcessImage

getInputRegisterRange

public net.wimpi.modbus.procimg.InputRegister[] getInputRegisterRange(int ref,
                                                                      int count)
Return the input registers in a range.

Specified by:
getInputRegisterRange in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - starting modbus address
count - int - number of registers
Returns:
InputRegister[] - array of input registers in the range

getIpAddress

public java.lang.String getIpAddress()
Return the extracted IP address.

Returns:
String - the IP address in dotted decimal form

getPortNumber

public int getPortNumber()
Return the Modbus port number. This was read in by the configuration file.

Returns:
int - Modbus Port Number, default 502

getRegister

public net.wimpi.modbus.procimg.Register getRegister(int ref)
Return the register at the given address.

Specified by:
getRegister in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - the memory map address
Returns:
Register - the Register at that address

getRegisterCount

public int getRegisterCount()
Specified by:
getRegisterCount in interface net.wimpi.modbus.procimg.ProcessImage

getRegisterRange

public net.wimpi.modbus.procimg.Register[] getRegisterRange(int ref,
                                                            int count)
Return the registers in the range given. We first find the number of registers in the range. Then we actually find the registers in the range. The first step allows us to determine how many registers to allocate for the return.

Specified by:
getRegisterRange in interface net.wimpi.modbus.procimg.ProcessImage
Parameters:
ref - int - starting reference address
count - int - number of registers
Returns:
Register[] - array of register

getUnitName

public java.lang.String getUnitName()
Return the unit name. This is used for class loading.

Returns:
String - the unit name/class name

removeDigitalIn

public void removeDigitalIn(net.wimpi.modbus.procimg.DigitalIn di)
Specified by:
removeDigitalIn in interface net.wimpi.modbus.procimg.ProcessImageImplementation

removeDigitalOut

public void removeDigitalOut(net.wimpi.modbus.procimg.DigitalOut digout)
Specified by:
removeDigitalOut in interface net.wimpi.modbus.procimg.ProcessImageImplementation

removeInputRegister

public void removeInputRegister(net.wimpi.modbus.procimg.InputRegister reg)
Specified by:
removeInputRegister in interface net.wimpi.modbus.procimg.ProcessImageImplementation

removeRegister

public void removeRegister(net.wimpi.modbus.procimg.Register reg)
Specified by:
removeRegister in interface net.wimpi.modbus.procimg.ProcessImageImplementation

setDigitalIn

public void setDigitalIn(int ref,
                         net.wimpi.modbus.procimg.DigitalIn di)
Create a digital input at the address given.

Specified by:
setDigitalIn in interface net.wimpi.modbus.procimg.ProcessImageImplementation
Parameters:
ref - int - modbus address
di - DigitalIn - DigitalIn register

setDigitalOut

public void setDigitalOut(int ref,
                          net.wimpi.modbus.procimg.DigitalOut digout)
Create a digital output at the address given.

Specified by:
setDigitalOut in interface net.wimpi.modbus.procimg.ProcessImageImplementation
Parameters:
ref - int - modbus address
digout - DigitalOut - digital register

setInputRegister

public void setInputRegister(int ref,
                             net.wimpi.modbus.procimg.InputRegister reg)
Create an input register at the address. Used for 32 bit registers.

Specified by:
setInputRegister in interface net.wimpi.modbus.procimg.ProcessImageImplementation
Parameters:
ref - int - modbus address
reg - Register - Register to creeate

setRegister

public void setRegister(int ref,
                        net.wimpi.modbus.procimg.Register reg)
Create a register at the address.

Specified by:
setRegister in interface net.wimpi.modbus.procimg.ProcessImageImplementation
Parameters:
ref - int - modbus address
reg - Register - Register to creeate