-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotRaw.js
28 lines (24 loc) · 863 Bytes
/
plotRaw.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
#!/usr/bin/env node
var Promise = require('bluebird');
var MongodbConnection = require('../lib/mongodb/connection');
var StreamPrinter = require('../lib/stream/printer');
var promisifyStream = require('../lib/stream/promisify');
var cli = require('../lib/cli');
var plot = require('../lib/plot').plot;
var streamToArray = require('stream-to-array');
var mongo = new MongodbConnection('mongodb://localhost:27017/neurosky');
var timeMin = new Date('2015-05-07 21:26:00 +0200');
var timeMax = new Date('2015-05-07 21:36:00 +0200');
cli.observePromise('plotRaw', Promise.join(
mongo.getReader('samples', {
type: 'rawEeg',
time: {$gte: timeMin, $lte: timeMax}
}),
function(reader) {
var printer = new StreamPrinter(1);
reader.pipe(printer);
return streamToArray(reader).then(function(sampleList) {
plot(sampleList);
});
})
);