-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.js
61 lines (51 loc) · 1.42 KB
/
startup.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
// Require an assersion library
var DataNode = require('./lib/data-node.js'),
FakeGPS = require('./lib/fake-gps.js');
// Parse in a file with plans
var Parser = require('./lib/node-by-line.js');
var fs = require('fs');
/*------------------------------Input--------------------------------*/
// Variables for argumentes
var config = {}
//var filename = process.argv[2];
var verbose = false;
var speed = 1;
var id;
var fname;
// Process the arguments
process.argv.forEach(function (val, index, array) {
switch( val ) {
case "-s":
case "--speed":
speed = array[index+1];
break;
case "-v":
case "--verbose":
verbose = true;
break;
case "-id":
id = array[index+1];
break;
case "-f":
case "--file":
fname = array[index+1];
default:
}
});
// Validate arguments
if( !id || !fname ) {
console.log( "Usage node startup.js [--speed|-s] speed [-id] uid [-f|--file] filename [--verbose|-v] ");
return;
}
// Create file stream
var file = fs.createReadStream( fname );
// Parse the file into plan
Parser.parse( file, function( pls ) {
start( pls );
});
function start( plans ) {
//console.log( plans[0].toBonString() );
var node = new DataNode( { id: id,
gps: new FakeGPS( plans[ id - 1 ], 1, { id: id } )
} );
}