summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorfahimkhan2016-08-23 12:02:09 +0530
committerfahimkhan2016-08-23 12:02:09 +0530
commitaf10f80e9f318f0329e477a07d540b1aee19baeb (patch)
tree05911153b9eb947ab174d3ca9254cf62d6bdf202 /routes
parent9c1e0a4a5fd4099302e63144987f67f5b28b4890 (diff)
downloadOnline-NgSpice-Simulator-af10f80e9f318f0329e477a07d540b1aee19baeb.tar.gz
Online-NgSpice-Simulator-af10f80e9f318f0329e477a07d540b1aee19baeb.tar.bz2
Online-NgSpice-Simulator-af10f80e9f318f0329e477a07d540b1aee19baeb.zip
Subject: Added plots details
Description: Now user can write what voltage or current needs to plot
Diffstat (limited to 'routes')
-rw-r--r--routes/routes.js27
1 files changed, 10 insertions, 17 deletions
diff --git a/routes/routes.js b/routes/routes.js
index 5dbda92..f65a084 100644
--- a/routes/routes.js
+++ b/routes/routes.js
@@ -12,7 +12,6 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){
io.on('connection', function (socket) {
socketID = getSocketID(socket);
var plot_allv_file = '/tmp/plot_allv_'+socketID.toLowerCase()+'.txt'
- var plot_alli_file = '/tmp/plot_alli_'+socketID.toLowerCase()+'.txt'
var fileName = '/tmp/'+socketID+'.cir.out';
socket.emit('loadingPage', 'User with socket ID '+socket.id+' is Connected');
@@ -20,8 +19,11 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){
console.log('Socket ID : '+data['socketID']);
});
- socket.on('netlist',function(netlistContent){
+ socket.on('netlist',function(data){
+ netlistContent = data['netlist'];
+ plotOption = data['plotOption'];
console.log('Server : '+netlistContent);
+ console.log('Plot Option :'+plotOption);
// socket.emit('serverMessage','Recived message for client '+socketID);
fs.writeFile(fileName, netlistContent, function (err) {
if (err){
@@ -30,7 +32,7 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){
console.log('File is stored at '+fileName);
fs.exists(fileName, function(exists) {
if (exists) {
- addPlotDetails(fileName);
+ addPlotDetails(fileName,plotOption);
executeNgspiceNetlist(fileName);
}
@@ -58,23 +60,15 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){
}
});
- fs.exists(plot_alli_file, function(exists) {
- // console.log("Check Plot alli "+plot_alli_file)
- if (exists) {
- console.log("Check Plot alli files")
- //Deleting plot alli file
- deleteNetlistFile(plot_alli_file);
- }
- });
+
});
- function addPlotDetails(fileName)
+ function addPlotDetails(fileName,plotOption)
{
-
+ plotOption=plotOption.replace(/^(\r\n)|(\n)/,'');
//Adding Plot component in a file
- sed('-i', 'run', 'run \n print allv > /tmp/plot_allv_'+socketID+'.txt \n \
- print alli > /tmp/plot_alli_'+socketID+'.txt', fileName);
+ sed('-i', 'run', 'run \n print '+plotOption.trim()+'> /tmp/plot_allv_'+socketID+'.txt \n' , fileName);
}
@@ -113,7 +107,6 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){
function parsePlotData(){
console.log("Ngspice netlist executed successfully "+fileName);
- // console.log("Allv :"+plot_allv_file)
//socket.emit('serverMessage','Ngspice netlist executed successfully: ');
//var analysisInfo = grep('.tran|.dc|.ac', fileName); //Not reliable
var analysisInfo = getAnalysisInfo(fileName);
@@ -123,7 +116,7 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){
pythonPath: pyEnv,
pythonOptions: ['-u'],
scriptPath: scriptPath,
- args: [analysisInfo, plot_allv_file, plot_alli_file]
+ args: [analysisInfo, plot_allv_file]
};
PythonShell.run('parser.py', options, function (err, results) {