Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 8x 8x 8x 8x 2x 2x 1x 1x 2x 8x 6x 6x 8x 8x 8x 8x 1x 1x 1x 1x 1x | "use strict" import BuildLight from 'buildlight'; /** * class NestorBuildLight * * @param {String} opts: optional * - map: status-colour map, defaults to { OK: 'green', FAIL: 'red', WARN: 'blue' } * - scheme: color scheme array, defaults to [ 'red', 'green', 'blue' ] * scheme allows flexibility to use BuildLight with various Delcom devices (RGB, RGY) * - usbled: path to usbled installation, if not specified then it will try to * find a usbled installation at /sys/bus/usb/drivers/usbled/ * - platform: override platform, used by unit tests to override buildlight platform * - blinkOnFailure: if true then build light will display blinking red, otherwise display red without blinking */ class NestorBuildLight { constructor(opts) { this.opts = opts; this.opts.scheme = this.opts.scheme || ['red', 'green', 'blue']; const MAP = { ok: 'green', fail: 'red', warn: this.opts.scheme.indexOf('blue') !== -1 ? 'blue' : 'yellow' }; this.opts.map = this.opts.map || MAP; this.buildLight = new BuildLight(this.opts); } /** * Notify build status as a colour on Delcom USB Visual Indocator build light. * Device color schemes contain red and green, which are used for OK and FAIL statuses. * While blue or yellow is used to represent a WARN. * Unknown/other status will be represented as all colors switched on. * * @param {String} status: build status */ notify(status) { const UNKNOWN = 'on'; const colour = this.opts.map[status] || UNKNOWN; const self = this; function _colourise() { console.log('Setting build light colour to %s for status %s', colour, status); if (self.opts.blinkOnFailure && status === 'fail') { self.buildLight.blink(colour, function (err) { if (err) { console.error(err.message); } }); } else { self.buildLight[colour](); } } this.buildLight.unblink(_colourise); } } export { NestorBuildLight as default }; |