Package nl.basjes.modbus.schema.fetcher
Class OptimizingModbusBlockFetcher
-
- All Implemented Interfaces:
public final class OptimizingModbusBlockFetcher extends ModbusBlockFetcher
-
-
Field Summary
Fields Modifier and Type Field Description private IntegerallowedGapReadSize
-
Constructor Summary
Constructors Constructor Description OptimizingModbusBlockFetcher(SchemaDevice schemaDevice, ModbusDevice modbusDevice)
-
Method Summary
Modifier and Type Method Description final IntegergetAllowedGapReadSize()How many registers may needlessly be read to optimize fetching final UnitsetAllowedGapReadSize(Integer allowedGapReadSize)List<ModbusQuery>calculateModbusQueries(List<Field> fields, Long maxAge)Reduce the full set of modbus queries to a lower number by combining requests that are close enough together. final List<ModbusQuery>splitMergedModbusRequest(MergedModbusQuery modbusQuery, Function1<MergedModbusQuery, Boolean> isFull)Split an existing MergedModbusQuery into 2 or more smaller modbus queries. final List<ModbusQuery>mergeQueries(List<ModbusQuery> providedModbusQueries, Integer maxRegistersPerModbusRequest, Integer maxDiscretesPerModbusRequest)Combine the provided set of queries into a smaller set of Merged Queries where possible. -
-
Constructor Detail
-
OptimizingModbusBlockFetcher
OptimizingModbusBlockFetcher(SchemaDevice schemaDevice, ModbusDevice modbusDevice)
-
-
Method Detail
-
getAllowedGapReadSize
final Integer getAllowedGapReadSize()
How many registers may needlessly be read to optimize fetching
-
setAllowedGapReadSize
final Unit setAllowedGapReadSize(Integer allowedGapReadSize)
-
calculateModbusQueries
List<ModbusQuery> calculateModbusQueries(List<Field> fields, Long maxAge)
Reduce the full set of modbus queries to a lower number by combining requests that are close enough together.
- Parameters:
fields- The list of fields that must be updatedmaxAge- The maximum age (in milliseconds) of the data for it to need an update.
-
splitMergedModbusRequest
final List<ModbusQuery> splitMergedModbusRequest(MergedModbusQuery modbusQuery, Function1<MergedModbusQuery, Boolean> isFull)
Split an existing MergedModbusQuery into 2 or more smaller modbus queries. This simply walks over the underlying modbus queries and recombines them up to a limit which is determined by the 'isFull' lambda.
-
mergeQueries
final List<ModbusQuery> mergeQueries(List<ModbusQuery> providedModbusQueries, Integer maxRegistersPerModbusRequest, Integer maxDiscretesPerModbusRequest)
Combine the provided set of queries into a smaller set of Merged Queries where possible.
-
-
-
-