Documentation
¶
Overview ¶
Package rangenode contains the range node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RangeConfig ¶
type RangeConfig struct {
// Action is "scale" (default, extrapolate freely), "drop"
// (discard out-of-range messages), "clamp" (clamp to the input
// range) or "roll" (wrap into the input range)
Action string `json:"action"`
// Property is the dotted path into the payload; "payload" (the
// default) targets the whole payload
Property string `json:"property"`
MinIn float64 `json:"minin"`
MaxIn float64 `json:"maxin"`
MinOut float64 `json:"minout"`
MaxOut float64 `json:"maxout"`
// Round rounds the scaled result to the nearest integer
Round bool `json:"round"`
}
RangeConfig holds configuration for the range node — the Node-RED range equivalent. MinIn/MaxIn define the input range, MinOut/MaxOut the output range the value is linearly mapped to.
type RangeNode ¶
RangeNode linearly maps a numeric payload property from an input range to an output range, with an optional out-of-range action applied to the input range before scaling.
func NewRangeNode ¶
func NewRangeNode(node nodestore.NodeInterface, config *RangeConfig) *RangeNode
NewRangeNode creates a new range node
func (*RangeNode) Execute ¶
func (n *RangeNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute reads the configured property, applies the out-of-range action, scales the value and writes it back. A non-numeric value or a value dropped by the "drop" action ends the message here (nil output); a missing property passes the message through unchanged.