File tree Expand file tree Collapse file tree 1 file changed +27
-25
lines changed
modules/hivemq-edge-module-modbus/src/main/java/com/hivemq/edge/adapters/modbus Expand file tree Collapse file tree 1 file changed +27
-25
lines changed Original file line number Diff line number Diff line change @@ -224,32 +224,34 @@ protected static CompletableFuture<DataPoint> doRead(
224224 final @ NotNull ModbusDataType dataType ,
225225 final @ NotNull ModbusAdu readType ,
226226 final @ NotNull ModbusClient modbusClient ) {
227- if (HOLDING_REGISTERS .equals (readType )) {
228- return modbusClient
229- .readHoldingRegisters (
230- startIdx ,
231- dataType ,
232- unitId ,
233- flipRegisters );
234- } else if (INPUT_REGISTERS .equals (readType )) {
235- return modbusClient
236- .readInputRegisters (
237- startIdx ,
238- dataType ,
239- unitId ,
240- flipRegisters );
241- } else if (COILS .equals (readType )) {
242- return modbusClient
243- .readCoils (
244- startIdx ,
245- unitId );
246- } else if (DISCRETE_INPUT .equals (readType )) {
247- return modbusClient
248- .readDiscreteInput (
249- startIdx ,
250- unitId );
227+ switch (readType ) {
228+ case HOLDING_REGISTERS :
229+ return modbusClient
230+ .readHoldingRegisters (
231+ startIdx ,
232+ dataType ,
233+ unitId ,
234+ flipRegisters );
235+ case INPUT_REGISTERS :
236+ return modbusClient
237+ .readInputRegisters (
238+ startIdx ,
239+ dataType ,
240+ unitId ,
241+ flipRegisters );
242+ case COILS :
243+ return modbusClient
244+ .readCoils (
245+ startIdx ,
246+ unitId );
247+ case DISCRETE_INPUT :
248+ return modbusClient
249+ .readDiscreteInput (
250+ startIdx ,
251+ unitId );
252+ default :
253+ return CompletableFuture .failedFuture (new Exception ("Unknown read type " + readType ));
251254 }
252- return CompletableFuture .failedFuture (new Exception ("Unknown read type " + readType ));
253255 }
254256
255257 private static void addAddresses (
You can’t perform that action at this time.
0 commit comments