public abstract class FCOCDevice
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
FCOCInterfaceInfo[] |
m_aInterfacesInfo
Informations about the interfaces found.
|
Constructor and Description |
---|
FCOCDevice(int nNumberOfRegisters,
int nBufferSize) |
FCOCDevice(int nNumberOfRegisters,
int nBufferSize,
long lThreadLoopTime) |
FCOCDevice(int nNumberOfRegisters,
int nBufferSize,
long lThreadLoopTime,
int nParentMaxBufferSize) |
Modifier and Type | Method and Description |
---|---|
void |
addDeviceListener(FCOIDeviceEvent DevListener)
Adds an
DeviceListener to the device. |
void |
addRegister(java.lang.String szRegisterName,
int nRegisterAddress,
int nRegisterSize,
int nRegisterAccessType,
int nDataType,
boolean isAutoReadEnabled)
Add a new register to this device.
|
void |
addRegister(java.lang.String szRegisterName,
int nRegisterAddress,
int nRegisterSize,
int nRegisterAccessType,
int nDataType,
boolean isAutoReadEnabled,
java.lang.Object GeneralCallbackParameter)
Add a new register to this device.
|
abstract FCOCDevice |
addSubDevice(java.lang.String szSubDevName,
int nAddress,
int nNumberOfRegisters,
int nInterface) |
boolean |
askGetInterfaceInfo(boolean isCreateRegisters,
java.lang.Object Asker)
Ask the device to retrieve its device info from the hardware module
|
void |
call(java.lang.String szRegisterName)
Call a function register of this device.
|
abstract void |
delete()
Ask device object to stop its communication thread.
|
int |
getBufferSize() |
FCOIDeviceEvent[] |
getDeviceListeners()
Returns an array of all the
DeviceListener s added to this device with addDeviceListener(). |
abstract int |
getInterface() |
java.lang.Object |
getLastValueRead(java.lang.String szRegisterName)
Get the last register value read by the thread of this device.
|
java.lang.Object |
getLastValueWritten(java.lang.String szRegisterName)
Get the last register value written by the app.
|
boolean |
getRegisterAddress(java.lang.String szRegisterName,
java.lang.Integer nRegisterAddress)
Gets the register address based on its name.
|
int |
getThisInterfaceInfo()
Return the interface number of the device used to communicate with us.
|
long |
getThreadLoopTime()
Set sleep time to wait for an answer to an ask packet.
|
void |
getValue(java.lang.String szRegisterName)
Read a register of this device.
|
void |
getValue(java.lang.String szRegisterName,
boolean isForced,
java.lang.Object CallbackParameter)
Read a register of this device.
|
boolean |
receivedGetInterfacesInfo(java.lang.Object CallbackParameter)
Retrieve device info from local registers when above get values are terminated
|
void |
removeDeviceListener(FCOIDeviceEvent DevListener)
Removes an
DeviceListener from the device. |
FCOCRegisterBase |
removeRegister(java.lang.String szRegisterName)
Remove a register of this device.
|
abstract void |
removeSubDevice(java.lang.String szSubDevName) |
abstract void |
run()
Main communication thread loop (threadLoop() in dot net lib)
|
void |
setAutoreadState(java.lang.String szRegisterName,
boolean isAutoReadEnabled)
Set the autoread state of a register of this device.
|
void |
setAutoreadSupended(boolean isSuspended)
Ask device object to suspend registers autoread.
|
void |
setBufferSize(int nBufferSize)
Change the current communication buffer size.
|
void |
setDebugLogEnabled(boolean isEnabled) |
void |
setInterfaceComSupendedState(boolean isInterfaceComSupended)
Ask device object to suspend registers access.
|
void |
setMaxParentBufferSize(int nParentMaxBufferSize)
Tell device what is its parent interface max buffer size
|
void |
setThreadLoopTime(long lThreadLoopTime)
Set sleep time to wait for an answer to an ask packet.
|
void |
setValue(java.lang.String szRegisterName,
java.lang.Object Value)
Write in a register of this device.
|
void |
setValue(java.lang.String szRegisterName,
java.lang.Object Value,
boolean isMandatory)
Write in a register of this device.
|
public FCOCInterfaceInfo[] m_aInterfacesInfo
public FCOCDevice(int nNumberOfRegisters, int nBufferSize, long lThreadLoopTime, int nParentMaxBufferSize)
nNumberOfRegisters
- Max number of registers of this devicenBufferSize
- Communication link buffer size in byteslThreadLoopTime
- Communication thread loop time in millisecondsnParentMaxBufferSize
- Communication link buffer size in bytes of the parent device (for sub devices)public FCOCDevice(int nNumberOfRegisters, int nBufferSize, long lThreadLoopTime)
nNumberOfRegisters
- Max number of registers of this devicenBufferSize
- Communication link buffer size in byteslThreadLoopTime
- Communication thread loop time in millisecondspublic FCOCDevice(int nNumberOfRegisters, int nBufferSize)
nNumberOfRegisters
- Max number of registers of this devicenBufferSize
- Communication link buffer size in bytespublic void setMaxParentBufferSize(int nParentMaxBufferSize)
nParentMaxBufferSize
- Parent buffer sizepublic void setBufferSize(int nBufferSize)
nBufferSize
- New buffer sizepublic int getBufferSize()
public abstract void delete()
Ask device object to stop its communication thread.
public void addDeviceListener(FCOIDeviceEvent DevListener)
DeviceListener
to the device.DevListener
- the DeviceListener
to be addedpublic void removeDeviceListener(FCOIDeviceEvent DevListener)
DeviceListener
from the device.DevListener
- the listener to be removedpublic FCOIDeviceEvent[] getDeviceListeners()
DeviceListener
s added to this device with addDeviceListener().DeviceListener
s added or an empty array if no listeners have been addedpublic void setInterfaceComSupendedState(boolean isInterfaceComSupended)
Ask device object to suspend registers access.
isInterfaceComSupended
- True to suspendpublic void setDebugLogEnabled(boolean isEnabled)
isEnabled
- True to enable protocol log file (on desktop).public void setAutoreadSupended(boolean isSuspended)
Ask device object to suspend registers autoread.
isSuspended
- True to suspend autoread on this device.public void setThreadLoopTime(long lThreadLoopTime)
Set sleep time to wait for an answer to an ask packet.
lThreadLoopTime
- Sleep time in millisecondspublic long getThreadLoopTime()
Set sleep time to wait for an answer to an ask packet.
public void addRegister(java.lang.String szRegisterName, int nRegisterAddress, int nRegisterSize, int nRegisterAccessType, int nDataType, boolean isAutoReadEnabled, java.lang.Object GeneralCallbackParameter) throws java.lang.IllegalArgumentException
Add a new register to this device.
szRegisterName
- Name of the registernRegisterAddress
- Register index in registers tablenRegisterSize
- Register's sizenRegisterAccessType
- Access type between nAT_FCT, nAT_R, nAT_W and nAT_RWnDataType
- Data packing class type between nDT_INT (Long), nDT_UINT (Long), nDT_BIN (BitSet), nDT_PERCENT (Double
0-100), nDT_TEXT (string), nDT_ARRAY (Byte[]), nDT_FIXEDP (Double)isAutoReadEnabled
- Ask thread to read this register at each communication loopGeneralCallbackParameter
- Object to transmit to listener as callback parameters with a register autoread answer or when telling
listener that an autoread start for that register.java.lang.IllegalArgumentException
- If one parameter is not valid (see console)public void addRegister(java.lang.String szRegisterName, int nRegisterAddress, int nRegisterSize, int nRegisterAccessType, int nDataType, boolean isAutoReadEnabled) throws java.lang.IllegalArgumentException
Add a new register to this device.
szRegisterName
- Name of the registernRegisterAddress
- Register index in registers tablenRegisterSize
- Register's sizenRegisterAccessType
- Access type between nAT_FCT, nAT_R, nAT_W and nAT_RWnDataType
- Data packing class type between nDT_INT (Long), nDT_UINT (Long), nDT_BIN (BitSet), nDT_PERCENT (Double
0-100), nDT_TEXT (string), nDT_ARRAY (Byte[]), nDT_FIXEDP (Double)isAutoReadEnabled
- Ask thread to read this register at each communication loopjava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public boolean getRegisterAddress(java.lang.String szRegisterName, java.lang.Integer nRegisterAddress)
szRegisterName
- Size register name.nRegisterAddress
- Register address.public FCOCRegisterBase removeRegister(java.lang.String szRegisterName)
Remove a register of this device.
szRegisterName
- Name of the registerpublic void call(java.lang.String szRegisterName) throws java.lang.IllegalArgumentException
Call a function register of this device.
szRegisterName
- Function (register) namejava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public void setValue(java.lang.String szRegisterName, java.lang.Object Value, boolean isMandatory) throws java.lang.IllegalArgumentException
Write in a register of this device.
szRegisterName
- Register nameValue
- Object that contains value to write (must be in the correct class type)isMandatory
- True to force write even if this register is already in write queuejava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public void setValue(java.lang.String szRegisterName, java.lang.Object Value) throws java.lang.IllegalArgumentException
Write in a register of this device. A call to this function is identical that calling the same function with 3rd parameter set to true.
szRegisterName
- Register nameValue
- Object that contains value to write (must be in the correct class type)java.lang.IllegalArgumentException
- If one parameter is not valid (see console)public void getValue(java.lang.String szRegisterName) throws java.lang.IllegalArgumentException
Read a register of this device. When thread gets the value, it will call dataDevEvtOccured() function of the FCOIDeviceEvent interface.
szRegisterName
- Register namejava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public void getValue(java.lang.String szRegisterName, boolean isForced, java.lang.Object CallbackParameter) throws java.lang.IllegalArgumentException
Read a register of this device. When thread gets the value, it will call dataDevEvtOccured() function of the FCOIDeviceEvent interface.
szRegisterName
- Register nameisForced
- Force the read, even if already in read queueCallbackParameter
- An object to pass to callback method dataDevEvtOccuredjava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public java.lang.Object getLastValueRead(java.lang.String szRegisterName) throws java.lang.IllegalArgumentException
Get the last register value read by the thread of this device.
szRegisterName
- Register namejava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public java.lang.Object getLastValueWritten(java.lang.String szRegisterName) throws java.lang.IllegalArgumentException
Get the last register value written by the app.
szRegisterName
- Register namejava.lang.IllegalArgumentException
- If one parameter is not valid (see console)public boolean askGetInterfaceInfo(boolean isCreateRegisters, java.lang.Object Asker)
isCreateRegisters
- True if you want that flash access registers been created automatically if not definedAsker
- A optional callback parameter that caller object can use to identify answerpublic boolean receivedGetInterfacesInfo(java.lang.Object CallbackParameter)
CallbackParameter
- Optional callback parameterspublic int getThisInterfaceInfo()
public void setAutoreadState(java.lang.String szRegisterName, boolean isAutoReadEnabled) throws java.lang.IllegalArgumentException
Set the autoread state of a register of this device.
szRegisterName
- Register nameisAutoReadEnabled
- True to start autoread.java.lang.IllegalArgumentException
- If one parameter is not valid (see console)public abstract void removeSubDevice(java.lang.String szSubDevName)
szSubDevName
- Name of the sub device to removepublic abstract FCOCDevice addSubDevice(java.lang.String szSubDevName, int nAddress, int nNumberOfRegisters, int nInterface) throws java.io.IOException
szSubDevName
- Name of the sub device to addnAddress
- New sub device addressnNumberOfRegisters
- Maximum registers count of the sub devicenInterface
- Interface number of the sub devicejava.io.IOException
- Exception thrown if a parameter is invalidpublic abstract int getInterface()
public abstract void run()
run
in interface java.lang.Runnable