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/05/16 18:13:26 UTC
[plc4x] branch develop updated: refactor(plc4go): streamline imports
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 d89e40f73f refactor(plc4go): streamline imports
d89e40f73f is described below
commit d89e40f73f2c4000187cb75b8e7f8cdc9e6ecf80
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue May 16 20:12:23 2023 +0200
refactor(plc4go): streamline imports
---
plc4go/examples/ads/discovery/Discovery.go | 4 +-
plc4go/examples/ads/subscribe/Subscribe.go | 5 +-
.../hello_world_plc4go_bacnet_discovery.go | 10 +-
.../discovery/hello_world_plc4go_knx_discovery.go | 11 +-
.../hello_world_plc4go_knx_read_group_address.go | 4 +-
.../hello_world_plc4go_knx_subscription.go | 20 +--
plc4go/examples/read/hello_world_plc4go_read.go | 4 +-
plc4go/examples/write/hello_world_plc4go_write.go | 4 +-
plc4go/internal/ads/Browser.go | 14 +-
plc4go/internal/ads/Connection.go | 67 ++++----
plc4go/internal/ads/Discoverer.go | 4 +-
plc4go/internal/ads/DriverContext.go | 32 ++--
plc4go/internal/ads/Reader.go | 34 ++--
plc4go/internal/ads/Subscriber.go | 28 +--
plc4go/internal/ads/TagHandler.go | 26 +--
plc4go/internal/ads/TagHandler_test.go | 188 ++++++++++-----------
plc4go/internal/ads/ValueHandler.go | 29 ++--
plc4go/internal/ads/Writer.go | 45 ++---
plc4go/internal/ads/model/AdsSubscriptionHandle.go | 12 +-
plc4go/internal/ads/model/Tag.go | 43 ++---
plc4go/internal/bacnetip/Connection.go | 6 +-
plc4go/internal/bacnetip/Discoverer.go | 6 +-
plc4go/internal/bacnetip/Tag.go | 14 +-
plc4go/internal/bacnetip/TagHandler.go | 7 +-
plc4go/internal/cbus/Connection.go | 10 +-
plc4go/internal/cbus/Discoverer.go | 4 +-
plc4go/internal/eip/Connection.go | 6 +-
plc4go/internal/eip/Tag.go | 26 +--
plc4go/internal/eip/TagHandler.go | 6 +-
plc4go/internal/eip/Writer.go | 16 +-
plc4go/internal/knxnetip/Browser.go | 8 +-
plc4go/internal/knxnetip/Discoverer.go | 4 +-
plc4go/internal/knxnetip/SubscriptionEvent.go | 10 +-
plc4go/internal/knxnetip/ValueHandler.go | 6 +-
plc4go/internal/knxnetip/Writer.go | 12 +-
plc4go/internal/modbus/Reader.go | 17 +-
plc4go/internal/modbus/Tag.go | 33 ++--
plc4go/internal/modbus/TagHandler.go | 29 ++--
plc4go/internal/modbus/Writer.go | 37 ++--
plc4go/internal/s7/Connection.go | 6 +-
plc4go/internal/s7/Reader.go | 35 ++--
plc4go/internal/s7/Tag.go | 22 +--
plc4go/internal/s7/TagHandler.go | 7 +-
plc4go/internal/s7/Writer.go | 19 ++-
plc4go/internal/simulated/Connection.go | 14 +-
plc4go/internal/simulated/Connection_test.go | 14 +-
plc4go/internal/simulated/Driver_test.go | 4 +-
plc4go/internal/simulated/Reader.go | 18 +-
plc4go/internal/simulated/Reader_test.go | 86 +++++-----
plc4go/internal/simulated/TagHandler_test.go | 18 +-
plc4go/internal/simulated/ValueHandler.go | 6 +-
plc4go/internal/simulated/Writer.go | 12 +-
plc4go/internal/simulated/Writer_test.go | 108 ++++++------
plc4go/pkg/api/connection.go | 1 +
plc4go/pkg/api/driverManager.go | 4 +-
plc4go/spi/default/DefaultBrowser.go | 6 +-
plc4go/spi/default/DefaultConnection.go | 14 +-
plc4go/spi/default/DefaultConnection_test.go | 22 +--
plc4go/spi/interceptors/RequestInterceptor.go | 11 +-
.../spi/model/DefaultPlcSubscriptionEventItem.go | 18 +-
.../spi/model/DefaultPlcUnsubscriptionRequest.go | 7 +-
plc4go/spi/model/DefaultPlcWriteResponse_test.go | 141 ++++++++++++++++
plc4go/spi/testutils/ManualTestRunner.go | 16 +-
plc4go/spi/values/PlcValueHandler.go | 76 ++++-----
.../drivers/tests/manual_bacnet_PcapTest_test.go | 4 +-
.../tests/drivers/tests/manual_cbus_driver_test.go | 10 +-
plc4go/tools/plc4xbrowser/ui/commands.go | 9 +-
plc4go/tools/plc4xbrowser/ui/ui.go | 12 +-
plc4go/tools/plc4xpcapanalyzer/ui/common.go | 12 +-
plc4go/tools/plc4xpcapanalyzer/ui/ui.go | 14 +-
70 files changed, 878 insertions(+), 709 deletions(-)
diff --git a/plc4go/examples/ads/discovery/Discovery.go b/plc4go/examples/ads/discovery/Discovery.go
index dc503c3127..354bfabf53 100644
--- a/plc4go/examples/ads/discovery/Discovery.go
+++ b/plc4go/examples/ads/discovery/Discovery.go
@@ -24,12 +24,12 @@ import (
"time"
"github.com/apache/plc4x/plc4go/internal/ads"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
func main() {
discoverer := ads.NewDiscoverer()
- discoverer.Discover(context.Background(), func(event model.PlcDiscoveryItem) {
+ discoverer.Discover(context.Background(), func(event apiModel.PlcDiscoveryItem) {
print(event)
})
time.Sleep(time.Second * 5)
diff --git a/plc4go/examples/ads/subscribe/Subscribe.go b/plc4go/examples/ads/subscribe/Subscribe.go
index dc2f07a390..6e2dea6ce5 100644
--- a/plc4go/examples/ads/subscribe/Subscribe.go
+++ b/plc4go/examples/ads/subscribe/Subscribe.go
@@ -24,7 +24,8 @@ import (
plc4go "github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
@@ -39,7 +40,7 @@ func main() {
subscriptionRequest, err := connection.GetConnection().SubscriptionRequestBuilder().
AddChangeOfStateTagAddress("value-int", "MAIN.rivianTest01.HorizontalPosition").
- AddPreRegisteredConsumer("value-int", func(event model.PlcSubscriptionEvent) {
+ AddPreRegisteredConsumer("value-int", func(event apiModel.PlcSubscriptionEvent) {
value := event.GetValue("value-int")
log.Info().Msgf("Got value: %d", value.GetUint16())
}).
diff --git a/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go b/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go
index 2f16ec288a..b115eaa277 100644
--- a/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go
+++ b/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go
@@ -21,13 +21,15 @@ package main
import (
"fmt"
+ "os"
+ "time"
+
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
"github.com/apache/plc4x/plc4go/pkg/api/logging"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
"github.com/rs/zerolog/log"
- "os"
- "time"
)
func main() {
@@ -39,7 +41,7 @@ func main() {
var connectionStrings []string
if len(os.Args) < 2 {
// Try to auto-find bacnet devices via broadcast-message discovery
- if err := driverManager.Discover(func(event model.PlcDiscoveryItem) {
+ if err := driverManager.Discover(func(event apiModel.PlcDiscoveryItem) {
connStr := event.GetProtocolCode() + "://" + event.GetTransportUrl().Host
log.Info().Str("connection string", connStr).Stringer("event", event.(fmt.Stringer)).Msg("Found Bacnet Gateway")
diff --git a/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go b/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go
index ade6cd2288..fd9e368ede 100644
--- a/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go
+++ b/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go
@@ -26,8 +26,9 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
"github.com/apache/plc4x/plc4go/pkg/api/logging"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/rs/zerolog/log"
)
@@ -41,7 +42,7 @@ func main() {
var connectionStrings []string
if len(os.Args) < 2 {
// Try to auto-find KNX gateways via broadcast-message discovery
- _ = driverManager.Discover(func(event model.PlcDiscoveryItem) {
+ _ = driverManager.Discover(func(event apiModel.PlcDiscoveryItem) {
connStr := event.GetProtocolCode() + "://" + event.GetTransportUrl().Host
log.Info().Str("connection string", connStr).Msg("Found KNX Gateway")
@@ -79,7 +80,7 @@ func main() {
log.Error().Err(err).Msg("error creating browse request")
return
}
- brr := browseRequest.ExecuteWithInterceptor(func(result model.PlcBrowseItem) bool {
+ brr := browseRequest.ExecuteWithInterceptor(func(result apiModel.PlcBrowseItem) bool {
knxTag := result.GetTag()
knxAddress := knxTag.GetAddressString()
log.Info().Msgf("Inspecting detected Device at KNX Address: %s", knxAddress)
@@ -136,9 +137,9 @@ func main() {
}
readResponse := readRequestResult.GetResponse()
var programVersion []byte
- if readResponse.GetResponseCode("applicationProgramVersion") == model.PlcResponseCode_OK {
+ if readResponse.GetResponseCode("applicationProgramVersion") == apiModel.PlcResponseCode_OK {
programVersion = utils.PlcValueUint8ListToByteArray(readResponse.GetValue("applicationProgramVersion"))
- } else if readResponse.GetResponseCode("interfaceProgramVersion") == model.PlcResponseCode_OK {
+ } else if readResponse.GetResponseCode("interfaceProgramVersion") == apiModel.PlcResponseCode_OK {
programVersion = utils.PlcValueUint8ListToByteArray(readResponse.GetValue("interfaceProgramVersion"))
}
rb := utils.NewReadBufferByteBased(utils.ByteArrayToUint8Array(programVersion))
diff --git a/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go b/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
index 905cc240ab..5ea6b7b9ae 100644
--- a/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
+++ b/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
@@ -25,7 +25,7 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
"github.com/apache/plc4x/plc4go/pkg/api/logging"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
func main() {
@@ -71,7 +71,7 @@ func main() {
// Do something with the response
for _, tagName := range rrr.GetResponse().GetTagNames() {
- if rrr.GetResponse().GetResponseCode(tagName) != model.PlcResponseCode_OK {
+ if rrr.GetResponse().GetResponseCode(tagName) != apiModel.PlcResponseCode_OK {
fmt.Printf("error an non-ok return code for tag %s: %s\n", tagName, rrr.GetResponse().GetResponseCode(tagName).GetName())
continue
}
diff --git a/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go b/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go
index 6974006553..c9739227c1 100644
--- a/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go
+++ b/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go
@@ -27,8 +27,8 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
"github.com/apache/plc4x/plc4go/pkg/api/logging"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
)
func main() {
@@ -54,23 +54,23 @@ func main() {
// Prepare a subscription-request
if subscriptionRequest, err := connection.SubscriptionRequestBuilder().
- // Intentionally catching all without datatype and the temperature values of the first floor with type
+ // Intentionally catching all without datatype and the temperature apiValues of the first floor with type
AddChangeOfStateTagAddress("all", "*/*/*").
AddChangeOfStateTagAddress("firstFlorTemperatures", "2/[1,2,4,6]/10:DPT_Value_Temp").
- AddPreRegisteredConsumer("all", func(event model.PlcSubscriptionEvent) {
+ AddPreRegisteredConsumer("all", func(event apiModel.PlcSubscriptionEvent) {
// Iterate over all tags that were triggered in the current event.
for _, tagName := range event.GetTagNames() {
- if event.GetResponseCode(tagName) == model.PlcResponseCode_OK {
+ if event.GetResponseCode(tagName) == apiModel.PlcResponseCode_OK {
address := event.GetAddress(tagName)
value := event.GetValue(tagName)
// If the plc-value was a raw-plcValue, we will try lazily decode the value
- // In my installation all group addresses ending with "/10" are temperature values
+ // In my installation all group addresses ending with "/10" are temperature apiValues
// and ending on "/0" are light switch actions.
// So if I find a group address ending on that, decode it with a given type name,
- // If not, simply output it as array of USINT values.
+ // If not, simply output it as array of USINT apiValues.
switch value.(type) {
- case values.RawPlcValue:
- rawValue := value.(values.RawPlcValue)
+ case apiValues.RawPlcValue:
+ rawValue := value.(apiValues.RawPlcValue)
datatypeName := "USINT"
if strings.HasSuffix(address, "/10") {
datatypeName = "DPT_Value_Temp"
@@ -104,7 +104,7 @@ func main() {
// Do something with the response
for _, tagName := range rrr.GetResponse().GetTagNames() {
- if rrr.GetResponse().GetResponseCode(tagName) != model.PlcResponseCode_OK {
+ if rrr.GetResponse().GetResponseCode(tagName) != apiModel.PlcResponseCode_OK {
fmt.Printf("error an non-ok return code for tag %s: %s\n", tagName, rrr.GetResponse().GetResponseCode(tagName).GetName())
continue
}
diff --git a/plc4go/examples/read/hello_world_plc4go_read.go b/plc4go/examples/read/hello_world_plc4go_read.go
index 465a7ff6c7..7f1113049f 100644
--- a/plc4go/examples/read/hello_world_plc4go_read.go
+++ b/plc4go/examples/read/hello_world_plc4go_read.go
@@ -24,7 +24,7 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
func main() {
@@ -65,7 +65,7 @@ func main() {
}
// Do something with the response
- if rrr.GetResponse().GetResponseCode("tag") != model.PlcResponseCode_OK {
+ if rrr.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK {
fmt.Printf("error an non-ok return code: %s", rrr.GetResponse().GetResponseCode("tag").GetName())
return
}
diff --git a/plc4go/examples/write/hello_world_plc4go_write.go b/plc4go/examples/write/hello_world_plc4go_write.go
index 15b225b0cd..36408179bb 100644
--- a/plc4go/examples/write/hello_world_plc4go_write.go
+++ b/plc4go/examples/write/hello_world_plc4go_write.go
@@ -24,7 +24,7 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/drivers"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
func main() {
@@ -64,7 +64,7 @@ func main() {
return
}
- if wrr.GetResponse().GetResponseCode("tag") != model.PlcResponseCode_OK {
+ if wrr.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK {
fmt.Printf("error an non-ok return code: %s", wrr.GetResponse().GetResponseCode("tag").GetName())
return
}
diff --git a/plc4go/internal/ads/Browser.go b/plc4go/internal/ads/Browser.go
index aa0aa720e2..19c65d2cd0 100644
--- a/plc4go/internal/ads/Browser.go
+++ b/plc4go/internal/ads/Browser.go
@@ -27,11 +27,11 @@ import (
"github.com/apache/plc4x/plc4go/internal/ads/model"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
func (m *Connection) BrowseRequestBuilder() apiModel.PlcBrowseRequestBuilder {
- return internalModel.NewDefaultPlcBrowseRequestBuilder(m.GetPlcTagHandler(), m)
+ return spiModel.NewDefaultPlcBrowseRequestBuilder(m.GetPlcTagHandler(), m)
}
func (m *Connection) Browse(ctx context.Context, browseRequest apiModel.PlcBrowseRequest) <-chan apiModel.PlcBrowseRequestResult {
@@ -45,7 +45,7 @@ func (m *Connection) BrowseWithInterceptor(ctx context.Context, browseRequest ap
go func() {
defer func() {
if err := recover(); err != nil {
- result <- internalModel.NewDefaultPlcBrowseRequestResult(browseRequest, nil, errors.Errorf("Recovered from panic: %v", err))
+ result <- spiModel.NewDefaultPlcBrowseRequestResult(browseRequest, nil, errors.Errorf("Recovered from panic: %v", err))
}
}()
responseCodes := map[string]apiModel.PlcResponseCode{}
@@ -54,8 +54,8 @@ func (m *Connection) BrowseWithInterceptor(ctx context.Context, browseRequest ap
query := browseRequest.GetQuery(queryName)
responseCodes[queryName], results[queryName] = m.BrowseQuery(ctx, interceptor, queryName, query)
}
- browseResponse := internalModel.NewDefaultPlcBrowseResponse(browseRequest, results, responseCodes)
- result <- internalModel.NewDefaultPlcBrowseRequestResult(browseRequest, browseResponse, nil)
+ browseResponse := spiModel.NewDefaultPlcBrowseResponse(browseRequest, results, responseCodes)
+ result <- spiModel.NewDefaultPlcBrowseRequestResult(browseRequest, browseResponse, nil)
}()
return result
}
@@ -110,12 +110,12 @@ func (m *Connection) filterDataTypes(parentName string, currentType driverModel.
if len(remainingAddressSegments) == 0 {
arrayInfo := []apiModel.ArrayInfo{}
for _, ai := range currentType.GetArrayInfo() {
- arrayInfo = append(arrayInfo, &internalModel.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: ai.GetLowerBound(),
UpperBound: ai.GetUpperBound(),
})
}
- foundTag := internalModel.NewDefaultPlcBrowseItem(
+ foundTag := spiModel.NewDefaultPlcBrowseItem(
model.SymbolicPlcTag{
PlcTag: model.PlcTag{
ArrayInfo: arrayInfo,
diff --git a/plc4go/internal/ads/Connection.go b/plc4go/internal/ads/Connection.go
index a03aec00e2..c2a04cca7d 100644
--- a/plc4go/internal/ads/Connection.go
+++ b/plc4go/internal/ads/Connection.go
@@ -26,17 +26,18 @@ import (
"strconv"
"strings"
- model2 "github.com/apache/plc4x/plc4go/internal/ads/model"
+ "github.com/apache/plc4x/plc4go/internal/ads/model"
"github.com/apache/plc4x/plc4go/pkg/api"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/default"
"github.com/apache/plc4x/plc4go/spi/interceptors"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/transports"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -46,14 +47,14 @@ type Connection struct {
messageCodec spi.MessageCodec
requestInterceptor interceptors.RequestInterceptor
- configuration model2.Configuration
+ configuration model.Configuration
driverContext *DriverContext
tracer *spi.Tracer
subscriptions map[uint32]apiModel.PlcSubscriptionHandle
}
-func NewConnection(messageCodec spi.MessageCodec, configuration model2.Configuration, options map[string][]string) (*Connection, error) {
+func NewConnection(messageCodec spi.MessageCodec, configuration model.Configuration, options map[string][]string) (*Connection, error) {
driverContext, err := NewDriverContext(configuration)
if err != nil {
return nil, err
@@ -129,7 +130,7 @@ func (m *Connection) setupConnection(ctx context.Context, ch chan plc4go.PlcConn
m.driverContext.deviceName = GetZeroTerminatedString(deviceInfoResponse.GetDevice())
// Read the symbol-version (offline changes)
- symbolVersionResponse, err := m.ExecuteAdsReadRequest(ctx, uint32(model.ReservedIndexGroups_ADSIGRP_SYM_VERSION), 0, 1)
+ symbolVersionResponse, err := m.ExecuteAdsReadRequest(ctx, uint32(readWriteModel.ReservedIndexGroups_ADSIGRP_SYM_VERSION), 0, 1)
if err != nil {
ch <- _default.NewDefaultPlcConnectionCloseResult(nil, err)
return
@@ -137,7 +138,7 @@ func (m *Connection) setupConnection(ctx context.Context, ch chan plc4go.PlcConn
m.driverContext.symbolVersion = symbolVersionResponse.GetData()[0]
// Read the online-version
- onlineVersionResponse, err := m.ExecuteAdsReadWriteRequest(ctx, uint32(model.ReservedIndexGroups_ADSIGRP_SYM_VALBYNAME), 0, 4, nil, []byte("TwinCAT_SystemInfoVarList._AppInfo.OnlineChangeCnt"))
+ onlineVersionResponse, err := m.ExecuteAdsReadWriteRequest(ctx, uint32(readWriteModel.ReservedIndexGroups_ADSIGRP_SYM_VALBYNAME), 0, 4, nil, []byte("TwinCAT_SystemInfoVarList._AppInfo.OnlineChangeCnt"))
if err != nil {
ch <- _default.NewDefaultPlcConnectionCloseResult(nil, err)
return
@@ -167,13 +168,13 @@ func (m *Connection) setupConnection(ctx context.Context, ch chan plc4go.PlcConn
}()
for message := range defaultIncomingMessageChannel {
switch message.(type) {
- case model.AmsTCPPacket:
- amsTCPPacket := message.(model.AmsTCPPacket)
+ case readWriteModel.AmsTCPPacket:
+ amsTCPPacket := message.(readWriteModel.AmsTCPPacket)
switch amsTCPPacket.GetUserdata().(type) {
// Forward all device notification requests to the subscriber component.
- case model.AdsDeviceNotificationRequest:
+ case readWriteModel.AdsDeviceNotificationRequest:
m.handleIncomingDeviceNotificationRequest(
- amsTCPPacket.GetUserdata().(model.AdsDeviceNotificationRequest))
+ amsTCPPacket.GetUserdata().(readWriteModel.AdsDeviceNotificationRequest))
default:
log.Warn().Msgf("Got unexpected type of incoming ADS message %v", message)
}
@@ -245,31 +246,31 @@ func (m *Connection) readSymbolTableAndDatatypeTable(ctx context.Context) error
return nil
}
-func (m *Connection) readDataTypeTableAndSymbolTableSizes(ctx context.Context) (model.AdsTableSizes, error) {
- response, err := m.ExecuteAdsReadRequest(ctx, uint32(model.ReservedIndexGroups_ADSIGRP_SYMBOL_AND_DATA_TYPE_SIZES), 0x00000000, 24)
+func (m *Connection) readDataTypeTableAndSymbolTableSizes(ctx context.Context) (readWriteModel.AdsTableSizes, error) {
+ response, err := m.ExecuteAdsReadRequest(ctx, uint32(readWriteModel.ReservedIndexGroups_ADSIGRP_SYMBOL_AND_DATA_TYPE_SIZES), 0x00000000, 24)
if err != nil {
return nil, fmt.Errorf("error reading table: %v", err)
}
// Parse and process the response
- tableSizes, err := model.AdsTableSizesParse(response.GetData())
+ tableSizes, err := readWriteModel.AdsTableSizesParse(response.GetData())
if err != nil {
return nil, fmt.Errorf("error parsing table: %v", err)
}
return tableSizes, nil
}
-func (m *Connection) readDataTypeTable(ctx context.Context, dataTableSize uint32, numDataTypes uint32) (map[string]model.AdsDataTypeTableEntry, error) {
- response, err := m.ExecuteAdsReadRequest(ctx, uint32(model.ReservedIndexGroups_ADSIGRP_DATA_TYPE_TABLE_UPLOAD), 0x00000000, dataTableSize)
+func (m *Connection) readDataTypeTable(ctx context.Context, dataTableSize uint32, numDataTypes uint32) (map[string]readWriteModel.AdsDataTypeTableEntry, error) {
+ response, err := m.ExecuteAdsReadRequest(ctx, uint32(readWriteModel.ReservedIndexGroups_ADSIGRP_DATA_TYPE_TABLE_UPLOAD), 0x00000000, dataTableSize)
if err != nil {
return nil, fmt.Errorf("error reading data-type table: %v", err)
}
// Parse and process the response
readBuffer := utils.NewReadBufferByteBased(response.GetData(), utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
- dataTypes := map[string]model.AdsDataTypeTableEntry{}
+ dataTypes := map[string]readWriteModel.AdsDataTypeTableEntry{}
for i := uint32(0); i < numDataTypes; i++ {
- dataType, err := model.AdsDataTypeTableEntryParseWithBuffer(context.Background(), readBuffer)
+ dataType, err := readWriteModel.AdsDataTypeTableEntryParseWithBuffer(context.Background(), readBuffer)
if err != nil {
return nil, fmt.Errorf("error parsing table: %v", err)
}
@@ -278,17 +279,17 @@ func (m *Connection) readDataTypeTable(ctx context.Context, dataTableSize uint32
return dataTypes, nil
}
-func (m *Connection) readSymbolTable(ctx context.Context, symbolTableSize uint32, numSymbols uint32) (map[string]model.AdsSymbolTableEntry, error) {
- response, err := m.ExecuteAdsReadRequest(ctx, uint32(model.ReservedIndexGroups_ADSIGRP_SYM_UPLOAD), 0x00000000, symbolTableSize)
+func (m *Connection) readSymbolTable(ctx context.Context, symbolTableSize uint32, numSymbols uint32) (map[string]readWriteModel.AdsSymbolTableEntry, error) {
+ response, err := m.ExecuteAdsReadRequest(ctx, uint32(readWriteModel.ReservedIndexGroups_ADSIGRP_SYM_UPLOAD), 0x00000000, symbolTableSize)
if err != nil {
return nil, fmt.Errorf("error reading data-type table: %v", err)
}
// Parse and process the response
readBuffer := utils.NewReadBufferByteBased(response.GetData(), utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
- symbols := map[string]model.AdsSymbolTableEntry{}
+ symbols := map[string]readWriteModel.AdsSymbolTableEntry{}
for i := uint32(0); i < numSymbols; i++ {
- symbol, err := model.AdsSymbolTableEntryParseWithBuffer(context.Background(), readBuffer)
+ symbol, err := readWriteModel.AdsSymbolTableEntryParseWithBuffer(context.Background(), readBuffer)
if err != nil {
return nil, fmt.Errorf("error parsing table")
}
@@ -297,7 +298,7 @@ func (m *Connection) readSymbolTable(ctx context.Context, symbolTableSize uint32
return symbols, nil
}
-func (m *Connection) resolveSymbolicTag(ctx context.Context, symbolicTag model2.SymbolicPlcTag) (*model2.DirectPlcTag, error) {
+func (m *Connection) resolveSymbolicTag(ctx context.Context, symbolicTag model.SymbolicPlcTag) (*model.DirectPlcTag, error) {
// Find the initial datatype, based on the first to segments.
symbolicAddress := symbolicTag.SymbolicAddress
addressParts := strings.Split(symbolicAddress, ".")
@@ -324,19 +325,19 @@ func (m *Connection) resolveSymbolicTag(ctx context.Context, symbolicTag model2.
return m.resolveSymbolicAddress(ctx, addressParts, dataType, symbol.GetGroup(), symbol.GetOffset())
}
-func (m *Connection) resolveSymbolicAddress(ctx context.Context, addressParts []string, curDataType model.AdsDataTypeTableEntry, indexGroup uint32, indexOffset uint32) (*model2.DirectPlcTag, error) {
+func (m *Connection) resolveSymbolicAddress(ctx context.Context, addressParts []string, curDataType readWriteModel.AdsDataTypeTableEntry, indexGroup uint32, indexOffset uint32) (*model.DirectPlcTag, error) {
// If we've reached then end of the resolution, return the final entry.
if len(addressParts) == 0 {
var arrayInfo []apiModel.ArrayInfo
for _, adsArrayInfo := range curDataType.GetArrayInfo() {
- arrayInfo = append(arrayInfo, &internalModel.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: adsArrayInfo.GetLowerBound(),
UpperBound: adsArrayInfo.GetUpperBound(),
})
}
plcValueType, stringLength := m.getPlcValueForAdsDataTypeTableEntry(curDataType)
- return &model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
+ return &model.DirectPlcTag{
+ PlcTag: model.PlcTag{
ArrayInfo: arrayInfo,
},
IndexGroup: indexGroup,
@@ -365,27 +366,27 @@ func (m *Connection) resolveSymbolicAddress(ctx context.Context, addressParts []
curAddressPart, curDataType.GetDataTypeName())
}
-func (m *Connection) getPlcValueForAdsDataTypeTableEntry(entry model.AdsDataTypeTableEntry) (values.PlcValueType, int32) {
+func (m *Connection) getPlcValueForAdsDataTypeTableEntry(entry readWriteModel.AdsDataTypeTableEntry) (apiValues.PlcValueType, int32) {
stringLength := -1
dataTypeName := entry.GetDataTypeName()
if strings.HasPrefix(dataTypeName, "STRING(") {
var err error
stringLength, err = strconv.Atoi(dataTypeName[7 : len(dataTypeName)-1])
if err != nil {
- return values.NULL, -1
+ return apiValues.NULL, -1
}
dataTypeName = "STRING"
} else if strings.HasPrefix(dataTypeName, "WSTRING(") {
var err error
stringLength, err = strconv.Atoi(dataTypeName[8 : len(dataTypeName)-1])
if err != nil {
- return values.NULL, -1
+ return apiValues.NULL, -1
}
dataTypeName = "WSTRING"
}
- plcValueType, ok := values.PlcValueByName(dataTypeName)
+ plcValueType, ok := apiValues.PlcValueByName(dataTypeName)
if !ok {
- return values.NULL, -1
+ return apiValues.NULL, -1
}
return plcValueType, int32(stringLength)
}
diff --git a/plc4go/internal/ads/Discoverer.go b/plc4go/internal/ads/Discoverer.go
index b9d6606202..79fafd40ae 100644
--- a/plc4go/internal/ads/Discoverer.go
+++ b/plc4go/internal/ads/Discoverer.go
@@ -34,7 +34,7 @@ import (
"github.com/apache/plc4x/plc4go/protocols/ads/discovery/readwrite/model"
driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/options"
values2 "github.com/apache/plc4x/plc4go/spi/values"
"github.com/rs/zerolog/log"
@@ -218,7 +218,7 @@ func (d *Discoverer) Discover(ctx context.Context, callback func(event apiModel.
strconv.Itoa(int(remoteAmsNetId.GetOctet4())) + ":" +
strconv.Itoa(int(driverModel.AdsConstants_ADSTCPDEFAULTPORT)))
if err2 == nil {
- plcDiscoveryItem := internalModel.NewDefaultPlcDiscoveryItem(
+ plcDiscoveryItem := spiModel.NewDefaultPlcDiscoveryItem(
"ads",
"tcp",
*remoteAddress,
diff --git a/plc4go/internal/ads/DriverContext.go b/plc4go/internal/ads/DriverContext.go
index 19bdc1302c..a88ff41880 100644
--- a/plc4go/internal/ads/DriverContext.go
+++ b/plc4go/internal/ads/DriverContext.go
@@ -26,11 +26,11 @@ import (
"strings"
"sync/atomic"
- model3 "github.com/apache/plc4x/plc4go/internal/ads/model"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ "github.com/apache/plc4x/plc4go/internal/ads/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
- model2 "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
type DriverContext struct {
@@ -46,7 +46,7 @@ type DriverContext struct {
awaitDisconnectComplete bool
}
-func NewDriverContext(configuration model3.Configuration) (*DriverContext, error) {
+func NewDriverContext(configuration model.Configuration) (*DriverContext, error) {
return &DriverContext{
invokeId: 0,
}, nil
@@ -65,7 +65,7 @@ func (m *DriverContext) clear() {
m.awaitDisconnectComplete = false
}
-func (m *DriverContext) getDirectTagForSymbolTag(symbolicPlcTag model3.SymbolicPlcTag) (*model3.DirectPlcTag, error) {
+func (m *DriverContext) getDirectTagForSymbolTag(symbolicPlcTag model.SymbolicPlcTag) (*model.DirectPlcTag, error) {
address := symbolicPlcTag.SymbolicAddress
addressSegments := strings.Split(address, ".")
var symbolName string
@@ -91,15 +91,15 @@ func (m *DriverContext) getDirectTagForSymbolTag(symbolicPlcTag model3.SymbolicP
return m.resolveDirectTag(remainingSegments, dataTypeEntry, symbolEntry.GetGroup(), symbolEntry.GetOffset())
}
-func (m *DriverContext) resolveDirectTag(remainingSegments []string, currentDatatype driverModel.AdsDataTypeTableEntry, indexGroup uint32, indexOffset uint32) (*model3.DirectPlcTag, error) {
+func (m *DriverContext) resolveDirectTag(remainingSegments []string, currentDatatype driverModel.AdsDataTypeTableEntry, indexGroup uint32, indexOffset uint32) (*model.DirectPlcTag, error) {
if len(remainingSegments) == 0 {
- return &model3.DirectPlcTag{
+ return &model.DirectPlcTag{
IndexGroup: indexGroup,
IndexOffset: indexOffset,
ValueType: m.getDataTypeForDataTypeTableEntry(currentDatatype),
StringLength: m.getStringLengthForDataTypeTableEntry(currentDatatype),
DataType: currentDatatype,
- PlcTag: model3.PlcTag{
+ PlcTag: model.PlcTag{
ArrayInfo: m.getArrayInfoForDataTypeTableEntry(currentDatatype),
},
}, nil
@@ -119,12 +119,12 @@ func (m *DriverContext) resolveDirectTag(remainingSegments []string, currentData
return nil, fmt.Errorf("couldn't find child with name %s in type %s", currentSegment, currentDatatype.GetDataTypeName())
}
-func (m *DriverContext) getDataTypeForDataTypeTableEntry(entry driverModel.AdsDataTypeTableEntry) values.PlcValueType {
+func (m *DriverContext) getDataTypeForDataTypeTableEntry(entry driverModel.AdsDataTypeTableEntry) apiValues.PlcValueType {
if entry.GetArrayInfo() != nil && len(entry.GetArrayInfo()) > 0 {
- return values.List
+ return apiValues.List
}
if entry.GetNumChildren() > 0 {
- return values.Struct
+ return apiValues.Struct
}
dataTypeName := entry.GetDataTypeName()
if strings.HasPrefix(dataTypeName, "STRING(") {
@@ -132,7 +132,7 @@ func (m *DriverContext) getDataTypeForDataTypeTableEntry(entry driverModel.AdsDa
} else if strings.HasPrefix(dataTypeName, "WSTRING(") {
dataTypeName = "WSTRING"
}
- plcValueType, _ := values.PlcValueByName(dataTypeName)
+ plcValueType, _ := apiValues.PlcValueByName(dataTypeName)
return plcValueType
}
@@ -156,10 +156,10 @@ func (m *DriverContext) getStringLengthForDataTypeTableEntry(entry driverModel.A
return 0
}
-func (m *DriverContext) getArrayInfoForDataTypeTableEntry(entry driverModel.AdsDataTypeTableEntry) []model.ArrayInfo {
- var arrayInfos []model.ArrayInfo
+func (m *DriverContext) getArrayInfoForDataTypeTableEntry(entry driverModel.AdsDataTypeTableEntry) []apiModel.ArrayInfo {
+ var arrayInfos []apiModel.ArrayInfo
for _, adsArrayInfo := range entry.GetArrayInfo() {
- arrayInfo := model2.DefaultArrayInfo{
+ arrayInfo := spiModel.DefaultArrayInfo{
LowerBound: adsArrayInfo.GetLowerBound(),
UpperBound: adsArrayInfo.GetUpperBound(),
}
diff --git a/plc4go/internal/ads/Reader.go b/plc4go/internal/ads/Reader.go
index ce28c0e2f9..a4edefa115 100644
--- a/plc4go/internal/ads/Reader.go
+++ b/plc4go/internal/ads/Reader.go
@@ -29,7 +29,7 @@ import (
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/pkg/api/values"
driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
internalValues "github.com/apache/plc4x/plc4go/spi/values"
"github.com/pkg/errors"
@@ -37,7 +37,7 @@ import (
)
func (m *Connection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
- return internalModel.NewDefaultPlcReadRequestBuilder(m.GetPlcTagHandler(), m)
+ return spiModel.NewDefaultPlcReadRequestBuilder(m.GetPlcTagHandler(), m)
}
func (m *Connection) Read(ctx context.Context, readRequest apiModel.PlcReadRequest) <-chan apiModel.PlcReadRequestResult {
@@ -46,7 +46,7 @@ func (m *Connection) Read(ctx context.Context, readRequest apiModel.PlcReadReque
go func() {
defer func() {
if err := recover(); err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Errorf("panic-ed %v", err))
+ result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Errorf("panic-ed %v", err))
}
}()
if len(readRequest.GetTagNames()) <= 1 {
@@ -60,7 +60,7 @@ func (m *Connection) Read(ctx context.Context, readRequest apiModel.PlcReadReque
func (m *Connection) singleRead(ctx context.Context, readRequest apiModel.PlcReadRequest, result chan apiModel.PlcReadRequestResult) {
if len(readRequest.GetTagNames()) != 1 {
- result <- internalModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.New("this part of the ads driver only supports single-item requests"))
+ result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.New("this part of the ads driver only supports single-item requests"))
log.Debug().Msgf("this part of the ads driver only supports single-item requests. Got %d tags", len(readRequest.GetTagNames()))
return
}
@@ -71,14 +71,14 @@ func (m *Connection) singleRead(ctx context.Context, readRequest apiModel.PlcRea
if model.NeedsResolving(tag) {
adsField, err := model.CastToSymbolicPlcTagFromPlcTag(tag)
if err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Wrap(err, "invalid tag item type"))
+ result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Wrap(err, "invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
// Replace the symbolic tag with a direct one
tag, err = m.resolveSymbolicTag(ctx, adsField)
if err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
nil,
errors.Wrap(err, "invalid tag item type"),
@@ -89,7 +89,7 @@ func (m *Connection) singleRead(ctx context.Context, readRequest apiModel.PlcRea
}
directAdsTag, ok := tag.(*model.DirectPlcTag)
if !ok {
- result <- internalModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.New("invalid tag item type"))
+ result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.New("invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
@@ -97,12 +97,12 @@ func (m *Connection) singleRead(ctx context.Context, readRequest apiModel.PlcRea
go func() {
defer func() {
if err := recover(); err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Errorf("panic-ed %v", err))
+ result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Errorf("panic-ed %v", err))
}
}()
response, err := m.ExecuteAdsReadRequest(ctx, directAdsTag.IndexGroup, directAdsTag.IndexOffset, directAdsTag.DataType.GetSize())
if err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
nil,
errors.Wrap(err, "got error executing the read request"),
@@ -130,9 +130,9 @@ func (m *Connection) singleRead(ctx context.Context, readRequest apiModel.PlcRea
}
}
// Return the response to the caller.
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
- internalModel.NewDefaultPlcReadResponse(readRequest, responseCodes, plcValues),
+ spiModel.NewDefaultPlcReadResponse(readRequest, responseCodes, plcValues),
nil,
)
}()
@@ -149,7 +149,7 @@ func (m *Connection) multiRead(ctx context.Context, readRequest apiModel.PlcRead
if model.NeedsResolving(tag) {
adsField, err := model.CastToSymbolicPlcTagFromPlcTag(tag)
if err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
nil,
errors.Wrap(err, "invalid tag item type"),
@@ -160,7 +160,7 @@ func (m *Connection) multiRead(ctx context.Context, readRequest apiModel.PlcRead
// Replace the symbolic tag with a direct one
tag, err = m.resolveSymbolicTag(ctx, adsField)
if err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
nil,
errors.Wrap(err, "invalid tag item type"),
@@ -171,7 +171,7 @@ func (m *Connection) multiRead(ctx context.Context, readRequest apiModel.PlcRead
}
directAdsTag, ok := tag.(*model.DirectPlcTag)
if !ok {
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
nil,
errors.New("invalid tag item type"),
@@ -202,7 +202,7 @@ func (m *Connection) multiRead(ctx context.Context, readRequest apiModel.PlcRead
response, err := m.ExecuteAdsReadWriteRequest(ctx, uint32(driverModel.ReservedIndexGroups_ADSIGRP_MULTIPLE_READ), uint32(len(directAdsTags)), expectedResponseDataSize, requestItems, nil)
if err != nil {
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
nil,
errors.Wrap(err, "error executing multi-item read request"),
@@ -247,9 +247,9 @@ func (m *Connection) multiRead(ctx context.Context, readRequest apiModel.PlcRead
}
// Return the response to the caller.
- result <- internalModel.NewDefaultPlcReadRequestResult(
+ result <- spiModel.NewDefaultPlcReadRequestResult(
readRequest,
- internalModel.NewDefaultPlcReadResponse(readRequest, responseCodes, plcValues),
+ spiModel.NewDefaultPlcReadResponse(readRequest, responseCodes, plcValues),
nil,
)
}
diff --git a/plc4go/internal/ads/Subscriber.go b/plc4go/internal/ads/Subscriber.go
index df73d2be3d..88c346adf8 100644
--- a/plc4go/internal/ads/Subscriber.go
+++ b/plc4go/internal/ads/Subscriber.go
@@ -26,14 +26,14 @@ import (
dirverModel "github.com/apache/plc4x/plc4go/internal/ads/model"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
func (m *Connection) SubscriptionRequestBuilder() apiModel.PlcSubscriptionRequestBuilder {
- return internalModel.NewDefaultPlcSubscriptionRequestBuilder(m.GetPlcTagHandler(), m.GetPlcValueHandler(), m)
+ return spiModel.NewDefaultPlcSubscriptionRequestBuilder(m.GetPlcTagHandler(), m.GetPlcValueHandler(), m)
}
func (m *Connection) UnsubscriptionRequestBuilder() apiModel.PlcUnsubscriptionRequestBuilder {
@@ -42,7 +42,7 @@ func (m *Connection) UnsubscriptionRequestBuilder() apiModel.PlcUnsubscriptionRe
}
func (m *Connection) Subscribe(ctx context.Context, subscriptionRequest apiModel.PlcSubscriptionRequest) <-chan apiModel.PlcSubscriptionRequestResult {
- defaultSubscriptionRequest := subscriptionRequest.(*internalModel.DefaultPlcSubscriptionRequest)
+ defaultSubscriptionRequest := subscriptionRequest.(*spiModel.DefaultPlcSubscriptionRequest)
// Subscription requests are unfortunately now supported as multi-item requests,
// so we have to send one subscription request for every tag.
@@ -61,22 +61,22 @@ func (m *Connection) Subscribe(ctx context.Context, subscriptionRequest apiModel
symbolicTag := tag.(dirverModel.SymbolicPlcTag)
directTagPtr, err := m.driverContext.getDirectTagForSymbolTag(symbolicTag)
if err != nil {
- subResults[tagName] = internalModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, errors.Wrap(err, "error resolving symbolic tag"))
+ subResults[tagName] = spiModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, errors.Wrap(err, "error resolving symbolic tag"))
continue
}
directTag = *directTagPtr
default:
- subResults[tagName] = internalModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, errors.New("invalid tag type"))
+ subResults[tagName] = spiModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, errors.New("invalid tag type"))
continue
}
subscriptionType := defaultSubscriptionRequest.GetType(tagName)
interval := defaultSubscriptionRequest.GetInterval(tagName)
preRegisteredConsumers := defaultSubscriptionRequest.GetPreRegisteredConsumers(tagName)
- subSubscriptionRequests[tagName] = internalModel.NewDefaultPlcSubscriptionRequest(m,
+ subSubscriptionRequests[tagName] = spiModel.NewDefaultPlcSubscriptionRequest(m,
[]string{tagName},
map[string]apiModel.PlcTag{tagName: directTag},
- map[string]internalModel.SubscriptionType{tagName: subscriptionType},
+ map[string]spiModel.SubscriptionType{tagName: subscriptionType},
map[string]time.Duration{tagName: interval},
map[string][]apiModel.PlcSubscriptionEventConsumer{tagName: preRegisteredConsumers})
}
@@ -106,7 +106,7 @@ func (m *Connection) Subscribe(ctx context.Context, subscriptionRequest apiModel
for _, subResultChannel := range subResultChannels {
select {
case <-ctx.Done():
- globalResultChannel <- internalModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, ctx.Err())
+ globalResultChannel <- spiModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, ctx.Err())
return
case subResult := <-subResultChannel:
// These are all single value requests ... so it's safe to assume this shortcut.
@@ -128,7 +128,7 @@ func (m *Connection) subscribe(ctx context.Context, subscriptionRequest apiModel
go func() {
defer func() {
if err := recover(); err != nil {
- responseChan <- internalModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, errors.Errorf("panic-ed %v", err))
+ responseChan <- spiModel.NewDefaultPlcSubscriptionRequestResult(subscriptionRequest, nil, errors.Errorf("panic-ed %v", err))
}
}()
// At this point we are sure to only have single item direct tag requests.
@@ -140,7 +140,7 @@ func (m *Connection) subscribe(ctx context.Context, subscriptionRequest apiModel
response, err := m.ExecuteAdsAddDeviceNotificationRequest(ctx, directTag.IndexGroup, directTag.IndexOffset, directTag.DataType.GetSize(), model.AdsTransMode_ON_CHANGE, 0, 0)
if err != nil {
- responseChan <- internalModel.NewDefaultPlcSubscriptionRequestResult(
+ responseChan <- spiModel.NewDefaultPlcSubscriptionRequestResult(
subscriptionRequest,
nil,
err,
@@ -148,9 +148,9 @@ func (m *Connection) subscribe(ctx context.Context, subscriptionRequest apiModel
}
// Create a new subscription handle.
subscriptionHandle := dirverModel.NewAdsSubscriptionHandle(m, tagName, directTag)
- responseChan <- internalModel.NewDefaultPlcSubscriptionRequestResult(
+ responseChan <- spiModel.NewDefaultPlcSubscriptionRequestResult(
subscriptionRequest,
- internalModel.NewDefaultPlcSubscriptionResponse(
+ spiModel.NewDefaultPlcSubscriptionResponse(
subscriptionRequest,
map[string]apiModel.PlcResponseCode{tagName: apiModel.PlcResponseCode_OK},
map[string]apiModel.PlcSubscriptionHandle{tagName: subscriptionHandle},
@@ -200,9 +200,9 @@ func (m *Connection) processSubscriptionResponses(_ context.Context, subscriptio
}
}
}
- return internalModel.NewDefaultPlcSubscriptionRequestResult(
+ return spiModel.NewDefaultPlcSubscriptionRequestResult(
subscriptionRequest,
- internalModel.NewDefaultPlcSubscriptionResponse(subscriptionRequest, responseCodes, subscriptionHandles),
+ spiModel.NewDefaultPlcSubscriptionResponse(subscriptionRequest, responseCodes, subscriptionHandles),
err,
)
}
diff --git a/plc4go/internal/ads/TagHandler.go b/plc4go/internal/ads/TagHandler.go
index f21f77fc88..5f5ee1573b 100644
--- a/plc4go/internal/ads/TagHandler.go
+++ b/plc4go/internal/ads/TagHandler.go
@@ -29,8 +29,8 @@ import (
"github.com/apache/plc4x/plc4go/internal/ads/model"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- model2 "github.com/apache/plc4x/plc4go/spi/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/pkg/errors"
)
@@ -106,7 +106,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if adsDataTypeName == "" {
return nil, errors.Errorf("Missing ads data type")
}
- plcValueType, ok := values.PlcValueByName(adsDataTypeName)
+ plcValueType, ok := apiValues.PlcValueByName(adsDataTypeName)
if !ok {
return nil, fmt.Errorf("invalid ads data type")
}
@@ -140,7 +140,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: endElement,
})
@@ -153,7 +153,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: startElement + numElements,
})
@@ -162,7 +162,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: numElements,
})
@@ -213,7 +213,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if adsDataTypeName == "" {
return nil, errors.Errorf("Missing ads data type")
}
- plcValueType, ok := values.PlcValueByName(adsDataTypeName)
+ plcValueType, ok := apiValues.PlcValueByName(adsDataTypeName)
if !ok {
return nil, fmt.Errorf("invalid ads data type")
}
@@ -240,7 +240,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: endElement,
})
@@ -253,7 +253,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: startElement + numElements,
})
@@ -262,7 +262,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: numElements,
})
@@ -295,7 +295,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: endElement,
})
@@ -308,7 +308,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: startElement + numElements,
})
@@ -317,7 +317,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: numElements,
})
diff --git a/plc4go/internal/ads/TagHandler_test.go b/plc4go/internal/ads/TagHandler_test.go
index 52434ae45d..bc5d4f5e4f 100644
--- a/plc4go/internal/ads/TagHandler_test.go
+++ b/plc4go/internal/ads/TagHandler_test.go
@@ -24,10 +24,10 @@ import (
"regexp"
"testing"
- model2 "github.com/apache/plc4x/plc4go/internal/ads/model"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- model3 "github.com/apache/plc4x/plc4go/spi/model"
+ "github.com/apache/plc4x/plc4go/internal/ads/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
func TestTagHandler_ParseQuery(t *testing.T) {
@@ -43,7 +43,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
name string
tags tags
args args
- want model.PlcTag
+ want apiModel.PlcTag
wantErr bool
}{
// All tests without any array notation.
@@ -52,11 +52,11 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:BOOL",
},
- want: model2.DirectPlcTag{
+ want: model.DirectPlcTag{
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -64,11 +64,11 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:BOOL",
},
- want: model2.DirectPlcTag{
+ want: model.DirectPlcTag{
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -76,10 +76,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:STRING(80)",
},
- want: model2.DirectPlcTag{
+ want: model.DirectPlcTag{
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.STRING,
+ ValueType: apiValues.STRING,
StringLength: 80,
},
},
@@ -88,10 +88,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:WSTRING(80)",
},
- want: model2.DirectPlcTag{
+ want: model.DirectPlcTag{
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.WSTRING,
+ ValueType: apiValues.WSTRING,
StringLength: 80,
},
},
@@ -100,7 +100,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "MAIN.testVariable",
},
- want: model2.SymbolicPlcTag{
+ want: model.SymbolicPlcTag{
SymbolicAddress: "MAIN.testVariable",
},
},
@@ -110,10 +110,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:BOOL[42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -121,8 +121,8 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -130,10 +130,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:BOOL[42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -141,8 +141,8 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -150,10 +150,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:STRING(80)[42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -161,7 +161,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.STRING,
+ ValueType: apiValues.STRING,
StringLength: 80,
},
},
@@ -170,10 +170,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:WSTRING(80)[42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -181,7 +181,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.WSTRING,
+ ValueType: apiValues.WSTRING,
StringLength: 80,
},
},
@@ -190,10 +190,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "MAIN.testVariable[42]",
},
- want: model2.SymbolicPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.SymbolicPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -208,10 +208,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:BOOL[23..42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -219,8 +219,8 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -228,10 +228,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:BOOL[23..42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -239,8 +239,8 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -248,10 +248,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:STRING(80)[23..42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -259,7 +259,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.STRING,
+ ValueType: apiValues.STRING,
StringLength: 80,
},
},
@@ -268,10 +268,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:WSTRING(80)[23..42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -279,7 +279,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.WSTRING,
+ ValueType: apiValues.WSTRING,
StringLength: 80,
},
},
@@ -288,10 +288,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "MAIN.testVariable[23..42]",
},
- want: model2.SymbolicPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.SymbolicPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -306,10 +306,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:BOOL[23:42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -317,8 +317,8 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -326,10 +326,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:BOOL[23:42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -337,8 +337,8 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.BOOL,
- StringLength: model2.NONE,
+ ValueType: apiValues.BOOL,
+ StringLength: model.NONE,
},
},
{
@@ -346,10 +346,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "1234/5678:STRING(80)[23:42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -357,7 +357,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.STRING,
+ ValueType: apiValues.STRING,
StringLength: 80,
},
},
@@ -366,10 +366,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "0x04D2/0x162E:WSTRING(80)[23:42]",
},
- want: model2.DirectPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.DirectPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -377,7 +377,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
},
IndexGroup: 1234,
IndexOffset: 5678,
- ValueType: values.WSTRING,
+ ValueType: apiValues.WSTRING,
StringLength: 80,
},
},
@@ -386,10 +386,10 @@ func TestTagHandler_ParseQuery(t *testing.T) {
args: args{
query: "MAIN.testVariable[23:42]",
},
- want: model2.SymbolicPlcTag{
- PlcTag: model2.PlcTag{
- ArrayInfo: []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ want: model.SymbolicPlcTag{
+ PlcTag: model.PlcTag{
+ ArrayInfo: []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
diff --git a/plc4go/internal/ads/ValueHandler.go b/plc4go/internal/ads/ValueHandler.go
index ba7155b69a..b640fbf760 100644
--- a/plc4go/internal/ads/ValueHandler.go
+++ b/plc4go/internal/ads/ValueHandler.go
@@ -24,11 +24,12 @@ import (
"reflect"
"strconv"
- model2 "github.com/apache/plc4x/plc4go/internal/ads/model"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ "github.com/apache/plc4x/plc4go/internal/ads/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
- driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
spiValues "github.com/apache/plc4x/plc4go/spi/values"
+
"github.com/pkg/errors"
)
@@ -50,29 +51,29 @@ func NewValueHandlerWithDriverContext(driverContext *DriverContext, tagHandler T
}
}
-func (t ValueHandler) NewPlcValue(tag model.PlcTag, value any) (apiValues.PlcValue, error) {
+func (t ValueHandler) NewPlcValue(tag apiModel.PlcTag, value any) (apiValues.PlcValue, error) {
return t.parseType(tag, value)
}
-func (t ValueHandler) parseType(tag model.PlcTag, value any) (apiValues.PlcValue, error) {
+func (t ValueHandler) parseType(tag apiModel.PlcTag, value any) (apiValues.PlcValue, error) {
// Resolve the symbolic tag to a direct tag, that has all the important information.
- var directTag model2.DirectPlcTag
+ var directTag model.DirectPlcTag
switch tag.(type) {
- case model2.SymbolicPlcTag:
- symbolicTag := tag.(model2.SymbolicPlcTag)
+ case model.SymbolicPlcTag:
+ symbolicTag := tag.(model.SymbolicPlcTag)
directTagPointer, err := t.driverContext.getDirectTagForSymbolTag(symbolicTag)
if err != nil {
return nil, fmt.Errorf("couldn't resolve address %s to a valid tag on the PLC", symbolicTag.SymbolicAddress)
}
directTag = *directTagPointer
- case model2.DirectPlcTag:
- directTag = tag.(model2.DirectPlcTag)
+ case model.DirectPlcTag:
+ directTag = tag.(model.DirectPlcTag)
}
return t.AdsParseType(directTag.DataType, directTag.DataType.GetArrayInfo(), value)
}
-func (t ValueHandler) AdsParseType(datatype driverModel.AdsDataTypeTableEntry, arrayInfo []driverModel.AdsDataTypeArrayInfo, value any) (apiValues.PlcValue, error) {
+func (t ValueHandler) AdsParseType(datatype readWriteModel.AdsDataTypeTableEntry, arrayInfo []readWriteModel.AdsDataTypeArrayInfo, value any) (apiValues.PlcValue, error) {
// Do the normal resolution.
if (arrayInfo != nil) && (len(arrayInfo) > 0) {
return t.AdsParseListType(datatype, arrayInfo, value)
@@ -82,7 +83,7 @@ func (t ValueHandler) AdsParseType(datatype driverModel.AdsDataTypeTableEntry, a
return t.AdsParseSimpleType(datatype, value)
}
-func (t ValueHandler) AdsParseListType(dataType driverModel.AdsDataTypeTableEntry, arrayInfo []driverModel.AdsDataTypeArrayInfo, value any) (apiValues.PlcValue, error) {
+func (t ValueHandler) AdsParseListType(dataType readWriteModel.AdsDataTypeTableEntry, arrayInfo []readWriteModel.AdsDataTypeArrayInfo, value any) (apiValues.PlcValue, error) {
// We've reached the end of the recursion.
if len(arrayInfo) == 0 {
return t.AdsParseType(dataType, arrayInfo, value)
@@ -120,7 +121,7 @@ func (t ValueHandler) AdsParseListType(dataType driverModel.AdsDataTypeTableEntr
return spiValues.NewPlcList(plcValues), nil
}
-func (t ValueHandler) AdsParseStructType(dataType driverModel.AdsDataTypeTableEntry, value any) (apiValues.PlcValue, error) {
+func (t ValueHandler) AdsParseStructType(dataType readWriteModel.AdsDataTypeTableEntry, value any) (apiValues.PlcValue, error) {
// Unfortunately it seems impossible to cast map[string]apiValues.PlcValue to map[string]any
if plcStruct, ok := value.(spiValues.PlcStruct); ok {
parsedValues := map[string]apiValues.PlcValue{}
@@ -166,7 +167,7 @@ func (t ValueHandler) AdsParseStructType(dataType driverModel.AdsDataTypeTableEn
return nil, nil
}
-func (t ValueHandler) AdsParseSimpleType(dataType driverModel.AdsDataTypeTableEntry, value any) (apiValues.PlcValue, error) {
+func (t ValueHandler) AdsParseSimpleType(dataType readWriteModel.AdsDataTypeTableEntry, value any) (apiValues.PlcValue, error) {
// Get the PlcValue type for this ads-datatype.
plcValueType := t.driverContext.getDataTypeForDataTypeTableEntry(dataType)
return t.NewPlcValueFromType(plcValueType, value)
diff --git a/plc4go/internal/ads/Writer.go b/plc4go/internal/ads/Writer.go
index 4750aa4f23..1227a8c8e0 100644
--- a/plc4go/internal/ads/Writer.go
+++ b/plc4go/internal/ads/Writer.go
@@ -27,16 +27,17 @@ import (
"github.com/apache/plc4x/plc4go/internal/ads/model"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
func (m *Connection) WriteRequestBuilder() apiModel.PlcWriteRequestBuilder {
- return internalModel.NewDefaultPlcWriteRequestBuilder(m.GetPlcTagHandler(), m.GetPlcValueHandler(), m)
+ return spiModel.NewDefaultPlcWriteRequestBuilder(m.GetPlcTagHandler(), m.GetPlcValueHandler(), m)
}
func (m *Connection) Write(ctx context.Context, writeRequest apiModel.PlcWriteRequest) <-chan apiModel.PlcWriteRequestResult {
@@ -45,7 +46,7 @@ func (m *Connection) Write(ctx context.Context, writeRequest apiModel.PlcWriteRe
go func() {
defer func() {
if err := recover(); err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Errorf("panic-ed %v", err))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Errorf("panic-ed %v", err))
}
}()
if len(writeRequest.GetTagNames()) <= 1 {
@@ -59,7 +60,7 @@ func (m *Connection) Write(ctx context.Context, writeRequest apiModel.PlcWriteRe
func (m *Connection) singleWrite(ctx context.Context, writeRequest apiModel.PlcWriteRequest, result chan apiModel.PlcWriteRequestResult) {
if len(writeRequest.GetTagNames()) != 1 {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("this part of the ads driver only supports single-item requests"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("this part of the ads driver only supports single-item requests"))
log.Debug().Msgf("this part of the ads driver only supports single-item requests. Got %d tags", len(writeRequest.GetTagNames()))
return
}
@@ -70,7 +71,7 @@ func (m *Connection) singleWrite(ctx context.Context, writeRequest apiModel.PlcW
if model.NeedsResolving(tag) {
adsField, err := model.CastToSymbolicPlcTagFromPlcTag(tag)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(
+ result <- spiModel.NewDefaultPlcWriteRequestResult(
writeRequest,
nil,
errors.Wrap(err, "invalid tag item type"),
@@ -81,14 +82,14 @@ func (m *Connection) singleWrite(ctx context.Context, writeRequest apiModel.PlcW
// Replace the symbolic tag with a direct one
tag, err = m.resolveSymbolicTag(ctx, adsField)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "invalid tag item type"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
}
directAdsTag, ok := tag.(*model.DirectPlcTag)
if !ok {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("invalid tag item type"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
@@ -98,7 +99,7 @@ func (m *Connection) singleWrite(ctx context.Context, writeRequest apiModel.PlcW
io := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
err := m.serializePlcValue(directAdsTag.DataType, directAdsTag.GetArrayInfo(), value, io)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "error serializing plc value"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "error serializing plc value"))
return
}
data := io.GetBytes()
@@ -106,12 +107,12 @@ func (m *Connection) singleWrite(ctx context.Context, writeRequest apiModel.PlcW
go func() {
defer func() {
if err := recover(); err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Errorf("panic-ed %v", err))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Errorf("panic-ed %v", err))
}
}()
response, err := m.ExecuteAdsWriteRequest(ctx, directAdsTag.IndexGroup, directAdsTag.IndexOffset, data)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "got error executing the write request"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "got error executing the write request"))
return
}
@@ -127,7 +128,7 @@ func (m *Connection) singleWrite(ctx context.Context, writeRequest apiModel.PlcW
responseCodes[tagName] = apiModel.PlcResponseCode_OK
}
// Return the response to the caller.
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, internalModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil)
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, spiModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil)
}()
}
@@ -143,21 +144,21 @@ func (m *Connection) multiWrite(ctx context.Context, writeRequest apiModel.PlcWr
if model.NeedsResolving(tag) {
adsField, err := model.CastToSymbolicPlcTagFromPlcTag(tag)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "invalid tag item type"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
// Replace the symbolic tag with a direct one
tag, err = m.resolveSymbolicTag(ctx, adsField)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "invalid tag item type"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
}
directAdsTag, ok := tag.(*model.DirectPlcTag)
if !ok {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("invalid tag item type"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("invalid tag item type"))
log.Debug().Msgf("Invalid tag item type %T", tag)
return
}
@@ -167,7 +168,7 @@ func (m *Connection) multiWrite(ctx context.Context, writeRequest apiModel.PlcWr
// Serialize the plc value
err := m.serializePlcValue(directAdsTag.DataType, directAdsTag.GetArrayInfo(), writeRequest.GetValue(tagName), io)
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "error serializing plc value"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "error serializing plc value"))
return
}
@@ -193,12 +194,12 @@ func (m *Connection) multiWrite(ctx context.Context, writeRequest apiModel.PlcWr
uint32(driverModel.ReservedIndexGroups_ADSIGRP_MULTIPLE_WRITE), uint32(len(directAdsTags)),
expectedResponseDataSize, requestItems, io.GetBytes())
if err != nil {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "error executing multi-item write request"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.Wrap(err, "error executing multi-item write request"))
return
}
if response.GetResult() != driverModel.ReturnCode_OK {
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, fmt.Errorf("got return result %s from remote", response.GetResult().String()))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, fmt.Errorf("got return result %s from remote", response.GetResult().String()))
return
}
@@ -219,10 +220,10 @@ func (m *Connection) multiWrite(ctx context.Context, writeRequest apiModel.PlcWr
}
// Return the response to the caller.
- result <- internalModel.NewDefaultPlcWriteRequestResult(writeRequest, internalModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil)
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, spiModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil)
}
-func (m *Connection) serializePlcValue(dataType driverModel.AdsDataTypeTableEntry, arrayInfo []apiModel.ArrayInfo, plcValue values.PlcValue, wb utils.WriteBufferByteBased) error {
+func (m *Connection) serializePlcValue(dataType driverModel.AdsDataTypeTableEntry, arrayInfo []apiModel.ArrayInfo, plcValue apiValues.PlcValue, wb utils.WriteBufferByteBased) error {
// Decode the data according to the information from the request
// Based on the AdsDataTypeTableEntry in tag.DataType() parse the data
if len(arrayInfo) > 0 {
@@ -279,7 +280,7 @@ func (m *Connection) serializePlcValue(dataType driverModel.AdsDataTypeTableEntr
}
var childArrayInfo []apiModel.ArrayInfo
for _, adsArrayInfo := range childDataType.GetArrayInfo() {
- childArrayInfo = append(childArrayInfo, &internalModel.DefaultArrayInfo{
+ childArrayInfo = append(childArrayInfo, &spiModel.DefaultArrayInfo{
LowerBound: adsArrayInfo.GetLowerBound(),
UpperBound: adsArrayInfo.GetUpperBound(),
})
@@ -294,7 +295,7 @@ func (m *Connection) serializePlcValue(dataType driverModel.AdsDataTypeTableEntr
} else {
// This is a primitive type.
valueType, stringLength := m.getPlcValueForAdsDataTypeTableEntry(dataType)
- if valueType == values.NULL {
+ if valueType == apiValues.NULL {
return errors.New(fmt.Sprintf("error converting %s into plc4x plc-value type", dataType.GetDataTypeName()))
}
adsValueType, ok := driverModel.PlcValueTypeByName(valueType.String())
diff --git a/plc4go/internal/ads/model/AdsSubscriptionHandle.go b/plc4go/internal/ads/model/AdsSubscriptionHandle.go
index 84e90e1fe5..111b0d576c 100644
--- a/plc4go/internal/ads/model/AdsSubscriptionHandle.go
+++ b/plc4go/internal/ads/model/AdsSubscriptionHandle.go
@@ -23,9 +23,9 @@ import (
"time"
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
"github.com/apache/plc4x/plc4go/spi"
- "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
type AdsSubscriptionHandle struct {
@@ -48,7 +48,7 @@ func NewAdsSubscriptionHandle(subscriber spi.PlcSubscriber, tagName string, dire
func (t *AdsSubscriptionHandle) Register(consumer apiModel.PlcSubscriptionEventConsumer) apiModel.PlcConsumerRegistration {
t.consumers = append(t.consumers, consumer)
- return model.NewDefaultPlcConsumerRegistration(t.subscriber, consumer, t)
+ return spiModel.NewDefaultPlcConsumerRegistration(t.subscriber, consumer, t)
}
func (t *AdsSubscriptionHandle) GetNumConsumers() int {
@@ -59,13 +59,13 @@ func (t *AdsSubscriptionHandle) GetDirectTag() DirectPlcTag {
return t.directTag
}
-func (t *AdsSubscriptionHandle) PublishPlcValue(value values.PlcValue) {
+func (t *AdsSubscriptionHandle) PublishPlcValue(value apiValues.PlcValue) {
event := NewSubscriptionEvent(
map[string]apiModel.PlcTag{t.tagName: t.directTag},
- map[string]model.SubscriptionType{t.tagName: model.SubscriptionChangeOfState},
+ map[string]spiModel.SubscriptionType{t.tagName: spiModel.SubscriptionChangeOfState},
map[string]time.Duration{t.tagName: time.Second},
map[string]apiModel.PlcResponseCode{t.tagName: apiModel.PlcResponseCode_OK},
- map[string]values.PlcValue{t.tagName: value})
+ map[string]apiValues.PlcValue{t.tagName: value})
for _, consumer := range t.consumers {
consumer(&event)
}
diff --git a/plc4go/internal/ads/model/Tag.go b/plc4go/internal/ads/model/Tag.go
index 868466799e..b37290ca12 100644
--- a/plc4go/internal/ads/model/Tag.go
+++ b/plc4go/internal/ads/model/Tag.go
@@ -25,22 +25,23 @@ import (
"fmt"
"strconv"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- driverModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/ads/readwrite/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
)
const NONE = int32(-1)
type PlcTag struct {
- model.PlcTag
+ apiModel.PlcTag
- ArrayInfo []model.ArrayInfo
+ ArrayInfo []apiModel.ArrayInfo
}
-func NeedsResolving(plcTag model.PlcTag) bool {
+func NeedsResolving(plcTag apiModel.PlcTag) bool {
switch plcTag.(type) {
case SymbolicPlcTag:
return true
@@ -56,12 +57,12 @@ type DirectPlcTag struct {
IndexGroup uint32
IndexOffset uint32
- ValueType values.PlcValueType
+ ValueType apiValues.PlcValueType
StringLength int32
- DataType driverModel.AdsDataTypeTableEntry
+ DataType readWriteModel.AdsDataTypeTableEntry
}
-func NewDirectAdsPlcTag(indexGroup uint32, indexOffset uint32, valueType values.PlcValueType, stringLength int32, arrayInfo []model.ArrayInfo) (model.PlcTag, error) {
+func NewDirectAdsPlcTag(indexGroup uint32, indexOffset uint32, valueType apiValues.PlcValueType, stringLength int32, arrayInfo []apiModel.ArrayInfo) (apiModel.PlcTag, error) {
return DirectPlcTag{
IndexGroup: indexGroup,
IndexOffset: indexOffset,
@@ -73,7 +74,7 @@ func NewDirectAdsPlcTag(indexGroup uint32, indexOffset uint32, valueType values.
}, nil
}
-func CastToDirectAdsTagFromPlcTag(plcTag model.PlcTag) (DirectPlcTag, error) {
+func CastToDirectAdsTagFromPlcTag(plcTag apiModel.PlcTag) (DirectPlcTag, error) {
if adsTag, ok := plcTag.(DirectPlcTag); ok {
return adsTag, nil
}
@@ -82,7 +83,7 @@ func CastToDirectAdsTagFromPlcTag(plcTag model.PlcTag) (DirectPlcTag, error) {
func (m DirectPlcTag) GetAddressString() string {
address := fmt.Sprintf("0x%d/%d:%s", m.IndexGroup, m.IndexOffset, m.ValueType.String())
- if m.ValueType == values.STRING || m.ValueType == values.WSTRING {
+ if m.ValueType == apiValues.STRING || m.ValueType == apiValues.WSTRING {
address = address + "(" + strconv.Itoa(int(m.StringLength)) + ")"
}
if len(m.ArrayInfo) > 0 {
@@ -93,12 +94,12 @@ func (m DirectPlcTag) GetAddressString() string {
return address
}
-func (m DirectPlcTag) GetValueType() values.PlcValueType {
+func (m DirectPlcTag) GetValueType() apiValues.PlcValueType {
return m.ValueType
}
-func (m DirectPlcTag) GetArrayInfo() []model.ArrayInfo {
- return []model.ArrayInfo{}
+func (m DirectPlcTag) GetArrayInfo() []apiModel.ArrayInfo {
+ return []apiModel.ArrayInfo{}
}
func (m DirectPlcTag) Serialize() ([]byte, error) {
@@ -123,7 +124,7 @@ func (m DirectPlcTag) SerializeWithWriteBuffer(writeBuffer utils.WriteBuffer) er
if err := writeBuffer.WriteString("adsDatatypeName", uint32(len([]rune(m.ValueType.String()))*8), "UTF-8", m.ValueType.String()); err != nil {
return err
}
- if (m.ValueType == values.STRING || m.ValueType == values.WSTRING) && (m.StringLength != NONE) {
+ if (m.ValueType == apiValues.STRING || m.ValueType == apiValues.WSTRING) && (m.StringLength != NONE) {
if err := writeBuffer.WriteInt32("stringLength", 32, m.StringLength); err != nil {
return err
}
@@ -167,7 +168,7 @@ type SymbolicPlcTag struct {
SymbolicAddress string
}
-func NewAdsSymbolicPlcTag(symbolicAddress string, arrayInfo []model.ArrayInfo) (model.PlcTag, error) {
+func NewAdsSymbolicPlcTag(symbolicAddress string, arrayInfo []apiModel.ArrayInfo) (apiModel.PlcTag, error) {
return SymbolicPlcTag{
SymbolicAddress: symbolicAddress,
PlcTag: PlcTag{
@@ -176,7 +177,7 @@ func NewAdsSymbolicPlcTag(symbolicAddress string, arrayInfo []model.ArrayInfo) (
}, nil
}
-func CastToSymbolicPlcTagFromPlcTag(plcTag model.PlcTag) (SymbolicPlcTag, error) {
+func CastToSymbolicPlcTagFromPlcTag(plcTag apiModel.PlcTag) (SymbolicPlcTag, error) {
if adsTag, ok := plcTag.(SymbolicPlcTag); ok {
return adsTag, nil
}
@@ -187,12 +188,12 @@ func (m SymbolicPlcTag) GetAddressString() string {
return m.SymbolicAddress
}
-func (m SymbolicPlcTag) GetValueType() values.PlcValueType {
- return values.NULL
+func (m SymbolicPlcTag) GetValueType() apiValues.PlcValueType {
+ return apiValues.NULL
}
-func (m SymbolicPlcTag) GetArrayInfo() []model.ArrayInfo {
- return []model.ArrayInfo{}
+func (m SymbolicPlcTag) GetArrayInfo() []apiModel.ArrayInfo {
+ return []apiModel.ArrayInfo{}
}
func (m SymbolicPlcTag) Serialize() ([]byte, error) {
diff --git a/plc4go/internal/bacnetip/Connection.go b/plc4go/internal/bacnetip/Connection.go
index 2d1cb5c5db..1bc799b950 100644
--- a/plc4go/internal/bacnetip/Connection.go
+++ b/plc4go/internal/bacnetip/Connection.go
@@ -31,7 +31,7 @@ import (
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/default"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/rs/zerolog/log"
)
@@ -120,11 +120,11 @@ func (c *Connection) GetMessageCodec() spi.MessageCodec {
}
func (c *Connection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
- return internalModel.NewDefaultPlcReadRequestBuilder(c.GetPlcTagHandler(), NewReader(&c.invokeIdGenerator, c.messageCodec, c.tm))
+ return spiModel.NewDefaultPlcReadRequestBuilder(c.GetPlcTagHandler(), NewReader(&c.invokeIdGenerator, c.messageCodec, c.tm))
}
func (c *Connection) SubscriptionRequestBuilder() apiModel.PlcSubscriptionRequestBuilder {
- return internalModel.NewDefaultPlcSubscriptionRequestBuilder(c.GetPlcTagHandler(), c.GetPlcValueHandler(), NewSubscriber(c))
+ return spiModel.NewDefaultPlcSubscriptionRequestBuilder(c.GetPlcTagHandler(), c.GetPlcValueHandler(), NewSubscriber(c))
}
func (c *Connection) addSubscriber(subscriber *Subscriber) {
diff --git a/plc4go/internal/bacnetip/Discoverer.go b/plc4go/internal/bacnetip/Discoverer.go
index 70126d4c1b..9989a0d6b3 100644
--- a/plc4go/internal/bacnetip/Discoverer.go
+++ b/plc4go/internal/bacnetip/Discoverer.go
@@ -29,7 +29,7 @@ import (
"time"
"github.com/IBM/netaddr"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/libp2p/go-reuseport"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
@@ -255,7 +255,7 @@ func handleIncomingBVLCs(ctx context.Context, callback func(event apiModel.PlcDi
if err != nil {
log.Debug().Err(err).Msg("Error parsing url")
}
- discoveryEvent := internalModel.NewDefaultPlcDiscoveryItem(
+ discoveryEvent := spiModel.NewDefaultPlcDiscoveryItem(
"bacnet-ip",
"udp",
*remoteUrl,
@@ -272,7 +272,7 @@ func handleIncomingBVLCs(ctx context.Context, callback func(event apiModel.PlcDi
if err != nil {
log.Debug().Err(err).Msg("Error parsing url")
}
- discoveryEvent := internalModel.NewDefaultPlcDiscoveryItem(
+ discoveryEvent := spiModel.NewDefaultPlcDiscoveryItem(
"bacnet-ip",
"udp",
*remoteUrl,
diff --git a/plc4go/internal/bacnetip/Tag.go b/plc4go/internal/bacnetip/Tag.go
index 7e9de273de..78934cd604 100644
--- a/plc4go/internal/bacnetip/Tag.go
+++ b/plc4go/internal/bacnetip/Tag.go
@@ -24,14 +24,14 @@ import (
"fmt"
"strings"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi/utils"
)
type BacNetPlcTag interface {
- model.PlcTag
+ apiModel.PlcTag
GetObjectId() objectId
GetProperties() []property
@@ -110,12 +110,12 @@ func (m plcTag) GetAddressString() string {
return fmt.Sprintf("%v/%s", m.ObjectId, propertiesString)
}
-func (m plcTag) GetValueType() values.PlcValueType {
- return values.Struct
+func (m plcTag) GetValueType() apiValues.PlcValueType {
+ return apiValues.Struct
}
-func (m plcTag) GetArrayInfo() []model.ArrayInfo {
- return []model.ArrayInfo{}
+func (m plcTag) GetArrayInfo() []apiModel.ArrayInfo {
+ return []apiModel.ArrayInfo{}
}
func (m plcTag) GetObjectId() objectId {
diff --git a/plc4go/internal/bacnetip/TagHandler.go b/plc4go/internal/bacnetip/TagHandler.go
index af44efc7ad..fa0e5106d0 100644
--- a/plc4go/internal/bacnetip/TagHandler.go
+++ b/plc4go/internal/bacnetip/TagHandler.go
@@ -25,9 +25,10 @@ import (
"strconv"
"strings"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
)
@@ -51,7 +52,7 @@ const (
ARRAY_INDEX = "arrayIndex"
)
-func (m TagHandler) ParseTag(tagString string) (model.PlcTag, error) {
+func (m TagHandler) ParseTag(tagString string) (apiModel.PlcTag, error) {
if addressMatch := utils.GetSubgroupMatches(m.addressPattern, tagString); addressMatch != nil {
var result plcTag
{
@@ -107,6 +108,6 @@ func (m TagHandler) ParseTag(tagString string) (model.PlcTag, error) {
return nil, errors.Errorf("Unable to parse %s", tagString)
}
-func (m TagHandler) ParseQuery(_ string) (model.PlcQuery, error) {
+func (m TagHandler) ParseQuery(_ string) (apiModel.PlcQuery, error) {
return nil, fmt.Errorf("queries not supported")
}
diff --git a/plc4go/internal/cbus/Connection.go b/plc4go/internal/cbus/Connection.go
index a424fe415a..a4935e6c88 100644
--- a/plc4go/internal/cbus/Connection.go
+++ b/plc4go/internal/cbus/Connection.go
@@ -30,7 +30,7 @@ import (
readWriteModel "github.com/apache/plc4x/plc4go/protocols/cbus/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/default"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
@@ -147,15 +147,15 @@ func (c *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
}
func (c *Connection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
- return internalModel.NewDefaultPlcReadRequestBuilder(c.GetPlcTagHandler(), NewReader(&c.alphaGenerator, c.messageCodec, c.tm))
+ return spiModel.NewDefaultPlcReadRequestBuilder(c.GetPlcTagHandler(), NewReader(&c.alphaGenerator, c.messageCodec, c.tm))
}
func (c *Connection) WriteRequestBuilder() apiModel.PlcWriteRequestBuilder {
- return internalModel.NewDefaultPlcWriteRequestBuilder(c.GetPlcTagHandler(), c.GetPlcValueHandler(), NewWriter(&c.alphaGenerator, c.messageCodec, c.tm))
+ return spiModel.NewDefaultPlcWriteRequestBuilder(c.GetPlcTagHandler(), c.GetPlcValueHandler(), NewWriter(&c.alphaGenerator, c.messageCodec, c.tm))
}
func (c *Connection) SubscriptionRequestBuilder() apiModel.PlcSubscriptionRequestBuilder {
- return internalModel.NewDefaultPlcSubscriptionRequestBuilder(c.GetPlcTagHandler(), c.GetPlcValueHandler(), NewSubscriber(c))
+ return spiModel.NewDefaultPlcSubscriptionRequestBuilder(c.GetPlcTagHandler(), c.GetPlcValueHandler(), NewSubscriber(c))
}
func (c *Connection) UnsubscriptionRequestBuilder() apiModel.PlcUnsubscriptionRequestBuilder {
@@ -164,7 +164,7 @@ func (c *Connection) UnsubscriptionRequestBuilder() apiModel.PlcUnsubscriptionRe
}
func (c *Connection) BrowseRequestBuilder() apiModel.PlcBrowseRequestBuilder {
- return internalModel.NewDefaultPlcBrowseRequestBuilder(c.GetPlcTagHandler(), NewBrowser(c))
+ return spiModel.NewDefaultPlcBrowseRequestBuilder(c.GetPlcTagHandler(), NewBrowser(c))
}
func (c *Connection) addSubscriber(subscriber *Subscriber) {
diff --git a/plc4go/internal/cbus/Discoverer.go b/plc4go/internal/cbus/Discoverer.go
index 9313c4592f..1cd681b71e 100644
--- a/plc4go/internal/cbus/Discoverer.go
+++ b/plc4go/internal/cbus/Discoverer.go
@@ -33,7 +33,7 @@ import (
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/cbus/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
"github.com/apache/plc4x/plc4go/spi/utils"
@@ -282,7 +282,7 @@ func (d *Discoverer) createDeviceScanDispatcher(tcpTransportInstance *tcp.Transp
}
// TODO: manufacturer + type would be good but this means two requests then
deviceName := identifyReplyCommand.GetManufacturerName()
- discoveryEvent := internalModel.NewDefaultPlcDiscoveryItem(
+ discoveryEvent := spiModel.NewDefaultPlcDiscoveryItem(
"c-bus",
"tcp",
remoteUrl,
diff --git a/plc4go/internal/eip/Connection.go b/plc4go/internal/eip/Connection.go
index 242d143a83..54fbb595b6 100644
--- a/plc4go/internal/eip/Connection.go
+++ b/plc4go/internal/eip/Connection.go
@@ -28,7 +28,7 @@ import (
readWriteModel "github.com/apache/plc4x/plc4go/protocols/eip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/default"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
@@ -374,11 +374,11 @@ func (m *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
}
func (m *Connection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
- return internalModel.NewDefaultPlcReadRequestBuilder(m.GetPlcTagHandler(), NewReader(m.messageCodec, m.tm, m.configuration, &m.sessionHandle))
+ return spiModel.NewDefaultPlcReadRequestBuilder(m.GetPlcTagHandler(), NewReader(m.messageCodec, m.tm, m.configuration, &m.sessionHandle))
}
func (m *Connection) WriteRequestBuilder() apiModel.PlcWriteRequestBuilder {
- return internalModel.NewDefaultPlcWriteRequestBuilder(
+ return spiModel.NewDefaultPlcWriteRequestBuilder(
m.GetPlcTagHandler(), m.GetPlcValueHandler(), NewWriter(m.messageCodec, m.tm, m.configuration, &m.sessionHandle, &m.senderContext))
}
diff --git a/plc4go/internal/eip/Tag.go b/plc4go/internal/eip/Tag.go
index 6b689e07ce..799e24cbf1 100644
--- a/plc4go/internal/eip/Tag.go
+++ b/plc4go/internal/eip/Tag.go
@@ -23,28 +23,28 @@ import (
"context"
"encoding/binary"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- readWrite "github.com/apache/plc4x/plc4go/protocols/eip/readwrite/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/eip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi/utils"
)
type EIPPlcTag interface {
- model.PlcTag
+ apiModel.PlcTag
utils.Serializable
GetTag() string
- GetType() readWrite.CIPDataTypeCode
+ GetType() readWriteModel.CIPDataTypeCode
GetElementNb() uint16
}
type plcTag struct {
Tag string
- Type readWrite.CIPDataTypeCode
+ Type readWriteModel.CIPDataTypeCode
ElementNb uint16
}
-func NewTag(tag string, _type readWrite.CIPDataTypeCode, elementNb uint16) plcTag {
+func NewTag(tag string, _type readWriteModel.CIPDataTypeCode, elementNb uint16) plcTag {
return plcTag{
Tag: tag,
Type: _type,
@@ -56,23 +56,23 @@ func (m plcTag) GetAddressString() string {
return m.GetTag()
}
-func (m plcTag) GetValueType() values.PlcValueType {
- if plcValueType, ok := values.PlcValueByName(m.GetType().String()); !ok {
- return values.NULL
+func (m plcTag) GetValueType() apiValues.PlcValueType {
+ if plcValueType, ok := apiValues.PlcValueByName(m.GetType().String()); !ok {
+ return apiValues.NULL
} else {
return plcValueType
}
}
-func (m plcTag) GetArrayInfo() []model.ArrayInfo {
- return []model.ArrayInfo{}
+func (m plcTag) GetArrayInfo() []apiModel.ArrayInfo {
+ return []apiModel.ArrayInfo{}
}
func (m plcTag) GetTag() string {
return m.Tag
}
-func (m plcTag) GetType() readWrite.CIPDataTypeCode {
+func (m plcTag) GetType() readWriteModel.CIPDataTypeCode {
return m.Type
}
diff --git a/plc4go/internal/eip/TagHandler.go b/plc4go/internal/eip/TagHandler.go
index 2ba47d6aa3..aa3eb94313 100644
--- a/plc4go/internal/eip/TagHandler.go
+++ b/plc4go/internal/eip/TagHandler.go
@@ -23,7 +23,7 @@ import (
"fmt"
"regexp"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
type TagHandler struct {
@@ -42,11 +42,11 @@ const (
ELEMENT_NB = "elementNb"
)
-func (m TagHandler) ParseTag(tagAddress string) (model.PlcTag, error) {
+func (m TagHandler) ParseTag(tagAddress string) (apiModel.PlcTag, error) {
// TODO: This isn't pretty ...
return NewTag(tagAddress, 0, uint16(1)), nil
}
-func (m TagHandler) ParseQuery(query string) (model.PlcQuery, error) {
+func (m TagHandler) ParseQuery(query string) (apiModel.PlcQuery, error) {
return nil, fmt.Errorf("queries not supported")
}
diff --git a/plc4go/internal/eip/Writer.go b/plc4go/internal/eip/Writer.go
index 6522cec5f3..81f05206c5 100644
--- a/plc4go/internal/eip/Writer.go
+++ b/plc4go/internal/eip/Writer.go
@@ -24,8 +24,8 @@ import (
"encoding/binary"
"strings"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/eip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
@@ -53,9 +53,9 @@ func NewWriter(messageCodec spi.MessageCodec, tm spi.RequestTransactionManager,
}
}
-func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <-chan model.PlcWriteRequestResult {
+func (m Writer) Write(ctx context.Context, writeRequest apiModel.PlcWriteRequest) <-chan apiModel.PlcWriteRequestResult {
// TODO: handle context
- result := make(chan model.PlcWriteRequestResult, 1)
+ result := make(chan apiModel.PlcWriteRequestResult, 1)
go func() {
defer func() {
if err := recover(); err != nil {
@@ -266,7 +266,7 @@ func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <
return result
}
-func encodeValue(value values.PlcValue, _type readWriteModel.CIPDataTypeCode, elements uint16) ([]byte, error) {
+func encodeValue(value apiValues.PlcValue, _type readWriteModel.CIPDataTypeCode, elements uint16) ([]byte, error) {
buffer := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
switch _type {
case readWriteModel.CIPDataTypeCode_SINT:
@@ -296,8 +296,8 @@ func encodeValue(value values.PlcValue, _type readWriteModel.CIPDataTypeCode, el
return buffer.GetBytes(), nil
}
-func (m Writer) ToPlc4xWriteResponse(response readWriteModel.CipService, writeRequest model.PlcWriteRequest) (model.PlcWriteResponse, error) {
- responseCodes := map[string]model.PlcResponseCode{}
+func (m Writer) ToPlc4xWriteResponse(response readWriteModel.CipService, writeRequest apiModel.PlcWriteRequest) (apiModel.PlcWriteResponse, error) {
+ responseCodes := map[string]apiModel.PlcResponseCode{}
switch response := response.(type) {
case readWriteModel.CipWriteResponse: // only 1 tag
cipReadResponse := response
@@ -331,7 +331,7 @@ func (m Writer) ToPlc4xWriteResponse(response readWriteModel.CipService, writeRe
code := decodeResponseCode(writeResponse.GetStatus())
responseCodes[tagName] = code
} else {
- responseCodes[tagName] = model.PlcResponseCode_INTERNAL_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_INTERNAL_ERROR
}
}*/
default:
diff --git a/plc4go/internal/knxnetip/Browser.go b/plc4go/internal/knxnetip/Browser.go
index 88905c36d0..df081b2741 100644
--- a/plc4go/internal/knxnetip/Browser.go
+++ b/plc4go/internal/knxnetip/Browser.go
@@ -33,7 +33,7 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api/values"
driverModel "github.com/apache/plc4x/plc4go/protocols/knxnetip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
- "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
@@ -103,7 +103,7 @@ func (m Browser) executeDeviceQuery(ctx context.Context, query DeviceQuery, inte
// If the request returned a connection, process it,
// otherwise just ignore it.
if deviceConnection.connection != nil {
- queryResult := model.NewDefaultPlcBrowseItem(
+ queryResult := spiModel.NewDefaultPlcBrowseItem(
NewDeviceQuery(
strconv.Itoa(int(knxAddress.GetMainGroup())),
strconv.Itoa(int(knxAddress.GetMiddleGroup())),
@@ -405,7 +405,7 @@ func (m Browser) executeCommunicationObjectQuery(ctx context.Context, query Comm
&tagType)
}
- results = append(results, model.NewDefaultPlcBrowseItem(
+ results = append(results, spiModel.NewDefaultPlcBrowseItem(
tag,
fmt.Sprintf("#%d", comObjectNumber),
"",
@@ -487,7 +487,7 @@ func (m Browser) executeCommunicationObjectQuery(ctx context.Context, query Comm
for _, groupAddress := range groupAddresses {
tag := m.getTagForGroupAddress(groupAddress, tagType)
- results = append(results, model.NewDefaultPlcBrowseItem(
+ results = append(results, spiModel.NewDefaultPlcBrowseItem(
tag,
fmt.Sprintf("#%d", comObjectNumber),
"",
diff --git a/plc4go/internal/knxnetip/Discoverer.go b/plc4go/internal/knxnetip/Discoverer.go
index 2007cdb262..dd1b8ad024 100644
--- a/plc4go/internal/knxnetip/Discoverer.go
+++ b/plc4go/internal/knxnetip/Discoverer.go
@@ -33,7 +33,7 @@ import (
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
driverModel "github.com/apache/plc4x/plc4go/protocols/knxnetip/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
"github.com/apache/plc4x/plc4go/spi/transports/udp"
@@ -215,7 +215,7 @@ func (d *Discoverer) createDeviceScanDispatcher(udpTransportInstance *udp.Transp
continue
}
deviceName := string(bytes.Trim(searchResponse.GetDibDeviceInfo().GetDeviceFriendlyName(), "\x00"))
- discoveryEvent := internalModel.NewDefaultPlcDiscoveryItem(
+ discoveryEvent := spiModel.NewDefaultPlcDiscoveryItem(
"knxnet-ip",
"udp",
*remoteUrl,
diff --git a/plc4go/internal/knxnetip/SubscriptionEvent.go b/plc4go/internal/knxnetip/SubscriptionEvent.go
index c02a45b3e5..974f57d159 100644
--- a/plc4go/internal/knxnetip/SubscriptionEvent.go
+++ b/plc4go/internal/knxnetip/SubscriptionEvent.go
@@ -25,22 +25,22 @@ import (
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/pkg/api/values"
driverModel "github.com/apache/plc4x/plc4go/protocols/knxnetip/readwrite/model"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/rs/zerolog/log"
)
type SubscriptionEvent struct {
- *internalModel.DefaultPlcSubscriptionEvent
+ *spiModel.DefaultPlcSubscriptionEvent
addresses map[string][]byte
}
-func NewSubscriptionEvent(tags map[string]apiModel.PlcTag, types map[string]internalModel.SubscriptionType,
+func NewSubscriptionEvent(tags map[string]apiModel.PlcTag, types map[string]spiModel.SubscriptionType,
intervals map[string]time.Duration, responseCodes map[string]apiModel.PlcResponseCode,
addresses map[string][]byte, values map[string]values.PlcValue) SubscriptionEvent {
subscriptionEvent := SubscriptionEvent{addresses: addresses}
- event := internalModel.NewDefaultPlcSubscriptionEvent(&subscriptionEvent, tags, types, intervals, responseCodes, values)
- subscriptionEvent.DefaultPlcSubscriptionEvent = event.(*internalModel.DefaultPlcSubscriptionEvent)
+ event := spiModel.NewDefaultPlcSubscriptionEvent(&subscriptionEvent, tags, types, intervals, responseCodes, values)
+ subscriptionEvent.DefaultPlcSubscriptionEvent = event.(*spiModel.DefaultPlcSubscriptionEvent)
return subscriptionEvent
}
diff --git a/plc4go/internal/knxnetip/ValueHandler.go b/plc4go/internal/knxnetip/ValueHandler.go
index 402b916203..127447f87f 100644
--- a/plc4go/internal/knxnetip/ValueHandler.go
+++ b/plc4go/internal/knxnetip/ValueHandler.go
@@ -20,8 +20,8 @@
package knxnetip
import (
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
)
type ValueHandler struct {
@@ -31,6 +31,6 @@ func NewValueHandler() ValueHandler {
return ValueHandler{}
}
-func (m ValueHandler) NewPlcValue(tag model.PlcTag, value any) (values.PlcValue, error) {
+func (m ValueHandler) NewPlcValue(tag apiModel.PlcTag, value any) (apiValues.PlcValue, error) {
return nil, nil
}
diff --git a/plc4go/internal/knxnetip/Writer.go b/plc4go/internal/knxnetip/Writer.go
index 7b62ba14d7..df6f0c7c77 100644
--- a/plc4go/internal/knxnetip/Writer.go
+++ b/plc4go/internal/knxnetip/Writer.go
@@ -23,10 +23,10 @@ import (
"context"
"errors"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/knxnetip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
- plc4goModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
type Writer struct {
@@ -39,9 +39,9 @@ func NewWriter(messageCodec spi.MessageCodec) Writer {
}
}
-func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <-chan model.PlcWriteRequestResult {
+func (m Writer) Write(ctx context.Context, writeRequest apiModel.PlcWriteRequest) <-chan apiModel.PlcWriteRequestResult {
// TODO: handle context
- result := make(chan model.PlcWriteRequestResult, 1)
+ result := make(chan apiModel.PlcWriteRequestResult, 1)
// If we are requesting only one tag, use a
if len(writeRequest.GetTagNames()) == 1 {
tagName := writeRequest.GetTagNames()[0]
@@ -50,7 +50,7 @@ func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <
tag := writeRequest.GetTag(tagName)
groupAddressTag, err := CastToGroupAddressTagFromPlcTag(tag)
if err != nil {
- result <- plc4goModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("invalid tag item type"))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("invalid tag item type"))
return result
}
@@ -59,7 +59,7 @@ func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <
tagType := groupAddressTag.GetTagType()
// TODO: why do we ignore the bytes here?
if _, err := readWriteModel.KnxDatapointSerialize(value, *tagType); err != nil {
- result <- plc4goModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("error serializing value: "+err.Error()))
+ result <- spiModel.NewDefaultPlcWriteRequestResult(writeRequest, nil, errors.New("error serializing value: "+err.Error()))
return result
}
}
diff --git a/plc4go/internal/modbus/Reader.go b/plc4go/internal/modbus/Reader.go
index 586b840150..9d94f74cce 100644
--- a/plc4go/internal/modbus/Reader.go
+++ b/plc4go/internal/modbus/Reader.go
@@ -25,11 +25,12 @@ import (
"sync/atomic"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -48,10 +49,10 @@ func NewReader(unitIdentifier uint8, messageCodec spi.MessageCodec) *Reader {
}
}
-func (m *Reader) Read(ctx context.Context, readRequest model.PlcReadRequest) <-chan model.PlcReadRequestResult {
+func (m *Reader) Read(ctx context.Context, readRequest apiModel.PlcReadRequest) <-chan apiModel.PlcReadRequestResult {
// TODO: handle ctx
log.Trace().Msg("Reading")
- result := make(chan model.PlcReadRequestResult, 1)
+ result := make(chan apiModel.PlcReadRequestResult, 1)
go func() {
defer func() {
if err := recover(); err != nil {
@@ -164,7 +165,7 @@ func (m *Reader) Read(ctx context.Context, readRequest model.PlcReadRequest) <-c
return result
}
-func (m *Reader) ToPlc4xReadResponse(responseAdu readWriteModel.ModbusTcpADU, readRequest model.PlcReadRequest) (model.PlcReadResponse, error) {
+func (m *Reader) ToPlc4xReadResponse(responseAdu readWriteModel.ModbusTcpADU, readRequest apiModel.PlcReadRequest) (apiModel.PlcReadResponse, error) {
var data []uint8
switch pdu := responseAdu.GetPdu().(type) {
case readWriteModel.ModbusPDUReadDiscreteInputsResponse:
@@ -198,10 +199,10 @@ func (m *Reader) ToPlc4xReadResponse(responseAdu readWriteModel.ModbusTcpADU, re
if err != nil {
return nil, errors.Wrap(err, "Error parsing data item")
}
- responseCodes := map[string]model.PlcResponseCode{}
- plcValues := map[string]values.PlcValue{}
+ responseCodes := map[string]apiModel.PlcResponseCode{}
+ plcValues := map[string]apiValues.PlcValue{}
plcValues[tagName] = value
- responseCodes[tagName] = model.PlcResponseCode_OK
+ responseCodes[tagName] = apiModel.PlcResponseCode_OK
// Return the response
log.Trace().Msg("Returning the response")
diff --git a/plc4go/internal/modbus/Tag.go b/plc4go/internal/modbus/Tag.go
index 0a5d9aff26..e9b6b1863e 100644
--- a/plc4go/internal/modbus/Tag.go
+++ b/plc4go/internal/modbus/Tag.go
@@ -25,11 +25,12 @@ import (
"fmt"
"strconv"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- model2 "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite/model"
- model3 "github.com/apache/plc4x/plc4go/spi/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -39,15 +40,15 @@ const (
)
type modbusTag struct {
- model.PlcTag
+ apiModel.PlcTag
TagType TagType
Address uint16
Quantity uint16
- Datatype model2.ModbusDataType
+ Datatype readWriteModel.ModbusDataType
}
-func NewTag(tagType TagType, address uint16, quantity uint16, datatype model2.ModbusDataType) modbusTag {
+func NewTag(tagType TagType, address uint16, quantity uint16, datatype readWriteModel.ModbusDataType) modbusTag {
return modbusTag{
TagType: tagType,
Address: address - AddressOffset,
@@ -56,7 +57,7 @@ func NewTag(tagType TagType, address uint16, quantity uint16, datatype model2.Mo
}
}
-func NewModbusPlcTagFromStrings(tagType TagType, addressString string, quantityString string, datatype model2.ModbusDataType) (model.PlcTag, error) {
+func NewModbusPlcTagFromStrings(tagType TagType, addressString string, quantityString string, datatype readWriteModel.ModbusDataType) (apiModel.PlcTag, error) {
address, err := strconv.ParseUint(addressString, 10, 16)
if err != nil {
return nil, errors.Errorf("Couldn't parse address string '%s' into an int", addressString)
@@ -77,27 +78,27 @@ func (m modbusTag) GetAddressString() string {
return fmt.Sprintf("%dx%05d:%s[%d]", m.TagType, m.Address, m.Datatype.String(), m.Quantity)
}
-func (m modbusTag) GetValueType() values.PlcValueType {
- if plcValueType, ok := values.PlcValueByName(m.Datatype.String()); !ok {
- return values.NULL
+func (m modbusTag) GetValueType() apiValues.PlcValueType {
+ if plcValueType, ok := apiValues.PlcValueByName(m.Datatype.String()); !ok {
+ return apiValues.NULL
} else {
return plcValueType
}
}
-func (m modbusTag) GetArrayInfo() []model.ArrayInfo {
+func (m modbusTag) GetArrayInfo() []apiModel.ArrayInfo {
if m.Quantity != 1 {
- return []model.ArrayInfo{
- &model3.DefaultArrayInfo{
+ return []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(m.Quantity),
},
}
}
- return []model.ArrayInfo{}
+ return []apiModel.ArrayInfo{}
}
-func CastToModbusTagFromPlcTag(plcTag model.PlcTag) (modbusTag, error) {
+func CastToModbusTagFromPlcTag(plcTag apiModel.PlcTag) (modbusTag, error) {
if modbusTagVar, ok := plcTag.(modbusTag); ok {
return modbusTagVar, nil
}
diff --git a/plc4go/internal/modbus/TagHandler.go b/plc4go/internal/modbus/TagHandler.go
index 746fb287e5..47987b49dc 100644
--- a/plc4go/internal/modbus/TagHandler.go
+++ b/plc4go/internal/modbus/TagHandler.go
@@ -23,9 +23,10 @@ import (
"fmt"
"regexp"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- model2 "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
)
@@ -74,63 +75,63 @@ func NewTagHandler() TagHandler {
}
}
-func (m TagHandler) ParseTag(tagAddress string) (model.PlcTag, error) {
+func (m TagHandler) ParseTag(tagAddress string) (apiModel.PlcTag, error) {
if match := utils.GetSubgroupMatches(m.plc4xCoilPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(Coil, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.numericCoilPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(Coil, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.plc4xDiscreteInputPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(DiscreteInput, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.numericDiscreteInputPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(DiscreteInput, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.plc4xInputRegisterPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(InputRegister, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.numericInputRegisterPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(InputRegister, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.plc4xHoldingRegisterPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(HoldingRegister, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.numericHoldingRegisterPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(HoldingRegister, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.plc4xExtendedRegisterPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
return NewModbusPlcTagFromStrings(ExtendedRegister, match["address"], match["quantity"], typeByName)
} else if match := utils.GetSubgroupMatches(m.numericExtendedRegisterPattern, tagAddress); match != nil {
- typeByName, ok := model2.ModbusDataTypeByName(match["datatype"])
+ typeByName, ok := readWriteModel.ModbusDataTypeByName(match["datatype"])
if !ok {
return nil, errors.Errorf("Unknown type %s", match["datatype"])
}
@@ -139,6 +140,6 @@ func (m TagHandler) ParseTag(tagAddress string) (model.PlcTag, error) {
return nil, errors.Errorf("Invalid address format for address '%s'", tagAddress)
}
-func (m TagHandler) ParseQuery(query string) (model.PlcQuery, error) {
+func (m TagHandler) ParseQuery(query string) (apiModel.PlcQuery, error) {
return nil, fmt.Errorf("queries not supported")
}
diff --git a/plc4go/internal/modbus/Writer.go b/plc4go/internal/modbus/Writer.go
index a28e718dce..24f14dd89b 100644
--- a/plc4go/internal/modbus/Writer.go
+++ b/plc4go/internal/modbus/Writer.go
@@ -25,10 +25,11 @@ import (
"sync/atomic"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -47,9 +48,9 @@ func NewWriter(unitIdentifier uint8, messageCodec spi.MessageCodec) Writer {
}
}
-func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <-chan model.PlcWriteRequestResult {
+func (m Writer) Write(ctx context.Context, writeRequest apiModel.PlcWriteRequest) <-chan apiModel.PlcWriteRequestResult {
// TODO: handle context
- result := make(chan model.PlcWriteRequestResult, 1)
+ result := make(chan apiModel.PlcWriteRequestResult, 1)
go func() {
// If we are requesting only one tag, use a
if len(writeRequest.GetTagNames()) != 1 {
@@ -145,45 +146,45 @@ func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <
return result
}
-func (m Writer) ToPlc4xWriteResponse(requestAdu readWriteModel.ModbusTcpADU, responseAdu readWriteModel.ModbusTcpADU, writeRequest model.PlcWriteRequest) (model.PlcWriteResponse, error) {
- responseCodes := map[string]model.PlcResponseCode{}
+func (m Writer) ToPlc4xWriteResponse(requestAdu readWriteModel.ModbusTcpADU, responseAdu readWriteModel.ModbusTcpADU, writeRequest apiModel.PlcWriteRequest) (apiModel.PlcWriteResponse, error) {
+ responseCodes := map[string]apiModel.PlcResponseCode{}
tagName := writeRequest.GetTagNames()[0]
// we default to an error until its proven wrong
- responseCodes[tagName] = model.PlcResponseCode_INTERNAL_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_INTERNAL_ERROR
switch resp := responseAdu.GetPdu().(type) {
case readWriteModel.ModbusPDUWriteMultipleCoilsResponse:
req := requestAdu.GetPdu().(readWriteModel.ModbusPDUWriteMultipleCoilsRequest)
if req.GetQuantity() == resp.GetQuantity() {
- responseCodes[tagName] = model.PlcResponseCode_OK
+ responseCodes[tagName] = apiModel.PlcResponseCode_OK
}
case readWriteModel.ModbusPDUWriteMultipleHoldingRegistersResponse:
req := requestAdu.GetPdu().(readWriteModel.ModbusPDUWriteMultipleHoldingRegistersRequest)
if req.GetQuantity() == resp.GetQuantity() {
- responseCodes[tagName] = model.PlcResponseCode_OK
+ responseCodes[tagName] = apiModel.PlcResponseCode_OK
}
case readWriteModel.ModbusPDUError:
switch resp.GetExceptionCode() {
case readWriteModel.ModbusErrorCode_ILLEGAL_FUNCTION:
- responseCodes[tagName] = model.PlcResponseCode_UNSUPPORTED
+ responseCodes[tagName] = apiModel.PlcResponseCode_UNSUPPORTED
case readWriteModel.ModbusErrorCode_ILLEGAL_DATA_ADDRESS:
- responseCodes[tagName] = model.PlcResponseCode_INVALID_ADDRESS
+ responseCodes[tagName] = apiModel.PlcResponseCode_INVALID_ADDRESS
case readWriteModel.ModbusErrorCode_ILLEGAL_DATA_VALUE:
- responseCodes[tagName] = model.PlcResponseCode_INVALID_DATA
+ responseCodes[tagName] = apiModel.PlcResponseCode_INVALID_DATA
case readWriteModel.ModbusErrorCode_SLAVE_DEVICE_FAILURE:
- responseCodes[tagName] = model.PlcResponseCode_REMOTE_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_REMOTE_ERROR
case readWriteModel.ModbusErrorCode_ACKNOWLEDGE:
- responseCodes[tagName] = model.PlcResponseCode_OK
+ responseCodes[tagName] = apiModel.PlcResponseCode_OK
case readWriteModel.ModbusErrorCode_SLAVE_DEVICE_BUSY:
- responseCodes[tagName] = model.PlcResponseCode_REMOTE_BUSY
+ responseCodes[tagName] = apiModel.PlcResponseCode_REMOTE_BUSY
case readWriteModel.ModbusErrorCode_NEGATIVE_ACKNOWLEDGE:
- responseCodes[tagName] = model.PlcResponseCode_REMOTE_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_REMOTE_ERROR
case readWriteModel.ModbusErrorCode_MEMORY_PARITY_ERROR:
- responseCodes[tagName] = model.PlcResponseCode_INTERNAL_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_INTERNAL_ERROR
case readWriteModel.ModbusErrorCode_GATEWAY_PATH_UNAVAILABLE:
- responseCodes[tagName] = model.PlcResponseCode_INTERNAL_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_INTERNAL_ERROR
case readWriteModel.ModbusErrorCode_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND:
- responseCodes[tagName] = model.PlcResponseCode_REMOTE_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_REMOTE_ERROR
default:
log.Debug().Msgf("Unmapped exception code %x", resp.GetExceptionCode())
}
diff --git a/plc4go/internal/s7/Connection.go b/plc4go/internal/s7/Connection.go
index e980e7bbed..cc45c9111e 100644
--- a/plc4go/internal/s7/Connection.go
+++ b/plc4go/internal/s7/Connection.go
@@ -31,7 +31,7 @@ import (
readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/default"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
@@ -438,11 +438,11 @@ func (m *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
}
func (m *Connection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
- return internalModel.NewDefaultPlcReadRequestBuilder(m.GetPlcTagHandler(), NewReader(&m.tpduGenerator, m.messageCodec, m.tm))
+ return spiModel.NewDefaultPlcReadRequestBuilder(m.GetPlcTagHandler(), NewReader(&m.tpduGenerator, m.messageCodec, m.tm))
}
func (m *Connection) WriteRequestBuilder() apiModel.PlcWriteRequestBuilder {
- return internalModel.NewDefaultPlcWriteRequestBuilder(
+ return spiModel.NewDefaultPlcWriteRequestBuilder(
m.GetPlcTagHandler(), m.GetPlcValueHandler(), NewWriter(&m.tpduGenerator, m.messageCodec, m.tm))
}
diff --git a/plc4go/internal/s7/Reader.go b/plc4go/internal/s7/Reader.go
index 95a50c48e1..45b8ccfa19 100644
--- a/plc4go/internal/s7/Reader.go
+++ b/plc4go/internal/s7/Reader.go
@@ -23,12 +23,13 @@ import (
"context"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
spiValues "github.com/apache/plc4x/plc4go/spi/values"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -47,10 +48,10 @@ func NewReader(tpduGenerator *TpduGenerator, messageCodec spi.MessageCodec, tm s
}
}
-func (m *Reader) Read(ctx context.Context, readRequest model.PlcReadRequest) <-chan model.PlcReadRequestResult {
+func (m *Reader) Read(ctx context.Context, readRequest apiModel.PlcReadRequest) <-chan apiModel.PlcReadRequestResult {
// TODO: handle ctx
log.Trace().Msg("Reading")
- result := make(chan model.PlcReadRequestResult, 1)
+ result := make(chan apiModel.PlcReadRequestResult, 1)
go func() {
defer func() {
if err := recover(); err != nil {
@@ -162,7 +163,7 @@ func (m *Reader) Read(ctx context.Context, readRequest model.PlcReadRequest) <-c
return result
}
-func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequest model.PlcReadRequest) (model.PlcReadResponse, error) {
+func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequest apiModel.PlcReadRequest) (apiModel.PlcReadResponse, error) {
var errorClass uint8
var errorCode uint8
switch messageResponseData := response.(type) {
@@ -175,8 +176,8 @@ func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequ
default:
return nil, errors.Errorf("unsupported response type %T", response)
}
- responseCodes := map[string]model.PlcResponseCode{}
- plcValues := map[string]values.PlcValue{}
+ responseCodes := map[string]apiModel.PlcResponseCode{}
+ plcValues := map[string]apiValues.PlcValue{}
// If the result contains any form of non-null error code, handle this instead.
if (errorClass != 0) || (errorCode != 0) {
@@ -185,7 +186,7 @@ func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequ
log.Warn().Msg("Got an error response from the PLC. This particular response code usually indicates " +
"that PUT/GET is not enabled on the PLC.")
for _, tagName := range readRequest.GetTagNames() {
- responseCodes[tagName] = model.PlcResponseCode_ACCESS_DENIED
+ responseCodes[tagName] = apiModel.PlcResponseCode_ACCESS_DENIED
plcValues[tagName] = spiValues.NewPlcNULL()
}
log.Trace().Msg("Returning the response")
@@ -197,7 +198,7 @@ func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequ
"containing a capture of the communication.",
errorClass, errorCode)
for _, tagName := range readRequest.GetTagNames() {
- responseCodes[tagName] = model.PlcResponseCode_INTERNAL_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_INTERNAL_ERROR
plcValues[tagName] = spiValues.NewPlcNULL()
}
return spiModel.NewDefaultPlcReadResponse(readRequest, responseCodes, plcValues), nil
@@ -223,7 +224,7 @@ func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequ
// Decode the data according to the information from the request
log.Trace().Msg("decode data")
responseCodes[tagName] = responseCode
- if responseCode == model.PlcResponseCode_OK {
+ if responseCode == apiModel.PlcResponseCode_OK {
plcValue, err := readWriteModel.DataItemParse(context.Background(), payloadItem.GetData(), tag.GetDataType().DataProtocolId(), int32(tag.GetNumElements()))
if err != nil {
return nil, errors.Wrap(err, "Error parsing data item")
@@ -239,7 +240,7 @@ func (m *Reader) ToPlc4xReadResponse(response readWriteModel.S7Message, readRequ
// Currently we only support the S7 Any type of addresses. This helper simply converts the S7Tag from PLC4X into
// S7Address objects.
-func encodeS7Address(tag model.PlcTag) (readWriteModel.S7Address, error) {
+func encodeS7Address(tag apiModel.PlcTag) (readWriteModel.S7Address, error) {
s7Tag, ok := tag.(PlcTag)
if !ok {
return nil, errors.Errorf("Unsupported address type %t", tag)
@@ -280,17 +281,17 @@ func encodeS7Address(tag model.PlcTag) (readWriteModel.S7Address, error) {
}
// Helper to convert the return codes returned from the S7 into one of our standard
-func decodeResponseCode(dataTransportErrorCode readWriteModel.DataTransportErrorCode) model.PlcResponseCode {
+func decodeResponseCode(dataTransportErrorCode readWriteModel.DataTransportErrorCode) apiModel.PlcResponseCode {
switch dataTransportErrorCode {
case readWriteModel.DataTransportErrorCode_OK:
- return model.PlcResponseCode_OK
+ return apiModel.PlcResponseCode_OK
case readWriteModel.DataTransportErrorCode_NOT_FOUND:
- return model.PlcResponseCode_NOT_FOUND
+ return apiModel.PlcResponseCode_NOT_FOUND
case readWriteModel.DataTransportErrorCode_INVALID_ADDRESS:
- return model.PlcResponseCode_INVALID_ADDRESS
+ return apiModel.PlcResponseCode_INVALID_ADDRESS
case readWriteModel.DataTransportErrorCode_DATA_TYPE_NOT_SUPPORTED:
- return model.PlcResponseCode_INVALID_DATATYPE
+ return apiModel.PlcResponseCode_INVALID_DATATYPE
default:
- return model.PlcResponseCode_INTERNAL_ERROR
+ return apiModel.PlcResponseCode_INTERNAL_ERROR
}
}
diff --git a/plc4go/internal/s7/Tag.go b/plc4go/internal/s7/Tag.go
index 4c01472234..443e5b33a1 100644
--- a/plc4go/internal/s7/Tag.go
+++ b/plc4go/internal/s7/Tag.go
@@ -24,15 +24,15 @@ import (
"encoding/binary"
"fmt"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
- model2 "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
)
type PlcTag interface {
- model.PlcTag
+ apiModel.PlcTag
utils.Serializable
GetDataType() readWriteModel.TransportSize
@@ -90,23 +90,23 @@ func (m plcTag) GetAddressString() string {
return fmt.Sprintf("%d:%s[%d]", m.TagType, m.Datatype, m.NumElements)
}
-func (m plcTag) GetValueType() values.PlcValueType {
- if plcValueByName, ok := values.PlcValueByName(m.Datatype.String()); ok {
+func (m plcTag) GetValueType() apiValues.PlcValueType {
+ if plcValueByName, ok := apiValues.PlcValueByName(m.Datatype.String()); ok {
return plcValueByName
}
- return values.NULL
+ return apiValues.NULL
}
-func (m plcTag) GetArrayInfo() []model.ArrayInfo {
+func (m plcTag) GetArrayInfo() []apiModel.ArrayInfo {
if m.NumElements != 1 {
- return []model.ArrayInfo{
- &model2.DefaultArrayInfo{
+ return []apiModel.ArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(m.NumElements),
},
}
}
- return []model.ArrayInfo{}
+ return []apiModel.ArrayInfo{}
}
func (m plcTag) GetDataType() readWriteModel.TransportSize {
diff --git a/plc4go/internal/s7/TagHandler.go b/plc4go/internal/s7/TagHandler.go
index 6c2bc99cb0..026e876aad 100644
--- a/plc4go/internal/s7/TagHandler.go
+++ b/plc4go/internal/s7/TagHandler.go
@@ -26,9 +26,10 @@ import (
"strconv"
"strings"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
"github.com/apache/plc4x/plc4go/spi/utils"
+
"github.com/pkg/errors"
)
@@ -76,7 +77,7 @@ const (
MEMORY_AREA = "memoryArea"
)
-func (m TagHandler) ParseTag(tagAddress string) (model.PlcTag, error) {
+func (m TagHandler) ParseTag(tagAddress string) (apiModel.PlcTag, error) {
if match := utils.GetSubgroupMatches(m.dataBlockStringAddressPattern, tagAddress); match != nil {
dataType, ok := readWriteModel.TransportSizeByName(match[DATA_TYPE])
if !ok {
@@ -319,7 +320,7 @@ func (m TagHandler) ParseTag(tagAddress string) (model.PlcTag, error) {
return nil, errors.Errorf("Unable to parse %s", tagAddress)
}
-func (m TagHandler) ParseQuery(query string) (model.PlcQuery, error) {
+func (m TagHandler) ParseQuery(query string) (apiModel.PlcQuery, error) {
return nil, fmt.Errorf("queries not supported")
}
diff --git a/plc4go/internal/s7/Writer.go b/plc4go/internal/s7/Writer.go
index 870d98f8e1..171fe0660e 100644
--- a/plc4go/internal/s7/Writer.go
+++ b/plc4go/internal/s7/Writer.go
@@ -23,11 +23,12 @@ import (
"context"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -46,9 +47,9 @@ func NewWriter(tpduGenerator *TpduGenerator, messageCodec spi.MessageCodec, tm s
}
}
-func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <-chan model.PlcWriteRequestResult {
+func (m Writer) Write(ctx context.Context, writeRequest apiModel.PlcWriteRequest) <-chan apiModel.PlcWriteRequestResult {
// TODO: handle context
- result := make(chan model.PlcWriteRequestResult, 1)
+ result := make(chan apiModel.PlcWriteRequestResult, 1)
go func() {
defer func() {
if err := recover(); err != nil {
@@ -150,7 +151,7 @@ func (m Writer) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <
return result
}
-func (m Writer) ToPlc4xWriteResponse(response readWriteModel.S7Message, writeRequest model.PlcWriteRequest) (model.PlcWriteResponse, error) {
+func (m Writer) ToPlc4xWriteResponse(response readWriteModel.S7Message, writeRequest apiModel.PlcWriteRequest) (apiModel.PlcWriteResponse, error) {
var errorClass uint8
var errorCode uint8
switch messageResponseData := response.(type) {
@@ -163,7 +164,7 @@ func (m Writer) ToPlc4xWriteResponse(response readWriteModel.S7Message, writeReq
default:
return nil, errors.Errorf("unsupported response type %T", response)
}
- responseCodes := map[string]model.PlcResponseCode{}
+ responseCodes := map[string]apiModel.PlcResponseCode{}
// If the result contains any form of non-null error code, handle this instead.
if (errorClass != 0) || (errorCode != 0) {
@@ -172,7 +173,7 @@ func (m Writer) ToPlc4xWriteResponse(response readWriteModel.S7Message, writeReq
log.Warn().Msg("Got an error response from the PLC. This particular response code usually indicates " +
"that PUT/GET is not enabled on the PLC.")
for _, tagName := range writeRequest.GetTagNames() {
- responseCodes[tagName] = model.PlcResponseCode_ACCESS_DENIED
+ responseCodes[tagName] = apiModel.PlcResponseCode_ACCESS_DENIED
}
log.Trace().Msg("Returning the response")
return spiModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil
@@ -183,7 +184,7 @@ func (m Writer) ToPlc4xWriteResponse(response readWriteModel.S7Message, writeReq
"containing a capture of the communication.",
errorClass, errorCode)
for _, tagName := range writeRequest.GetTagNames() {
- responseCodes[tagName] = model.PlcResponseCode_INTERNAL_ERROR
+ responseCodes[tagName] = apiModel.PlcResponseCode_INTERNAL_ERROR
}
return spiModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil
}
@@ -214,7 +215,7 @@ func (m Writer) ToPlc4xWriteResponse(response readWriteModel.S7Message, writeReq
return spiModel.NewDefaultPlcWriteResponse(writeRequest, responseCodes), nil
}
-func serializePlcValue(tag model.PlcTag, plcValue values.PlcValue) (readWriteModel.S7VarPayloadDataItem, error) {
+func serializePlcValue(tag apiModel.PlcTag, plcValue apiValues.PlcValue) (readWriteModel.S7VarPayloadDataItem, error) {
s7Tag, ok := tag.(PlcTag)
if !ok {
return nil, errors.Errorf("Unsupported address type %t", tag)
diff --git a/plc4go/internal/simulated/Connection.go b/plc4go/internal/simulated/Connection.go
index 371303a1c5..0942a30e1c 100644
--- a/plc4go/internal/simulated/Connection.go
+++ b/plc4go/internal/simulated/Connection.go
@@ -25,7 +25,7 @@ import (
"time"
"github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
_default "github.com/apache/plc4x/plc4go/spi/default"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
@@ -228,7 +228,7 @@ func (c *Connection) Ping() <-chan plc4go.PlcConnectionPingResult {
return ch
}
-func (c *Connection) GetMetadata() model.PlcConnectionMetadata {
+func (c *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
return _default.DefaultConnectionMetadata{
ConnectionAttributes: map[string]string{
"connectionDelay": "Delay applied when connecting",
@@ -244,22 +244,22 @@ func (c *Connection) GetMetadata() model.PlcConnectionMetadata {
}
}
-func (c *Connection) ReadRequestBuilder() model.PlcReadRequestBuilder {
+func (c *Connection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
return spiModel.NewDefaultPlcReadRequestBuilder(c.tagHandler, NewReader(c.device, c.options, c.tracer))
}
-func (c *Connection) WriteRequestBuilder() model.PlcWriteRequestBuilder {
+func (c *Connection) WriteRequestBuilder() apiModel.PlcWriteRequestBuilder {
return spiModel.NewDefaultPlcWriteRequestBuilder(c.tagHandler, c.valueHandler, NewWriter(c.device, c.options, c.tracer))
}
-func (c *Connection) SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder {
+func (c *Connection) SubscriptionRequestBuilder() apiModel.PlcSubscriptionRequestBuilder {
return spiModel.NewDefaultPlcSubscriptionRequestBuilder(c.tagHandler, c.valueHandler, NewSubscriber(c.device, c.options, c.tracer))
}
-func (c *Connection) UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder {
+func (c *Connection) UnsubscriptionRequestBuilder() apiModel.PlcUnsubscriptionRequestBuilder {
panic("not provided by simulated connection")
}
-func (c *Connection) BrowseRequestBuilder() model.PlcBrowseRequestBuilder {
+func (c *Connection) BrowseRequestBuilder() apiModel.PlcBrowseRequestBuilder {
panic("not provided by simulated connection")
}
diff --git a/plc4go/internal/simulated/Connection_test.go b/plc4go/internal/simulated/Connection_test.go
index 99573f4d6c..bcdd87cab1 100644
--- a/plc4go/internal/simulated/Connection_test.go
+++ b/plc4go/internal/simulated/Connection_test.go
@@ -25,10 +25,10 @@ import (
"time"
"github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
_default "github.com/apache/plc4x/plc4go/spi/default"
- internalModel "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
)
@@ -367,7 +367,7 @@ func TestConnection_GetMetadata(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcConnectionMetadata
+ want apiModel.PlcConnectionMetadata
}{
{
name: "simple",
@@ -585,7 +585,7 @@ func TestConnection_ReadRequestBuilder(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcReadRequestBuilder
+ want apiModel.PlcReadRequestBuilder
}{
{
name: "simple",
@@ -596,7 +596,7 @@ func TestConnection_ReadRequestBuilder(t *testing.T) {
options: map[string][]string{},
connected: true,
},
- want: internalModel.NewDefaultPlcReadRequestBuilder(NewTagHandler(), NewReader(NewDevice("hurz"), map[string][]string{}, nil)),
+ want: spiModel.NewDefaultPlcReadRequestBuilder(NewTagHandler(), NewReader(NewDevice("hurz"), map[string][]string{}, nil)),
},
}
for _, tt := range tests {
@@ -709,7 +709,7 @@ func TestConnection_WriteRequestBuilder(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcWriteRequestBuilder
+ want apiModel.PlcWriteRequestBuilder
}{
{
name: "simple",
@@ -720,7 +720,7 @@ func TestConnection_WriteRequestBuilder(t *testing.T) {
options: map[string][]string{},
connected: true,
},
- want: internalModel.NewDefaultPlcWriteRequestBuilder(NewTagHandler(), NewValueHandler(), NewWriter(NewDevice("hurz"), map[string][]string{}, nil)),
+ want: spiModel.NewDefaultPlcWriteRequestBuilder(NewTagHandler(), NewValueHandler(), NewWriter(NewDevice("hurz"), map[string][]string{}, nil)),
},
}
for _, tt := range tests {
diff --git a/plc4go/internal/simulated/Driver_test.go b/plc4go/internal/simulated/Driver_test.go
index c7f3f5c35e..b9847c43fe 100644
--- a/plc4go/internal/simulated/Driver_test.go
+++ b/plc4go/internal/simulated/Driver_test.go
@@ -24,7 +24,7 @@ import (
"testing"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
"github.com/apache/plc4x/plc4go/spi/utils"
@@ -62,7 +62,7 @@ func TestDriver_Discover(t *testing.T) {
valueHandler ValueHandler
}
type args struct {
- callback func(event model.PlcDiscoveryItem)
+ callback func(event apiModel.PlcDiscoveryItem)
discoveryOptions []options.WithDiscoveryOption
}
tests := []struct {
diff --git a/plc4go/internal/simulated/Reader.go b/plc4go/internal/simulated/Reader.go
index 11510260a5..4be8926393 100644
--- a/plc4go/internal/simulated/Reader.go
+++ b/plc4go/internal/simulated/Reader.go
@@ -25,8 +25,8 @@ import (
"strconv"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
@@ -45,8 +45,8 @@ func NewReader(device *Device, options map[string][]string, tracer *spi.Tracer)
}
}
-func (r *Reader) Read(_ context.Context, readRequest model.PlcReadRequest) <-chan model.PlcReadRequestResult {
- ch := make(chan model.PlcReadRequestResult, 1)
+func (r *Reader) Read(_ context.Context, readRequest apiModel.PlcReadRequest) <-chan apiModel.PlcReadRequestResult {
+ ch := make(chan apiModel.PlcReadRequestResult, 1)
go func() {
defer func() {
if err := recover(); err != nil {
@@ -68,21 +68,21 @@ func (r *Reader) Read(_ context.Context, readRequest model.PlcReadRequest) <-cha
}
// Process the request
- responseCodes := make(map[string]model.PlcResponseCode)
- responseValues := make(map[string]values.PlcValue)
+ responseCodes := make(map[string]apiModel.PlcResponseCode)
+ responseValues := make(map[string]apiValues.PlcValue)
for _, tagName := range readRequest.GetTagNames() {
tag := readRequest.GetTag(tagName)
simulatedTagVar, ok := tag.(simulatedTag)
if !ok {
- responseCodes[tagName] = model.PlcResponseCode_INVALID_ADDRESS
+ responseCodes[tagName] = apiModel.PlcResponseCode_INVALID_ADDRESS
responseValues[tagName] = nil
} else {
value := r.device.Get(simulatedTagVar)
if value == nil {
- responseCodes[tagName] = model.PlcResponseCode_NOT_FOUND
+ responseCodes[tagName] = apiModel.PlcResponseCode_NOT_FOUND
responseValues[tagName] = nil
} else {
- responseCodes[tagName] = model.PlcResponseCode_OK
+ responseCodes[tagName] = apiModel.PlcResponseCode_OK
responseValues[tagName] = *value
}
}
diff --git a/plc4go/internal/simulated/Reader_test.go b/plc4go/internal/simulated/Reader_test.go
index c9ef020161..e2df890bb6 100644
--- a/plc4go/internal/simulated/Reader_test.go
+++ b/plc4go/internal/simulated/Reader_test.go
@@ -26,13 +26,13 @@ import (
"time"
"github.com/apache/plc4x/plc4go/internal/s7"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- model4 "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
- model2 "github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
- model3 "github.com/apache/plc4x/plc4go/spi/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
+ simulatedReadWriteModel "github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
- values2 "github.com/apache/plc4x/plc4go/spi/values"
+ spiValues "github.com/apache/plc4x/plc4go/spi/values"
)
func TestReader_Read(t *testing.T) {
@@ -41,14 +41,14 @@ func TestReader_Read(t *testing.T) {
options map[string][]string
}
type args struct {
- fields map[string]model.PlcTag
+ fields map[string]apiModel.PlcTag
fieldNames []string
}
tests := []struct {
name string
fields fields
args args
- want model.PlcReadResponse
+ want apiModel.PlcReadResponse
delayAtLeast time.Duration
}{
{
@@ -56,24 +56,24 @@ func TestReader_Read(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1),
+ fields: map[string]apiModel.PlcTag{
+ "test": NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcReadResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_OK,
+ want: spiModel.NewDefaultPlcReadResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_OK,
},
- map[string]values.PlcValue{
- "test": values2.NewPlcBOOL(true),
+ map[string]apiValues.PlcValue{
+ "test": spiValues.NewPlcBOOL(true),
}),
delayAtLeast: 0,
},
@@ -82,8 +82,8 @@ func TestReader_Read(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{
@@ -91,17 +91,17 @@ func TestReader_Read(t *testing.T) {
},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1),
+ fields: map[string]apiModel.PlcTag{
+ "test": NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcReadResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_OK,
+ want: spiModel.NewDefaultPlcReadResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_OK,
},
- map[string]values.PlcValue{
- "test": values2.NewPlcBOOL(true),
+ map[string]apiValues.PlcValue{
+ "test": spiValues.NewPlcBOOL(true),
}),
delayAtLeast: 1000,
},
@@ -110,23 +110,23 @@ func TestReader_Read(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": NewSimulatedTag(TagState, "lalala", model2.SimulatedDataTypeSizes_BOOL, 1),
+ fields: map[string]apiModel.PlcTag{
+ "test": NewSimulatedTag(TagState, "lalala", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcReadResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_NOT_FOUND,
+ want: spiModel.NewDefaultPlcReadResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_NOT_FOUND,
},
- map[string]values.PlcValue{
+ map[string]apiValues.PlcValue{
"test": nil,
}),
delayAtLeast: 0,
@@ -137,23 +137,23 @@ func TestReader_Read(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": s7.NewTag(model4.MemoryArea_DATA_BLOCKS, 1, 1, 0, 1, model4.TransportSize_BOOL),
+ fields: map[string]apiModel.PlcTag{
+ "test": s7.NewTag(readWriteModel.MemoryArea_DATA_BLOCKS, 1, 1, 0, 1, readWriteModel.TransportSize_BOOL),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcReadResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_INVALID_ADDRESS,
+ want: spiModel.NewDefaultPlcReadResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_INVALID_ADDRESS,
},
- map[string]values.PlcValue{
+ map[string]apiValues.PlcValue{
"test": nil,
}),
delayAtLeast: 0,
@@ -162,7 +162,7 @@ func TestReader_Read(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := NewReader(tt.fields.device, tt.fields.options, nil)
- readRequest := model3.NewDefaultPlcReadRequest(tt.args.fields, tt.args.fieldNames, r, nil)
+ readRequest := spiModel.NewDefaultPlcReadRequest(tt.args.fields, tt.args.fieldNames, r, nil)
timeBeforeReadRequest := time.Now()
readResponseChannel := r.Read(context.TODO(), readRequest)
timeout := time.NewTimer(3 * time.Second)
diff --git a/plc4go/internal/simulated/TagHandler_test.go b/plc4go/internal/simulated/TagHandler_test.go
index 6d788311d0..8bf01f8a8e 100644
--- a/plc4go/internal/simulated/TagHandler_test.go
+++ b/plc4go/internal/simulated/TagHandler_test.go
@@ -23,8 +23,8 @@ import (
"github.com/stretchr/testify/assert"
"testing"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- model2 "github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
)
func TestFieldHandler_ParseQuery(t *testing.T) {
@@ -34,7 +34,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
tests := []struct {
name string
args args
- want model.PlcTag
+ want apiModel.PlcTag
wantErr bool
}{
{
@@ -42,7 +42,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
args: args{
query: "RANDOM/test_random:BOOL",
},
- want: NewSimulatedTag(TagRandom, "test_random", model2.SimulatedDataTypeSizes_BOOL, 1),
+ want: NewSimulatedTag(TagRandom, "test_random", readWriteModel.SimulatedDataTypeSizes_BOOL, 1),
wantErr: false,
},
{
@@ -50,7 +50,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
args: args{
query: "RANDOM/test_random:BOOL[10]",
},
- want: NewSimulatedTag(TagRandom, "test_random", model2.SimulatedDataTypeSizes_BOOL, 10),
+ want: NewSimulatedTag(TagRandom, "test_random", readWriteModel.SimulatedDataTypeSizes_BOOL, 10),
wantErr: false,
},
{
@@ -58,7 +58,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
args: args{
query: "STATE/test_state:BOOL",
},
- want: NewSimulatedTag(TagState, "test_state", model2.SimulatedDataTypeSizes_BOOL, 1),
+ want: NewSimulatedTag(TagState, "test_state", readWriteModel.SimulatedDataTypeSizes_BOOL, 1),
wantErr: false,
},
{
@@ -66,7 +66,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
args: args{
query: "STATE/test_state:BOOL[42]",
},
- want: NewSimulatedTag(TagState, "test_state", model2.SimulatedDataTypeSizes_BOOL, 42),
+ want: NewSimulatedTag(TagState, "test_state", readWriteModel.SimulatedDataTypeSizes_BOOL, 42),
wantErr: false,
},
{
@@ -74,7 +74,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
args: args{
query: "STDOUT/test_stdout:BOOL",
},
- want: NewSimulatedTag(TagStdOut, "test_stdout", model2.SimulatedDataTypeSizes_BOOL, 1),
+ want: NewSimulatedTag(TagStdOut, "test_stdout", readWriteModel.SimulatedDataTypeSizes_BOOL, 1),
wantErr: false,
},
{
@@ -82,7 +82,7 @@ func TestFieldHandler_ParseQuery(t *testing.T) {
args: args{
query: "STDOUT/test_stdout:BOOL[23]",
},
- want: NewSimulatedTag(TagStdOut, "test_stdout", model2.SimulatedDataTypeSizes_BOOL, 23),
+ want: NewSimulatedTag(TagStdOut, "test_stdout", readWriteModel.SimulatedDataTypeSizes_BOOL, 23),
wantErr: false,
},
{
diff --git a/plc4go/internal/simulated/ValueHandler.go b/plc4go/internal/simulated/ValueHandler.go
index ae4e87f9b5..1050394455 100644
--- a/plc4go/internal/simulated/ValueHandler.go
+++ b/plc4go/internal/simulated/ValueHandler.go
@@ -20,8 +20,8 @@
package simulated
import (
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
)
type ValueHandler struct {
@@ -31,7 +31,7 @@ func NewValueHandler() ValueHandler {
return ValueHandler{}
}
-func (v ValueHandler) NewPlcValue(tag model.PlcTag, value any) (values.PlcValue, error) {
+func (v ValueHandler) NewPlcValue(tag apiModel.PlcTag, value any) (apiValues.PlcValue, error) {
//TODO implement me
panic("implement me")
}
diff --git a/plc4go/internal/simulated/Writer.go b/plc4go/internal/simulated/Writer.go
index 9204a7db73..08dfa93836 100644
--- a/plc4go/internal/simulated/Writer.go
+++ b/plc4go/internal/simulated/Writer.go
@@ -25,7 +25,7 @@ import (
"strconv"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
@@ -44,8 +44,8 @@ func NewWriter(device *Device, options map[string][]string, tracer *spi.Tracer)
}
}
-func (w *Writer) Write(_ context.Context, writeRequest model.PlcWriteRequest) <-chan model.PlcWriteRequestResult {
- ch := make(chan model.PlcWriteRequestResult, 1)
+func (w *Writer) Write(_ context.Context, writeRequest apiModel.PlcWriteRequest) <-chan apiModel.PlcWriteRequestResult {
+ ch := make(chan apiModel.PlcWriteRequestResult, 1)
go func() {
defer func() {
if err := recover(); err != nil {
@@ -67,16 +67,16 @@ func (w *Writer) Write(_ context.Context, writeRequest model.PlcWriteRequest) <-
}
// Process the request
- responseCodes := map[string]model.PlcResponseCode{}
+ responseCodes := map[string]apiModel.PlcResponseCode{}
for _, tagName := range writeRequest.GetTagNames() {
tag := writeRequest.GetTag(tagName)
simulatedTagVar, ok := tag.(simulatedTag)
if !ok {
- responseCodes[tagName] = model.PlcResponseCode_INVALID_ADDRESS
+ responseCodes[tagName] = apiModel.PlcResponseCode_INVALID_ADDRESS
} else {
plcValue := writeRequest.GetValue(tagName)
w.device.Set(simulatedTagVar, &plcValue)
- responseCodes[tagName] = model.PlcResponseCode_OK
+ responseCodes[tagName] = apiModel.PlcResponseCode_OK
}
}
diff --git a/plc4go/internal/simulated/Writer_test.go b/plc4go/internal/simulated/Writer_test.go
index b70acd5ce1..e823a28344 100644
--- a/plc4go/internal/simulated/Writer_test.go
+++ b/plc4go/internal/simulated/Writer_test.go
@@ -26,13 +26,13 @@ import (
"time"
"github.com/apache/plc4x/plc4go/internal/s7"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
- model4 "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
- model2 "github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
- model3 "github.com/apache/plc4x/plc4go/spi/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
+ readWriteModel "github.com/apache/plc4x/plc4go/protocols/s7/readwrite/model"
+ simulatedReadWriteModel "github.com/apache/plc4x/plc4go/protocols/simulated/readwrite/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
"github.com/apache/plc4x/plc4go/spi/utils"
- values2 "github.com/apache/plc4x/plc4go/spi/values"
+ spiValues "github.com/apache/plc4x/plc4go/spi/values"
)
func TestWriter_Write(t *testing.T) {
@@ -41,16 +41,16 @@ func TestWriter_Write(t *testing.T) {
options map[string][]string
}
type args struct {
- fields map[string]model.PlcTag
- values map[string]values.PlcValue
+ fields map[string]apiModel.PlcTag
+ values map[string]apiValues.PlcValue
fieldNames []string
}
tests := []struct {
name string
fields fields
args args
- want model.PlcWriteResponse
- newState map[simulatedTag]*values.PlcValue
+ want apiModel.PlcWriteResponse
+ newState map[simulatedTag]*apiValues.PlcValue
delayAtLeast time.Duration
}{
{
@@ -58,25 +58,25 @@ func TestWriter_Write(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{},
+ State: map[simulatedTag]*apiValues.PlcValue{},
},
options: map[string][]string{},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1),
+ fields: map[string]apiModel.PlcTag{
+ "test": NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1),
},
- values: map[string]values.PlcValue{
- "test": values2.NewPlcBOOL(true),
+ values: map[string]apiValues.PlcValue{
+ "test": spiValues.NewPlcBOOL(true),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcWriteResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_OK,
+ want: spiModel.NewDefaultPlcWriteResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_OK,
}),
- newState: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ newState: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
delayAtLeast: 0,
},
@@ -85,27 +85,27 @@ func TestWriter_Write(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1),
+ fields: map[string]apiModel.PlcTag{
+ "test": NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1),
},
- values: map[string]values.PlcValue{
- "test": values2.NewPlcBOOL(false),
+ values: map[string]apiValues.PlcValue{
+ "test": spiValues.NewPlcBOOL(false),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcWriteResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_OK,
+ want: spiModel.NewDefaultPlcWriteResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_OK,
}),
- newState: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(false)),
+ newState: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(false)),
},
delayAtLeast: 0,
},
@@ -114,8 +114,8 @@ func TestWriter_Write(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{
@@ -123,20 +123,20 @@ func TestWriter_Write(t *testing.T) {
},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1),
+ fields: map[string]apiModel.PlcTag{
+ "test": NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1),
},
- values: map[string]values.PlcValue{
- "test": values2.NewPlcBOOL(false),
+ values: map[string]apiValues.PlcValue{
+ "test": spiValues.NewPlcBOOL(false),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcWriteResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_OK,
+ want: spiModel.NewDefaultPlcWriteResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_OK,
}),
- newState: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(false)),
+ newState: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(false)),
},
delayAtLeast: 1000,
},
@@ -146,27 +146,27 @@ func TestWriter_Write(t *testing.T) {
fields: fields{
device: &Device{
Name: "hurz",
- State: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ State: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
},
options: map[string][]string{},
},
args: args{
- fields: map[string]model.PlcTag{
- "test": s7.NewTag(model4.MemoryArea_DATA_BLOCKS, 1, 1, 0, 1, model4.TransportSize_BOOL),
+ fields: map[string]apiModel.PlcTag{
+ "test": s7.NewTag(readWriteModel.MemoryArea_DATA_BLOCKS, 1, 1, 0, 1, readWriteModel.TransportSize_BOOL),
},
- values: map[string]values.PlcValue{
- "test": values2.NewPlcBOOL(false),
+ values: map[string]apiValues.PlcValue{
+ "test": spiValues.NewPlcBOOL(false),
},
fieldNames: []string{"test"},
},
- want: model3.NewDefaultPlcWriteResponse(nil,
- map[string]model.PlcResponseCode{
- "test": model.PlcResponseCode_INVALID_ADDRESS,
+ want: spiModel.NewDefaultPlcWriteResponse(nil,
+ map[string]apiModel.PlcResponseCode{
+ "test": apiModel.PlcResponseCode_INVALID_ADDRESS,
}),
- newState: map[simulatedTag]*values.PlcValue{
- NewSimulatedTag(TagState, "test", model2.SimulatedDataTypeSizes_BOOL, 1): ToReference(values2.NewPlcBOOL(true)),
+ newState: map[simulatedTag]*apiValues.PlcValue{
+ NewSimulatedTag(TagState, "test", simulatedReadWriteModel.SimulatedDataTypeSizes_BOOL, 1): ToReference(spiValues.NewPlcBOOL(true)),
},
delayAtLeast: 0,
},
@@ -174,7 +174,7 @@ func TestWriter_Write(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := NewWriter(tt.fields.device, tt.fields.options, nil)
- writeRequest := model3.NewDefaultPlcWriteRequest(tt.args.fields, tt.args.fieldNames, tt.args.values, w, nil)
+ writeRequest := spiModel.NewDefaultPlcWriteRequest(tt.args.fields, tt.args.fieldNames, tt.args.values, w, nil)
timeBeforeWriteRequest := time.Now()
writeResponseChannel := w.Write(context.TODO(), writeRequest)
timeout := time.NewTimer(3 * time.Second)
diff --git a/plc4go/pkg/api/connection.go b/plc4go/pkg/api/connection.go
index c6f61e8e62..7ae8a6a4d8 100644
--- a/plc4go/pkg/api/connection.go
+++ b/plc4go/pkg/api/connection.go
@@ -21,6 +21,7 @@ package plc4go
import (
"context"
+
"github.com/apache/plc4x/plc4go/pkg/api/model"
)
diff --git a/plc4go/pkg/api/driverManager.go b/plc4go/pkg/api/driverManager.go
index 4ca897125d..820c44b979 100644
--- a/plc4go/pkg/api/driverManager.go
+++ b/plc4go/pkg/api/driverManager.go
@@ -21,12 +21,14 @@ package plc4go
import (
"context"
+ "net/url"
+
"github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
+
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
- "net/url"
)
// PlcDriverManager is the main entry point for PLC4Go applications
diff --git a/plc4go/spi/default/DefaultBrowser.go b/plc4go/spi/default/DefaultBrowser.go
index fc3a7e3e07..e1e08e8d81 100644
--- a/plc4go/spi/default/DefaultBrowser.go
+++ b/plc4go/spi/default/DefaultBrowser.go
@@ -25,7 +25,7 @@ import (
apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
- "github.com/apache/plc4x/plc4go/spi/model"
+ spiModel "github.com/apache/plc4x/plc4go/spi/model"
)
// DefaultBrowserRequirements adds required methods to Browser that are needed when using DefaultBrowser
@@ -79,8 +79,8 @@ func (m *defaultBrowser) BrowseWithInterceptor(ctx context.Context, browseReques
query := browseRequest.GetQuery(queryName)
responseCodes[queryName], results[queryName] = m.BrowseQuery(ctx, interceptor, queryName, query)
}
- browseResponse := model.NewDefaultPlcBrowseResponse(browseRequest, results, responseCodes)
- result <- model.NewDefaultPlcBrowseRequestResult(
+ browseResponse := spiModel.NewDefaultPlcBrowseResponse(browseRequest, results, responseCodes)
+ result <- spiModel.NewDefaultPlcBrowseRequestResult(
browseRequest,
browseResponse,
nil,
diff --git a/plc4go/spi/default/DefaultConnection.go b/plc4go/spi/default/DefaultConnection.go
index 2a8c58656a..c703f035ca 100644
--- a/plc4go/spi/default/DefaultConnection.go
+++ b/plc4go/spi/default/DefaultConnection.go
@@ -27,7 +27,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
@@ -304,7 +304,7 @@ func (d *defaultConnection) GetTtl() time.Duration {
return d.defaultTtl
}
-func (d *defaultConnection) GetMetadata() model.PlcConnectionMetadata {
+func (d *defaultConnection) GetMetadata() apiModel.PlcConnectionMetadata {
return DefaultConnectionMetadata{
ConnectionAttributes: nil,
ProvidesReading: false,
@@ -314,23 +314,23 @@ func (d *defaultConnection) GetMetadata() model.PlcConnectionMetadata {
}
}
-func (d *defaultConnection) ReadRequestBuilder() model.PlcReadRequestBuilder {
+func (d *defaultConnection) ReadRequestBuilder() apiModel.PlcReadRequestBuilder {
panic("not provided by actual connection")
}
-func (d *defaultConnection) WriteRequestBuilder() model.PlcWriteRequestBuilder {
+func (d *defaultConnection) WriteRequestBuilder() apiModel.PlcWriteRequestBuilder {
panic("not provided by actual connection")
}
-func (d *defaultConnection) SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder {
+func (d *defaultConnection) SubscriptionRequestBuilder() apiModel.PlcSubscriptionRequestBuilder {
panic("not provided by actual connection")
}
-func (d *defaultConnection) UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder {
+func (d *defaultConnection) UnsubscriptionRequestBuilder() apiModel.PlcUnsubscriptionRequestBuilder {
panic("not provided by actual connection")
}
-func (d *defaultConnection) BrowseRequestBuilder() model.PlcBrowseRequestBuilder {
+func (d *defaultConnection) BrowseRequestBuilder() apiModel.PlcBrowseRequestBuilder {
panic("not provided by actual connection")
}
diff --git a/plc4go/spi/default/DefaultConnection_test.go b/plc4go/spi/default/DefaultConnection_test.go
index 49ad8dd480..4965e5eda6 100644
--- a/plc4go/spi/default/DefaultConnection_test.go
+++ b/plc4go/spi/default/DefaultConnection_test.go
@@ -22,18 +22,18 @@ package _default
import (
"context"
"fmt"
- "github.com/apache/plc4x/plc4go/spi/utils"
- "github.com/stretchr/testify/mock"
"testing"
"time"
- "github.com/stretchr/testify/assert"
-
"github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
+ "github.com/apache/plc4x/plc4go/spi/utils"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/mock"
)
func TestDefaultConnectionMetadata_CanBrowse(t *testing.T) {
@@ -474,7 +474,7 @@ func Test_defaultConnection_BrowseRequestBuilder(t *testing.T) {
name string
fields fields
mockSetup func(t *testing.T, fields *fields)
- want model.PlcBrowseRequestBuilder
+ want apiModel.PlcBrowseRequestBuilder
}{
{
name: "create it",
@@ -689,7 +689,7 @@ func Test_defaultConnection_GetMetadata(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcConnectionMetadata
+ want apiModel.PlcConnectionMetadata
}{
{
name: "get it",
@@ -973,7 +973,7 @@ func Test_defaultConnection_ReadRequestBuilder(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcReadRequestBuilder
+ want apiModel.PlcReadRequestBuilder
}{
{
name: "create it",
@@ -1045,7 +1045,7 @@ func Test_defaultConnection_SubscriptionRequestBuilder(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcSubscriptionRequestBuilder
+ want apiModel.PlcSubscriptionRequestBuilder
}{
{
name: "create it",
@@ -1083,7 +1083,7 @@ func Test_defaultConnection_UnsubscriptionRequestBuilder(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcUnsubscriptionRequestBuilder
+ want apiModel.PlcUnsubscriptionRequestBuilder
}{
{
name: "create it",
@@ -1121,7 +1121,7 @@ func Test_defaultConnection_WriteRequestBuilder(t *testing.T) {
tests := []struct {
name string
fields fields
- want model.PlcWriteRequestBuilder
+ want apiModel.PlcWriteRequestBuilder
}{
{
name: "create it",
diff --git a/plc4go/spi/interceptors/RequestInterceptor.go b/plc4go/spi/interceptors/RequestInterceptor.go
index 30593b1c98..48deb30c26 100644
--- a/plc4go/spi/interceptors/RequestInterceptor.go
+++ b/plc4go/spi/interceptors/RequestInterceptor.go
@@ -21,17 +21,18 @@ package interceptors
import (
"context"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
type ReadRequestInterceptor interface {
- InterceptReadRequest(ctx context.Context, readRequest model.PlcReadRequest) []model.PlcReadRequest
- ProcessReadResponses(ctx context.Context, readRequest model.PlcReadRequest, readResults []model.PlcReadRequestResult) model.PlcReadRequestResult
+ InterceptReadRequest(ctx context.Context, readRequest apiModel.PlcReadRequest) []apiModel.PlcReadRequest
+ ProcessReadResponses(ctx context.Context, readRequest apiModel.PlcReadRequest, readResults []apiModel.PlcReadRequestResult) apiModel.PlcReadRequestResult
}
type WriteRequestInterceptor interface {
- InterceptWriteRequest(ctx context.Context, writeRequest model.PlcWriteRequest) []model.PlcWriteRequest
- ProcessWriteResponses(ctx context.Context, writeRequest model.PlcWriteRequest, writeResults []model.PlcWriteRequestResult) model.PlcWriteRequestResult
+ InterceptWriteRequest(ctx context.Context, writeRequest apiModel.PlcWriteRequest) []apiModel.PlcWriteRequest
+ ProcessWriteResponses(ctx context.Context, writeRequest apiModel.PlcWriteRequest, writeResults []apiModel.PlcWriteRequestResult) apiModel.PlcWriteRequestResult
}
type RequestInterceptor interface {
diff --git a/plc4go/spi/model/DefaultPlcSubscriptionEventItem.go b/plc4go/spi/model/DefaultPlcSubscriptionEventItem.go
index bb5c2b0f1d..e152215e06 100644
--- a/plc4go/spi/model/DefaultPlcSubscriptionEventItem.go
+++ b/plc4go/spi/model/DefaultPlcSubscriptionEventItem.go
@@ -22,20 +22,20 @@ package model
import (
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
)
//go:generate go run ../../tools/plc4xgenerator/gen.go -type=DefaultPlcSubscriptionEventItem
type DefaultPlcSubscriptionEventItem struct {
- code model.PlcResponseCode `stringer:"true"`
- tag model.PlcTag
+ code apiModel.PlcResponseCode `stringer:"true"`
+ tag apiModel.PlcTag
subscriptionType SubscriptionType
interval time.Duration `stringer:"true"`
- value values.PlcValue
+ value apiValues.PlcValue
}
-func NewDefaultPlcSubscriptionEventItem(code model.PlcResponseCode, tag model.PlcTag, subscriptionType SubscriptionType, interval time.Duration, value values.PlcValue) *DefaultPlcSubscriptionEventItem {
+func NewDefaultPlcSubscriptionEventItem(code apiModel.PlcResponseCode, tag apiModel.PlcTag, subscriptionType SubscriptionType, interval time.Duration, value apiValues.PlcValue) *DefaultPlcSubscriptionEventItem {
return &DefaultPlcSubscriptionEventItem{
code: code,
tag: tag,
@@ -45,11 +45,11 @@ func NewDefaultPlcSubscriptionEventItem(code model.PlcResponseCode, tag model.Pl
}
}
-func (d *DefaultPlcSubscriptionEventItem) GetCode() model.PlcResponseCode {
+func (d *DefaultPlcSubscriptionEventItem) GetCode() apiModel.PlcResponseCode {
return d.code
}
-func (d *DefaultPlcSubscriptionEventItem) GetTag() model.PlcTag {
+func (d *DefaultPlcSubscriptionEventItem) GetTag() apiModel.PlcTag {
return d.tag
}
@@ -61,6 +61,6 @@ func (d *DefaultPlcSubscriptionEventItem) GetInterval() time.Duration {
return d.interval
}
-func (d *DefaultPlcSubscriptionEventItem) GetValue() values.PlcValue {
+func (d *DefaultPlcSubscriptionEventItem) GetValue() apiValues.PlcValue {
return d.value
}
diff --git a/plc4go/spi/model/DefaultPlcUnsubscriptionRequest.go b/plc4go/spi/model/DefaultPlcUnsubscriptionRequest.go
index 048366cd33..16b9f3bdac 100644
--- a/plc4go/spi/model/DefaultPlcUnsubscriptionRequest.go
+++ b/plc4go/spi/model/DefaultPlcUnsubscriptionRequest.go
@@ -21,7 +21,8 @@ package model
import (
"context"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
)
type DefaultPlcUnsubscriptionRequest struct {
@@ -32,12 +33,12 @@ func NewDefaultPlcUnsubscriptionRequest() *DefaultPlcUnsubscriptionRequest {
return &DefaultPlcUnsubscriptionRequest{}
}
-func (d DefaultPlcUnsubscriptionRequest) Execute() <-chan model.PlcUnsubscriptionRequestResult {
+func (d DefaultPlcUnsubscriptionRequest) Execute() <-chan apiModel.PlcUnsubscriptionRequestResult {
//TODO implement me
panic("implement me")
}
-func (d DefaultPlcUnsubscriptionRequest) ExecuteWithContext(ctx context.Context) <-chan model.PlcUnsubscriptionRequestResult {
+func (d DefaultPlcUnsubscriptionRequest) ExecuteWithContext(ctx context.Context) <-chan apiModel.PlcUnsubscriptionRequestResult {
//TODO implement me
panic("implement me")
}
diff --git a/plc4go/spi/model/DefaultPlcWriteResponse_test.go b/plc4go/spi/model/DefaultPlcWriteResponse_test.go
new file mode 100644
index 0000000000..30c49c3244
--- /dev/null
+++ b/plc4go/spi/model/DefaultPlcWriteResponse_test.go
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://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
+ * "AS IS" 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.
+ */
+
+package model
+
+import (
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestDefaultPlcWriteResponse_GetRequest(t *testing.T) {
+ type fields struct {
+ request apiModel.PlcWriteRequest
+ responseCodes map[string]apiModel.PlcResponseCode
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want apiModel.PlcWriteRequest
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcWriteResponse{
+ request: tt.fields.request,
+ responseCodes: tt.fields.responseCodes,
+ }
+ assert.Equalf(t, tt.want, d.GetRequest(), "GetRequest()")
+ })
+ }
+}
+
+func TestDefaultPlcWriteResponse_GetResponseCode(t *testing.T) {
+ type fields struct {
+ request apiModel.PlcWriteRequest
+ responseCodes map[string]apiModel.PlcResponseCode
+ }
+ type args struct {
+ name string
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want apiModel.PlcResponseCode
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcWriteResponse{
+ request: tt.fields.request,
+ responseCodes: tt.fields.responseCodes,
+ }
+ assert.Equalf(t, tt.want, d.GetResponseCode(tt.args.name), "GetResponseCode(%v)", tt.args.name)
+ })
+ }
+}
+
+func TestDefaultPlcWriteResponse_GetTagNames(t *testing.T) {
+ type fields struct {
+ request apiModel.PlcWriteRequest
+ responseCodes map[string]apiModel.PlcResponseCode
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want []string
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcWriteResponse{
+ request: tt.fields.request,
+ responseCodes: tt.fields.responseCodes,
+ }
+ assert.Equalf(t, tt.want, d.GetTagNames(), "GetTagNames()")
+ })
+ }
+}
+
+func TestDefaultPlcWriteResponse_IsAPlcMessage(t *testing.T) {
+ type fields struct {
+ request apiModel.PlcWriteRequest
+ responseCodes map[string]apiModel.PlcResponseCode
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want bool
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcWriteResponse{
+ request: tt.fields.request,
+ responseCodes: tt.fields.responseCodes,
+ }
+ assert.Equalf(t, tt.want, d.IsAPlcMessage(), "IsAPlcMessage()")
+ })
+ }
+}
+
+func TestNewDefaultPlcWriteResponse(t *testing.T) {
+ type args struct {
+ request apiModel.PlcWriteRequest
+ responseCodes map[string]apiModel.PlcResponseCode
+ }
+ tests := []struct {
+ name string
+ args args
+ want apiModel.PlcWriteResponse
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewDefaultPlcWriteResponse(tt.args.request, tt.args.responseCodes), "NewDefaultPlcWriteResponse(%v, %v)", tt.args.request, tt.args.responseCodes)
+ })
+ }
+}
diff --git a/plc4go/spi/testutils/ManualTestRunner.go b/plc4go/spi/testutils/ManualTestRunner.go
index d0d5bb0dc4..317e00db42 100644
--- a/plc4go/spi/testutils/ManualTestRunner.go
+++ b/plc4go/spi/testutils/ManualTestRunner.go
@@ -29,8 +29,8 @@ import (
"time"
"github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/spi/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ spiValues "github.com/apache/plc4x/plc4go/spi/values"
"github.com/stretchr/testify/assert"
)
@@ -127,7 +127,7 @@ func (m *ManualTestSuite) runSingleTest(t *testing.T, connection plc4go.PlcConne
// Check the result
assert.Equalf(t, 1, len(readResponse.GetTagNames()), "response should have a tag for %s", tagName)
assert.Equalf(t, tagName, readResponse.GetTagNames()[0], "first tag should be equal to %s", tagName)
- assert.Equalf(t, model.PlcResponseCode_OK, readResponse.GetResponseCode(tagName), "response code should be ok for %s", tagName)
+ assert.Equalf(t, apiModel.PlcResponseCode_OK, readResponse.GetResponseCode(tagName), "response code should be ok for %s", tagName)
assert.NotNil(t, readResponse.GetValue(tagName), tagName)
expectation := reflect.ValueOf(testCase.ExpectedReadValue)
if readResponse.GetValue(tagName).IsList() && (expectation.Kind() == reflect.Slice || expectation.Kind() == reflect.Array) {
@@ -137,9 +137,9 @@ func (m *ManualTestSuite) runSingleTest(t *testing.T, connection plc4go.PlcConne
actual = plcList[j]
if testCase.UnwrappedValue {
switch actualCasted := actual.(type) {
- case values.PlcBOOL:
+ case spiValues.PlcBOOL:
actual = actualCasted.GetBool()
- case values.PlcWORD:
+ case spiValues.PlcWORD:
actual = actualCasted.GetInt8()
default:
t.Fatalf("%T not yet mapped", actualCasted)
@@ -194,7 +194,7 @@ func (m *ManualTestSuite) runBurstTest(t *testing.T, connection plc4go.PlcConnec
assert.Equal(t, len(shuffledTestcases), len(readResponse.GetTagNames()))
for _, testCase := range shuffledTestcases {
tagName := testCase.Address
- assert.Equalf(t, model.PlcResponseCode_OK, readResponse.GetResponseCode(tagName), "response code should be ok for %s", tagName)
+ assert.Equalf(t, apiModel.PlcResponseCode_OK, readResponse.GetResponseCode(tagName), "response code should be ok for %s", tagName)
assert.NotNil(t, readResponse.GetValue(tagName))
expectation := reflect.ValueOf(testCase.ExpectedReadValue)
if readResponse.GetValue(tagName).IsList() && (expectation.Kind() == reflect.Slice || expectation.Kind() == reflect.Array) {
@@ -204,9 +204,9 @@ func (m *ManualTestSuite) runBurstTest(t *testing.T, connection plc4go.PlcConnec
actual = plcList[j]
if testCase.UnwrappedValue {
switch actualCasted := actual.(type) {
- case values.PlcBOOL:
+ case spiValues.PlcBOOL:
actual = actualCasted.GetBool()
- case values.PlcWORD:
+ case spiValues.PlcWORD:
actual = actualCasted.GetInt8()
default:
t.Fatalf("%T not yet mapped", actualCasted)
diff --git a/plc4go/spi/values/PlcValueHandler.go b/plc4go/spi/values/PlcValueHandler.go
index a175d0c3ea..563c318a25 100644
--- a/plc4go/spi/values/PlcValueHandler.go
+++ b/plc4go/spi/values/PlcValueHandler.go
@@ -27,29 +27,29 @@ import (
"strings"
"time"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/pkg/api/values"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
"github.com/rs/zerolog/log"
)
type DefaultValueHandler struct {
}
-func (m DefaultValueHandler) NewPlcValue(tag model.PlcTag, value any) (values.PlcValue, error) {
+func (m DefaultValueHandler) NewPlcValue(tag apiModel.PlcTag, value any) (apiValues.PlcValue, error) {
return m.parseType(tag, tag.GetArrayInfo(), value)
}
-func (m DefaultValueHandler) parseType(tag model.PlcTag, arrayInfo []model.ArrayInfo, value any) (values.PlcValue, error) {
+func (m DefaultValueHandler) parseType(tag apiModel.PlcTag, arrayInfo []apiModel.ArrayInfo, value any) (apiValues.PlcValue, error) {
valueType := tag.GetValueType()
if (arrayInfo != nil) && (len(arrayInfo) > 0) {
return m.ParseListType(tag, arrayInfo, value)
- } else if valueType == values.Struct {
+ } else if valueType == apiValues.Struct {
return m.ParseStructType(tag, value)
}
return m.ParseSimpleType(tag, value)
}
-func (m DefaultValueHandler) ParseListType(tag model.PlcTag, arrayInfo []model.ArrayInfo, value any) (values.PlcValue, error) {
+func (m DefaultValueHandler) ParseListType(tag apiModel.PlcTag, arrayInfo []apiModel.ArrayInfo, value any) (apiValues.PlcValue, error) {
// We've reached the end of the recursion.
if len(arrayInfo) == 0 {
return m.parseType(tag, arrayInfo, value)
@@ -67,14 +67,14 @@ func (m DefaultValueHandler) ParseListType(tag model.PlcTag, arrayInfo []model.A
curArrayInfo := arrayInfo[0]
restArrayInfo := arrayInfo[1:]
- // Check that the current slice has enough values.
+ // Check that the current slice has enough apiValues.
if len(curValues) != int(curArrayInfo.GetSize()) {
- return nil, errors.New("number of actual values " + strconv.Itoa(len(curValues)) +
+ return nil, errors.New("number of actual apiValues " + strconv.Itoa(len(curValues)) +
" doesn't match tag size " + strconv.Itoa(int(curArrayInfo.GetSize())))
}
// Actually convert the current array info level.
- var plcValues []values.PlcValue
+ var plcValues []apiValues.PlcValue
for i := uint32(0); i < curArrayInfo.GetSize(); i++ {
curValue := curValues[i]
plcValue, err := m.ParseListType(tag, restArrayInfo, curValue)
@@ -86,11 +86,11 @@ func (m DefaultValueHandler) ParseListType(tag model.PlcTag, arrayInfo []model.A
return NewPlcList(plcValues), nil
}
-func (m DefaultValueHandler) ParseStructType(_ model.PlcTag, _ any) (values.PlcValue, error) {
+func (m DefaultValueHandler) ParseStructType(_ apiModel.PlcTag, _ any) (apiValues.PlcValue, error) {
return nil, errors.New("structured types not supported by the base value handler")
}
-func (m DefaultValueHandler) ParseSimpleType(tag model.PlcTag, value any) (values.PlcValue, error) {
+func (m DefaultValueHandler) ParseSimpleType(tag apiModel.PlcTag, value any) (apiValues.PlcValue, error) {
plcValue, err := m.NewPlcValueFromType(tag.GetValueType(), value)
if err != nil && strings.HasPrefix(err.Error(), "couldn't cast") {
stringValue := fmt.Sprintf("%v", value)
@@ -102,15 +102,15 @@ func (m DefaultValueHandler) ParseSimpleType(tag model.PlcTag, value any) (value
return plcValue, err
}
-func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType, value any) (values.PlcValue, error) {
+func (m DefaultValueHandler) NewPlcValueFromType(valueType apiValues.PlcValueType, value any) (apiValues.PlcValue, error) {
// If the user passed in PLCValues, take a shortcut.
- plcValue, isPlcValue := value.(values.PlcValue)
+ plcValue, isPlcValue := value.(apiValues.PlcValue)
if isPlcValue {
if plcValue.GetPlcValueType() != valueType {
// TODO: Check if the used PlcValueType can be casted to the target type.
- } else if plcValue.GetPlcValueType() == values.List {
+ } else if plcValue.GetPlcValueType() == apiValues.List {
// TODO: Check all items
- } else if plcValue.GetPlcValueType() == values.Struct {
+ } else if plcValue.GetPlcValueType() == apiValues.Struct {
// TODO: Check all children
}
return plcValue, nil
@@ -119,7 +119,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
stringValue, isString := value.(string)
switch valueType {
// Bit & Bit-Strings
- case values.BOOL:
+ case apiValues.BOOL:
if isString {
casted, err := strconv.ParseBool(stringValue)
if err != nil {
@@ -133,7 +133,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcBOOL(casted), nil
}
- case values.BYTE:
+ case apiValues.BYTE:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 8)
if err != nil {
@@ -147,7 +147,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcBYTE(casted), nil
}
- case values.WORD:
+ case apiValues.WORD:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 16)
if err != nil {
@@ -161,7 +161,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcWORD(casted), nil
}
- case values.DWORD:
+ case apiValues.DWORD:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 32)
if err != nil {
@@ -175,7 +175,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcDWORD(casted), nil
}
- case values.LWORD:
+ case apiValues.LWORD:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 64)
if err != nil {
@@ -191,7 +191,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
// Integers
- case values.USINT:
+ case apiValues.USINT:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 8)
if err != nil {
@@ -205,7 +205,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcUSINT(casted), nil
}
- case values.UINT:
+ case apiValues.UINT:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 16)
if err != nil {
@@ -219,7 +219,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcUINT(casted), nil
}
- case values.UDINT:
+ case apiValues.UDINT:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 32)
if err != nil {
@@ -233,7 +233,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcUDINT(casted), nil
}
- case values.ULINT:
+ case apiValues.ULINT:
if isString {
casted, err := strconv.ParseUint(stringValue, 10, 64)
if err != nil {
@@ -247,7 +247,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcULINT(casted), nil
}
- case values.SINT:
+ case apiValues.SINT:
if isString {
casted, err := strconv.ParseInt(stringValue, 10, 8)
if err != nil {
@@ -261,7 +261,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcSINT(casted), nil
}
- case values.INT:
+ case apiValues.INT:
if isString {
casted, err := strconv.ParseInt(stringValue, 10, 16)
if err != nil {
@@ -275,7 +275,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcINT(casted), nil
}
- case values.DINT:
+ case apiValues.DINT:
if isString {
casted, err := strconv.ParseInt(stringValue, 10, 32)
if err != nil {
@@ -289,7 +289,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcDINT(casted), nil
}
- case values.LINT:
+ case apiValues.LINT:
if isString {
casted, err := strconv.ParseInt(stringValue, 10, 64)
if err != nil {
@@ -305,7 +305,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
// Floating Point Values
- case values.REAL:
+ case apiValues.REAL:
if isString {
casted, err := strconv.ParseFloat(stringValue, 32)
if err != nil {
@@ -319,7 +319,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
return NewPlcREAL(casted), nil
}
- case values.LREAL:
+ case apiValues.LREAL:
if isString {
casted, err := strconv.ParseFloat(stringValue, 64)
if err != nil {
@@ -336,7 +336,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
// Temporal Values
// - Duration
- case values.TIME:
+ case apiValues.TIME:
if isString {
return nil, errors.New("string to IEC61131_TIME conversion not implemented")
} else {
@@ -347,7 +347,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
return NewPlcTIME(casted), nil
}
// - Date
- case values.DATE:
+ case apiValues.DATE:
if isString {
return nil, errors.New("string to IEC61131_DATE conversion not implemented")
} else {
@@ -358,7 +358,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
return NewPlcDATE(casted), nil
}
// - Time
- case values.TIME_OF_DAY:
+ case apiValues.TIME_OF_DAY:
if isString {
return nil, errors.New("string to IEC61131_TIME_OF_DAY conversion not implemented")
} else {
@@ -369,7 +369,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
return NewPlcTIME_OF_DAY(casted), nil
}
// - Date and Time
- case values.DATE_AND_TIME:
+ case apiValues.DATE_AND_TIME:
if isString {
return nil, errors.New("string to IEC61131_DATE_AND_TIME conversion not implemented")
} else {
@@ -381,7 +381,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
}
// Chars and Strings
- case values.CHAR:
+ case apiValues.CHAR:
if !isString {
return nil, errors.New("non-string to IEC61131_CHAR conversion not implemented")
} else if len(stringValue) > 1 {
@@ -389,7 +389,7 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
} else {
return NewPlcCHAR(stringValue), nil
}
- case values.WCHAR:
+ case apiValues.WCHAR:
if !isString {
return nil, errors.New("non-string to IEC61131_WCHAR conversion not implemented")
} else if len(stringValue) > 1 {
@@ -397,13 +397,13 @@ func (m DefaultValueHandler) NewPlcValueFromType(valueType values.PlcValueType,
} else {
return NewPlcWCHAR(stringValue), nil
}
- case values.STRING:
+ case apiValues.STRING:
if !isString {
return nil, errors.New("non-string to IEC61131_STRING conversion not implemented")
} else {
return NewPlcSTRING(stringValue), nil
}
- case values.WSTRING:
+ case apiValues.WSTRING:
if !isString {
return nil, errors.New("non-string to IEC61131_WSTRING conversion not implemented")
} else {
diff --git a/plc4go/tests/drivers/tests/manual_bacnet_PcapTest_test.go b/plc4go/tests/drivers/tests/manual_bacnet_PcapTest_test.go
index bc4ca8b6c4..1255fd80c7 100644
--- a/plc4go/tests/drivers/tests/manual_bacnet_PcapTest_test.go
+++ b/plc4go/tests/drivers/tests/manual_bacnet_PcapTest_test.go
@@ -31,7 +31,7 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api"
"github.com/apache/plc4x/plc4go/pkg/api/config"
"github.com/apache/plc4x/plc4go/pkg/api/logging"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/transports/pcap"
@@ -64,7 +64,7 @@ func TestBacnetDriverWithPcap(t *testing.T) {
defer connection.Close()
build, err := connection.SubscriptionRequestBuilder().
AddEventTagAddress("furz", "*/*/*").
- AddPreRegisteredConsumer("furz", func(event model.PlcSubscriptionEvent) {
+ AddPreRegisteredConsumer("furz", func(event apiModel.PlcSubscriptionEvent) {
println(event)
}).
Build()
diff --git a/plc4go/tests/drivers/tests/manual_cbus_driver_test.go b/plc4go/tests/drivers/tests/manual_cbus_driver_test.go
index 205f8d4515..d7e3889d65 100644
--- a/plc4go/tests/drivers/tests/manual_cbus_driver_test.go
+++ b/plc4go/tests/drivers/tests/manual_cbus_driver_test.go
@@ -26,7 +26,7 @@ import (
"github.com/apache/plc4x/plc4go/internal/cbus"
"github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/pkg/api/transports"
"github.com/apache/plc4x/plc4go/spi/testutils"
"github.com/apache/plc4x/plc4go/spi/utils"
@@ -58,7 +58,7 @@ func TestManualCBusDriverMixed(t *testing.T) {
subscriptionRequest, err := plcConnection.SubscriptionRequestBuilder().
AddEventTagAddress("mmi", "mmimonitor/*/*").
AddEventTagAddress("sal", "salmonitor/*/*").
- AddPreRegisteredConsumer("mmi", func(event model.PlcSubscriptionEvent) {
+ AddPreRegisteredConsumer("mmi", func(event apiModel.PlcSubscriptionEvent) {
fmt.Printf("mmi:\n%s", event)
if _, ok := event.GetValue("mmi").GetStruct()["SALData"]; ok {
panic("got sal in mmi")
@@ -68,7 +68,7 @@ func TestManualCBusDriverMixed(t *testing.T) {
default:
}
}).
- AddPreRegisteredConsumer("sal", func(event model.PlcSubscriptionEvent) {
+ AddPreRegisteredConsumer("sal", func(event apiModel.PlcSubscriptionEvent) {
fmt.Printf("sal:\n%s", event)
select {
case gotSAL <- true:
@@ -130,7 +130,7 @@ func TestManualCBusBrowse(t *testing.T) {
if err != nil {
panic(err)
}
- browseRequestResult := <-browseRequest.ExecuteWithInterceptor(func(result model.PlcBrowseItem) bool {
+ browseRequestResult := <-browseRequest.ExecuteWithInterceptor(func(result apiModel.PlcBrowseItem) bool {
fmt.Printf("%s\n", result)
return true
})
@@ -166,7 +166,7 @@ func TestManualDiscovery(t *testing.T) {
driver := cbus.NewDriver()
driverManager.RegisterDriver(driver)
transports.RegisterTcpTransport(driverManager)
- err := driver.Discover(func(event model.PlcDiscoveryItem) {
+ err := driver.Discover(func(event apiModel.PlcDiscoveryItem) {
println(event.(fmt.Stringer).String())
})
require.NoError(t, err)
diff --git a/plc4go/tools/plc4xbrowser/ui/commands.go b/plc4go/tools/plc4xbrowser/ui/commands.go
index 7759f99cc0..f9ced687ca 100644
--- a/plc4go/tools/plc4xbrowser/ui/commands.go
+++ b/plc4go/tools/plc4xbrowser/ui/commands.go
@@ -27,7 +27,8 @@ import (
"time"
plc4xConfig "github.com/apache/plc4x/plc4go/pkg/api/config"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
"github.com/pkg/errors"
"github.com/rivo/tview"
"github.com/rs/zerolog"
@@ -54,7 +55,7 @@ var rootCommand = Command{
if !driver.SupportsDiscovery() {
return errors.Errorf("%s doesn't support discovery", driverId)
}
- return driver.Discover(func(event model.PlcDiscoveryItem) {
+ return driver.Discover(func(event apiModel.PlcDiscoveryItem) {
_, _ = fmt.Fprintf(messageOutput, "%v\n", event)
})
} else {
@@ -293,7 +294,7 @@ var rootCommand = Command{
if err != nil {
return errors.Wrapf(err, "%s can't browse", connectionsString)
}
- browseRequestResult := <-browseRequest.ExecuteWithInterceptor(func(result model.PlcBrowseItem) bool {
+ browseRequestResult := <-browseRequest.ExecuteWithInterceptor(func(result apiModel.PlcBrowseItem) bool {
// TODO: Disabled for now ... not quite sure what this is for ...
//numberOfMessagesReceived++
//messageReceived(numberOfMessagesReceived, time.Now(), result)
@@ -373,7 +374,7 @@ var rootCommand = Command{
} else {
subscriptionRequest, err := connection.SubscriptionRequestBuilder().
AddEventTagAddress("subscriptionField", split[1]).
- AddPreRegisteredConsumer("subscriptionField", func(event model.PlcSubscriptionEvent) {
+ AddPreRegisteredConsumer("subscriptionField", func(event apiModel.PlcSubscriptionEvent) {
numberOfMessagesReceived++
messageReceived(numberOfMessagesReceived, time.Now(), event)
}).
diff --git a/plc4go/tools/plc4xbrowser/ui/ui.go b/plc4go/tools/plc4xbrowser/ui/ui.go
index bbb6f3f647..7492717e04 100644
--- a/plc4go/tools/plc4xbrowser/ui/ui.go
+++ b/plc4go/tools/plc4xbrowser/ui/ui.go
@@ -21,14 +21,16 @@ package ui
import (
"fmt"
+ "regexp"
+ "strconv"
+ "time"
+
plc4go "github.com/apache/plc4x/plc4go/pkg/api"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
"github.com/gdamore/tcell/v2"
"github.com/pkg/errors"
"github.com/rivo/tview"
- "regexp"
- "strconv"
- "time"
)
func SetupApplication() *tview.Application {
@@ -280,7 +282,7 @@ func buildOutputArea(newPrimitive func(text string) tview.Primitive, application
{
receivedMessagesList := tview.NewList()
- messageReceived = func(messageNumber int, receiveTime time.Time, message model.PlcMessage) {
+ messageReceived = func(messageNumber int, receiveTime time.Time, message apiModel.PlcMessage) {
application.QueueUpdateDraw(func() {
receivedMessagesList.AddItem(fmt.Sprintf("No %d @%s", messageNumber, receiveTime.Format("15:04:05.999999")), "", 0x0, func() {
if ok := jumpToMessageItem(messageNumber); !ok {
diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/common.go b/plc4go/tools/plc4xpcapanalyzer/ui/common.go
index 09bf5bfbd7..58e170b2a8 100644
--- a/plc4go/tools/plc4xpcapanalyzer/ui/common.go
+++ b/plc4go/tools/plc4xpcapanalyzer/ui/common.go
@@ -21,15 +21,17 @@ package ui
import (
"context"
- plc4go "github.com/apache/plc4x/plc4go/pkg/api"
- plc4goModel "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/spi"
- "github.com/rs/zerolog"
"io"
"os"
"strings"
"sync"
"time"
+
+ plc4go "github.com/apache/plc4x/plc4go/pkg/api"
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ "github.com/apache/plc4x/plc4go/spi"
+
+ "github.com/rs/zerolog"
)
const protocols = "ads,bacnetip,c-bus,s7"
@@ -49,7 +51,7 @@ type loadedPcapFile struct {
var loadedPcapFiles []loadedPcapFile
var loadedPcapFilesChanged func()
-var messageReceived func(messageNumber int, receiveTime time.Time, message plc4goModel.PlcMessage)
+var messageReceived func(messageNumber int, receiveTime time.Time, message apiModel.PlcMessage)
var numberOfMessagesReceived int
var spiMessageReceived func(messageNumber int, receiveTime time.Time, message spi.Message)
var spiNumberOfMessagesReceived int
diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/ui.go b/plc4go/tools/plc4xpcapanalyzer/ui/ui.go
index ad3bbfe433..83c1994272 100644
--- a/plc4go/tools/plc4xpcapanalyzer/ui/ui.go
+++ b/plc4go/tools/plc4xpcapanalyzer/ui/ui.go
@@ -22,15 +22,17 @@ package ui
import (
"context"
"fmt"
- "github.com/apache/plc4x/plc4go/pkg/api/model"
- "github.com/apache/plc4x/plc4go/spi"
- "github.com/gdamore/tcell/v2"
- "github.com/pkg/errors"
- "github.com/rivo/tview"
"math/rand"
"regexp"
"strconv"
"time"
+
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ "github.com/apache/plc4x/plc4go/spi"
+
+ "github.com/gdamore/tcell/v2"
+ "github.com/pkg/errors"
+ "github.com/rivo/tview"
)
func SetupApplication() *tview.Application {
@@ -287,7 +289,7 @@ func buildOutputArea(newPrimitive func(text string) tview.Primitive, application
{
receivedMessagesList := tview.NewList()
- messageReceived = func(messageNumber int, receiveTime time.Time, message model.PlcMessage) {
+ messageReceived = func(messageNumber int, receiveTime time.Time, message apiModel.PlcMessage) {
application.QueueUpdateDraw(func() {
receivedMessagesList.AddItem(fmt.Sprintf("No %d @%s (api)", messageNumber, receiveTime.Format("15:04:05.999999")), "", 0x0, func() {
if ok := jumpToMessageItem(messageNumber); !ok {