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 6ad5e84fe Site checkin for project PLC4X: Jenkins Tools
6ad5e84fe is described below
commit 6ad5e84feeda941546450858f4d6b2c3464f6b33
Author: jenkins <[email protected]>
AuthorDate: Wed Oct 11 19:04:15 2023 +0000
Site checkin for project PLC4X: Jenkins Tools
---
users/getting-started/plc4j.html | 101 +++++----------------------------------
1 file changed, 11 insertions(+), 90 deletions(-)
diff --git a/users/getting-started/plc4j.html b/users/getting-started/plc4j.html
index 1456a0154..85b344221 100644
--- a/users/getting-started/plc4j.html
+++ b/users/getting-started/plc4j.html
@@ -333,13 +333,13 @@ However, in order to actually connect to a device using a
given protocol, you ne
</div>
<div class="paragraph">
<p>So as soon as your project has the API and a driver implementation
available, you first need to get a <code>PlcConnection</code> instance.
-This is done via the <code>PlcDriverManager</code> by asking this to create an
instance for a given <code>PLC4X connection string</code>.</p>
+This is done via the <code>PlcConnectionManager</code>, which is provided to
you by the <code>PlcDriverManager</code> by asking this to create an instance
for a given <code>PLC4X connection string</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>String connectionString = "s7://10.10.64.20";
-try (PlcConnection plcConnection = new
PlcDriverManager().getConnection(connectionString)) {
+try (PlcConnection plcConnection =
PlcDriverManager.getDefault().getConnectionManager().getConnection(connectionString))
{
... do something with the connection here ...
@@ -411,15 +411,18 @@ This is done by getting a
<code>PlcReadRequest.Builder</code>:</p>
<pre>// Create a new read request:
// - Give the single item requested an alias name
PlcReadRequest.Builder builder = plcConnection.readRequestBuilder();
-builder.addItem("value-1", "%Q0.4:BOOL");
-builder.addItem("value-2", "%Q0:BYTE");
-builder.addItem("value-3", "%I0.2:BOOL");
-builder.addItem("value-4", "%DB.DB1.4:INT");
+builder.addTagAddress("value-1", "%Q0.4:BOOL");
+builder.addTagAddress("value-2", "%Q0:BYTE");
+builder.addTagAddress("value-3", "%I0.2:BOOL");
+builder.addTagAddress("value-4", "%DB.DB1.4:INT");
PlcReadRequest readRequest = builder.build();</pre>
</div>
</div>
<div class="paragraph">
-<p>So, as you can see, you prepare a request, by adding items to the request
and in the end by calling the <code>build</code> method.</p>
+<p>So, as you can see, you prepare a request, by adding tag addresses to the
request and in the end by calling the <code>build</code> method.</p>
+</div>
+<div class="paragraph">
+<p>If you are using the <code>BrowseApi</code> you might also have been
provided with <code>Tag</code> objects. In that case simply use
<code>addTag</code> and pass in the <code>Tag</code> object instead of the
address string.</p>
</div>
<div class="paragraph">
<p>The request is sent to the PLC by issuing the <code>execute</code> method
on the request object:</p>
@@ -437,7 +440,7 @@ asyncResponse.whenComplete((response, throwable) -> {
</div>
</div>
<div class="paragraph">
-<p>In general all requests are executed asynchronously.
+<p>In general, all requests are executed asynchronously.
As soon as the request is fully processed, the callback gets called and will
contain a <code>readResponse</code>, if everything went right or a
<code>throwable</code> if there were problems.</p>
</div>
<div class="paragraph">
@@ -455,32 +458,6 @@ As soon as the request is fully processed, the callback
gets called and will con
<p>The following example will demonstrate some of the options you have:</p>
</div>
<div class="listingblock">
-<div class="title">Up to version 0.10.0</div>
-<div class="content">
-<pre>for (String fieldName : response.getFieldNames()) {
- if(response.getResponseCode(fieldName) == PlcResponseCode.OK) {
- int numValues = response.getNumberOfValues(fieldName);
- // If it's just one element, output just one single line.
- if(numValues == 1) {
- logger.info("Value[" + fieldName + "]: " +
response.getObject(fieldName));
- }
- // If it's more than one element, output each in a single row.
- else {
- logger.info("Value[" + fieldName + "]:");
- for(int i = 0; i < numValues; i++) {
- logger.info(" - " + response.getObject(fieldName, i));
- }
- }
- }
- // Something went wrong, to output an error message instead.
- else {
- logger.error("Error[" + fieldName + "]: " +
response.getResponseCode(fieldName).name());
- }
-}</pre>
-</div>
-</div>
-<div class="listingblock">
-<div class="title">SNAPSHOT version (The general process is still the same we
however cleaned up some naming)</div>
<div class="content">
<pre>for (String tagName : response.getTagNames()) {
if(response.getResponseCode(tagName) == PlcResponseCode.OK) {
@@ -582,20 +559,6 @@ if (!plcConnection.getMetadata().canWrite()) {
<p>As soon as we are sure that we can write, we create a new
<code>PlcWriteRequest.Builder</code>:</p>
</div>
<div class="listingblock">
-<div class="title">Up to version 0.10.0</div>
-<div class="content">
-<pre>// Create a new write request:
-// - Give the single item requested an alias name
-// - Pass in the data you want to write (for arrays, pass in one value for
every element)
-PlcWriteRequest.Builder builder = plcConnection.writeRequestBuilder();
-builder.addItem("value-1", "%Q0.4:BOOL", true);
-builder.addItem("value-2", "%Q0:BYTE", (byte) 0xFF);
-builder.addItem("value-4", "%DB.DB1.4:INT[3]", 7, 23, 42);
-PlcWriteRequest writeRequest = builder.build();</pre>
-</div>
-</div>
-<div class="listingblock">
-<div class="title">SNAPSHOT version</div>
<div class="content">
<pre>// Create a new write request:
// - Give the single item requested an alias name
@@ -630,21 +593,6 @@ asyncResponse.whenComplete((response, throwable) -> {
<p>As we don’t have to process the data itself, for the write request,
it’s enough to simply check the return code for each field.</p>
</div>
<div class="listingblock">
-<div class="title">Up to version 0.10.0</div>
-<div class="content">
-<pre>for (String fieldName : response.getFieldNames()) {
- if(response.getResponseCode(fieldName) == PlcResponseCode.OK) {
- logger.info("Value[" + fieldName + "]: updated");
- }
- // Something went wrong, to output an error message instead.
- else {
- logger.error("Error[" + fieldName + "]: " +
response.getResponseCode(fieldName).name());
- }
-}</pre>
-</div>
-</div>
-<div class="listingblock">
-<div class="title">SNAPSHOT version (The general process is still the same we
however cleaned up some naming)</div>
<div class="content">
<pre>for (String tagName : response.getTagNames()) {
if(response.getResponseCode(tagName) == PlcResponseCode.OK) {
@@ -698,19 +646,6 @@ if (!plcConnection.getMetadata().canSubscribe()) {
<p>Therefore instead of using a normal <code>addItem</code> or
<code>addTag</code> in newer versions, there are tree different methods as you
can see in the following examples.</p>
</div>
<div class="listingblock">
-<div class="title">Up to version 0.10.0</div>
-<div class="content">
-<pre>// Create a new subscription request:
-// - Give the single item requested an alias name
-PlcSubscriptionRequest.Builder builder =
plcConnection.subscriptionRequestBuilder();
-builder.addChangeOfStateField("value-1", "{some address}");
-builder.addCyclicField("value-2", "{some address}", Duration.ofMillis(1000));
-builder.addEventField("value-3", "{some alarm address}");
-PlcSubscriptionRequest subscriptionRequest = builder.build();</pre>
-</div>
-</div>
-<div class="listingblock">
-<div class="title">SNAPSHOT version</div>
<div class="content">
<pre>// Create a new subscription request:
// - Give the single tag requested an alias name
@@ -749,20 +684,6 @@ The
<code>addCyclicField</code>/<code>addCyclicTagAddress</code> method requires
So it is double important to check or iterate over the field names.</p>
</div>
<div class="listingblock">
-<div class="title">Up to version 0.10.0</div>
-<div class="content">
-<pre>for (String subscriptionName : response.getFieldNames()) {
- final PlcSubscriptionHandle subscriptionHandle =
response.getSubscriptionHandle(subscriptionName);
- subscriptionHandle.register(plcSubscriptionEvent -> {
- for (String fieldName : plcSubscriptionEvent.getFieldNames()) {
- System.out.println(plcSubscriptionEvent.getPlcValue(fieldName));
- }
- });
-}</pre>
-</div>
-</div>
-<div class="listingblock">
-<div class="title">SNAPSHOT version</div>
<div class="content">
<pre>for (String subscriptionName : response.getFieldNames()) {
final PlcSubscriptionHandle subscriptionHandle =
response.getSubscriptionHandle(subscriptionName);