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 ¶
- func FormatPoints(pts []driver.TagPoint) string
- func ParsePoints(csv string) ([]driver.TagPoint, error)
- func ValidatePointLine(line string) error
- type DeviceComponent
- func (d *DeviceComponent) Draw(g paint.Painter)
- func (d *DeviceComponent) EnumProperties(list core.IPropertyList)
- func (d *DeviceComponent) Host() string
- func (d *DeviceComponent) Init(self gui.IWidget)
- func (d *DeviceComponent) Period() int
- func (d *DeviceComponent) Points() string
- func (d *DeviceComponent) Port() int
- func (d *DeviceComponent) Protocol() string
- func (d *DeviceComponent) Rack() int
- func (d *DeviceComponent) SetHost(s string)
- func (d *DeviceComponent) SetPeriod(v int)
- func (d *DeviceComponent) SetPoints(s string)
- func (d *DeviceComponent) SetPort(v int)
- func (d *DeviceComponent) SetProtocol(s string)
- func (d *DeviceComponent) SetRack(v int)
- func (d *DeviceComponent) SetSlot(v int)
- func (d *DeviceComponent) SetUnitID(v int)
- func (d *DeviceComponent) SizeHints() gui.SizeHints
- func (d *DeviceComponent) Slot() int
- func (d *DeviceComponent) Start(tags *core.TagDB) error
- func (d *DeviceComponent) Stop()
- func (d *DeviceComponent) UnitID() int
- type Protocol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatPoints ¶
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 ¶
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 ¶
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 ¶
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