-
Notifications
You must be signed in to change notification settings - Fork 95
/
index.js
64 lines (50 loc) · 1.88 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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('socketio', require('./drivers/socketio'));
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'));
this.registerDriver('sacn', require('./drivers/sacn'));
}
registerDriver(name, module) {
this.drivers[name] = module;
}
addUniverse(name, driver, deviceId, options) {
this.universes[name] = new this.drivers[driver](deviceId, options);
this.universes[name].on('update', (channels, extraData) => {
this.emit('update', name, channels, extraData);
});
return this.universes[name];
}
update(universe, channels, extraData) {
this.universes[universe].update(channels, extraData || {});
}
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;
}
}
util.inherits(DMX, EventEmitter);
DMX.devices = require('./devices');
DMX.Animation = require('./anim');
module.exports = DMX;