template

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Overview

Package template provides 结构化组态 device templates: define a device type once — its tags, their address offsets, data types, byte orders and access modes — then stamp it across many instances in one batch. This is FameView's (杰控) signature 结构化数据批次处理: a "Motor" template with Run/Speed/Fault is authored once and instantiated over hundreds of motors, each carrying its own tag prefix and address base, without re-entering every point by hand. The output is a flat []driver.TagPoint ready to feed a driver.Poller — the 万点 batch-config win.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	Name        string // tag prefix, e.g. "M1" -> tags "M1.Run", "M1.Speed"
	AddressBase string // address base, e.g. "DB1" -> address "DB1.DBX0.0"
}

Instance is one placement of a template: a tag-name prefix and the address base every TagDef offset is applied to.

type TagDef

type TagDef struct {
	Name          string           // tag name relative to the instance (e.g. "Run")
	AddressSuffix string           // address offset appended to the instance base
	Type          driver.DataType  // value type
	Order         driver.ByteOrder // register/byte order for multi-byte types
	Access        driver.AccessMode
}

TagDef is one tag inside a template. AddressSuffix is the point's offset from an instance's address base (e.g. ".DBX0.0" or "1"); Type/Order/Access carry straight through to every stamped driver.TagPoint.

type Template

type Template struct {
	Name string
	Tags []TagDef
}

Template is a reusable device type — e.g. a "Motor" with Run(bool), Speed(float) and Fault(bool) — authored once and stamped across instances.

func (Template) Instantiate

func (t Template) Instantiate(instanceName, addressBase string) []driver.TagPoint

Instantiate stamps the template onto one instance: each TagDef becomes a driver.TagPoint with Tag = instanceName+"."+def.Name and Address = addressBase+def.AddressSuffix, carrying Type/Order/Access.

func (Template) InstantiateMany

func (t Template) InstantiateMany(insts []Instance) []driver.TagPoint

InstantiateMany batch-stamps the template across every instance and returns the concatenated points — the 万点 batch-config path.

func (Template) Validate

func (t Template) Validate() error

Validate reports whether the template is well-formed: a non-empty name and no duplicate tag names (a duplicate would collide on Tag once stamped).

Jump to

Keyboard shortcuts

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