You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by er...@apache.org on 2020/05/07 13:00:41 UTC

[plc4x] branch feature/scraper created (now 2ba6b70)

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

erobinet pushed a change to branch feature/scraper
in repository https://gitbox.apache.org/repos/asf/plc4x.git.


      at 2ba6b70  SCRAPER -used generic TRIGGER (previously S7) -prepareField now in the PlcDriver interface --> create PlcField without connecting to the PLC -Need to test with different PLCs type

This branch includes the following new commits:

     new 80767dd  Merge branch 'develop' into feature/osgi
     new 2ba6b70  SCRAPER -used generic TRIGGER (previously S7) -prepareField now in the PlcDriver interface --> create PlcField without connecting to the PLC -Need to test with different PLCs type

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.



[plc4x] 01/02: Merge branch 'develop' into feature/osgi

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

erobinet pushed a commit to branch feature/scraper
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 80767dd24162ca985e8d02003459cb3beae74c9d
Merge: 1a70894 c8748c3
Author: etiennerobinet <61...@users.noreply.github.com>
AuthorDate: Mon May 4 10:25:52 2020 +0200

    Merge branch 'develop' into feature/osgi

 RELEASE_NOTES                                      |  24 +-
 .../knxnetip/protocol/KnxNetIpProtocolLogic.java   |   2 +-
 plc4j/examples/dummy-driver/pom.xml                |   1 -
 plc4j/examples/hello-connectivity-mqtt/pom.xml     |   5 +
 plc4j/examples/hello-storage-elasticsearch/pom.xml |   1 -
 plc4j/examples/hello-webapp/pom.xml                |   1 -
 plc4j/examples/hello-webapp/webapp/README.adoc     |  41 +++
 plc4j/examples/hello-webapp/webapp/pom.xml         |  66 ++++-
 .../src/main/resources/application.properties      |   3 +-
 plc4j/examples/pom.xml                             |   3 +-
 .../spi/configuration/ConfigurationFactory.java    |  19 +-
 .../ConfigurationParameterConverter.java           |  44 ++++
 .../annotations/ParameterConverter.java            |  30 ++-
 plc4j/tools/capture-replay/pom.xml                 |   1 -
 .../rawsockets/netty/RawSocketChannelTest.java     |   2 +
 pom.xml                                            |   4 +-
 .../main/resources/protocols/amsads/amsads.mspec   |  20 +-
 sandbox/plc-simulator/pom.xml                      |   1 -
 sandbox/plc4c/CMakeLists.txt                       |   2 +-
 sandbox/plc4c/api/CMakeLists.txt                   |   3 +-
 sandbox/plc4c/api/src/main/include/plc4c.h         | 280 +++++++++++++++++++++
 .../plc4c/design-guidelines.adoc                   |  16 +-
 sandbox/plc4c/examples/hello-world/CMakeLists.txt  |   9 +-
 .../examples/hello-world/src/main/c/hello_world.c  |  71 ++++++
 sandbox/plc4c/spi/CMakeLists.txt                   |   7 +-
 sandbox/plc4c/spi/src/main/c/plc4c.c               | 100 ++++++++
 .../src/main/c/plc4c_private_types.c}              |  23 +-
 .../amsads/configuration/AdsConfiguration.java     |  26 ++
 src/main/script/prerequisiteCheck.groovy           |   8 +-
 src/site/asciidoc/developers/preparing/linux.adoc  |   2 +-
 .../asciidoc/developers/release/build-tools.adoc   |   9 +-
 src/site/asciidoc/developers/release/release.adoc  |  13 +-
 src/site/asciidoc/users/protocols/ads.adoc         |  34 +++
 src/site/asciidoc/users/protocols/bacnetip.adoc    |  44 ++++
 src/site/asciidoc/users/protocols/opc-ua.adoc      |  55 ++++
 35 files changed, 898 insertions(+), 72 deletions(-)


[plc4x] 02/02: SCRAPER -used generic TRIGGER (previously S7) -prepareField now in the PlcDriver interface --> create PlcField without connecting to the PLC -Need to test with different PLCs type

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

erobinet pushed a commit to branch feature/scraper
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 2ba6b7035f7b354cb0a809136efb56c575fc5b78
Merge: 80767dd 169f53b
Author: Etienne Robinet <et...@gmail.com>
AuthorDate: Wed May 6 08:27:04 2020 +0200

    SCRAPER
    -used generic TRIGGER (previously S7)
    -prepareField now in the PlcDriver interface --> create PlcField without connecting to the PLC
    -Need to test with different PLCs type

 .../java/org/apache/plc4x/java/api/PlcDriver.java  |  5 ++
 .../apache/plc4x/java/eip/readwrite/EIPDriver.java |  6 ++
 .../apache/plc4x/java/s7/readwrite/S7Driver.java   |  6 ++
 .../java/spi/connection/GeneratedDriverBase.java   |  1 +
 plc4j/tools/scraper/pom.xml                        | 12 ++++
 .../triggerhandler/TriggerConfiguration.java       | 43 ++++++++----
 src/site/asciidoc/users/protocols/ethernet-ip.adoc | 78 ++++++++++++++++++++++
 7 files changed, 138 insertions(+), 13 deletions(-)

diff --cc plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcDriver.java
index 9fda101,9fda101..c3f8d10
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcDriver.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcDriver.java
@@@ -20,6 -20,6 +20,8 @@@ package org.apache.plc4x.java.api
  
  import org.apache.plc4x.java.api.authentication.PlcAuthentication;
  import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
++import org.apache.plc4x.java.api.exceptions.PlcNotImplementedException;
++import org.apache.plc4x.java.api.model.PlcField;
  
  /**
   * General interface defining the minimal methods required for adding a new type of driver to the PLC4J system.
@@@ -57,4 -57,4 +59,7 @@@ public interface PlcDriver 
       */
      PlcConnection getConnection(String url, PlcAuthentication authentication) throws PlcConnectionException;
  
++    default PlcField prepareField(String query){
++        throw new PlcNotImplementedException("Not implemented for "+getProtocolName());
++    }
  }
diff --cc plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/EIPDriver.java
index a58aba0,e3433b2..727b489
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/EIPDriver.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/EIPDriver.java
@@@ -19,7 -19,8 +19,8 @@@
  package org.apache.plc4x.java.eip.readwrite;
  
  import io.netty.buffer.ByteBuf;
 -import org.apache.plc4x.java.api.PlcDriver;
  import org.apache.plc4x.java.eip.readwrite.configuration.EIPConfiguration;
++import org.apache.plc4x.java.eip.readwrite.field.EipField;
  import org.apache.plc4x.java.eip.readwrite.field.EipFieldHandler;
  import org.apache.plc4x.java.eip.readwrite.io.EipPacketIO;
  import org.apache.plc4x.java.eip.readwrite.protocol.EipProtocolLogic;
@@@ -102,4 -105,4 +103,9 @@@ public class EIPDriver extends Generate
          }
      }
  
++    @Override
++    public EipField prepareField(String query){
++        return EipField.of(query);
++    }
++
  }
diff --cc plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7Driver.java
index 01c4140,476c4c2..ff75659
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7Driver.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7Driver.java
@@@ -19,8 -19,9 +19,9 @@@ under the License
  package org.apache.plc4x.java.s7.readwrite;
  
  import io.netty.buffer.ByteBuf;
 -import org.apache.plc4x.java.api.PlcDriver;
  import org.apache.plc4x.java.s7.readwrite.configuration.S7Configuration;
  import org.apache.plc4x.java.s7.readwrite.context.S7DriverContext;
++import org.apache.plc4x.java.s7.readwrite.field.S7Field;
  import org.apache.plc4x.java.s7.readwrite.io.TPKTPacketIO;
  import org.apache.plc4x.java.s7.readwrite.optimizer.S7Optimizer;
  import org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic;
@@@ -110,4 -113,4 +111,9 @@@ public class S7Driver extends Generated
          }
      }
  
++    @Override
++    public S7Field prepareField(String query){
++        return S7Field.of(query);
++    }
++
  }
diff --cc plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java
index e201603,e201603..e855b4a
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java
@@@ -150,4 -150,4 +150,5 @@@ public abstract class GeneratedDriverBa
          throw new PlcConnectionException("Authentication not supported.");
      }
  
++
  }
diff --cc plc4j/tools/scraper/pom.xml
index 91a17d4,91a17d4..ce16973
--- a/plc4j/tools/scraper/pom.xml
+++ b/plc4j/tools/scraper/pom.xml
@@@ -101,6 -101,6 +101,18 @@@
        <version>0.7.0-SNAPSHOT</version>
        <scope>test</scope>
      </dependency>
++      <dependency>
++          <groupId>org.apache.plc4x</groupId>
++          <artifactId>plc4j-driver-s7</artifactId>
++          <version>0.7.0-SNAPSHOT</version>
++          <scope>compile</scope>
++      </dependency>
++      <dependency>
++          <groupId>org.apache.plc4x</groupId>
++          <artifactId>plc4j-driver-s7</artifactId>
++          <version>0.7.0-SNAPSHOT</version>
++          <scope>compile</scope>
++      </dependency>
    </dependencies>
  
    <build>
diff --cc plc4j/tools/scraper/src/main/java/org/apache/plc4x/java/scraper/triggeredscraper/triggerhandler/TriggerConfiguration.java
index f9b2cfd,f9b2cfd..7b64422
--- a/plc4j/tools/scraper/src/main/java/org/apache/plc4x/java/scraper/triggeredscraper/triggerhandler/TriggerConfiguration.java
+++ b/plc4j/tools/scraper/src/main/java/org/apache/plc4x/java/scraper/triggeredscraper/triggerhandler/TriggerConfiguration.java
@@@ -19,7 -19,7 +19,12 @@@
  
  package org.apache.plc4x.java.scraper.triggeredscraper.triggerhandler;
  
++import org.apache.plc4x.java.PlcDriverManager;
++import org.apache.plc4x.java.api.PlcConnection;
++import org.apache.plc4x.java.api.PlcDriver;
++import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
  import org.apache.plc4x.java.api.model.PlcField;
++import org.apache.plc4x.java.s7.readwrite.field.S7Field;
  import org.apache.plc4x.java.scraper.exception.ScraperConfigurationException;
  import org.apache.plc4x.java.scraper.exception.ScraperException;
  import org.apache.plc4x.java.scraper.triggeredscraper.TriggeredScrapeJobImpl;
@@@ -37,7 -37,7 +42,8 @@@ import java.util.regex.Pattern
  public class TriggerConfiguration{
      private static final Logger logger = LoggerFactory.getLogger(TriggerConfiguration.class);
  
--    private static final String S_7_TRIGGER_VAR = "S7_TRIGGER_VAR";
++    //private static final String S_7_TRIGGER_VAR = "S7_TRIGGER_VAR";
++    private static final String TRIGGER = "TRIGGER_VAR";
      private static final String SCHEDULED       = "SCHEDULED";
      private static final String PREVIOUS_DEF    = "PREV";
  
@@@ -375,23 -375,23 +381,25 @@@
              String comparatorVariable = matcher.group("compVar");
  
              switch (triggerStrategy){
--                case S_7_TRIGGER_VAR:
++                case TRIGGER:
  
                      if(triggerVar ==null || comparatorString==null || comparatorVariable==null){
--                        throw new ScraperConfigurationException("S7_TRIGGER_VAR trigger strategy needs the trigger-condition - information missing! given configString: "+jobTriggerStrategy);
++                        throw new ScraperConfigurationException("TRIGGER_VAR trigger strategy needs the trigger-condition - information missing! given configString: "+jobTriggerStrategy);
                      }
  
                      List<TriggerElement> triggerElements = new ArrayList<>();
  
++                    //TODO Change this (probably only 1 source to get the connection directly)
++                    String connectionString = triggeredScrapeJob.getSourceConnections().get(triggeredScrapeJob.getSourceConnections().keySet().iterator().next());
                      TriggerElement triggerElement = new TriggerElement(
                          comparatorString,
                          null,
                          comparatorVariable,
                          triggerVar,
--                        triggerStrategy);
++                        triggerStrategy,
++                        connectionString);
  
                      triggerElement.setTriggerJob(triggeredScrapeJob.getJobName());
--
                      triggerElements.add(triggerElement);
  
                      String concatConn = matcher.group("concatConn");
@@@ -405,7 -405,7 +413,8 @@@
                              concatConn,
                              comparatorVariable2,
                              triggerVar2,
--                            triggerStrategy);
++                            triggerStrategy,
++                            connectionString);
  
  
                          triggerElement2.setTriggerJob(triggeredScrapeJob.getJobName());
@@@ -472,7 -472,7 +481,8 @@@
      //ToDo replace constant TriggerType by more generic ones --> PLC4X-89
      public enum TriggerType {
          SCHEDULED,
--        S7_TRIGGER_VAR
++        S7_TRIGGER_VAR,
++        TRIGGER_VAR
      }
  
      public enum ConcatType {
@@@ -527,21 -527,21 +537,21 @@@
              this.plcField = plcField;
          }
  
--        TriggerElement(String comparator, String concatType, String compareValue, String plcField, String triggerStrategy) throws ScraperConfigurationException {
++        TriggerElement(String comparator, String concatType, String compareValue, String plcField, String triggerStrategy, String plcConnectionString) throws ScraperConfigurationException {
              this();
              this.plcFieldString = plcField;
              this.plcConnectionString = plcConnectionString;
--            if(triggerStrategy.equals(S_7_TRIGGER_VAR)){
--                // TODO: This really has to be cleaned up by using the connections prepareField method.
--                /*try {
--                    this.plcField = S7Field.of(this.plcFieldString);
++            if(triggerStrategy.equals(TRIGGER)){
++                try {
++                    //this.plcField = S7Field.of(this.plcFieldString);
++                    this.plcField = prepareField(plcFieldString);
                  }
                  catch (Exception e){
                      if(logger.isDebugEnabled()) {
                          logger.debug("Exception occurred parsing a S7Field");
                      }
                      throw new ScraperConfigurationException("Exception on parsing S7Field (" + plcField + "): " + e.getMessage());
--                }*/
++                }
                  this.compareValue = convertCompareValue(compareValue,this.plcField);
                  this.comparatorType = detectComparatorType(comparator);
                  matchTypeAndComparator();
@@@ -551,6 -551,6 +561,13 @@@
  
          }
  
++        //I used this because the prepareField method is deprecated with generated drivers
++        //So I need to create the field using the connection string here
++        private PlcField prepareField(String fieldQuery) throws PlcConnectionException {
++            PlcDriverManager driverManager = new PlcDriverManager();
++            PlcDriver driver = driverManager.getDriver(plcConnectionString);
++            return driver.prepareField(fieldQuery);
++        }
  
          /**
           * parses the ref-value to a given value, as well as checking if ref-value matches to the given data-type