You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by GitBox <gi...@apache.org> on 2020/09/10 10:40:23 UTC

[GitHub] [plc4x] hutcheb opened a new pull request #186: Feature/modbus data type

hutcheb opened a new pull request #186:
URL: https://github.com/apache/plc4x/pull/186


   Add support for BOOL, INT, UINT and REAL data types for the Modbus protocol.
   address string can now include any of these types such as:- holding-register:10:REAL[10], extended-register:10:UINT[10].
   Note the previous format now defaults to BOOL or INT depending on the memory area.
   
   Add support to parse values from Java Strings to any of these types. This fixes a bug in the hello-world example when writing.
   
   Add support for BOOL, INT, UINT and REAL PlcValue types. This have been added as we are able to include the max/min value checks and casting of the input type within the constructors cleaning up the ModbusFieldHandler logic. The method getBytes has also been added to clean up the ModbusProtocolLogic class.
   
   I'll add Documentation once the other Modbus Documentation PR has been finalized.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-691032464






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on a change in pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on a change in pull request #186:
URL: https://github.com/apache/plc4x/pull/186#discussion_r487711822



##########
File path: plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDINT.java
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.apache.plc4x.java.api.exceptions.PlcIncompatibleDatatypeException;
+
+import org.apache.plc4x.java.api.value.*;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.LinkedList;
+import java.util.List;
+
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
+public class PlcDINT extends PlcIECValue<Integer> {
+
+    BigInteger minValue = BigInteger.valueOf((long) Integer.MIN_VALUE);
+    BigInteger maxValue = BigInteger.valueOf((long) Integer.MAX_VALUE);

Review comment:
       Same as with PlcBOOL (And probably all others) 

##########
File path: plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBOOL.java
##########
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
+
+import org.apache.plc4x.java.api.value.*;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
+public class PlcBOOL extends PlcIECValue<Boolean> {
+
+    BigInteger minValue = BigInteger.valueOf(0);
+    BigInteger maxValue = BigInteger.valueOf(1);

Review comment:
       Could we perhaps make these static ... A BigInteger is a pretty big type and creating these for every boolean PlcValue seems wasting memory and CPU time for cleaning up.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz closed pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz closed pull request #186:
URL: https://github.com/apache/plc4x/pull/186


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-694150435


   Do you need any help from my side in order to continue? If yes, just reach out to me.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-695931480


   Hi Ben,
   
   will do so asap …
   
   Chris
   
   Von: hutcheb <no...@github.com>
   Antworten an: apache/plc4x <re...@reply.github.com>
   Datum: Samstag, 19. September 2020 um 13:30
   An: apache/plc4x <pl...@noreply.github.com>
   Cc: Christofer Dutz <ch...@c-ware.de>, Comment <co...@noreply.github.com>
   Betreff: Re: [apache/plc4x] Feature/modbus data type (#186)
   
   
   Hi Chris,
   
   This should be in a position for you to review.
   
   Ben
   
   —
   You are receiving this because you commented.
   Reply to this email directly, view it on GitHub<https://github.com/apache/plc4x/pull/186#issuecomment-695201928>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAE66YL4X6FWUSX3B2I2RYLSGSI5RANCNFSM4REYHRRQ>.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-696964288


   Hi Ben ... sorry for the late response ... I'm currently drowning in getting some stuff finished as well as preparing for ApacheCon next week ... I'll try to squeeze it in, but can't promise ... haven't forgotten you and your hard work ... just want to invest the time for reviewing, that your work deserves.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-691032464


   Hi Niclas,
   
   The plan is to add support for as many IEC 61131 data types as possible. I've added DINT as an example for what it would take to add additional data types but will wait for more feedback before adding more.
   
   Ben
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-696981490


   Hi Chris, not a problem take your time. :)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-696058599


   Hi,
   
   I was looking at starting to use the staticSerialize method for Modbus as it would reduce the fromPLCValue method. However there are a few methods in the WriteBuffer class that aren't implemented. writeDouble and the writeBigInteger functions. The writeDouble function in particular would cause issues with writing floats of any kind for all protocols that use it.
   
   Does writing floats with the S7 protocol work or am I missing something?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] niclash commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
niclash commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-690872320






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-698989556


   The PR #190 now contains all changes of this PR.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] niclash commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
niclash commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-690872320






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-691032464






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-696981490


   Hi Chris, not a problem take your time. :)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-696964288


   Hi Ben ... sorry for the late response ... I'm currently drowning in getting some stuff finished as well as preparing for ApacheCon next week ... I'll try to squeeze it in, but can't promise ... haven't forgotten you and your hard work ... just want to invest the time for reviewing, that your work deserves.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] niclash commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
niclash commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-690872320


   I have also seen 32-bit integers. Maybe it should be available too.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-696058599


   Hi,
   
   I was looking at starting to use the staticSerialize method for Modbus as it would reduce the fromPLCValue method. However there are a few methods in the WriteBuffer class that aren't implemented. writeDouble and the writeBigInteger functions. The writeDouble function in particular would cause issues with writing floats of any kind for all protocols that use it.
   
   Does writing floats with the S7 protocol work or am I missing something?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-694153946


   I have created all of the numeric datatypes and char and wchar types as well as updated the ModbusFieldHandler file.
   
   I'm just sorting out some issues this morning with how BigIntegers are converted to byte[] within the PlcULINT and PlcLWORD classes.
   
   By the end of my session this morning I should be in a position to start writing test cases in the Modbus section.
   
   I haven't touched the other drivers.
   
   I'll commit what I have when I've finished this morning next 15mins or so, feel free to carry on as I won't be touching it until tomorrow.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] chrisdutz commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
chrisdutz commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-695931480


   Hi Ben,
   
   will do so asap …
   
   Chris
   
   Von: hutcheb <no...@github.com>
   Antworten an: apache/plc4x <re...@reply.github.com>
   Datum: Samstag, 19. September 2020 um 13:30
   An: apache/plc4x <pl...@noreply.github.com>
   Cc: Christofer Dutz <ch...@c-ware.de>, Comment <co...@noreply.github.com>
   Betreff: Re: [apache/plc4x] Feature/modbus data type (#186)
   
   
   Hi Chris,
   
   This should be in a position for you to review.
   
   Ben
   
   —
   You are receiving this because you commented.
   Reply to this email directly, view it on GitHub<https://github.com/apache/plc4x/pull/186#issuecomment-695201928>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAE66YL4X6FWUSX3B2I2RYLSGSI5RANCNFSM4REYHRRQ>.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [plc4x] hutcheb commented on pull request #186: Feature/modbus data type

Posted by GitBox <gi...@apache.org>.
hutcheb commented on pull request #186:
URL: https://github.com/apache/plc4x/pull/186#issuecomment-695201928


   Hi Chris,
   
   This should be in a position for you to review.
   
   Ben


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org