Interface ModbusElement<T>
- All Known Subinterfaces:
ModbusCoilElement
,ModbusReadElement<T>
,ModbusRegisterElement<T>
,ModbusWriteElement<T>
- All Known Implementing Classes:
AbstractDoubleWordElement
,AbstractModbusElement
,AbstractModbusRegisterElement
,AbstractQuadrupleWordElement
,AbstractWordElement
,BitsWordElement
,CoilElement
,DummyCoilElement
,DummyRegisterElement
,FloatDoublewordElement
,FloatQuadruplewordElement
,SignedDoublewordElement
,SignedQuadruplewordElement
,SignedWordElement
,StringWordElement
,UnsignedDoublewordElement
,UnsignedQuadruplewordElement
,UnsignedWordElement
public interface ModbusElement<T>
A ModbusElement represents one or more registers or coils in an
AbstractTask
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
_setNextWriteValue
(Optional<T> valueOpt) Sets a value that should be written to the Modbus device.void
This is called on deactivate of the Modbus-Bridge.int
Number of Registers or Coils.int
Gets the start address of this Modbus element.getType()
Gets the type of this Register, e.g.boolean
invalidate
(AbstractModbusBridge bridge) Invalidates the Channel in case it could not be read from the Modbus device, i.e.boolean
Whether this Element should be ignored (= DummyElement).void
onSetNextWrite
(Consumer<Optional<T>> callback) Add an onSetNextWrite callback.void
setModbusTask
(AbstractTask abstractTask) Set theAbstractTask
, where this Element belongs to.
-
Method Details
-
getStartAddress
int getStartAddress()Gets the start address of this Modbus element.- Returns:
- the start address
-
getLength
int getLength()Number of Registers or Coils.- Returns:
- the number of Registers or Coils
-
setModbusTask
Set theAbstractTask
, where this Element belongs to.This is called by the
AbstractTask
constructor.- Parameters:
abstractTask
- the AbstractTask
-
isIgnored
boolean isIgnored()Whether this Element should be ignored (= DummyElement).- Returns:
- true for ignored elements
-
getType
OpenemsType getType()Gets the type of this Register, e.g. INTEGER, BOOLEAN,..- Returns:
- the OpenemsType
-
_setNextWriteValue
Sets a value that should be written to the Modbus device.- Parameters:
valueOpt
- the Optional value- Throws:
OpenemsException
- on errorIllegalArgumentException
- on error
-
onSetNextWrite
Add an onSetNextWrite callback. It is called when a 'next write value' was set.- Parameters:
callback
- the callback
-
invalidate
Invalidates the Channel in case it could not be read from the Modbus device, i.e. sets the value to 'UNDEFINED'/null. Applies the 'invalidateElementsAfterReadErrors' config setting of the bridge.- Parameters:
bridge
- theAbstractModbusBridge
- Returns:
- true if Channel was invalidated
-
deactivate
void deactivate()This is called on deactivate of the Modbus-Bridge. It can be used to clear any references like listeners.
-