diff options
author | SaloniGoyal | 2016-05-31 15:55:07 +0530 |
---|---|---|
committer | SaloniGoyal | 2016-05-31 15:55:07 +0530 |
commit | d3d5a0c0e44d37bec5374c66efa99bd144a9fced (patch) | |
tree | ba3a8ce6a23cbd5c372fa406670da20d33b29af8 /routes | |
parent | 228f8ac592c781a208cf2d222f5fd663406daccf (diff) | |
download | eSimWebApp-d3d5a0c0e44d37bec5374c66efa99bd144a9fced.tar.gz eSimWebApp-d3d5a0c0e44d37bec5374c66efa99bd144a9fced.tar.bz2 eSimWebApp-d3d5a0c0e44d37bec5374c66efa99bd144a9fced.zip |
Run ngspice on the saved netlist
Diffstat (limited to 'routes')
-rw-r--r-- | routes/routes.js | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/routes/routes.js b/routes/routes.js index 1d7eb38..bcba542 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -1,4 +1,4 @@ -module.exports = function(express,app){ +module.exports = function(express,app,io,fs,exec){ var router = express.Router(); router.get('/',function(req,res,next){ @@ -7,7 +7,48 @@ module.exports = function(express,app){ }); app.use('/',router); + + + io.on('connection',function(socket){ + console.log('a user connected'); + socket.on('disconnect', function(){ + console.log('user disconnected'); + fs.stat('/tmp/' + socket.id + '.cir.out', function(err, stat){ + if(err == null){ + fs.unlink('/tmp/' + socket.id + '.cir.out'); + } + + }); + fs.stat('/tmp' + socket.id.toLowerCase() + '-dumpv.txt', function(err, stat){ + if(err == null){ + fs.unlink('/tmp' + socket.id.toLowerCase() + '-dumpv.txt'); + } + + }); + fs.stat('/tmp' + socket.id.toLowerCase() + '-dumpi.txt', function(err, stat){ + if(err == null){ + fs.unlink('/tmp' + socket.id.toLowerCase() + '-dumpi.txt'); + } + + }); + + }); + socket.on('chat message', function(msg){ + console.log('message: ' + msg); + }); + socket.on('netlist', function(msg){ + var update = msg.replace('dumpv', '/tmp' + socket.id.toLowerCase() + '-dumpv'); + var result = update.replace('dumpi', '/tmp' + socket.id.toLowerCase() + '-dumpi'); + fs.writeFile('/tmp/' + socket.id + '.cir.out', result, function(err){ + if(err){ + return console.log(err); + } + }); + exec('ngspice ' + '/tmp/' + socket.id + '.cir.out'); + + }); +}); } |