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 | |
parent | 228f8ac592c781a208cf2d222f5fd663406daccf (diff) | |
download | eSimWebApp-d3d5a0c0e44d37bec5374c66efa99bd144a9fced.tar.gz eSimWebApp-d3d5a0c0e44d37bec5374c66efa99bd144a9fced.tar.bz2 eSimWebApp-d3d5a0c0e44d37bec5374c66efa99bd144a9fced.zip |
Run ngspice on the saved netlist
-rw-r--r-- | app.js | 39 | ||||
-rw-r--r-- | routes/routes.js | 43 | ||||
-rw-r--r-- | views/script/form.js | 4 | ||||
-rw-r--r-- | views/script/gui.js | 4 | ||||
-rw-r--r-- | views/script/netlist.js | 2 | ||||
-rw-r--r-- | views/script/savenetlist.js | 3 |
6 files changed, 53 insertions, 42 deletions
@@ -15,44 +15,15 @@ app.set('port',process.env.PORT||4000); //Setting config app.set('host',config.host); -//Routing -require('./routes/routes.js')(express,app); - //Socket IO var server = require('http').createServer(app); var io = require('socket.io')(server); var fs = require('fs'); +var exec = require('child_process').exec; + +//Routing +require('./routes/routes.js')(express,app,io,fs,exec); server.listen(app.get('port'),function(){ console.log('eSim Runing on port : '+app.get('port')); -}); - -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'); - console.log('temp file deleted successfully'); - } - - }); - - }); - socket.on('chat message', function(msg){ - console.log('message: ' + msg); - }); - socket.on('netlist', function(msg){ - console.log('netlist stored in tmp folder') - fs.writeFile('/tmp/socket_id.cir.out', msg, function(err){ - if(err){ - return console.log(err); - } - }); - }); - io.emit('chat message', {hello: 'world'}); -}) - - - +})
\ No newline at end of file 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'); + + }); +}); } diff --git a/views/script/form.js b/views/script/form.js index 1d2bf2a..31099bc 100644 --- a/views/script/form.js +++ b/views/script/form.js @@ -9,7 +9,3 @@ jQuery("#websocket_form").click(function(){ return false; }); -socket.on('chat message', function(msg){ - console.log(msg); -}); - diff --git a/views/script/gui.js b/views/script/gui.js index 4ba11b0..d410c44 100644 --- a/views/script/gui.js +++ b/views/script/gui.js @@ -737,7 +737,7 @@ Here are the all Transiet Cases for generating final netlist values change_val = "1";
}
- socket.emit('netlist', jQuery("#webtronics_netlist_text_area").val());
+
}
@@ -773,7 +773,7 @@ else if( change_val == "1") change_val = "1";
}
- socket.emit('netlist', jQuery("#webtronics_netlist_text_area").val());
+
}
diff --git a/views/script/netlist.js b/views/script/netlist.js index 0fe044c..c3a686f 100644 --- a/views/script/netlist.js +++ b/views/script/netlist.js @@ -516,7 +516,7 @@ createnetlist:function(responsefunc){ if(sections.lastdir[i]!="")spice+=sections.lastdir[i]+"\n"; } } - responsefunc(spice.toLowerCase()); + responsefunc(spice); }, responder:function(text){ diff --git a/views/script/savenetlist.js b/views/script/savenetlist.js index bdabcfd..33898bb 100644 --- a/views/script/savenetlist.js +++ b/views/script/savenetlist.js @@ -5,11 +5,14 @@ For Simulation of Netlist and Removal of netlist Window ------------------------------------------------------------------------------------------------------------------------------------------------*/ jQuery("#webtronics_netlist_simulate").click(function(){ + socket.emit('netlist', jQuery("#webtronics_netlist_text_area").val()); console.log("simulation button clicked"); jQuery('#webtronics_netlist_text_div').hide(); jQuery('#webtronics_netlist_buttons').hide(); jQuery('#webtronics_netlist_text').hide(); jQuery('#webtronics_disable').hide(); + + |