Code Monkey home page Code Monkey logo

dmx's Introduction

Go DMX controller with ArtNet discovery + Angular Web UI with WebSockets

Web UI

qmsk::dmx Web UI

Usage

Docker

The recommended way to build and run the project is using Docker:

$ git clone https://github.com/qmsk/dmx.git qmsk-dmx && cd qmsk-dmx
$ docker build -t qmsk/dmx .
$ docker run --rm --name qmsk-dmx -v $PWD/config:/etc/qmsk-dmx:ro -e ARTNET_DISCOVERY=2.255.255.255 -p 8000:8000 qmsk/dmx

The -v $PWD/config:/go/src/github.com/qmsk/dmx/config:ro allows editing the config and reloading it use docker restart qmsk-dmx.

The -e ARTNET_DISCOVERY=2.255.255.255 allows configuring a comma-separated list of broadcast/unicast addresses for ArtNet discovery.

The -p 8000:8000 allows accessing the API/UI at http://localhost:8000 on the machine running the Docker container.

github.com/qmsk/dmx/cmd/qmsk-dmx


Usage:
  qmsk-dmx [OPTIONS] HeadsConfig

Application Options:
      --log=
      --demo                                  Demo Effect

ArtNet:
      --artnet-listen=ADDR
      --artnet-discovery=ADDR
      --artnet-discovery-interval=DURATION
      --artnet-discovery-timeout=DURATION
      --artnet-dmx-refresh=DURATION
      --log.artnet=

Heads:
      --log.heads=
      --heads-library=PATH

Web:
      --http-listen=[HOST]:PORT
      --http-static=PATH

Help Options:
  -h, --help                                  Show this help message

github.com/qmsk/dmx/artnet

Go package supporting Art-Net discovery and DMX output.

github.com/qmsk/dmx/heads

DMX controller with support for multi-channel heads. Configured using TOML configuration files, outputs DMX over Art-Net, controlled using a REST API and WebSocket event stream.

Configuration

Can be configured using a single toml file, or a structured directory of configuration files:

config/colors.toml

[colors.red]
Red     = 1.0

[colors.green]
Green   = 1.0

[colors.blue]
Blue    = 1.0

config/groups.toml

[led-par]
Name        = "LED-Par"

[tri-bar]
Name        = "Tri-Bar"

config/heads.toml

[led-par]
Type        = "stairville/ledpar56-5ch"
Universe    = 1
Address     = 1
Count       = 6
Name        = "LED-Par"
Groups      = ["led-par"]

[tribar-1]
Type        = "american-dj/megatri60_mode2"
Universe    = 1
Address     = 20
Name        = "TriBar @ floor"
Groups      = ["tri-bar"]

[tribar-2]
Type        = "american-dj/megatri60_mode2"
Universe    = 1
Address     = 30
Name        = "TriBar @ wall"
Groups      = ["tri-bar"]

config/presets/test.toml

[Groups.led-par.Color]
Red = 1.0
Blue = 0.5

[Groups.tri-bar.Intensity]
Intensity = 1.0
[Groups.tri-bar.Color]
Red = 1.0
Blue = 0.5

Web API

GET /api/

{
   "Heads" : {
      "tribar-1" : {
         "Channels" : {
            "color:green" : {
               "Address" : 21,
               "DMX" : 0,
               "ID" : "color:green",
               "Value" : 0,
               "Type" : {
                  "Color" : "green"
               },
               "Index" : 1
            },
            "intensity" : {
               "ID" : "intensity",
               "DMX" : 0,
               "Address" : 24,
               "Index" : 4,
               "Type" : {
                  "Intensity" : true
               },
               "Value" : 0
            },
            "color:red" : {
               "ID" : "color:red",
               "DMX" : 0,
               "Address" : 20,
               "Type" : {
                  "Color" : "red"
               },
               "Index" : 0,
               "Value" : 0
            },
            "control:control" : {
               "Value" : 0,
               "Index" : 3,
               "Type" : {
                  "Control" : "control"
               },
               "Address" : 23,
               "DMX" : 0,
               "ID" : "control:control"
            },
            "color:blue" : {
               "Index" : 2,
               "Type" : {
                  "Color" : "blue"
               },
               "Value" : 0,
               "ID" : "color:blue",
               "DMX" : 0,
               "Address" : 22
            }
         },
         "Intensity" : {
            "ScaleIntensity" : null,
            "Intensity" : 0
         },
         "Config" : {
            "Name" : "TriBar @ floor",
            "Type" : "american-dj/megatri60_mode2",
            "Universe" : 1,
            "Address" : 20,
            "Groups" : [
               "tri-bar"
            ],
            "Count" : 0
         },
         "Type" : {
            "URL" : "",
            "Model" : "Mega Tri 60",
            "Mode" : "2",
            "Channels" : [
               {
                  "Color" : "red"
               },
               {
                  "Color" : "green"
               },
               {
                  "Color" : "blue"
               },
               {
                  "Control" : "control"
               },
               {
                  "Intensity" : true
               }
            ],
            "Vendor" : "American DJ",
            "Colors" : {
               "red" : {
                  "Green" : 0,
                  "Blue" : 0,
                  "Red" : 1
               },
               "magenta" : {
                  "Red" : 1,
                  "Blue" : 1,
                  "Green" : 0
               },
               "blue" : {
                  "Red" : 0,
                  "Green" : 0,
                  "Blue" : 1
               },
               "cyan" : {
                  "Blue" : 1,
                  "Green" : 1,
                  "Red" : 0
               },
               "amber" : {
                  "Blue" : 0,
                  "Green" : 0.5,
                  "Red" : 1
               },
               "green" : {
                  "Green" : 1,
                  "Blue" : 0,
                  "Red" : 0
               }
            }
         },
         "Color" : {
            "Green" : 0,
            "Blue" : 0,
            "Red" : 0,
            "ScaleIntensity" : null
         },
         "ID" : "tribar-1"
      },
   },
   "Outputs" : [
      {
         "Universe" : 1,
         "ArtNetNode" : {
            "OutputPorts" : [
               {
                  "Address" : {
                     "Net" : 0,
                     "SubUni" : 1
                  },
                  "Type" : 0,
                  "Status" : 128
               },
               {
                  "Address" : {
                     "Net" : 0,
                     "SubUni" : 2
                  },
                  "Status" : 128,
                  "Type" : 0
               }
            ],
            "Version" : 1,
            "Description" : "",
            "BaseAddress" : {
               "Net" : 0,
               "SubUni" : 0
            },
            "OEM" : 0,
            "Name" : "NodeMCU-ARTNET",
            "Report" : "",
            "InputPorts" : null,
            "Ethernet" : "00:00:00:00:00:00"
         }
      }
   ],
   "Groups" : {
      "tri-bar" : {
         "Color" : {
            "Red" : 0,
            "ScaleIntensity" : null,
            "Green" : 0,
            "Blue" : 0
         },
         "ID" : "tri-bar",
         "Name" : "Tri-Bar",
         "Intensity" : {
            "Intensity" : 0,
            "ScaleIntensity" : null
         },
         "Colors" : {
            "green" : {
               "Red" : 0,
               "Green" : 1,
               "Blue" : 0
            },
            "amber" : {
               "Green" : 0.5,
               "Blue" : 0,
               "Red" : 1
            },
            "cyan" : {
               "Red" : 0,
               "Blue" : 1,
               "Green" : 1
            },
            "red" : {
               "Green" : 0,
               "Blue" : 0,
               "Red" : 1
            },
            "magenta" : {
               "Green" : 0,
               "Blue" : 1,
               "Red" : 1
            },
            "blue" : {
               "Red" : 0,
               "Blue" : 1,
               "Green" : 0
            }
         },
         "Heads" : [
            "tribar-1",
            "tribar-2"
         ]
      },
   },
   "Presets" : {
      "test" : {
         "ID" : "test",
         "Groups" : {
            "led-par" : {
               "Intensity" : null,
               "Color" : {
                  "Blue" : 0.5,
                  "Green" : 0,
                  "ScaleIntensity" : null,
                  "Red" : 1
               }
            },
            "tri-bar" : {
               "Intensity" : {
                  "Intensity" : 1,
                  "ScaleIntensity" : null
               },
               "Color" : {
                  "Red" : 1,
                  "ScaleIntensity" : null,
                  "Green" : 0,
                  "Blue" : 0.5
               }
            }
         },
         "Config" : {
            "Name" : "",
            "All" : null,
            "Heads" : null,
            "Groups" : {
               "led-par" : {
                  "Intensity" : null,
                  "Color" : {
                     "Green" : 0,
                     "Blue" : 0.5,
                     "Red" : 1,
                     "ScaleIntensity" : null
                  }
               },
               "tri-bar" : {
                  "Intensity" : {
                     "Intensity" : 1,
                     "ScaleIntensity" : null
                  },
                  "Color" : {
                     "Green" : 0,
                     "Blue" : 0.5,
                     "Red" : 1,
                     "ScaleIntensity" : null
                  }
               }
            }
         },
         "Heads" : {}
      }
   }
}

POST /api/heads/tribar-1

{ "Color": { "Red": 0.517, "Green": 0.0, "Blue": 0.0}}

POST /api/groups/dimmer

{ "Intensity": 0.21 }

POST /api/presets/test

{ "Intensity": 0.69 }

Concepts

Heads

Top-level object that binds together everything else.

Output

A DMX universe (512 channels). Refreshed on every update. Connected to something like a github.com/qmsk/dmx/artnet Universe output.

Channel

Each *Head has multiple Channels, which are patched to some Output universe.

Head

Group

A number of Heads.

Preset

Parameters

Both Heads, Groups and Presets use Parameters.

Intensity

A single Intensity value.

Color

A combination of Red, Green and Blue values.

dmx's People

Contributors

spcomb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dmx's Issues

web: reset state if websocket reconnects

If we lose the websocket connection, we might miss some update events, causing our state to be out of sync.

The server should send a full state on the initial websocket open, then we wouldn't need the separate GET api call.

panic in main.discovery(...)

INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.134:6454:
INFO                                                            Name: qmsk-esp-520358
INFO                                                            Ports: input=0 output=1
INFO                                                            Output 0: 0:0.7
INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.131:6454:
INFO                                                            Name: qmsk-esp-c94b30
INFO                                                            Ports: input=0 output=1
INFO                                                            Output 0: 0:2.1
INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.118:6454:
INFO                                                            Name: qmsk-esp-5f98ed
INFO                                                            Ports: input=0 output=1
INFO                                                            Output 0: 0:1.1
INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.130:6454:
INFO                                                            Name: qmsk-esp-fabd8c
INFO                                                            Ports: input=0 output=1
INFO                                                            Output 0: 0:3.0
INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.120:6454:
INFO                                                            Name: qmsk-esp-7567e8
INFO                                                            Ports: input=0 output=2
INFO                                                            Output 0: 0:2.3
INFO                 heads:events                         update
INFO                                                            Output 1: 0:2.4
INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.134:6454:
INFO                                                            Name: qmsk-esp-520358
INFO                                                            Ports: input=0 output=1
INFO                                                            Output 0: 0:0.7
INFO                 heads:events                         update
INFO                                                      artnet.Discovery: 192.168.2.131:6454:
INFO                                                            Name: qmsk-esp-c94b30
INFO                                                            Ports: input=1 output=1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x3 pc=0x6ffc71]
goroutine 5 [running]:
main.discovery(0xc4200a42c0, 0xc4200f9a40)
        /go/src/github.com/qmsk/dmx/cmd/qmsk-dmx/main.go:43 +0x121
created by main.main
        /go/src/github.com/qmsk/dmx/cmd/qmsk-dmx/main.go:149 +0x303
qmsk-dmx.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

building without docker

Can you share how to build this without using docker? I know that docker is the recoomended way, but I can't use docker for the project I am working on.

How To start

Hi,
I think this project is very cool, but I don't know how to run it.

Independent color parameter controls give inconsistent results if websocket updates are slow

For a head with RGB color controls, each of the RGB controls has its own independent component value. When each of those controls update, they use the most recent color parameter values updated by the server, not the values set by the other control components.

That means that adjusting two color controls will give the wrong color if the websocket does not update in between.

FATAL artnet discovery errors

The qmsk-dmx process exits if sending ArtNet discovery packets fails:

INFO              qmsk.web:                               POST presets/test: &heads.APIPresetParams{preset:(*heads.Preset)(0xc82001f880), Intensity:(*heads.Intensity)(0xc82026ea20)}
WARNING               artnet:controller<[::]:6454>          discovery timeout: 192.168.2.100:6454
INFO                                                      artnet.Discovery: 192.168.2.100:6454:
INFO                                                            Name: NodeMCU-ARTNET
INFO                                                            Output 0: 0:0.1
WARNING               artnet:controller<[::]:6454>          discovery timeout: 192.168.2.100:6454
INFO                                                      artnet.Discovery: 192.168.2.100:6454:
INFO                                                            Name: NodeMCU-ARTNET
INFO                                                            Output 0: 0:0.1
WARNING               artnet:controller<[::]:6454>          discovery timeout: 192.168.2.100:6454
INFO                                                      artnet.Discovery: 192.168.2.100:6454:
INFO                                                            Name: NodeMCU-ARTNET
INFO                                                            Output 0: 0:0.1
WARNING               artnet:controller<[::]:6454>          discovery timeout: 192.168.2.100:6454
INFO                                                      artnet.Discovery: 192.168.2.100:6454:
INFO                                                            Name: NodeMCU-ARTNET
INFO                                                            Output 0: 0:0.1
WARNING               artnet:controller<[::]:6454>          discovery timeout: 192.168.2.100:6454
WARNING               artnet:universe<0:0.1>                SendDMX: SendDMX broadcast 0:0.1: write udp [::]:6454->192.168.2.100:6454: sendto: network is unreachable
ERROR               artnet:controller<[::]:6454>          discovery: sendPoll: write udp [::]:6454->192.168.2.100:6454: sendto: network is unreachable
FATAL                                                     artnet discovery ended

This happens if the interface associated with the artnet discovery addresse goes link-down. The controller should keep running instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.