You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cg...@apache.org on 2025/08/08 03:51:41 UTC
(plc4x) 02/03: Update to new version.
This is an automated email from the ASF dual-hosted git repository.
cgarcia pushed a commit to branch fix/s7hmux
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 87ec0ad50c0d1615ba073900a371180b00ecf440
Author: César García <ce...@ceos.com.ve>
AuthorDate: Thu Aug 7 20:42:16 2025 -0400
Update to new version.
---
.../java/s7/readwrite/protocol/S7HMuxImpl.java | 25 +++++++++++-----------
.../s7/readwrite/protocol/S7ProtocolLogic.java | 2 +-
.../spi/transaction/RequestTransactionManager.java | 6 +++---
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HMuxImpl.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HMuxImpl.java
index ec76207414..0e367352ef 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HMuxImpl.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HMuxImpl.java
@@ -129,11 +129,12 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
* the Embeded channel when we created it.
*/
@Override
- protected void encode(ChannelHandlerContext ctx, ByteBuf outBB, List<Object> list) {
+ protected synchronized void encode(ChannelHandlerContext ctx, ByteBuf outBB, List<Object> list) throws InterruptedException {
if ((embedCtx == null) && (ctx.channel() instanceof EmbeddedChannel)) embedCtx = ctx;
if ((tcpChannel != null) && (embedCtx == ctx)) {
tcpChannel.writeAndFlush(outBB.copy());
}
+ logger.debug("ENCODE: " + ByteBufUtil.hexDump(outBB));
list.add(outBB.copy());
}
@@ -144,7 +145,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
*/
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf inBB, List<Object> list) throws Exception {
- System.out.println(ByteBufUtil.hexDump(inBB));
+ logger.debug("DECODE: " + ByteBufUtil.hexDump(inBB));
embedCtx.fireChannelRead(inBB.copy());
}
@@ -176,7 +177,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
*/
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
- logger.info(LocalTime.now() + " userEventTriggered: " + ctx.name() + " Event: " + evt);
+ logger.debug(LocalTime.now() + " userEventTriggered: " + ctx.name() + " Event: " + evt);
if (evt instanceof ConnectedEvent) {
try {
@@ -186,7 +187,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
}
} catch (Exception ex) {
- logger.info(ex.toString());
+ logger.debug(ex.toString());
}
try {
if ((embededChannel.attr(READ_TIME_OUT).get() > 0) &&
@@ -199,12 +200,12 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
embededChannel.attr(IS_CONNECTED).set(false);
}
} catch (Exception ex) {
- logger.info(ex.toString());
+ logger.debug(ex.toString());
}
}
if (evt instanceof DisconnectEvent) {
-// logger.info("userEventTriggered -> DisconnectEvent");
+// logger.debug("userEventTriggered -> DisconnectEvent");
}
// trigger other event handlers after IS_CONNECTED was set
@@ -234,7 +235,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
super.channelUnregistered(ctx);
logger.debug("{} channelUnregistered: {}", LocalTime.now(), ctx.name());
String strCanal = (tcpChannel == primaryChannel) ? "PRIMARY" : "SECONDARY";
- logger.info("Unregistered of channel: {}", strCanal);
+ logger.debug("Unregistered of channel: {}", strCanal);
//TODO: If embedded channel is closed, we need close all channels
if (ctx == embedCtx) return;
@@ -245,7 +246,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
}
if (embedCtx != null)
- logger.info(embedCtx.executor().toString());
+ logger.debug(embedCtx.executor().toString());
if ((tcpChannel == primaryChannel) &&
(primaryChannel == ctx.channel()))
@@ -253,7 +254,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
(secondaryChannel != null))
if (secondaryChannel.isActive()) {
synchronized (tcpChannel) {
- logger.info("Using secondary TCP channel.");
+ logger.debug("Using secondary TCP channel.");
tcpChannel = secondaryChannel;
embededChannel.attr(IS_PRIMARY).set(false);
embededChannel.pipeline().fireUserEventTriggered(new ConnectEvent());
@@ -267,7 +268,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
(primaryChannel != null))
if (primaryChannel.isActive()) {
synchronized (tcpChannel) {
- logger.info("Using primary TCP channel.");
+ logger.debug("Using primary TCP channel.");
tcpChannel = primaryChannel;
embededChannel.attr(IS_PRIMARY).set(true);
embededChannel.pipeline().fireUserEventTriggered(new ConnectEvent());
@@ -314,7 +315,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
embededChannel.attr(IS_PRIMARY).set(true);
if (tcpChannel.isActive()) {
- logger.info("Reassigns the inactive primary channel and send ConnectEvent..");
+ logger.debug("Reassigns the inactive primary channel and send ConnectEvent..");
embedCtx.fireUserEventTriggered(new ConnectEvent());
}
}
@@ -324,7 +325,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
this.primaryChannel = primary_channel;
tcpChannel = primary_channel;
embededChannel.attr(IS_PRIMARY).set(true);
- logger.info("Reassigns the primary channel and send ConnectEvent.");
+ logger.debug("Reassigns the primary channel and send ConnectEvent.");
if (tcpChannel.isActive()) {
embedCtx.fireUserEventTriggered(new ConnectEvent());
}
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
index 883f592aab..a231dc559b 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
@@ -86,7 +86,7 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> {
private static final Logger logger = LoggerFactory.getLogger(S7ProtocolLogic.class);
- public static final Duration REQUEST_TIMEOUT = Duration.ofMillis(10000);
+ public static final Duration REQUEST_TIMEOUT = Duration.ofMillis(10_000);
private final AtomicInteger tpduGenerator = new AtomicInteger(10);
/*
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java
index f71be3b2d4..e08b389ee1 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/transaction/RequestTransactionManager.java
@@ -187,7 +187,7 @@ public class RequestTransactionManager {
}
public void submit(Runnable operation) {
- logger.trace("Submission of transaction {}", transactionId);
+ logger.info("Submission of transaction {}", transactionId);
setOperation(new TransactionOperation(transactionId, operation));
parent.submit(this);
}
@@ -221,9 +221,9 @@ public class RequestTransactionManager {
public void run() {
//try (final MDC.MDCCloseable closeable = MDC.putCloseable("plc4x.transactionId", Integer.toString(transactionId))) {
try{
- logger.trace("Start execution of transaction {}", transactionId);
+ logger.info("Start execution of transaction {}", transactionId);
delegate.run();
- logger.trace("Completed execution of transaction {}", transactionId);
+ logger.info("Completed execution of transaction {}", transactionId);
} catch (Exception e) {
logger.info("Got an error executing transaction", e);
}