You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/12/28 08:01:44 UTC

[plc4x] branch next-gen-core updated (e214f5b -> f76e9e1)

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

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


    from e214f5b  - Major refactoring FieldItems -> PlcValue
     new bc867e5  - Made sure super.eventTriggered is not executed in case of ConnectEvent and DisconnectEvent
     new f76e9e1  - Enabled the code for writing data

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java  |  3 +--
 .../plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java  | 14 ++++++++------
 2 files changed, 9 insertions(+), 8 deletions(-)


[plc4x] 01/02: - Made sure super.eventTriggered is not executed in case of ConnectEvent and DisconnectEvent

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bc867e5f21c7a1278a62b4d333420bd3c117a993
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sat Dec 28 09:01:13 2019 +0100

    - Made sure super.eventTriggered is not executed in case of ConnectEvent and DisconnectEvent
---
 .../spi/src/main/java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java | 3 +--
 1 file changed, 1 insertion(+), 2 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 cfffd01..f9a281a 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
@@ -156,8 +156,7 @@ public class Plc4xNettyWrapper<T> extends MessageToMessageCodec<T, Object> {
             this.protocolBase.onConnect(new DefaultConversationContext<>(ctx));
         } else if (evt instanceof DisconnectEvent) {
             this.protocolBase.onDisconnect(new DefaultConversationContext<>(ctx));
-        }
-        if (evt instanceof CloseConnectionEvent) {
+        } else if (evt instanceof CloseConnectionEvent) {
             this.protocolBase.close(new DefaultConversationContext<>(ctx));
         } else {
             super.userEventTriggered(ctx, evt);


[plc4x] 02/02: - Enabled the code for writing data

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f76e9e15370f7a457bb508de2a1f803fed8342be
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sat Dec 28 09:01:36 2019 +0100

    - Enabled the code for writing data
---
 .../plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java  | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java b/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
index 9344c61..6f9b82f 100644
--- a/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
+++ b/sandbox/test-java-s7-driver/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
@@ -180,9 +180,9 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> implements Ha
         List<S7VarPayloadDataItem> payloadItems = new ArrayList<>(request.getNumberOfFields());
         for (String fieldName : request.getFieldNames()) {
             final S7Field field = (S7Field) request.getField(fieldName);
-/*            final BaseDefaultFieldItem fieldItem = request.getFieldItem(fieldName);
+            final PlcValue fieldItem = request.getFieldItem(fieldName);
             parameterItems.add(new S7VarRequestParameterItemAddress(encodeS7Address(field)));
-            payloadItems.add(serializeFieldItem(field, fieldItem));*/
+            payloadItems.add(serializeFieldItem(field, fieldItem));
         }
         final int tpduId = tpduGenerator.getAndIncrement();
         TPKTPacket tpktPacket = new TPKTPacket(new COTPPacketData(null,
@@ -213,7 +213,7 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> implements Ha
 
     @Override
     public void close(ConversationContext<TPKTPacket> context) {
-        // TODO Implement Closing on Protocl Level
+        // TODO Implement Closing on Protocol Level
     }
 
     private void extractControllerTypeAndFireConnected(ConversationContext<TPKTPacket> context, S7PayloadUserData payloadUserData) {
@@ -307,7 +307,7 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> implements Ha
             if (responseCode == PlcResponseCode.OK) {
                 fieldItem = parseFieldItem(field, data);
             }
-            Pair<PlcResponseCode, PlcValue> result = new ImmutablePair(responseCode, fieldItem);
+            Pair<PlcResponseCode, PlcValue> result = new ImmutablePair<>(responseCode, fieldItem);
             values.put(fieldName, result);
             index++;
         }
@@ -345,8 +345,10 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> implements Ha
             DataTransportSize transportSize = (field.getDataType().getDataProtocolId() == 1) ?
                 DataTransportSize.BIT : DataTransportSize.BYTE_WORD_DWORD;
             WriteBuffer writeBuffer = DataItemIO.serialize(plcValue, field.getDataType().getDataProtocolId());
-            byte[] data = writeBuffer.getData();
-            return new S7VarPayloadDataItem(DataTransportErrorCode.OK, transportSize, data.length, data);
+            if(writeBuffer != null) {
+                byte[] data = writeBuffer.getData();
+                return new S7VarPayloadDataItem(DataTransportErrorCode.OK, transportSize, data.length, data);
+            }
         } catch (ParseException e) {
             logger.warn(String.format("Error serializing field item of type: '%s'", field.getDataType().name()), e);
         }