plc4go

package
v0.0.0-...-13edf00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 14

Documentation

Overview

Package plc4go contains the main API for plc4go (go part of plc4x)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlcConnection

type PlcConnection interface {
	fmt.Stringer
	// Connect Initiate the connection to the PLC
	Connect() <-chan PlcConnectionConnectResult
	// ConnectWithContext connects connection codec with the supplied context
	ConnectWithContext(ctx context.Context) <-chan PlcConnectionConnectResult
	// BlockingClose Blocking variant of Close (for usage in "defer" statements)
	BlockingClose()
	// Close the connection to the PLC (gracefully)
	Close() <-chan PlcConnectionCloseResult
	// IsConnected Checks if the connection is currently still connected
	IsConnected() bool

	// Ping Executes a no-op operation to check if the current connection is still able to communicate
	Ping() <-chan PlcConnectionPingResult

	// GetMetadata Get some metadata regarding the current connection
	GetMetadata() model.PlcConnectionMetadata

	// ReadRequestBuilder Create a builder for assembling read-requests
	ReadRequestBuilder() model.PlcReadRequestBuilder
	// WriteRequestBuilder Create a builder for assembling write-requests
	WriteRequestBuilder() model.PlcWriteRequestBuilder
	// SubscriptionRequestBuilder Create a builder for assembling subscription-requests
	SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder
	// UnsubscriptionRequestBuilder Create a builder for assembling unsubscription-requests
	UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder
	// BrowseRequestBuilder Create a builder for assembling browser-requests
	BrowseRequestBuilder() model.PlcBrowseRequestBuilder
}

type PlcConnectionCloseResult

type PlcConnectionCloseResult interface {
	fmt.Stringer
	GetConnection() PlcConnection
	GetErr() error
}

type PlcConnectionConnectResult

type PlcConnectionConnectResult interface {
	fmt.Stringer
	GetConnection() PlcConnection
	GetErr() error
}

type PlcConnectionPingResult

type PlcConnectionPingResult interface {
	fmt.Stringer
	GetErr() error
}

type PlcDriver

type PlcDriver interface {
	fmt.Stringer
	io.Closer
	// GetProtocolCode Get the short code used to identify this driver (As used in the connection string)
	GetProtocolCode() string
	// GetProtocolName Get a human-readable name for this driver
	GetProtocolName() string

	// GetDefaultTransport If the driver has a default form of transport, provide this and make
	// providing the transport code optional in the connection string
	GetDefaultTransport() string

	// CheckTagAddress Have the driver parse the query string and provide feedback if it's not a valid one
	CheckTagAddress(tagAddress string) error
	// CheckQuery Have the driver parse the query string and provide feedback if it's not a valid one
	CheckQuery(query string) error

	// GetConnection Establishes a connection to a given PLC using the information in the connectionString
	// FIXME: this leaks spi in the signature move to spi driver or create interfaces. Can also be done by moving spi in a proper module
	GetConnection(transportUrl url.URL, transports map[string]transports.Transport, options map[string][]string) <-chan PlcConnectionConnectResult
	// GetConnectionWithContext Establishes a connection to a given PLC using the information in the connectionString
	// FIXME: this leaks spi in the signature move to spi driver or create interfaces. Can also be done by moving spi in a proper module
	GetConnectionWithContext(ctx context.Context, transportUrl url.URL, transports map[string]transports.Transport, driverOptions map[string][]string) <-chan PlcConnectionConnectResult

	// SupportsDiscovery returns true if this driver supports discovery
	SupportsDiscovery() bool

	// Discover TODO: document me
	// FIXME: this leaks spi in the signature move to spi driver or create interfaces. Can also be done by moving spi in a proper module
	Discover(callback func(event model.PlcDiscoveryItem), discoveryOptions ...options.WithDiscoveryOption) error
	DiscoverWithContext(ctx context.Context, callback func(event model.PlcDiscoveryItem), discoveryOptions ...options.WithDiscoveryOption) error
}

type PlcDriverManager

type PlcDriverManager interface {
	io.Closer
	// RegisterDriver Manually register a new driver
	RegisterDriver(driver PlcDriver)
	// ListDriverNames List the names of all drivers registered in the system
	ListDriverNames() []string
	// GetDriver Get access to a driver instance for a given driver-name
	GetDriver(driverName string) (PlcDriver, error)

	// GetConnection Get a connection to a remote PLC for a given plc4x connection-string
	GetConnection(connectionString string) <-chan PlcConnectionConnectResult

	// Discover Execute all available discovery methods on all available drivers using all transports
	Discover(callback func(event model.PlcDiscoveryItem), discoveryOptions ...WithDiscoveryOption) error
	// DiscoverWithContext Execute all available discovery methods on all available drivers using all transports
	DiscoverWithContext(ctx context.Context, callback func(event model.PlcDiscoveryItem), discoveryOptions ...WithDiscoveryOption) error
}

PlcDriverManager is the main entry point for PLC4Go applications

func NewPlcDriverManager

func NewPlcDriverManager(_options ...config.WithOption) PlcDriverManager

type Transport deprecated

type Transport interface {
	transports.Transport
}

Deprecated: don't use it in productive code

type WithDiscoveryOption

type WithDiscoveryOption interface {
	// contains filtered or unexported methods
}

WithDiscoveryOption is a marker interface for options regarding discovery FIXME: this is to avoid leaks spi in the signature move to spi driver or create interfaces. Can also be done by moving spi in a proper module

func WithDiscoveryOptionDeviceName

func WithDiscoveryOptionDeviceName(deviceName string) WithDiscoveryOption

WithDiscoveryOptionDeviceName sets an option for a deviceName

func WithDiscoveryOptionLocalAddress

func WithDiscoveryOptionLocalAddress(localAddress string) WithDiscoveryOption

WithDiscoveryOptionLocalAddress sets an option for a localAddress

func WithDiscoveryOptionProtocol

func WithDiscoveryOptionProtocol(protocolName string) WithDiscoveryOption

WithDiscoveryOptionProtocol sets an option for a protocol

func WithDiscoveryOptionProtocolSpecific

func WithDiscoveryOptionProtocolSpecific(key string, value any) WithDiscoveryOption

func WithDiscoveryOptionRemoteAddress

func WithDiscoveryOptionRemoteAddress(remoteAddress string) WithDiscoveryOption

WithDiscoveryOptionRemoteAddress sets an option for a remoteAddress

func WithDiscoveryOptionTransport

func WithDiscoveryOptionTransport(transportName string) WithDiscoveryOption

WithDiscoveryOptionTransport sets an option for a transportName

Directories

Path Synopsis
Deprecated: use options to configure logging
Deprecated: use options to configure logging

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL