profinetio

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndianBig    = "BE"
	EndianLittle = "LE"
)

Endian constants for address suffix #ENDIAN.

Variables

This section is empty.

Functions

func ByteSize

func ByteSize(dataType string) int

ByteSize returns number of bytes required for a data type.

func NewProfinetIODriver

func NewProfinetIODriver() driver.Driver

Types

type ParsedAddress

type ParsedAddress struct {
	Slot    int
	SubSlot int
	Index   int
	Bit     int // -1 when not a bit address
	Endian  string
	IsBit   bool
}

ParsedAddress represents SLOT:SUB_SLOT:INDEX[.BIT][#ENDIAN].

func ParseAddress

func ParseAddress(addr string) (*ParsedAddress, error)

ParseAddress parses Profinet IO point address format.

type ProfinetDecoder

type ProfinetDecoder struct{}

ProfinetDecoder encodes/decodes IO data by datatype and endianness.

func NewProfinetDecoder

func NewProfinetDecoder() *ProfinetDecoder

func (*ProfinetDecoder) DecodeValue

func (d *ProfinetDecoder) DecodeValue(data []byte, dataType string, addr *ParsedAddress) (any, error)

func (*ProfinetDecoder) EncodeValue

func (d *ProfinetDecoder) EncodeValue(value any, dataType string, addr *ParsedAddress) ([]byte, error)

type ProfinetIODriver

type ProfinetIODriver struct {
	// contains filtered or unexported fields
}

ProfinetIODriver implements PROFINET IO acyclic read/write as IO-Controller.

func (*ProfinetIODriver) Connect

func (d *ProfinetIODriver) Connect(ctx context.Context) error

func (*ProfinetIODriver) Disconnect

func (d *ProfinetIODriver) Disconnect() error

func (*ProfinetIODriver) GetConnectionMetrics

func (d *ProfinetIODriver) GetConnectionMetrics() (connectionSeconds int64, reconnectCount int64, localAddr string, remoteAddr string, lastDisconnectTime time.Time)

func (*ProfinetIODriver) GetMetrics

func (d *ProfinetIODriver) GetMetrics() model.ChannelMetrics

func (*ProfinetIODriver) Health

func (d *ProfinetIODriver) Health() driver.HealthStatus

func (*ProfinetIODriver) Init

func (*ProfinetIODriver) ReadPoints

func (d *ProfinetIODriver) ReadPoints(ctx context.Context, points []model.Point) (map[string]model.Value, error)

func (*ProfinetIODriver) SetDeviceConfig

func (d *ProfinetIODriver) SetDeviceConfig(config map[string]any) error

func (*ProfinetIODriver) SetSlaveID

func (d *ProfinetIODriver) SetSlaveID(_ uint8) error

func (*ProfinetIODriver) WritePoint

func (d *ProfinetIODriver) WritePoint(ctx context.Context, p model.Point, value any) error

type ProfinetScheduler

type ProfinetScheduler struct {
	// contains filtered or unexported fields
}

ProfinetScheduler reads/writes points via transport and decoder.

func NewProfinetScheduler

func NewProfinetScheduler(transport *ProfinetTransport, decoder *ProfinetDecoder) *ProfinetScheduler

func (*ProfinetScheduler) GetStats

func (s *ProfinetScheduler) GetStats() (total, success, failure int64)

func (*ProfinetScheduler) ReadPoints

func (s *ProfinetScheduler) ReadPoints(ctx context.Context, points []model.Point) (map[string]model.Value, error)

func (*ProfinetScheduler) WritePoint

func (s *ProfinetScheduler) WritePoint(ctx context.Context, p model.Point, value any) error

type ProfinetTransport

type ProfinetTransport struct {
	// contains filtered or unexported fields
}

ProfinetTransport manages TCP connection to IO devices.

func NewProfinetTransport

func NewProfinetTransport(channelCfg channelConfig) *ProfinetTransport

func (*ProfinetTransport) Connect

func (t *ProfinetTransport) Connect(ctx context.Context) error

func (*ProfinetTransport) Disconnect

func (t *ProfinetTransport) Disconnect() error

func (*ProfinetTransport) GetConnectionMetrics

func (t *ProfinetTransport) GetConnectionMetrics() (connectionSeconds int64, reconnectCount int64, localAddr string, remoteAddr string, lastDisconnectTime time.Time)

func (*ProfinetTransport) IsConnected

func (t *ProfinetTransport) IsConnected() bool

func (*ProfinetTransport) ReadIO

func (t *ProfinetTransport) ReadIO(ctx context.Context, slot, subslot, index, length int) ([]byte, error)

func (*ProfinetTransport) RecordSuccess

func (t *ProfinetTransport) RecordSuccess()

func (*ProfinetTransport) SetDeviceConfig

func (t *ProfinetTransport) SetDeviceConfig(cfg deviceConfig)

func (*ProfinetTransport) WriteIO

func (t *ProfinetTransport) WriteIO(ctx context.Context, slot, subslot, index int, data []byte) error

Jump to

Keyboard shortcuts

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