precess entire file from pnp format and back
This commit is contained in:
parent
817ef57379
commit
6caddeddcc
2 changed files with 38 additions and 22 deletions
35
index.js
35
index.js
|
@ -11,8 +11,6 @@ module.exports = function(input, output, feedFile, opts) {
|
|||
var section = -1;
|
||||
var sections = [[], [], [], []];
|
||||
|
||||
console.log("processing sections");
|
||||
|
||||
fs.createReadStream(feedFile)
|
||||
.on("data", function(data) {
|
||||
buf += data.toString();
|
||||
|
@ -27,10 +25,10 @@ module.exports = function(input, output, feedFile, opts) {
|
|||
|
||||
if(line.slice(0, 2) === "%,") {
|
||||
section++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(section === 3 && sections[3].length > 0) continue;
|
||||
|
||||
if(section === -1) { // input can be either just the CSV section or the entire pnp file
|
||||
sections[1].push(line);
|
||||
} else {
|
||||
|
@ -42,8 +40,6 @@ module.exports = function(input, output, feedFile, opts) {
|
|||
next(null, sections);
|
||||
})
|
||||
}, function(sections, next) {
|
||||
console.log("associating parts");
|
||||
|
||||
var components = [];
|
||||
var len = sections[1].length;
|
||||
|
||||
|
@ -58,15 +54,12 @@ module.exports = function(input, output, feedFile, opts) {
|
|||
}
|
||||
}
|
||||
|
||||
next(null, components);
|
||||
}, function(feeds, next) {
|
||||
var rs = fs.createReadStream(input);
|
||||
var ws = fs.createWriteStream(output);
|
||||
var wsCsv = csv.createWriteStream();
|
||||
next(null, components, sections);
|
||||
}, function(feeds, sections, next) {
|
||||
var data = "";
|
||||
var seq = 0;
|
||||
|
||||
var tr = through.obj(function(chunk, enc, done) {
|
||||
var tr = through(function(chunk, enc, done) {
|
||||
data += chunk.toString();
|
||||
|
||||
var lines = data.split("\n");
|
||||
|
@ -90,13 +83,25 @@ module.exports = function(input, output, feedFile, opts) {
|
|||
|
||||
var feed = feeds[p];
|
||||
|
||||
this.push([ 0, seq++, feed.slot, x, y, r ].join(",") + "\n");
|
||||
this.push([ 0, seq++, feed.slot, x, y, r, 0.50, 0, 100, null, null, null ].join(",") + "\n");
|
||||
};
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
next(null, tr, sections);
|
||||
}], function(err, tr, sections) {
|
||||
var rs = fs.createReadStream(input);
|
||||
var ws = fs.createWriteStream(output);
|
||||
|
||||
var i = 0;
|
||||
|
||||
async.forEachSeries(sections, function(section, next) {
|
||||
ws.write(section.join("\n") + (++i < 4 ? "\n\n" : "\n"), next);
|
||||
}, function() {
|
||||
rs.pipe(tr);
|
||||
tr.pipe(ws);
|
||||
}]);
|
||||
tr.pipe(ws).on("close", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
0,0,1,237.8710,-103.0732,270.0000
|
||||
0,1,1,213.8680,-99.4156,270.0000
|
||||
0,2,3,219.3061,-52.4408,210.0000
|
||||
0,3,3,219.9640,-55.0062,180.0000
|
||||
0,4,3,223.6470,-55.5840,90.0000
|
||||
0,5,3,214.8840,-60.2615,90.0000
|
||||
%,section 1
|
||||
65535,0,0.00,0.00
|
||||
|
||||
%,section 2
|
||||
65535,1,1,0.00,0.00,4.00,100nF,
|
||||
65535,1,3,-0.25,0.00,4.00,0.1uF,
|
||||
|
||||
%,section 3
|
||||
65535,3,0.00,0.00,
|
||||
|
||||
%,section 4
|
||||
0,0,1,237.8710,-103.0732,270.0000,0.5,0,100,,,
|
||||
0,1,1,213.8680,-99.4156,270.0000,0.5,0,100,,,
|
||||
0,2,3,219.3061,-52.4408,210.0000,0.5,0,100,,,
|
||||
0,3,3,219.9640,-55.0062,180.0000,0.5,0,100,,,
|
||||
0,4,3,223.6470,-55.5840,90.0000,0.5,0,100,,,
|
||||
0,5,3,214.8840,-60.2615,90.0000,0.5,0,100,,,
|
||||
|
|
|
Loading…
Reference in a new issue