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 2023/06/15 13:41:31 UTC
[plc4x] branch develop updated (4b4794311b -> 2ca899206f)
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 4b4794311b test(plc4go/cbus): add some wait time till dispatching mmi segments
new c12edf33d6 fix(plc4go/cbus): handle pre registered consumers
new 2ca899206f test(plc4go/spi): add env var to enable high precision timestamps
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.
Summary of changes:
plc4go/internal/ads/Subscriber.go | 6 ++++--
plc4go/internal/cbus/Subscriber.go | 13 ++++++++++++-
plc4go/spi/testutils/TestUtils.go | 27 ++++++++++++++++++++++-----
3 files changed, 38 insertions(+), 8 deletions(-)
[plc4x] 01/02: fix(plc4go/cbus): handle pre registered consumers
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 c12edf33d65c293dcfc8dfb5172905520cec6184
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Jun 15 15:11:24 2023 +0200
fix(plc4go/cbus): handle pre registered consumers
---
plc4go/internal/ads/Subscriber.go | 6 ++++--
plc4go/internal/cbus/Subscriber.go | 13 ++++++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/plc4go/internal/ads/Subscriber.go b/plc4go/internal/ads/Subscriber.go
index 232ce42816..6a0c874859 100644
--- a/plc4go/internal/ads/Subscriber.go
+++ b/plc4go/internal/ads/Subscriber.go
@@ -74,12 +74,14 @@ func (m *Connection) Subscribe(ctx context.Context, subscriptionRequest apiModel
subscriptionType := defaultSubscriptionRequest.GetType(tagName)
interval := defaultSubscriptionRequest.GetInterval(tagName)
preRegisteredConsumers := defaultSubscriptionRequest.GetPreRegisteredConsumers(tagName)
- subSubscriptionRequests[tagName] = spiModel.NewDefaultPlcSubscriptionRequest(m,
+ subSubscriptionRequests[tagName] = spiModel.NewDefaultPlcSubscriptionRequest(
+ m,
[]string{tagName},
map[string]apiModel.PlcTag{tagName: directTag},
map[string]spiModel.SubscriptionType{tagName: subscriptionType},
map[string]time.Duration{tagName: interval},
- map[string][]apiModel.PlcSubscriptionEventConsumer{tagName: preRegisteredConsumers})
+ map[string][]apiModel.PlcSubscriptionEventConsumer{tagName: preRegisteredConsumers},
+ )
}
// If this is a single item request, we can take a shortcut.
diff --git a/plc4go/internal/cbus/Subscriber.go b/plc4go/internal/cbus/Subscriber.go
index a9224fd79a..b88d5da690 100644
--- a/plc4go/internal/cbus/Subscriber.go
+++ b/plc4go/internal/cbus/Subscriber.go
@@ -74,7 +74,18 @@ func (s *Subscriber) Subscribe(_ context.Context, subscriptionRequest apiModel.P
subscriptionValues := make(map[string]apiModel.PlcSubscriptionHandle)
for _, tagName := range internalPlcSubscriptionRequest.GetTagNames() {
responseCodes[tagName] = apiModel.PlcResponseCode_OK
- subscriptionValues[tagName] = NewSubscriptionHandle(s, tagName, internalPlcSubscriptionRequest.GetTag(tagName), internalPlcSubscriptionRequest.GetType(tagName), internalPlcSubscriptionRequest.GetInterval(tagName))
+ handle := NewSubscriptionHandle(
+ s,
+ tagName,
+ internalPlcSubscriptionRequest.GetTag(tagName),
+ internalPlcSubscriptionRequest.GetType(tagName),
+ internalPlcSubscriptionRequest.GetInterval(tagName),
+ )
+ preRegisteredConsumers := internalPlcSubscriptionRequest.GetPreRegisteredConsumers(tagName)
+ for _, consumer := range preRegisteredConsumers {
+ _ = handle.Register(consumer)
+ }
+ subscriptionValues[tagName] = handle
}
result <- spiModel.NewDefaultPlcSubscriptionRequestResult(
[plc4x] 02/02: test(plc4go/spi): add env var to enable high precision timestamps
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 2ca899206f91e7dcf2da67af314e4e70c54921fa
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Jun 15 15:33:44 2023 +0200
test(plc4go/spi): add env var to enable high precision timestamps
---
plc4go/spi/testutils/TestUtils.go | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/plc4go/spi/testutils/TestUtils.go b/plc4go/spi/testutils/TestUtils.go
index 2e0752a932..3829067a1c 100644
--- a/plc4go/spi/testutils/TestUtils.go
+++ b/plc4go/spi/testutils/TestUtils.go
@@ -21,14 +21,14 @@ package testutils
import (
"context"
+ "github.com/apache/plc4x/plc4go/spi/options"
+ "github.com/apache/plc4x/plc4go/spi/pool"
+ "github.com/apache/plc4x/plc4go/spi/utils"
"os"
"runtime/debug"
"strings"
"testing"
-
- "github.com/apache/plc4x/plc4go/spi/options"
- "github.com/apache/plc4x/plc4go/spi/pool"
- "github.com/apache/plc4x/plc4go/spi/utils"
+ "time"
"github.com/ajankovic/xdiff"
"github.com/ajankovic/xdiff/parser"
@@ -115,9 +115,18 @@ func TestContext(t *testing.T) context.Context {
return ctx
}
+var highLogPrecision bool
+
+func init() {
+ highLogPrecision = os.Getenv("PLC4X_TEST_HIGH_TEST_LOG_PRECISION") == "true"
+ if highLogPrecision {
+ zerolog.TimeFieldFormat = time.RFC3339Nano
+ }
+}
+
// ProduceTestingLogger produces a logger which redirects to testing.T
func ProduceTestingLogger(t *testing.T) zerolog.Logger {
- return zerolog.New(
+ logger := zerolog.New(
zerolog.NewConsoleWriter(
zerolog.ConsoleTestWriter(t),
func(w *zerolog.ConsoleWriter) {
@@ -128,9 +137,17 @@ func ProduceTestingLogger(t *testing.T) zerolog.Logger {
if onJenkins || onGithubAction || onCI {
w.NoColor = true
}
+
+ },
+ func(w *zerolog.ConsoleWriter) {
+ w.TimeFormat = time.StampNano
},
),
)
+ if highLogPrecision {
+ logger = logger.With().Timestamp().Logger()
+ }
+ return logger
}
// EnrichOptionsWithOptionsForTesting appends options useful for testing to config.WithOption s