Package net.solarnetwork.io.modbus
Class UserModbusFunction
java.lang.Object
net.solarnetwork.io.modbus.UserModbusFunction
- All Implemented Interfaces:
ModbusFunction
A user-defined Modbus function.
-
Constructor Summary
ConstructorsConstructorDescriptionUserModbusFunction(byte code) Constructor.UserModbusFunction(String displayName, byte code) Constructor.UserModbusFunction(String displayName, byte code, ModbusBlockType blockType, boolean readFunction, ModbusFunction oppositeFunction) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the register block type related to this function.booleanbytegetCode()Get the function code.inthashCode()booleanReturn true if this function represents a read operation.Get an "opposite" function from this function.Get a friendly display string for this function.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.solarnetwork.io.modbus.ModbusFunction
functionCode
-
Constructor Details
-
UserModbusFunction
public UserModbusFunction(byte code) Constructor.- Parameters:
code- the function code
-
UserModbusFunction
Constructor.- Parameters:
displayName- the display namecode- the function code
-
UserModbusFunction
public UserModbusFunction(String displayName, byte code, ModbusBlockType blockType, boolean readFunction, ModbusFunction oppositeFunction) Constructor.- Parameters:
displayName- the display namecode- the function codeblockType- the block typereadFunction- the read function flagoppositeFunction- the opposite function
-
-
Method Details
-
toString
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceModbusFunction- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceModbusFunction- Overrides:
equalsin classObject
-
getCode
public byte getCode()Description copied from interface:ModbusFunctionGet the function code.- Specified by:
getCodein interfaceModbusFunction- Returns:
- the code
-
blockType
Description copied from interface:ModbusFunctionGet the register block type related to this function.- Specified by:
blockTypein interfaceModbusFunction- Returns:
- the block type
-
isReadFunction
public boolean isReadFunction()Description copied from interface:ModbusFunctionReturn true if this function represents a read operation.- Specified by:
isReadFunctionin interfaceModbusFunction- Returns:
- true if this function represents a read operation, false if a write operation
-
oppositeFunction
Description copied from interface:ModbusFunctionGet an "opposite" function from this function.This method is used to get a read function for a given write function, and a write function for a given read function. Note that not all functions have exact opposites, such that:
ModbusFunction a = myFunction(); ModbusFunction b = a.oppositeFunction(); ModbusFunction c = b.oppositeFunction(); // at this stage c is not necessarily equal to a- Specified by:
oppositeFunctionin interfaceModbusFunction- Returns:
- the function, or null if not applicable
-
toDisplayString
Description copied from interface:ModbusFunctionGet a friendly display string for this function.- Specified by:
toDisplayStringin interfaceModbusFunction- Returns:
- a display string
-