artnet

package module
v0.0.0-...-e4f1b1b Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 10 Imported by: 18

README

go-artnet Build Status GoDoc Go Report Card

Package artnet attempts to implement the Art-Net 4 specification from (c) Artistic Licence Holding Ltd, from art-net.pdf.

Art-Net is an Ethernet protocol based on the TCP/IP protocol suite. Its purpose is to allow transfer of large amounts of DMX512 data over a wide area using standard networking technology.

MIT Licensed.

This package is still unfinished. The API is highly unstable.

See Examples for some hints on how to use this package.

Documentation

Overview

Package artnet attempts to implement the Art-Net 4 specification from (c) Artistic Licence Holding Ltd, available at www.Art-Net.org.uk. Art-Net is an Ethernet protocol based on the TCP/IP protocol suite. Its purpose is to allow transfer of large amounts of DMX512 data over a wide area using standard networking technology.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArtPollReplyFromConfig

func ArtPollReplyFromConfig(c NodeConfig) *packet.ArtPollReplyPacket

ArtPollReplyFromConfig will return a ArtPollReplyPacket from the NodeConfig TODO: make this a more complete packet by adding the other NodeConfig fields

Types

type Address

type Address struct {
	Net    uint8 // 0-128
	SubUni uint8
}

Address contains a universe address

func (Address) Integer

func (a Address) Integer() int

Integer returns the integer representation of Address

func (Address) String

func (a Address) String() string

String returns a string representation of Address

type ControlledNode

type ControlledNode struct {
	LastSeen   time.Time
	Node       NodeConfig
	UDPAddress net.UDPAddr

	Sequence  uint8
	DMXBuffer map[Address]*dmxBuffer
	// contains filtered or unexported fields
}

ControlledNode hols the configuration of a node we control

type Controller

type Controller struct {

	// Nodes is a slice of nodes that are seen by this controller
	Nodes         []*ControlledNode
	OutputAddress map[Address]*ControlledNode
	InputAddress  map[Address]*ControlledNode
	// contains filtered or unexported fields
}

Controller holds the information for a controller

func NewController

func NewController(name string, ip net.IP, log Logger, opts ...Option) *Controller

NewController return a Controller

func (*Controller) SendDMXToAddress

func (c *Controller) SendDMXToAddress(dmx [512]byte, address Address)

SendDMXToAddress will set the DMXBuffer for a destination address and update the node

func (*Controller) SetOption

func (c *Controller) SetOption(option Option) error

SetOption runs a functional option against Controller.

func (*Controller) Start

func (c *Controller) Start() error

Start will start this controller

func (*Controller) Stop

func (c *Controller) Stop()

Stop will stop this controller

type Fields

type Fields map[string]interface{}

Fields are a representation of formatted log fields

type InputPort

type InputPort struct {
	Address Address
	Type    code.PortType
	Status  code.GoodInput
}

InputPort contains information for an input port

type Logger

type Logger interface {
	logrus.StdLogger
	With(fields Fields) *logger
}

Logger is the interface for a logger

func NewDefaultLogger

func NewDefaultLogger() Logger

NewDefaultLogger returns a Logger based on logrus

func NewLogger

func NewLogger(log *logrus.Entry) Logger

NewLogger creates a new logger from given logrus logger

type Node

type Node struct {
	// Config holds the configuration of this node
	Config NodeConfig
	// contains filtered or unexported fields
}

Node is the information known about a node

func NewNode

func NewNode(name string, style code.StyleCode, ip net.IP, log Logger, opts ...NodeOption) *Node

NewNode return a Node

func (*Node) DeregisterCallback

func (n *Node) DeregisterCallback(opcode code.OpCode)

DeregisterCallback deletes a callback stored for the given opcode. This deregistration function can only deregister callbacks before the node has been started.

func (*Node) RegisterCallback

func (n *Node) RegisterCallback(opcode code.OpCode, callback NodeCallbackFn)

RegisterCallback stores the given callback which will be called when a packet with the given opcode arrives. This registration function can only register callbacks before the node has been started. Calling this function multiple times replaces every previous callback.

func (*Node) SetOption

func (n *Node) SetOption(option NodeOption) error

SetOption runs a functional option against Node.

func (*Node) Start

func (n *Node) Start() error

Start will start the controller

func (*Node) Stop

func (n *Node) Stop()

Stop will stop all running routines and close the network connection

type NodeCallbackFn

type NodeCallbackFn func(p packet.ArtNetPacket)

NodeCallbackFn gets called when a new packet has been received and needs to be processed

type NodeConfig

type NodeConfig struct {
	OEM          uint16
	Version      uint16
	BiosVersion  uint8
	Manufacturer string
	Type         code.StyleCode
	Name         string
	Description  string

	Ethernet  net.HardwareAddr
	IP        net.IP
	BindIP    net.IP
	BindIndex uint8
	Port      uint16

	Report  []code.NodeReportCode
	Status1 code.Status1
	Status2 code.Status2

	BaseAddress Address
	InputPorts  []InputPort
	OutputPorts []OutputPort
}

NodeConfig is a representation of a single node.

func ConfigFromArtPollReply

func ConfigFromArtPollReply(p packet.ArtPollReplyPacket) NodeConfig

ConfigFromArtPollReply will return a Config from the information in the ArtPollReplyPacket

func (NodeConfig) NumberOfPorts

func (c NodeConfig) NumberOfPorts() uint16

NumberOfPorts returns the count of node ports. This method assumes that NodeConfig is validated.

func (NodeConfig) PortTypes

func (c NodeConfig) PortTypes() [4]code.PortType

PortType merges the InputPorts and OutputPorts config into a single PortTypes definition. This method assumes that NodeConfig is validated.

type NodeOption

type NodeOption func(*Node) error

NodeOption is a functional option handler for Node.

func NodeBroadcastAddress

func NodeBroadcastAddress(addr net.UDPAddr) NodeOption

NodeBroadcastAddress sets the broadcast address to use; defaults to 2.255.255.255:6454

type Option

type Option func(*Controller) error

Option is a functional option handler for Controller.

func BroadcastAddr

func BroadcastAddr(addr net.UDPAddr) Option

BroadcastAddr sets the broadcast address to use; defaults to 2.255.255.255:6454

func MaxFPS

func MaxFPS(fps int) Option

MaxFPS sets the maximum amount of updates sent out per second

type OutputPort

type OutputPort struct {
	Address Address
	Type    code.PortType
	Status  code.GoodOutput
}

OutputPort contains information for an input port

Directories

Path Synopsis
example
Package packet contains the ArtNet packet definitions
Package packet contains the ArtNet packet definitions
code
Package code contains codes used in ArtNet packets
Package code contains codes used in ArtNet packets
Package version implements the version of the protocol
Package version implements the version of the protocol

Jump to

Keyboard shortcuts

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