You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2021/04/21 18:12:09 UTC

[plc4x] branch develop updated: plc4site: update the plc4go getting started to use the builder pattern

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

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new c3c877a  plc4site: update the plc4go getting started to use the builder pattern
c3c877a is described below

commit c3c877a8ea8700a81ca8a4941ea3eba80e27683d
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Apr 21 20:11:33 2021 +0200

    plc4site: update the plc4go getting started to use the builder pattern
---
 .../asciidoc/users/getting-started/plc4go.adoc     | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/site/asciidoc/users/getting-started/plc4go.adoc b/src/site/asciidoc/users/getting-started/plc4go.adoc
index 1ed7b91..e3bd188 100644
--- a/src/site/asciidoc/users/getting-started/plc4go.adoc
+++ b/src/site/asciidoc/users/getting-started/plc4go.adoc
@@ -35,7 +35,7 @@ This should look like this:
 ```
 module main
 
-go 1.14
+go 1.16
 ```
 
 Now we need to create a `app.go` file which will be our main program.
@@ -162,10 +162,10 @@ In order to create and run such a `PlcReadRequest`, please add the following cod
 
 ----
 	// Prepare a read-request
-	readRequestBuilder := connection.ReadRequestBuilder()
-	readRequestBuilder.AddItem("field1", "holding-register:1:REAL")
-	readRequestBuilder.AddItem("field2", "holding-register:3:REAL")
-	readRequest, err := readRequestBuilder.Build()
+	readRequest, err := connection.ReadRequestBuilder().
+	    AddItem("field1", "holding-register:1:REAL").
+	    AddItem("field2", "holding-register:3:REAL").
+        Build()
 	if err != nil {
 		t.Errorf("error preparing read-request: %s", connectionResult.Err.Error())
 		t.Fail()
@@ -237,12 +237,12 @@ Therefore instead of using a normal `AddItem`, there are tree different function
 
 ----
 	// Prepare a subscription-request
-    subscriptionRequestBuilder := connection.SubscriptionRequestBuilder()
-    subscriptionRequestBuilder.AddChangeOfStateItem("heating-actual-temperature", "*/*/10:DPT_Value_Temp")
-    subscriptionRequestBuilder.AddChangeOfStateItem("heating-target-temperature", "*/*/11:DPT_Value_Temp")
-    subscriptionRequestBuilder.AddCyclicItem("heating-valve-open", "*/*/12:DPT_OpenClose", 500 * time.Millisecond)
-    subscriptionRequestBuilder.AddItemHandler(knxEventHandler)
-    subscriptionRequest, err := subscriptionRequestBuilder.Build()
+    subscriptionRequest, err := connection.SubscriptionRequestBuilder().
+        AddChangeOfStateItem("heating-actual-temperature", "*/*/10:DPT_Value_Temp").
+        AddChangeOfStateItem("heating-target-temperature", "*/*/11:DPT_Value_Temp").
+        AddCyclicItem("heating-valve-open", "*/*/12:DPT_OpenClose", 500 * time.Millisecond).
+        AddItemHandler(knxEventHandler).
+        Build()
     if err != nil {
 	    fmt.Printf("Error preparing subscription-request: %s", connectionResult.Err.Error())
         return