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 2022/08/05 13:08:00 UTC

[plc4x] branch develop updated (5faa9e14a -> 7adec2930)

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

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


    from 5faa9e14a feat(plc4xbrowser): added first iteration of read support
     new f2b5ec0dc feat(plc4xbrowser): hook ctrl-c onto command input clear
     new 5af52b765 feat(plc4xbrowser): made read produce a proper message
     new 7adec2930 feat(plc-simulator/s7): support a alternate s7 port

The 3 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.


Summary of changes:
 plc4go/tools/plc4xbrowser/commands.go                     | 12 ++++++++----
 plc4go/tools/plc4xbrowser/ui.go                           | 15 ++++++++-------
 .../java/org/apache/plc4x/simulator/PlcSimulator.java     |  2 ++
 .../org/apache/plc4x/simulator/PlcSimulatorConfig.java    |  6 ++++++
 .../apache/plc4x/simulator/server/s7/S7ServerModule.java  |  6 +++++-
 5 files changed, 29 insertions(+), 12 deletions(-)


[plc4x] 01/03: feat(plc4xbrowser): hook ctrl-c onto command input clear

Posted by sr...@apache.org.
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

commit f2b5ec0dc1d9104a6410bfecdc4cc26fc887d179
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Aug 5 15:01:09 2022 +0200

    feat(plc4xbrowser): hook ctrl-c onto command input clear
---
 plc4go/tools/plc4xbrowser/ui.go | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/plc4go/tools/plc4xbrowser/ui.go b/plc4go/tools/plc4xbrowser/ui.go
index e79c55e52..f6401d32a 100644
--- a/plc4go/tools/plc4xbrowser/ui.go
+++ b/plc4go/tools/plc4xbrowser/ui.go
@@ -61,13 +61,6 @@ func setupApplication() *tview.Application {
 
 	application.SetRoot(grid, true).EnableMouse(true)
 
-	application.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
-		switch event.Key() {
-		case tcell.KeyCtrlC:
-			shutdown()
-		}
-		return event
-	})
 	return application
 }
 
@@ -139,6 +132,14 @@ func buildCommandArea(newPrimitive func(text string) tview.Primitive, applicatio
 		commandInputField := tview.NewInputField().
 			SetLabel("$").
 			SetFieldWidth(30)
+		application.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
+			switch event.Key() {
+			case tcell.KeyCtrlC:
+				commandInputField.SetText("")
+				return nil
+			}
+			return event
+		})
 		commandInputField.
 			SetDoneFunc(func(key tcell.Key) {
 				commandText := commandInputField.GetText()


[plc4x] 03/03: feat(plc-simulator/s7): support a alternate s7 port

Posted by sr...@apache.org.
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

commit 7adec29306c07da3679677751e3a7d7c7c710825
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Aug 5 15:07:53 2022 +0200

    feat(plc-simulator/s7): support a alternate s7 port
---
 .../src/main/java/org/apache/plc4x/simulator/PlcSimulator.java      | 2 ++
 .../main/java/org/apache/plc4x/simulator/PlcSimulatorConfig.java    | 6 ++++++
 .../java/org/apache/plc4x/simulator/server/s7/S7ServerModule.java   | 6 +++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulator.java b/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulator.java
index 579a3e209..d66d59da6 100644
--- a/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulator.java
+++ b/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulator.java
@@ -147,6 +147,7 @@ public class PlcSimulator {
         Options options = new Options();
 
         options.addOption("host", true, "display current time");
+        options.addOption("s7port", true, "changes the s7 port");
 
         // Parse args
         CommandLineParser parser = new DefaultParser();
@@ -154,6 +155,7 @@ public class PlcSimulator {
 
         // Map options
         config.host = cmd.getOptionValue("host", "localhost");
+        config.s7Port = cmd.getOptionValue("s7port");
 
         return config;
     }
diff --git a/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulatorConfig.java b/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulatorConfig.java
index 5a1fcc253..2879d571e 100644
--- a/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulatorConfig.java
+++ b/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/PlcSimulatorConfig.java
@@ -21,7 +21,13 @@ package org.apache.plc4x.simulator;
 public class PlcSimulatorConfig {
     String host;
 
+    String s7Port;
+
     public String getHost() {
         return host;
     }
+
+    public String getS7Port() {
+        return s7Port;
+    }
 }
diff --git a/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/s7/S7ServerModule.java b/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/s7/S7ServerModule.java
index c57646521..f3bdacf3f 100644
--- a/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/s7/S7ServerModule.java
+++ b/sandbox/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/s7/S7ServerModule.java
@@ -87,7 +87,11 @@ public class S7ServerModule implements ServerModule {
                 }).option(ChannelOption.SO_BACKLOG, 128)
                 .childOption(ChannelOption.SO_KEEPALIVE, true);
 
-            bootstrap.bind(config.getHost(),ISO_ON_TCP_PORT).sync();
+            int port = ISO_ON_TCP_PORT;
+            if (config.getS7Port() != null) {
+                port = Integer.parseInt(config.getS7Port());
+            }
+            bootstrap.bind(config.getHost(), port).sync();
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
             throw new SimulatorException(e);


[plc4x] 02/03: feat(plc4xbrowser): made read produce a proper message

Posted by sr...@apache.org.
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

commit 5af52b7652e823ddd2604848a40ecae3c126e2dd
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Aug 5 15:07:32 2022 +0200

    feat(plc4xbrowser): made read produce a proper message
---
 plc4go/tools/plc4xbrowser/commands.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/plc4go/tools/plc4xbrowser/commands.go b/plc4go/tools/plc4xbrowser/commands.go
index bec0d764b..b0a2132bc 100644
--- a/plc4go/tools/plc4xbrowser/commands.go
+++ b/plc4go/tools/plc4xbrowser/commands.go
@@ -134,6 +134,7 @@ var rootCommand = Command{
 				if connection, ok := connections[connectionsString]; !ok {
 					return errors.Errorf("%s not connected", connectionsString)
 				} else {
+					start := time.Now()
 					readRequest, err := connection.ReadRequestBuilder().
 						AddQuery("readField", split[1]).
 						Build()
@@ -144,7 +145,12 @@ var rootCommand = Command{
 					if err := readRequestResult.GetErr(); err != nil {
 						return errors.Wrapf(err, "%s can't read", connectionsString)
 					}
-					log.Info().Msgf("read result %s", readRequestResult.GetResponse())
+					plc4xBrowserLog.Debug().Msgf("read took %f seconds", time.Now().Sub(start).Seconds())
+					if err := readRequestResult.GetErr(); err != nil {
+						return errors.Wrapf(err, "%s error reading", connectionsString)
+					}
+					numberOfMessagesReceived++
+					messageReceived(numberOfMessagesReceived, time.Now(), readRequestResult.GetResponse())
 				}
 				return nil
 			},
@@ -228,9 +234,7 @@ var rootCommand = Command{
 						AddEventQuery("subscriptionField", split[1]).
 						AddItemHandler(func(event model.PlcSubscriptionEvent) {
 							numberOfMessagesReceived++
-							start := time.Now()
-							messageReceived(numberOfMessagesReceived, start, event)
-							plc4xBrowserLog.Debug().Msgf("write took %f seconds", time.Now().Sub(start).Seconds())
+							messageReceived(numberOfMessagesReceived, time.Now(), event)
 						}).
 						Build()
 					if err != nil {