This is an automated email from the ASF dual-hosted git repository. sruehl pushed a commit to branch refactoring/java_generify in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit 78780b9237d845fe66735fd7dba2cf636b26400b Merge: d4fdb5b fe4b740 Author: Sebastian Rühl <sru...@apache.org> AuthorDate: Thu Jan 4 09:59:17 2018 +0100 Merge remote-tracking branch 'origin/master' into refactoring/java_generify # Conflicts: # integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java # plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java .gitignore | 1 + .../apache/plc4x/edgent/PlcConnectionAdapter.java | 2 +- .../plc4x/java/isotp/netty/IsoTPProtocol.java | 25 +- .../plc4x/java/s7/connection/S7PlcConnection.java | 2 +- .../plc4x/java/s7/netty/Plc4XS7Protocol.java | 12 +- .../org/apache/plc4x/java/s7/netty/S7Protocol.java | 2 +- .../plc4x/java/isotp/netty/IsoTPProtocolTest.java | 362 ++++++++++++++++++++- .../apache/plc4x/java/isotp/netty/MockChannel.java | 225 +++++++++++++ .../isotp/netty/MockChannelHandlerContext.java | 216 ++++++++++++ .../java/isotp/netty/MockChannelPipeline.java | 336 +++++++++++++++++++ .../apache/plc4x/java/s7/S7PlcReaderSample.java | 2 +- .../org/apache/plc4x/java/s7/S7PlcScanner.java | 2 +- .../org/apache/plc4x/java/s7/S7PlcTestConsole.java | 2 +- .../apache/plc4x/java/s7/S7PlcWriterSample.java | 2 +- sonar-project.properties | 29 ++ src/site/asciidoc/development/building.adoc | 82 +++++ 16 files changed, 1286 insertions(+), 16 deletions(-) diff --cc integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java index 1a91c26,2bff661..ab55af8 --- a/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java +++ b/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java @@@ -53,17 -53,17 +53,17 @@@ import java.util.Calendar * support for multiple connections from a single client. * <p> * A single PlcConnectionAdapter can be used by multiple threads concurrently - * (e.g., used by multiple PlcFunctions Consumers for {@code Topology.poll()} and/or - * multiple Suppliers for {@code TStream.sink()}). - * + * (e.g., used by multiple PlcFunctions Consumers for {@code Topology.poll()} and/or + * multiple Suppliers for {@code TStream.sink()}). + * * @see PlcFunctions */ -public class PlcConnectionAdapter implements AutoCloseable{ +public class PlcConnectionAdapter implements AutoCloseable { - private final static Logger logger = LoggerFactory.getLogger(PlcConnectionAdapter.class); - private static final Logger logger = LoggerFactory.getLogger(PlcConnectionAdapter.class); - - private String plcConnectionUrl; - private PlcConnection plcConnection; ++ private static final Logger logger = LoggerFactory.getLogger(PlcConnectionAdapter.class); + + private String plcConnectionUrl; + private PlcConnection plcConnection; /* * NOTES: diff --cc plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java index 09eea8f,d234a46..ad46f53 --- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java +++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java @@@ -294,13 -293,13 +294,13 @@@ public class Plc4XS7Protocol extends Me Class valueType = values[0].getClass(); if (valueType == Boolean.class) { // TODO: Check if this is true and the result is not Math.ceil(values.lenght / 8) - result = new byte[values.length * 1]; + result = new byte[values.length]; - for(int i = 0; i < values.length; i++) { + for (int i = 0; i < values.length; i++) { result[i] = (byte) (((Boolean) values[i]) ? 0x01 : 0x00); } } else if (valueType == Byte[].class) { - result = new byte[values.length * 1]; + result = new byte[values.length]; - for(int i = 0; i < values.length; i++) { + for (int i = 0; i < values.length; i++) { result[i] = (byte) values[i]; } } else if (valueType == Short.class) { @@@ -355,22 -354,21 +355,22 @@@ return ResponseCode.INTERNAL_ERROR; } - private List<Object> decodeData(Class<?> datatype, byte[] s7Data) throws PlcProtocolException { - if(s7Data.length == 0) { + @SuppressWarnings("unchecked") - private <T> List<T> decodeData(Class<T> datatype, byte[] s7Data) { ++ private <T> List<T> decodeData(Class<T> datatype, byte[] s7Data) throws PlcProtocolException { + if (s7Data.length == 0) { return null; } List<Object> result = new LinkedList<>(); - for (int i = 0; i < s7Data.length; i++) { - for(int i = 0; i < s7Data.length;) { ++ for (int i = 0; i < s7Data.length;) { if (datatype == Boolean.class) { result.add((s7Data[i] & 0x01) == 0x01); - i+=1; + i += 1; } else if (datatype == Byte.class) { result.add(s7Data[i]); - i+=1; + i += 1; } else if (datatype == Short.class) { - result.add((short) (((s7Data[i] & 0xff) << 8) | (s7Data[i+1] & 0xff))); - i+=2; + result.add((short) (((s7Data[i] & 0xff) << 8) | (s7Data[i + 1] & 0xff))); + i += 2; } else if (datatype == Integer.class) { result.add((((s7Data[i] & 0xff) << 24) | ((s7Data[i + 1] & 0xff) << 16) | ((s7Data[i + 2] & 0xff) << 8) | (s7Data[i + 3] & 0xff))); @@@ -382,10 -380,12 +382,12 @@@ int intValue = (((s7Data[i] & 0xff) << 24) | ((s7Data[i + 1] & 0xff) << 16) | ((s7Data[i + 2] & 0xff) << 8) | (s7Data[i + 3] & 0xff)); result.add(Float.intBitsToFloat(intValue)); - i+=4; + i += 4; + } else { + throw new PlcProtocolException("Unsupported datatype " + datatype.getSimpleName()); } } - return result; + return (List<T>) result; } } -- To stop receiving notification emails like this one, please contact "commits@plc4x.apache.org" <commits@plc4x.apache.org>.