2018-12-19 19:24:06 +00:00
|
|
|
const util = require('util');
|
|
|
|
const EventEmitter = require('events').EventEmitter;
|
|
|
|
|
|
|
|
class DMX {
|
|
|
|
constructor(options) {
|
|
|
|
const opt = options || {};
|
|
|
|
const devices = opt.devices || {};
|
|
|
|
|
|
|
|
this.universes = {};
|
|
|
|
this.drivers = {};
|
|
|
|
this.devices = Object.assign({}, require('./devices'), devices);
|
|
|
|
this.animation = require('./anim');
|
|
|
|
|
|
|
|
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'));
|
|
|
|
}
|
|
|
|
|
|
|
|
registerDriver(name, module) {
|
|
|
|
this.drivers[name] = module;
|
|
|
|
}
|
|
|
|
|
|
|
|
addUniverse(name, driver, deviceId, options) {
|
|
|
|
this.universes[name] = new this.drivers[driver](deviceId, options);
|
|
|
|
return this.universes[name];
|
|
|
|
}
|
|
|
|
|
|
|
|
update(universe, channels) {
|
|
|
|
this.universes[universe].update(channels);
|
|
|
|
this.emit('update', universe, channels);
|
|
|
|
}
|
|
|
|
|
|
|
|
updateAll(universe, value) {
|
|
|
|
this.universes[universe].updateAll(value);
|
|
|
|
this.emit('updateAll', universe, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
universeToObject(universeKey) {
|
|
|
|
const universe = this.universes[universeKey];
|
|
|
|
const u = {};
|
|
|
|
|
|
|
|
for (let i = 0; i < 512; i++) {
|
|
|
|
u[i] = universe.get(i);
|
|
|
|
}
|
|
|
|
return u;
|
|
|
|
}
|
2013-11-17 00:41:27 +00:00
|
|
|
}
|
2012-09-08 12:43:04 +00:00
|
|
|
|
2018-12-19 19:24:06 +00:00
|
|
|
util.inherits(DMX, EventEmitter);
|
2012-09-08 12:43:04 +00:00
|
|
|
|
2018-12-19 19:24:06 +00:00
|
|
|
DMX.devices = require('./devices');
|
|
|
|
DMX.Animation = require('./anim');
|
2013-11-17 16:45:53 +00:00
|
|
|
|
2018-12-19 19:24:06 +00:00
|
|
|
module.exports = DMX;
|