device

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package device is the designer-facing bridge between silk's UI and the field-device layer (package driver). DeviceComponent is a placeable widget whose properties configure a Modbus TCP or S7 connection and its tag points; at runtime it builds a driver.Poller that streams the device into a core.TagDB, from which silk's existing bindings drive the screen. Keeping it in its own package means only apps that need device I/O pull the protocol dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPoints

func FormatPoints(pts []driver.TagPoint) string

FormatPoints renders points back to canonical CSV text: one line per point with all five fields, each line newline-terminated. It round-trips with ParsePoints, so ParsePoints(FormatPoints(pts)) returns pts.

func ParsePoints

func ParsePoints(csv string) ([]driver.TagPoint, error)

ParsePoints parses the CSV point list into driver.TagPoint values. It is the one parser for the point-list format. Blank and comment lines are skipped; a malformed line returns an error naming its 1-based line number.

func ValidatePointLine

func ValidatePointLine(line string) error

ValidatePointLine reports whether one point line is well-formed, returning the same field error ParsePoints would raise for it (without the line-number prefix). Blank and comment lines are valid and carry no point.

Types

type DeviceComponent

type DeviceComponent struct {
	gui.Widget
	// contains filtered or unexported fields
}

DeviceComponent configures one device connection and its tag points and, when Started, polls it into a tag database. Connection settings are exposed as design-time properties; points are an editable CSV list.

func NewDeviceComponent

func NewDeviceComponent() *DeviceComponent

NewDeviceComponent returns a component with sensible Modbus TCP defaults.

func (*DeviceComponent) Draw

func (d *DeviceComponent) Draw(g paint.Painter)

Draw renders a small labeled box so the component is visible and identifiable on the design surface.

func (*DeviceComponent) EnumProperties

func (d *DeviceComponent) EnumProperties(list core.IPropertyList)

EnumProperties exposes the connection + point config in the property sheet.

func (*DeviceComponent) Host

func (d *DeviceComponent) Host() string

func (*DeviceComponent) Init

func (d *DeviceComponent) Init(self gui.IWidget)

Init carries the connection defaults, not NewDeviceComponent: the designer and the .tdoc loader build components through the core factory, which reflects on Init and never sees the constructor. A factory component left at zero draws ":0" on the design surface and Start dials "tcp://:0" with unit id 0.

func (*DeviceComponent) Period

func (d *DeviceComponent) Period() int

func (*DeviceComponent) Points

func (d *DeviceComponent) Points() string

func (*DeviceComponent) Port

func (d *DeviceComponent) Port() int

func (*DeviceComponent) Protocol

func (d *DeviceComponent) Protocol() string

func (*DeviceComponent) Rack

func (d *DeviceComponent) Rack() int

func (*DeviceComponent) SetHost

func (d *DeviceComponent) SetHost(s string)

func (*DeviceComponent) SetPeriod

func (d *DeviceComponent) SetPeriod(v int)

func (*DeviceComponent) SetPoints

func (d *DeviceComponent) SetPoints(s string)

func (*DeviceComponent) SetPort

func (d *DeviceComponent) SetPort(v int)

func (*DeviceComponent) SetProtocol

func (d *DeviceComponent) SetProtocol(s string)

func (*DeviceComponent) SetRack

func (d *DeviceComponent) SetRack(v int)

func (*DeviceComponent) SetSlot

func (d *DeviceComponent) SetSlot(v int)

func (*DeviceComponent) SetUnitID

func (d *DeviceComponent) SetUnitID(v int)

func (*DeviceComponent) SizeHints

func (d *DeviceComponent) SizeHints() gui.SizeHints

SizeHints gives the designer a compact default box.

func (*DeviceComponent) Slot

func (d *DeviceComponent) Slot() int

func (*DeviceComponent) Start

func (d *DeviceComponent) Start(tags *core.TagDB) error

Start builds the driver + poller from the current config and begins polling into tags. Stop it when the screen closes.

func (*DeviceComponent) Stop

func (d *DeviceComponent) Stop()

Stop halts polling and closes the device. Safe if never started.

func (*DeviceComponent) UnitID

func (d *DeviceComponent) UnitID() int

type Protocol

type Protocol int

Protocol selects the field-bus a DeviceComponent speaks.

const (
	ProtoModbusTCP Protocol = iota
	ProtoS7
	ProtoOPCUA
	ProtoMQTT
)

func (Protocol) String

func (p Protocol) String() string

Jump to

Keyboard shortcuts

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