dmx-flok/dmx.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

"use strict"
2012-09-01 12:17:39 +00:00
var util = require('util')
var EventEmitter = require('events').EventEmitter
2012-09-01 12:17:39 +00:00
2015-11-29 16:02:34 +00:00
function DMX(options) {
var options = options || {}
this.universes = {}
2015-11-29 16:02:34 +00:00
this.drivers = {}
this.devices = options.devices || require('./devices')
this.registerDriver('null', require('./drivers/null'))
this.registerDriver('dmx4all', require('./drivers/dmx4all'))
this.registerDriver('enttec-usb-dmx-pro', require('./drivers/enttec-usb-dmx-pro'))
this.registerDriver('enttec-open-usb-dmx', require('./drivers/enttec-open-usb-dmx'))
this.registerDriver('dmxking-ultra-dmx-pro', require('./drivers/dmxking-ultra-dmx-pro'))
this.registerDriver('artnet', require('./drivers/artnet'))
this.registerDriver('bbdmx', require('./drivers/bbdmx'))
}
2012-09-08 12:43:04 +00:00
util.inherits(DMX, EventEmitter)
2012-09-08 12:43:04 +00:00
2015-11-29 16:02:34 +00:00
DMX.devices = require('./devices')
DMX.Animation = require('./anim')
DMX.prototype.registerDriver = function(name, module) {
this.drivers[name] = module
2012-09-08 12:43:04 +00:00
}
DMX.prototype.addUniverse = function(name, driver, device_id, options) {
return this.universes[name] = new this.drivers[driver](device_id, options)
2012-09-08 12:43:04 +00:00
}
DMX.prototype.update = function(universe, channels) {
this.universes[universe].update(channels)
this.emit('update', universe, channels)
}
2012-09-08 12:43:04 +00:00
DMX.prototype.updateAll = function(universe, value) {
2016-10-15 21:23:51 +00:00
this.universes[universe].updateAll(value)
this.emit('updateAll', universe, value)
}
2016-11-12 14:51:32 +00:00
DMX.prototype.universeToObject = function(universe) {
var universe = this.universes[universe]
2016-10-15 21:23:51 +00:00
var u = {}
for(var i = 0; i < 512; i++) {
2016-10-15 21:23:51 +00:00
u[i] = universe.get(i)
}
return u
}
module.exports = DMX