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

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/plc4x-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new efd01ae  Site checkin for project PLC4X: Jenkins Tools
efd01ae is described below

commit efd01aeca4aec4cb402d53111eff9b83a29b76b7
Author: jenkins <[email protected]>
AuthorDate: Mon Jul 6 09:14:31 2020 +0000

    Site checkin for project PLC4X: Jenkins Tools
---
 licenses.html            | 205 +++++++++++++++++++++++++++++++++++-
 users/tools/scraper.html | 265 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 469 insertions(+), 1 deletion(-)

diff --git a/licenses.html b/licenses.html
index 6a40223..12be9f0 100644
--- a/licenses.html
+++ b/licenses.html
@@ -119,7 +119,210 @@
 <p>Typically the licenses listed for the project are that of the project 
itself, and not of dependencies.</p></section><section>
 <h2><a name="Project_Licenses"></a>Project Licenses</h2><a 
name="Project_Licenses"></a><section>
 <h3><a name="Apache_License.2C_Version_2.0"></a>Apache License, Version 
2.0</h3><a name="Apache_License.2C_Version_2.0"></a>
-<p>Can't read the url [https://www.apache.org/licenses/LICENSE-2.0.txt] : 
connect timed out</p></section></section>
+<div class="source">
+<pre>
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      &quot;License&quot; shall mean the terms and conditions for use, 
reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      &quot;Licensor&quot; shall mean the copyright owner or entity authorized 
by
+      the copyright owner that is granting the License.
+
+      &quot;Legal Entity&quot; shall mean the union of the acting entity and 
all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      &quot;control&quot; means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      &quot;You&quot; (or &quot;Your&quot;) shall mean an individual or Legal 
Entity
+      exercising permissions granted by this License.
+
+      &quot;Source&quot; form shall mean the preferred form for making 
modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      &quot;Object&quot; form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      &quot;Work&quot; shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      &quot;Derivative Works&quot; shall mean any work, whether in Source or 
Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      &quot;Contribution&quot; shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, 
&quot;submitted&quot;
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as &quot;Not a 
Contribution.&quot;
+
+      &quot;Contributor&quot; shall mean Licensor and any individual or Legal 
Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a &quot;NOTICE&quot; text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an &quot;AS IS&quot; BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets &quot;[]&quot;
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same &quot;printed page&quot; as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+   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 &quot;AS IS&quot; 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.
+</pre></div></section></section>
         </main>
         <footer class="pt-4 my-md-5 pt-md-5 w-100 border-top">
             <div class="row justify-content-md-center" style="font-size: 13px">
diff --git a/users/tools/scraper.html b/users/tools/scraper.html
index aa8ac8e..029ec48 100644
--- a/users/tools/scraper.html
+++ b/users/tools/scraper.html
@@ -268,7 +268,272 @@
             <div class="sect1">
 <h2 id="scraper">Scraper</h2>
 <div class="sectionbody">
+<div class="paragraph">
+<p>While the Apache PLC4X API allows simple access to PLC resources, if you 
want to continuously monitor some values and have them retrieved in a 
pre-defined interval, the core PLC4X API method is a little bit 
uncomfortable.</p>
+</div>
+<div class="paragraph">
+<p>Especially when you have multiple batches of data you want to have 
refreshed in different intervals.</p>
+</div>
+<div class="paragraph">
+<p>In this case you need to take care of the scheduling of queries, need to 
manage the connection state (Check if the connection is still available and to 
apply countermeasures, if there are problems)</p>
+</div>
+<div class="paragraph">
+<p>As we have encountered exactly the same problem for about every integration 
module we created, the Apache PLC4X team has created a tool called the 
<code>Scraper</code>.</p>
+</div>
+<div class="paragraph">
+<p>This tool automatically handles all of the tasks mentioned above.</p>
+</div>
+<div class="sect2">
+<h3 id="getting_started_with_the_scraper">Getting started with the 
<code>Scraper</code></h3>
+<div class="paragraph">
+<p>In general, you need 3 parts to work with the <code>Scraper</code>:</p>
+</div>
+<div class="paragraph">
+<p>1) A <code>Scraper</code> Configuration
+2) A <code>Scraper</code> Implementation
+3) A Handler to handle the results of <code>Scraper</code> jobs</p>
+</div>
+<div class="paragraph">
+<p>In the <code>Scraper</code> Configuration you define the so-called 
<code>jobs</code>.</p>
+</div>
+<div class="sect3">
+<h4 id="sources">Sources</h4>
+<div class="paragraph">
+<p>Sources define connections to PLCs using PLC4X drivers.</p>
+</div>
+<div class="paragraph">
+<p>Generally you can think of a <code>Source</code> as a PLC4X connection 
string, given an alias name.</p>
+</div>
+</div>
+<div class="sect3">
+<h4 id="jobs">Jobs</h4>
+<div class="paragraph">
+<p>A <code>Job</code> defines which resources (PLC Addresses) should be 
collected from which <code>Sources</code> with a given <code>Trigger</code>.</p>
+</div>
+<div class="paragraph">
+<p>All resources in a job will be collected as a batch.</p>
+</div>
+<div class="paragraph">
+<p>Generally multiple types of triggers could theoretically be supported, but 
for now only a time triggered job (Aka <code>SCHEDULED</code>) is actually 
supported.</p>
+</div>
+<div class="paragraph">
+<p>In the near future we&#8217;re hoping that we will be able to support:
+- External triggers
+- Triggering collection based upon PLC-values</p>
+</div>
+<div class="paragraph">
+<p>But, as to now, this has not been implemented yet.</p>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="configuration_using_the_java_api">Configuration using the Java API</h3>
+<div class="paragraph">
+<p>The core of the Scraper configuration is the 
<code>ScraperConfigurationTriggeredImplBuilder</code> class.
+Use this to build the configuration objects used to bootstrap the Scraper.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>ScraperConfigurationTriggeredImplBuilder builder = new 
ScraperConfigurationTriggeredImplBuilder();</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>As soon as you have your <code>builder</code> instance, you should add at 
least one <code>source</code> to it.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>builder.addSource({connectionName}, {plc4xConnectionString});</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>connectionName</code> will be what we use when configuring the 
job to reference which source it should use to collect.</p>
+</div>
+<div class="paragraph">
+<p>In order to configure a <code>job</code> we have to get an instance of a 
<code>JobConfigurationTriggeredImplBuilder</code>.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>JobConfigurationTriggeredImplBuilder jobBuilder = builder.job({jobName}, 
{triggerCommand});</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This creates a new <code>job</code> with a given name which is executed 
based on the information in the <code>triggerCommand</code>.</p>
+</div>
+<div class="paragraph">
+<p>As mentioned above, we currently only support a time-scheduled 
collection.</p>
+</div>
+<div class="paragraph">
+<p>This genrally just requires one parameter: The number of 
<code>milliseconds</code> between each collection.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>SCHEDULED:1000</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Above would schedule a collection every 1000ms - so once every second.</p>
+</div>
+<div class="paragraph">
+<p>Up to now this job would not be run anywhere, and it would also not collect 
anything.
+So in order to have the job actually do something, we should assign it a 
<code>source</code> to collect from.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>jobBuilder.source({connectionName});</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here we could theoretically collect on multiple sources, by simply calling 
the <code>source()</code> method multiple times.</p>
+</div>
+<div class="paragraph">
+<p>All sources would be collected at the same time, whenever the trigger tells 
it to.</p>
+</div>
+<div class="paragraph">
+<p>So the last thing we need to configure our first <code>Scraper</code> job, 
is to add a few fields for it to collect.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>jobBuilder.field({fieldName}, {fieldAddress});</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>field</code> method has to be called for every field we want to 
add to the current job configuration.
+It gives a PLC4X address string an easy to understand string name, just like 
when using the core PLC4X API.</p>
+</div>
+<div class="paragraph">
+<p>As soon as we&#8217;re done adding fields, we configure the job by calling 
the <code>build</code> method.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>jobBuilder.build();</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This configures the finished job and attaches that to the overall 
<code>Scraper</code> configuration of the scraper configuration.</p>
+</div>
+<div class="paragraph">
+<p>As soon as we&#8217;re done configuring jobs, we need to create the 
<code>Scraper</code> configuration by calling the <code>buiold</code> method on 
the <code>builder</code>:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>ScraperConfigurationTriggeredImpl scraperConfig = builder.build();</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="running_the_scraper">Running the <code>Scraper</code></h3>
+<div class="paragraph">
+<p>In order to run the <code>Scraper</code>, the following boilerplate code is 
needed.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>       try {
+            PlcDriverManager plcDriverManager = new PooledPlcDriverManager();
+            TriggerCollector triggerCollector = new 
TriggerCollectorImpl(plcDriverManager);
+            TriggeredScraperImpl scraper = new 
TriggeredScraperImpl(scraperConfig, (jobName, sourceName, results) -&gt; {
+
+                ...
 
+            }, triggerCollector);
+            scraper.start();
+            triggerCollector.start();
+        } catch (ScraperException e) {
+            log.error("Error starting the scraper", e);
+        }</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>At first a new <code>PooledPlcDriverManager</code> is created (It actually 
doesn&#8217;t have to be the pooled version, but we strongly suggest you use it 
as for some protocols the connection process is stressfull for the connected 
PLC).</p>
+</div>
+<div class="paragraph">
+<p>With this <code>plcDriverManager</code> we can then create a so-called 
<code>TriggerCollector</code>, which we pass in the driver manager as 
argument.</p>
+</div>
+<div class="paragraph">
+<p>Next comes the probably most important part: We configure the scraper, by 
binding a <code>Scraper Configuration</code>, a <code>ResultHandler</code> and 
a <code>TriggerCollector</code> together.</p>
+</div>
+<div class="paragraph">
+<p>After this, the scraper is ready to start, which is then done by calling 
<code>start</code> on the <code>scraper</code> as well as the 
<code>triggerCollector</code>.</p>
+</div>
+<div class="paragraph">
+<p>For the sake of clarity, here comes the definition of the 
<code>ResultHandler</code> interface:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>@FunctionalInterface
+public interface ResultHandler {
+
+    /**
+     * Callback handler.
+     * @param jobName name of the job (from config)
+     * @param connectionName alias of the connection (&lt;b&gt;not&lt;/b&gt; 
connection String)
+     * @param results Results in the form alias to result value
+     */
+    void handle(String jobName, String connectionName, Map&lt;String, 
Object&gt; results);
+
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="configuration_using_a_json_or_yaml_file">Configuration using a 
<code>JSON</code> or <code>YAML</code> file</h3>
+<div class="paragraph">
+<p>As an alternative to using the Java API, the Scraper Configuration can also 
be read from a <code>JSON</code> or <code>YAML</code> document.</p>
+</div>
+<div class="paragraph">
+<p>Here come some examples:</p>
+</div>
+<div class="paragraph">
+<p>JSON:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>{
+    "sources": {
+        "connectionName": "connectionString"
+    },
+    "jobs": [
+        {
+            "name": "jobName",
+            "triggerConfig": (SCHEDULED,10000)
+            "sources": [
+                "connectionName"
+            ],
+            "fields": {
+                "a": "{address-a}",
+                "b": "{address-b}"
+            }
+        }
+    ]
+}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>YAML:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>---
+sources:
+  connectionName: connectionString
+jobs:
+  - name: jobName
+    triggerConfig: (SCHEDULED,10000)
+    sources:
+      - connectionName
+    fields:
+      a: {address-a}
+      b: {address-b}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In both cases, you can create the <code>ScraperConfiguration</code> with 
the following code:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>ScraperConfiguration conf = ScraperConfiguration.fromFile("{path to the 
JSON or YAML file}", ScraperConfigurationTriggeredImpl.class);</pre>
+</div>
+</div>
+</div>
 </div>
 </div>
         </main>

Reply via email to