You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2021/08/30 10:04:04 UTC

[plc4x] branch s7event updated: Restructured the internal and external parts

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

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


The following commit(s) were added to refs/heads/s7event by this push:
     new d7bdbe7  Restructured the internal and external parts
d7bdbe7 is described below

commit d7bdbe77454917df74a03c572ddf4b3f8a79d45b
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Aug 30 03:03:57 2021 -0700

    Restructured the internal and external parts
---
 plc4go/pkg/plc4go/model/plc_discovery.go | 124 +++++++++++++------------------
 1 file changed, 52 insertions(+), 72 deletions(-)

diff --git a/plc4go/pkg/plc4go/model/plc_discovery.go b/plc4go/pkg/plc4go/model/plc_discovery.go
index 00ed108..107221c 100644
--- a/plc4go/pkg/plc4go/model/plc_discovery.go
+++ b/plc4go/pkg/plc4go/model/plc_discovery.go
@@ -21,25 +21,67 @@ package model
 
 import "net/url"
 
-type WithDiscoveryOption interface {
-	IsDiscoveryOption() bool
+type PlcDiscoveryEvent struct {
+	ProtocolCode  string
+	TransportCode string
+	TransportUrl  url.URL
+	Options       map[string][]string
+	Name          string
 }
 
-type discoveryOption struct {
+func NewPlcDiscoveryEvent(protocolCode string, transportCode string, transportUrl url.URL, options map[string][]string, name string) PlcDiscoveryEvent {
+	return PlcDiscoveryEvent{
+		ProtocolCode:  protocolCode,
+		TransportCode: transportCode,
+		TransportUrl:  transportUrl,
+		Options:       options,
+		Name:          name,
+	}
 }
 
-func (_ discoveryOption) IsDiscoveryOption() bool {
-	return true
+func WithDiscoveryOptionProtocol(protocolName string) WithDiscoveryOption {
+	return discoveryOptionProtocol{
+		protocolName: protocolName,
+	}
+}
+
+func WithDiscoveryOptionTransport(transportName string) WithDiscoveryOption {
+	return discoveryOptionTransport{
+		transportName: transportName,
+	}
+}
+
+func WithDiscoveryDeviceName(deviceName string) WithDiscoveryOption {
+	return discoveryOptionDeviceName{
+		deviceName: deviceName,
+	}
+}
+
+func WithDiscoveryLocalAddress(localAddress string) WithDiscoveryOption {
+	return discoveryOptionLocalAddress{
+		localAddress: localAddress,
+	}
+}
+
+func WithDiscoveryRemoteAddress(remoteAddress string) WithDiscoveryOption {
+	return discoveryOptionRemoteAddress{
+		remoteAddress: remoteAddress,
+	}
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////7
-// Protocol Option
+// Internal
 /////////////////////////////////////////////////////////////////////////////////////////7
 
-func WithDiscoveryOptionProtocol(protocolName string) WithDiscoveryOption {
-	return discoveryOptionProtocol{
-		protocolName: protocolName,
-	}
+type WithDiscoveryOption interface {
+	IsDiscoveryOption() bool
+}
+
+type discoveryOption struct {
+}
+
+func (_ discoveryOption) IsDiscoveryOption() bool {
+	return true
 }
 
 func FilterDiscoveryOptionsProtocol(options []WithDiscoveryOption) []DiscoveryOptionProtocol {
@@ -66,16 +108,6 @@ func (d *discoveryOptionProtocol) GetProtocolName() string {
 	return d.protocolName
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////7
-// Transport Option
-/////////////////////////////////////////////////////////////////////////////////////////7
-
-func WithDiscoveryOptionTransport(transportName string) WithDiscoveryOption {
-	return discoveryOptionTransport{
-		transportName: transportName,
-	}
-}
-
 func FilterDiscoveryOptionsTransport(options []WithDiscoveryOption) []DiscoveryOptionTransport {
 	var filtered []DiscoveryOptionTransport
 	for _, option := range options {
@@ -100,16 +132,6 @@ func (d *discoveryOptionTransport) GetTransportName() string {
 	return d.transportName
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////7
-// Device Name Option
-/////////////////////////////////////////////////////////////////////////////////////////7
-
-func WithDiscoveryDeviceName(deviceName string) WithDiscoveryOption {
-	return discoveryOptionDeviceName{
-		deviceName: deviceName,
-	}
-}
-
 func FilterDiscoveryOptionsDeviceName(options []WithDiscoveryOption) []DiscoveryOptionDeviceName {
 	var filtered []DiscoveryOptionDeviceName
 	for _, option := range options {
@@ -134,16 +156,6 @@ func (d *discoveryOptionDeviceName) GetDeviceName() string {
 	return d.deviceName
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////7
-// Local Address Option
-/////////////////////////////////////////////////////////////////////////////////////////7
-
-func WithDiscoveryLocalAddress(localAddress string) WithDiscoveryOption {
-	return discoveryOptionLocalAddress{
-		localAddress: localAddress,
-	}
-}
-
 func FilterDiscoveryOptionsLocalAddress(options []WithDiscoveryOption) []DiscoveryOptionLocalAddress {
 	var filtered []DiscoveryOptionLocalAddress
 	for _, option := range options {
@@ -168,16 +180,6 @@ func (d *discoveryOptionLocalAddress) GetLocalAddress() string {
 	return d.localAddress
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////7
-// Remote Address Option
-/////////////////////////////////////////////////////////////////////////////////////////7
-
-func WithDiscoveryRemoteAddress(remoteAddress string) WithDiscoveryOption {
-	return discoveryOptionRemoteAddress{
-		remoteAddress: remoteAddress,
-	}
-}
-
 func FilterDiscoveryOptionsRemoteAddress(options []WithDiscoveryOption) []DiscoveryOptionRemoteAddress {
 	var filtered []DiscoveryOptionRemoteAddress
 	for _, option := range options {
@@ -201,25 +203,3 @@ type discoveryOptionRemoteAddress struct {
 func (d *discoveryOptionRemoteAddress) GetRemoteAddress() string {
 	return d.remoteAddress
 }
-
-/////////////////////////////////////////////////////////////////////////////////////////7
-// Discovery Events
-/////////////////////////////////////////////////////////////////////////////////////////7
-
-type PlcDiscoveryEvent struct {
-	ProtocolCode  string
-	TransportCode string
-	TransportUrl  url.URL
-	Options       map[string][]string
-	Name          string
-}
-
-func NewPlcDiscoveryEvent(protocolCode string, transportCode string, transportUrl url.URL, options map[string][]string, name string) PlcDiscoveryEvent {
-	return PlcDiscoveryEvent{
-		ProtocolCode:  protocolCode,
-		TransportCode: transportCode,
-		TransportUrl:  transportUrl,
-		Options:       options,
-		Name:          name,
-	}
-}