Documentation
¶
Overview ¶
Package channel defines the engine's workflow-level handles to external resources — hardware drivers (GPIO, ADC, UART, ...) and network protocols (MQTT, future HTTP). A channel mediates between nodes that read/write it and the underlying driver or transport. Nodes register against the channel during build; Setup configures the driver accordingly.
Index ¶
Constants ¶
const SubBufSize = 64
SubBufSize is the buffer size used in subscription channels. Events are dropped when this buffer size is exceeded.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶
type Broadcaster[T any] struct { // contains filtered or unexported fields }
Broadcaster is the fanout primitive for channels that emit events to trigger nodes. broadcast pushes non-blockingly and drops on full so a slow subscriber can never stall the producing driver thread.
func (*Broadcaster[T]) Subscribe ¶
func (b *Broadcaster[T]) Subscribe() <-chan T
Subscribe appends a buffered channel to the fanout list and returns it; call during build, before the driver starts producing.
type Channel ¶
type Channel interface {
Setup() error // Setup configures the underlying driver according to the registered nodes. Called once during engine setup, after all nodes have registered.
}
Channel is the contract that all channel types must satisfy.
type DAC ¶
DAC is a true analog output channel — sets a real voltage, in contrast with PWM which produces a switched square wave. Channels do not need per-channel acquisition, so Setup is a no-op.
type GPIOInput ¶
type GPIOInput struct {
Broadcaster[bool]
Driver driver.GPIODriver
Line int
Bias driver.Bias
DebounceMs int // Debounce time in milliseconds; 0 for no debounce
}
GPIOInput is a digital input pin channel.
type GPIOOutput ¶
type GPIOOutput struct {
Driver driver.GPIODriver
Line int
}
GPIOOutput is a digital output pin.
func (*GPIOOutput) Setup ¶
func (v *GPIOOutput) Setup() error
func (*GPIOOutput) Write ¶
func (v *GPIOOutput) Write(value bool) error
type MQTT ¶
type MQTT struct {
Transport transport.MQTTTransport
Topic string // the channel's topic (publish target / subscribe filter)
PublishPrefix string // prepended on every Publish; "" = pass-through
SubscribePrefix string // prepended on every Subscribe; "" = pass-through
}
MQTT is a workflow-level MQTT channel: a topic endpoint on a bound broker.
type PWM ¶
type PWM struct {
Driver driver.PWMDriver
Channel int
Frequency int // Pulse cycles per second (Hz) for this channel
}
PWM is a PWM output channel.
type UART ¶
type UART struct {
Broadcaster[string]
Driver driver.SerialDriver
}
UART is a serial port channel wrapping a SerialDriver and the fanout list of OnSerialReceive subscribers.