You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2019/12/18 23:40:53 UTC

[plc4x] branch next-gen-core updated: Minor Refactorings

This is an automated email from the ASF dual-hosted git repository.

jfeinauer pushed a commit to branch next-gen-core
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/next-gen-core by this push:
     new d53a642  Minor Refactorings
d53a642 is described below

commit d53a64263993a9916e7616306a83fb4ab7f7f30d
Author: Julian Feinauer <j....@pragmaticminds.de>
AuthorDate: Thu Dec 19 00:40:43 2019 +0100

    Minor Refactorings
---
 .../apache/plc4x/java/spi/Plc4xNettyWrapper.java   | 24 +++++++++++-----------
 .../s7/readwrite/protocol/Plc4xS7Protocol.java     |  2 --
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java
index c03933a..7f21126 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java
@@ -55,11 +55,11 @@ public class Plc4xNettyWrapper<T> extends MessageToMessageCodec<T, PlcRequestCon
 
     @Override
     protected void encode(ChannelHandlerContext channelHandlerContext, PlcRequestContainer plcRequestContainer, List<Object> list) throws Exception {
-        logger.info("Encoding {}", plcRequestContainer);
+        logger.trace("Encoding {}", plcRequestContainer);
         protocolBase.encode(new DefaultConversationContext<T>(channelHandlerContext) {
             @Override
             public void sendToWire(T msg) {
-                logger.info("Sending to wire {}", msg);
+                logger.trace("Sending to wire {}", msg);
                 list.add(msg);
             }
         }, plcRequestContainer);
@@ -67,7 +67,7 @@ public class Plc4xNettyWrapper<T> extends MessageToMessageCodec<T, PlcRequestCon
 
     @Override
     protected void decode(ChannelHandlerContext channelHandlerContext, T t, List<Object> list) throws Exception {
-        logger.info("Decoding {}", t);
+        logger.trace("Decoding {}", t);
         // Just iterate the list to find a suitable  Handler
 
         registrations:
@@ -75,13 +75,13 @@ public class Plc4xNettyWrapper<T> extends MessageToMessageCodec<T, PlcRequestCon
             HandlerRegistration registration = iter.next();
             // Check if the handler can still be used or should be removed
             if (registration.getTimeout().isBefore(Instant.now())) {
-                logger.info("Removing {} as its timed out (was set till {})", registration, registration.getTimeout());
+                logger.debug("Removing {} as its timed out (was set till {})", registration, registration.getTimeout());
                 iter.remove();
                 continue;
             }
-            logger.info("Checking handler {} for Object of type {}", registration, t.getClass().getSimpleName());
+            logger.trace("Checking handler {} for Object of type {}", registration, t.getClass().getSimpleName());
             if (registration.getExpectClazz().isInstance(t)) {
-                logger.info("Handler {} has right expected type {}, checking condition", registration, registration.getExpectClazz().getSimpleName());
+                logger.trace("Handler {} has right expected type {}, checking condition", registration, registration.getExpectClazz().getSimpleName());
                 // Check all Commands / Functions
                 Deque<Either<Function<?, ?>, Predicate<?>>> commands = registration.getCommands();
                 Object instance = t;
@@ -94,19 +94,19 @@ public class Plc4xNettyWrapper<T> extends MessageToMessageCodec<T, PlcRequestCon
                         Predicate predicate = either.get();
                         if (predicate.test(instance) == false) {
                             // We do not match -> cannot handle
-                            logger.info("Registration {} does not match object {} (currently wrapped to {})", registration, t.getClass().getSimpleName(), instance.getClass().getSimpleName());
+                            logger.trace("Registration {} does not match object {} (currently wrapped to {})", registration, t.getClass().getSimpleName(), instance.getClass().getSimpleName());
                             continue registrations;
                         }
                     }
                 }
-                logger.info("Handler {} accepts element {}, calling handle method", registration, t);
+                logger.trace("Handler {} accepts element {}, calling handle method", registration, t);
                 this.registeredHandlers.remove(registration);
                 Consumer handler = registration.getPacketConsumer();
                 handler.accept(instance);
                 return;
             }
         }
-        logger.info("No registered handler found for message {}, using default decode method", t);
+        logger.trace("No registered handler found for message {}, using default decode method", t);
         protocolBase.decode(new DefaultConversationContext<>(channelHandlerContext), t);
     }
 
@@ -130,20 +130,20 @@ public class Plc4xNettyWrapper<T> extends MessageToMessageCodec<T, PlcRequestCon
 
         @Override
         public void sendToWire(T1 msg) {
-            logger.info("Sending to wire {}", msg);
+            logger.trace("Sending to wire {}", msg);
             channelHandlerContext.channel().writeAndFlush(msg);
         }
 
         @Override
         public void fireConnected() {
-            logger.info("Firing Connected!");
+            logger.trace("Firing Connected!");
             channelHandlerContext.pipeline().fireUserEventTriggered(new ConnectedEvent());
         }
 
         @Override
         public SendRequestContext<T1> sendRequest(T1 packet) {
             return new DefaultSendRequestContext<T1>(handler -> {
-                logger.info("Adding Response Handler...");
+                logger.trace("Adding Response Handler...");
                 registeredHandlers.add(handler);
             }, packet, (DefaultConversationContext)this);
         }
diff --git a/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/Plc4xS7Protocol.java b/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/Plc4xS7Protocol.java
index 14fabb5..32c55c9 100644
--- a/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/Plc4xS7Protocol.java
+++ b/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/Plc4xS7Protocol.java
@@ -128,8 +128,6 @@ public class Plc4xS7Protocol extends Plc4xProtocolBase<TPKTPacket> {
                             });
                     });
             });
-
-        // context.sendToWire(packet);
     }
 
     private void extractControllerTypeAndFireConnected(ConversationContext<TPKTPacket> context, S7PayloadUserData payloadUserData) {