From 67860416b798cf61e0345ed5b14bf2da8db6a1e9 Mon Sep 17 00:00:00 2001 From: AJ Keller Date: Sun, 10 Jul 2016 02:49:17 -0400 Subject: [PATCH] ADD daisy --- .travis.yml | 1 + openBCISimulator.js | 6 +-- test/openBCIBoard-test.js | 77 +++++++++++++++++++++++++++++++++++ test/openBCISimulator-test.js | 2 +- 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03150c8..af127aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ node_js: - "6.0" - "6.1" - "6.2" + - "6.3" install: - npm install --all script: diff --git a/openBCISimulator.js b/openBCISimulator.js index ae10d39..d1ce2d9 100644 --- a/openBCISimulator.js +++ b/openBCISimulator.js @@ -50,11 +50,7 @@ function OpenBCISimulatorFactory() { if (options.sampleRate) { opts.sampleRate = options.sampleRate; } else { - if (opts.daisy) { - opts.sampleRate = k.OBCISampleRate125; - } else { - opts.sampleRate = k.OBCISampleRate250; - } + opts.sampleRate = k.OBCISampleRate250; } opts.serialPortFailure = options.serialPortFailure || _options.serialPortFailure; opts.verbose = options.verbose || _options.verbose; diff --git a/test/openBCIBoard-test.js b/test/openBCIBoard-test.js index a2d1897..1421f10 100644 --- a/test/openBCIBoard-test.js +++ b/test/openBCIBoard-test.js @@ -372,6 +372,8 @@ describe('openbci-sdk',function() { }); }); + + describe('#boardTests', function() { this.timeout(2000); before(function() { @@ -2476,6 +2478,81 @@ describe('openbci-sdk',function() { }); +describe('#daisy', function () { + var ourBoard; + this.timeout(4000); + before(function (done) { + ourBoard = new openBCIBoard.OpenBCIBoard({ + verbose:true, + simulatorFirmwareVersion: 'v2', + simulatorDaisyModuleAttached: true, + }); + + var useSim = () => { + ourBoard.simulatorEnable() + .then(() => { + console.log(`has daisy module: ${ourBoard.options.simulatorDaisyModuleAttached}`); + return ourBoard.connect(k.OBCISimulatorPortName); + }) + .then(() => { + return ourBoard.softReset(); + }) + .catch(err => console.log(err)); + }; + ourBoard.autoFindOpenBCIBoard() + .then(portName => { + return setTimeout(() => { + console.log('Issuing connect'); + ourBoard.connect(portName); + },500); + }) + .catch((err) => { + useSim(); + }) + .then(() => { + //console.log('connected'); + }) + .catch(err => { + console.log('Error: ' + err); + }); + + + ourBoard.once('ready', () => { + done(); + }); + }); + after(done => { + if (ourBoard.connected) { + ourBoard.disconnect().then(() => { + done(); + }).catch(() => done); + } else { + done(); + } + }); + it("can get samples with channel array of length 16", done => { + var numberOfSamples = 130; + var sampleCount = 0; + var samp = sample => { + console.log(`sample`, sample); + // expect(sample.sampleNumber).to.equal(sampleCount); + expect(sample.channelData.length).to.equal(k.OBCINumberOfChannelsDaisy); + if (sampleCount <= numberOfSamples) { + sampleCount++; + } else { + ourBoard.disconnect() + .then(() => { + done(); + }); + ourBoard.removeListener('sample',samp); + } + }; + ourBoard.on('sample',samp); + ourBoard.streamStart().catch(err => done); + // Attached the emitted + }); +}); + // Need a better test describe('#sync', function() { var ourBoard; diff --git a/test/openBCISimulator-test.js b/test/openBCISimulator-test.js index 23461f1..c2cad54 100644 --- a/test/openBCISimulator-test.js +++ b/test/openBCISimulator-test.js @@ -50,7 +50,7 @@ describe('openBCISimulator',function() { simulator = new openBCISimulator.OpenBCISimulator(portName,{ daisy: true }); - expect(simulator.options.sampleRate).to.equal(125); + expect(simulator.options.sampleRate).to.equal(250); // produce samples at same rate }); it('should use provided sample rate even if daisy is true',function () { simulator = new openBCISimulator.OpenBCISimulator(portName,{