summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfahim2015-08-04 14:37:09 +0530
committerfahim2015-08-04 14:37:09 +0530
commit6e60c73be373e72a69826fe955d890b9e407df79 (patch)
tree6a1bf037f4a4c8ba2b9736efcda8afd9ebf02226
parentac7e0e4bfc466af13cf6e600e08d8c055db31c3f (diff)
downloadeSim-6e60c73be373e72a69826fe955d890b9e407df79.tar.gz
eSim-6e60c73be373e72a69826fe955d890b9e407df79.tar.bz2
eSim-6e60c73be373e72a69826fe955d890b9e407df79.zip
Subject: Added installation script.
Description: Added installation script and updated README
-rw-r--r--INSTALL38
-rw-r--r--README.md3
-rwxr-xr-xesim-start.sh5
-rwxr-xr-xesim.desktop15
-rwxr-xr-xinstall-linux.sh216
-rw-r--r--kicadSchematicLibrary/kicad.pro69
-rwxr-xr-xsrc/frontEnd/Application.py.bkp363
-rw-r--r--src/kicadtoNgspice/KicadtoNgspice.py.bkp671
8 files changed, 1379 insertions, 1 deletions
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 00000000..3986307a
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,38 @@
+
+eSim installation instructions
+=================================
+
+Table of contents
+
+ 1. eSim installation in Ubuntu (LINUX)
+ 1.1 Prerequisites
+ 1.2 Install from tarball (e.g. ngspice-26.tar.gz)
+
+ 2. eSim installation in Windows
+
+
+
+1. eSim installation in Ubuntu.
+
+ After downloading the zip file from https://github.com/FOSSEE/eSim to a local directory unpack it using:
+
+ $ unzip eSim.zip
+
+ Now change directories in to the top-level source directory (where this INSTALL file can be found).
+
+ To install eSim and other dependecies run the following command.
+
+ $ ../install-linux.sh --install
+
+ Above script will install eSim along with dependencies.
+
+ eSim will be installed to /opt/eSim
+
+ To run eSim you can directly run it from terminal as
+ $ esim
+
+ or you can double click on eSim icon created on desktop after installation.
+
+2. eSim installation in Windows
+
+
diff --git a/README.md b/README.md
index 1402c984..f1079dbc 100644
--- a/README.md
+++ b/README.md
@@ -44,4 +44,5 @@ eSim has been successfully ported to low cost FOSSEE laptop (http://laptop.fosse
`sudo apt-get install ngspice`
-
+##Simple way to install eSim in Ubuntu.
+Please read INSTALL for more information on how to install eSim with single script.
diff --git a/esim-start.sh b/esim-start.sh
new file mode 100755
index 00000000..6e2617e1
--- /dev/null
+++ b/esim-start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cd /opt/eSim/src/frontEnd
+
+exec python Application.py
diff --git a/esim.desktop b/esim.desktop
new file mode 100755
index 00000000..ae29c0a4
--- /dev/null
+++ b/esim.desktop
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Version=0.9
+Name=eSim
+Comment=Open Source CAD
+GenericName=eSim
+Keywords=eda-tools
+Exec=esim %u
+Terminal=false
+X-MultipleArgs=false
+Type=Application
+Icon=/usr/share/icons/freeeda.png
+Categories=Development;
+MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
+StartupNotify=true
+Actions=NewWindow;NewPrivateWindow;
diff --git a/install-linux.sh b/install-linux.sh
new file mode 100755
index 00000000..e8f1fd09
--- /dev/null
+++ b/install-linux.sh
@@ -0,0 +1,216 @@
+#!/bin/bash
+#===============================================================================
+#
+# FILE: install.sh
+#
+# USAGE: ./install.sh --install
+# or
+# ./install.sh --uninstall
+#
+# DESCRIPTION: This is installation/uninstallation script for eSim
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Fahim Khan, (fahim.elex@gmail.com)
+# ORGANIZATION: FOSSEE at IIT Bombay.
+# CREATED: Wednesday 15 July 2015 15:26
+# REVISION: ---
+#===============================================================================
+
+##All Functions goes here
+function addKicadPPA
+{
+echo "Adding Kicad PPA to install latest Kicad version"
+sudo add-apt-repository ppa:js-reynaud/ppa-kicad
+sudo apt-get update
+
+}
+
+function installDependency
+{
+
+echo "Installing Kicad............"
+sudo apt-get install kicad
+echo "Installing ngspice.........."
+sudo apt-get install ngspice
+echo "Installing PyQt4............"
+sudo apt-get install python-qt4
+echo "Installing Matplotlib......."
+sudo apt-get install python-matplotlib
+
+}
+
+function copyKicadLibrary
+{
+
+#Copy Kicad library made for eSim
+sudo cp -r kicadSchematicLibrary/*.lib /usr/share/kicad/library/
+sudo cp -r kicadSchematicLibrary/*.dcm /usr/share/kicad/library/
+
+# Full path of 'kicad.pro file'[Verified for Ubuntu 12.04]
+KICAD_PRO="/usr/share/kicad/template/kicad.pro"
+KICAD_ORIGINAL="/usr/share/kicad/template/kicad.pro.original"
+
+if [ -f "$KICAD_ORIGINAL" ];then
+ echo "kicad.pro.original file found....."
+ sudo cp -rv kicadSchematicLibrary/kicad.pro ${KICAD_PRO}
+else
+ echo "Making copy of original file"
+ sudo cp -rv ${KICAD_PRO}{,.original}
+ sudo cp -rv kicadSchematicLibrary/kicad.pro ${KICAD_PRO}
+fi
+
+}
+
+function copySourceCode
+{
+
+#Creating eSim directory
+esim_loc="/opt/eSim"
+
+if [ -d "$esim_loc" ];then
+ #sudo rm -r "$esim_loc"
+ #sudo mkdir -v "$esim_loc"
+
+ #Copy source code to eSim directory
+ sudo cp -rvp src/configuration/* "$esim_loc/src/configuration"
+ sudo cp -rvp src/modelParamXML/* "$esim_loc/src/modelParamXML"
+ sudo cp -rvp src/modelEditor/* "$esim_loc/src/modelEditor"
+ sudo cp -rvp src/projManagement/* "$esim_loc/src/projManagement"
+ sudo cp -rvp src/ngspiceSimulation/* "$esim_loc/src/ngspiceSimulation"
+ sudo cp -rvp src/kicadtoNgspice/* "$esim_loc/src/kicadtoNgspice"
+ sudo cp -rvp src/browser/* "$esim_loc/src/browser"
+ sudo cp -rvp src/frontEnd/* "$esim_loc/src/frontEnd"
+ sudo cp -rvp kicadSchematicLibrary "$esim_loc"
+ sudo cp -rvp images "$esim_loc"
+else
+ sudo mkdir -v "$esim_loc"
+ #Copy source code to eSim directory
+ sudo cp -rvp src "$esim_loc"
+ sudo cp -rvp kicadSchematicLibrary "$esim_loc"
+ sudo cp -rvp images "$esim_loc"
+fi
+
+if [ "$?" -eq 1 ];then
+ echo "Unable to create /opt/eSim "
+ exit 1;
+else
+ echo "Created /opt/eSim"
+fi
+
+
+#Copy desktop icon file to Desktop
+cp -vp esim.desktop $HOME/Desktop/
+
+#Copy esim start script
+sudo cp -vp esim-start.sh /usr/bin/esim
+
+#Change mode of eSim directory
+sudo chmod -R 777 "$esim_loc"
+
+
+
+}
+
+
+###Checking if file is passsed as arguement to script
+
+if [ "$#" -eq 1 ];then
+ option=$1
+else
+ echo "USAGE : "
+ echo "./install.sh --install"
+ exit 1;
+fi
+
+##Checking flags
+
+if [ $option == "--install" ];then
+ echo "Enter proxy details if you are connected to internet thorugh proxy"
+
+ echo -n "Is your internet connection behind proxy? (y/n): "
+ read getProxy
+ if [ $getProxy == "y" -o $getProxy == "Y" ];then
+ echo -n 'Proxy Hostname :'
+ read proxyHostname
+
+ echo -n 'Proxy Port :'
+ read proxyPort
+
+ echo -n username@$proxyHostname:$proxyPort :
+ read username
+
+ echo -n 'Password :'
+ read -s passwd
+
+ unset http_proxy
+ unset https_proxy
+ unset HTTP_PROXY
+ unset HTTPS_PROXY
+ unset ftp_proxy
+ unset FTP_PROXY
+
+ export http_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
+ export https_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
+ export https_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
+ export HTTP_PROXY=http://$username:$passwd@$proxyHostname:$proxyPort
+ export HTTPS_PROXY=http://$username:$passwd@$proxyHostname:$proxyPort
+ export ftp_proxy=http://$username:$passwd@$proxyHostname:$proxyPort
+ export FTP_PROXY=http://$username:$passwd@$proxyHostname:$proxyPort
+
+ echo "Install with proxy"
+ #Calling functions
+ addKicadPPA
+ installDependency
+ copyKicadLibrary
+ copySourceCode
+
+ elif [ $getProxy == "n" -o $getProxy == "N" ];then
+ echo "Install without proxy"
+
+ #Calling functions
+ addKicadPPA
+ installDependency
+ copyKicadLibrary
+ copySourceCode
+
+ if [ $? -ne 0 ];then
+ echo -e "\n\n\nFreeEDA ERROR: Unable to install required packages. Please check your internet connection.\n\n"
+ exit 0
+ fi
+
+ else
+ echo "Please select the right option"
+ exit 0
+ fi
+
+
+elif [ $option == "--uninstall" ];then
+ echo -n "Are you sure ? As it will remove complete eSim including your subcircuit and model library packages(y/n):"
+ read getConfirmation
+ if [ $getConfirmation == "y" -o $getConfirmation == "Y" ];then
+ sudo rm -rf /opt/eSim/
+ elif [ $getConfirmation == "n" -o $getConfirmation == "N" ];then
+ exit 0
+ else
+ echo "Please select the right option"
+ exit 0
+ fi
+
+
+else
+ echo "Please select the proper operation."
+ echo "--install"
+ echo "--uninstall"
+
+fi
+
+
+
+
+
+
+
+
diff --git a/kicadSchematicLibrary/kicad.pro b/kicadSchematicLibrary/kicad.pro
new file mode 100644
index 00000000..ca36a197
--- /dev/null
+++ b/kicadSchematicLibrary/kicad.pro
@@ -0,0 +1,69 @@
+update=22/05/2015 07:44:53
+version=1
+last_client=kicad
+[general]
+version=1
+RootSch=
+BoardNm=
+[pcbnew]
+version=1
+LastNetListRead=
+UseCmpFile=1
+PadDrill=0.600000000000
+PadDrillOvalY=0.600000000000
+PadSizeH=1.500000000000
+PadSizeV=1.500000000000
+PcbTextSizeV=1.500000000000
+PcbTextSizeH=1.500000000000
+PcbTextThickness=0.300000000000
+ModuleTextSizeV=1.000000000000
+ModuleTextSizeH=1.000000000000
+ModuleTextSizeThickness=0.150000000000
+SolderMaskClearance=0.000000000000
+SolderMaskMinWidth=0.000000000000
+DrawSegmentWidth=0.200000000000
+BoardOutlineThickness=0.100000000000
+ModuleOutlineThickness=0.150000000000
+[cvpcb]
+version=1
+NetIExt=net
+[eeschema]
+version=1
+LibDir=
+[eeschema/libraries]
+LibName1=eSim_Analog
+LibName2=eSim_Devices
+LibName3=eSim_Digital
+LibName4=eSim_Hybrid
+LibName5=eSim_Miscellaneous
+LibName6=eSim_Sources
+LibName7=eSim_Subckt
+LibName8=eSim_User
+LibName9=adc-dac
+LibName10=memory
+LibName11=xilinx
+LibName12=microcontrollers
+LibName13=dsp
+LibName14=microchip
+LibName15=analog_switches
+LibName16=motorola
+LibName17=texas
+LibName18=intel
+LibName19=audio
+LibName20=interface
+LibName21=digital-audio
+LibName22=philips
+LibName23=display
+LibName24=cypress
+LibName25=siliconi
+LibName26=opto
+LibName27=atmel
+LibName28=contrib
+LibName29=power
+LibName30=device
+LibName31=transistors
+LibName32=conn
+LibName33=linear
+LibName34=regul
+LibName35=74xx
+LibName36=cmos4000
diff --git a/src/frontEnd/Application.py.bkp b/src/frontEnd/Application.py.bkp
new file mode 100755
index 00000000..408cd967
--- /dev/null
+++ b/src/frontEnd/Application.py.bkp
@@ -0,0 +1,363 @@
+#===============================================================================
+#
+# FILE: Application.py
+#
+# USAGE: ---
+#
+# DESCRIPTION: This main file use to start the Application
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
+# CREATED: Wednesday 21 January 2015
+# REVISION: ---
+#===============================================================================
+import os
+import sys
+#Setting PYTHONPATH
+cwd = os.getcwd()
+(setPath,fronEnd) = os.path.split(cwd)
+sys.path.append(setPath)
+
+from PyQt4 import QtGui, QtCore
+from configuration.Appconfig import Appconfig
+from projManagement.openProject import OpenProjectInfo
+from projManagement.newProject import NewProjectInfo
+from projManagement.Kicad import Kicad
+from frontEnd import ProjectExplorer
+from frontEnd import Workspace
+from frontEnd import DockArea
+import time
+from PyQt4.Qt import QSize
+
+
+class Application(QtGui.QMainWindow):
+ global project_name
+ """
+ Its our main window of application
+ """
+ def __init__(self,*args):
+ """
+ Initialize main Application window
+ """
+ #Calling __init__ of super class
+ QtGui.QMainWindow.__init__(self,*args)
+
+ #Creating require Object
+ self.obj_workspace = Workspace.Workspace()
+ self.obj_kicad = Kicad()
+ self.obj_Mainview = MainView()
+ self.obj_appconfig = Appconfig()
+
+ #Initialize all widget
+ self.setCentralWidget(self.obj_Mainview)
+ self.initToolBar()
+
+ self.setGeometry(self.obj_appconfig._app_xpos,
+ self.obj_appconfig._app_ypos,
+ self.obj_appconfig._app_width,
+ self.obj_appconfig._app_heigth)
+ self.setWindowTitle(self.obj_appconfig._APPLICATION)
+ self.showMaximized()
+ self.setWindowIcon(QtGui.QIcon('../../images/logo.png'))
+ #self.show()
+
+
+ def initToolBar(self):
+ """
+ This function initialize Tool Bar
+ """
+ #Top Tool bar
+ self.newproj = QtGui.QAction(QtGui.QIcon('../../images/newProject.png'),'<b>New Project</b>',self)
+ self.newproj.setShortcut('Ctrl+N')
+ self.newproj.triggered.connect(self.new_project)
+ #self.newproj.connect(self.newproj,QtCore.SIGNAL('triggered()'),self,QtCore.SLOT(self.new_project()))
+
+ self.openproj = QtGui.QAction(QtGui.QIcon('../../images/openProject.png'),'<b>Open Project</b>',self)
+ self.openproj.setShortcut('Ctrl+O')
+ self.openproj.triggered.connect(self.open_project)
+
+ self.exitproj = QtGui.QAction(QtGui.QIcon('../../images/closeProject.png'),'<b>Exit</b>',self)
+ self.exitproj.setShortcut('Ctrl+X')
+ self.exitproj.triggered.connect(self.exit_project)
+
+ self.helpfile = QtGui.QAction(QtGui.QIcon('../../images/helpProject.png'),'<b>Help</b>',self)
+ self.helpfile.setShortcut('Ctrl+H')
+ self.helpfile.triggered.connect(self.help_project)
+
+ self.topToolbar = self.addToolBar('Top Tool Bar')
+ self.topToolbar.addAction(self.newproj)
+ self.topToolbar.addAction(self.openproj)
+ self.topToolbar.addAction(self.exitproj)
+ self.topToolbar.addAction(self.helpfile)
+
+ self.spacer = QtGui.QWidget()
+ self.spacer.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
+ self.topToolbar.addWidget(self.spacer)
+ self.logo = QtGui.QLabel()
+ self.logopic = QtGui.QPixmap(os.path.join(os.path.abspath('../..'),'images','fosseeLogo.png'))
+ self.logopic = self.logopic.scaled(QSize(150,150),QtCore.Qt.KeepAspectRatio)
+ self.logo.setPixmap(self.logopic)
+ self.logo.setStyleSheet("padding:0 15px 0 0;")
+ self.topToolbar.addWidget(self.logo)
+
+ #Left Tool bar Action Widget
+ self.kicad = QtGui.QAction(QtGui.QIcon('../../images/kicad.png'),'<b>Open Schematic</b>',self)
+ self.kicad.triggered.connect(self.obj_kicad.openSchematic)
+
+ self.conversion = QtGui.QAction(QtGui.QIcon('../../images/ki-ng.png'),'<b>Convert Kicad to Ngspice</b>',self)
+ self.conversion.triggered.connect(self.obj_kicad.openKicadToNgspice)
+
+ self.ngspice = QtGui.QAction(QtGui.QIcon('../../images/ngspice.png'), '<b>Simulation</b>', self)
+ self.ngspice.triggered.connect(self.open_ngspice)
+
+ self.footprint = QtGui.QAction(QtGui.QIcon('../../images/footprint.png'),'<b>Footprint Editor</b>',self)
+ self.footprint.triggered.connect(self.obj_kicad.openFootprint)
+
+ self.pcb = QtGui.QAction(QtGui.QIcon('../../images/pcb.png'),'<b>PCB Layout</b>',self)
+ self.pcb.triggered.connect(self.obj_kicad.openLayout)
+
+ self.model = QtGui.QAction(QtGui.QIcon('../../images/model.png'),'<b>Model Editor</b>',self)
+ self.model.triggered.connect(self.open_modelEditor)
+
+ self.subcircuit=QtGui.QAction(QtGui.QIcon('../../images/subckt.png'),'<b>Subcircuit</b>',self)
+ self.subcircuit.triggered.connect(self.open_subcircuit)
+
+ #Adding Action Widget to tool bar
+ self.lefttoolbar = QtGui.QToolBar('Left ToolBar')
+ self.addToolBar(QtCore.Qt.LeftToolBarArea, self.lefttoolbar)
+ self.lefttoolbar.addAction(self.kicad)
+ self.lefttoolbar.addAction(self.conversion)
+ self.lefttoolbar.addAction(self.ngspice)
+ self.lefttoolbar.addAction(self.footprint)
+ self.lefttoolbar.addAction(self.pcb)
+ self.lefttoolbar.addAction(self.model)
+ self.lefttoolbar.addAction(self.subcircuit)
+ self.lefttoolbar.setOrientation(QtCore.Qt.Vertical)
+ self.lefttoolbar.setIconSize(QSize(40,40))
+
+
+ def new_project(self):
+ """
+ This function call New Project Info class.
+ """
+ text, ok = QtGui.QInputDialog.getText(self, 'New Project Info','Enter Project Name:')
+ if ok:
+ self.projname = (str(text))
+ self.project = NewProjectInfo()
+ directory, filelist =self.project.createProject(self.projname)
+
+ self.obj_Mainview.obj_projectExplorer.addTreeNode(directory, filelist)
+
+ else:
+ print "No project created"
+ self.obj_appconfig.print_info('No new project created')
+ try:
+ self.obj_appconfig.print_info('Current project is : ' + self.obj_appconfig.current_project["ProjectName"])
+ except:
+ pass
+ def open_project(self):
+ """
+ This project call Open Project Info class
+ """
+ print "Open Project called"
+ self.project = OpenProjectInfo()
+
+ try:
+ directory, filelist = self.project.body()
+ self.obj_Mainview.obj_projectExplorer.addTreeNode(directory, filelist)
+ except:
+ pass
+
+ def open_ngspice(self):
+ """
+ This Function execute ngspice on current project
+ """
+
+ self.projDir = self.obj_appconfig.current_project["ProjectName"]
+
+ if self.projDir != None:
+ self.obj_Mainview.obj_dockarea.ngspiceEditor(self.projDir)
+ time.sleep(2) #Need permanent solution
+ #Calling Python Plotting
+
+ try:
+ self.obj_Mainview.obj_dockarea.plottingEditor()
+ except Exception as e:
+ self.msg = QtGui.QErrorMessage(None)
+ self.msg.showMessage('Error while opening python plotting Editor.')
+ print "Exception:",str(e)
+ self.obj_appconfig.print_error('Exception generated : ' + str(e))
+ self.msg.setWindowTitle("Error Message")
+
+ else:
+ self.msg = QtGui.QErrorMessage()
+ self.msg.showMessage('Please select the project first. You can either create new project or open existing project')
+ self.msg.setWindowTitle("Error Message")
+
+ def open_subcircuit(self):
+ print "Subcircuit editor is called"
+ self.obj_appconfig.print_info('Subcircuit editor is called')
+ self.obj_Mainview.obj_dockarea.subcircuiteditor()
+
+
+ def exit_project(self):
+ print "Exit Project called"
+ for proc in self.obj_appconfig.procThread_list:
+ try:
+ proc.terminate()
+ except:
+ pass
+ ##Just checking if open and New window is open. If yes just close it when application is closed
+ try:
+ self.project.close()
+ except:
+ pass
+
+ self.close()
+
+ def help_project(self):
+ print "Help is called"
+ self.obj_appconfig.print_info('Help is called')
+ print "Current Project : ",self.obj_appconfig.current_project
+ #self.obj_appconfig.print_info('Current Project : ' + self.obj_appconfig.current_project['ProjectName'])
+ #self.obj_Mainview.obj_dockarea.plottingEditor()
+
+
+ def open_modelEditor(self):
+ print "model editor is called"
+ self.obj_appconfig.print_info('model editor is called')
+ self.obj_Mainview.obj_dockarea.modelEditor()
+
+ def testing(self):
+ print "Success hit kicad button"
+
+
+class MainView(QtGui.QWidget):
+ """
+ This class initialize the Main View of Application
+ """
+ def __init__(self, *args):
+ # call init method of superclass
+ QtGui.QWidget.__init__(self, *args)
+
+ self.obj_appconfig = Appconfig()
+
+ self.leftSplit = QtGui.QSplitter()
+ self.middleSplit = QtGui.QSplitter()
+
+ self.mainLayout = QtGui.QVBoxLayout()
+ #Intermediate Widget
+ self.middleContainer = QtGui.QWidget()
+ self.middleContainerLayout = QtGui.QVBoxLayout()
+
+ #Area to be included in MainView
+ self.noteArea = QtGui.QTextEdit()
+ self.obj_appconfig.noteArea['Note'] = self.noteArea
+ self.obj_appconfig.noteArea['Note'].append(' eSim Started......')
+ self.obj_appconfig.noteArea['Note'].append('Project Selected : None')
+ self.obj_appconfig.noteArea['Note'].append('\n')
+
+ #CSS
+ self.noteArea.setStyleSheet(" \
+ QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px; } \
+ ")
+
+ self.obj_dockarea = DockArea.DockArea()
+ self.obj_projectExplorer = ProjectExplorer.ProjectExplorer()
+
+ #Adding content to vertical middle Split.
+ self.middleSplit.setOrientation(QtCore.Qt.Vertical)
+ self.middleSplit.addWidget(self.obj_dockarea)
+ self.middleSplit.addWidget(self.noteArea)
+
+ #Adding middle split to Middle Container Widget
+ self.middleContainerLayout.addWidget(self.middleSplit)
+ self.middleContainer.setLayout(self.middleContainerLayout)
+
+ #Adding content of left split
+ self.leftSplit.addWidget(self.obj_projectExplorer)
+ self.leftSplit.addWidget(self.middleContainer)
+
+
+ #Adding to main Layout
+ self.mainLayout.addWidget(self.leftSplit)
+ self.leftSplit.setSizes([self.width()/4.5,self.height()])
+ self.middleSplit.setSizes([self.width(),self.height()/2])
+ self.setLayout(self.mainLayout)
+
+
+def main(args):
+ """
+ It is main function of the module.It starts the application
+ """
+ print "Starting eSim......"
+ app = QtGui.QApplication(args)
+
+ splash_pix = QtGui.QPixmap('../../images/splash_screen_esim.png')
+ splash = QtGui.QSplashScreen(splash_pix,QtCore.Qt.WindowStaysOnTopHint)
+ splash.setMask(splash_pix.mask())
+ splash.show()
+ #QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
+ appView = Application()
+ appView.splash=splash
+ appView.obj_workspace.returnWhetherClickedOrNot(appView)
+ appView.hide()
+ appView.obj_workspace.show()
+ sys.exit(app.exec_())
+ #appView.hide()
+ ########################################################################################################################################
+
+ """splash_pix = QtGui.QPixmap('../images/splash_screen_esim.png')
+ splash = QtGui.QSplashScreen(splash_pix,QtCore.Qt.WindowStaysOnTopHint)
+ progressBar = QtGui.QProgressBar(splash)
+ progressBar.setGeometry(0,470,1004,20)
+ splash.setMask(splash_pix.mask())
+ splash.show()
+
+ for i in range(0, 100):
+ progressBar.setValue(i)
+ #cond=threading.Condition()
+ if i==50:
+
+ appView = Application()
+ appView.hide()
+ #appView.obj_workspace.returnWhetherClickedOrNot(appView)
+ appView.obj_workspace.show()
+ #appView.obj_workspace.show()
+ appView.obj_workspace.calledFromApplicationToAssignSysAndApp(sys,app)#`11 ,cond)
+ #with cond:
+ #cond.wait()
+
+ t = time.time()
+ while time.time() < t + 0.1:
+ app.processEvents()
+
+ #time.sleep(2)
+
+ #appView = Application()
+ #appView.hide()
+ splash.finish(appView)
+ #sys.exit(app.exec_())
+
+ #QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
+ #appView.obj_workspace.returnWhetherClickedOrNot(appView)
+ #appView.obj_workspace.show()
+ #appView.hide()
+
+ appView.show()
+ sys.exit(app.exec_())"""
+######################################################################################################################################################
+
+
+
+# Call main function
+if __name__ == '__main__':
+ # Create and display the splash screen
+ main(sys.argv)
+
+
+
diff --git a/src/kicadtoNgspice/KicadtoNgspice.py.bkp b/src/kicadtoNgspice/KicadtoNgspice.py.bkp
new file mode 100644
index 00000000..c262f564
--- /dev/null
+++ b/src/kicadtoNgspice/KicadtoNgspice.py.bkp
@@ -0,0 +1,671 @@
+#===============================================================================
+#
+# FILE: kicadtoNgspice.py
+#
+# USAGE: ---
+#
+# DESCRIPTION: This define all configuration used in Application.
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
+# CREATED: Wednesday 04 March 2015
+# REVISION: ---
+#===============================================================================
+import sys
+import os
+#Setting PYTHONPATH
+cwd = os.getcwd()
+(setPath,fronEnd) = os.path.split(cwd)
+sys.path.append(setPath)
+
+from PyQt4 import QtGui,QtCore
+from Processing import PrcocessNetlist
+import Analysis
+import Source
+import Model
+import DeviceModel
+import SubcircuitTab
+import Convert
+import TrackWidget
+
+from xml.etree import ElementTree as ET
+
+
+
+class MainWindow(QtGui.QWidget):
+ """
+ This class create KicadtoNgspice window.
+ And Call Convert function if convert button is pressed.
+ The convert function takes all the value entered by user and create a final netlist "*.cir.out".
+ This final netlist is compatible with NgSpice.
+ """
+ def __init__(self):
+ QtGui.QWidget.__init__(self)
+ #Create object of track widget
+ self.obj_track = TrackWidget.TrackWidget()
+ """
+ Checking if any unknown model is used in schematic which is not recognized by NgSpice.
+ Also if the two model of same name is present under modelParamXML directory
+ """
+ if unknownModelList:
+ print "Unknown Model List is : ",unknownModelList
+ self.msg = QtGui.QErrorMessage()
+ self.content = "Your schematic contain unknown model "+', '.join(unknownModelList)
+ self.msg.showMessage(self.content)
+ self.msg.setWindowTitle("Unknown Models")
+
+ elif multipleModelList:
+ print "Multiple Model List is : ",multipleModelList
+ self.msg = QtGui.QErrorMessage()
+ self.mcontent = "Look like you have duplicate model in modelParamXML directory "+', '.join(multipleModelList[0])
+ self.msg.showMessage(self.mcontent)
+ self.msg.setWindowTitle("Multiple Models")
+
+ else:
+ self.createMainWindow()
+
+
+ def createMainWindow(self):
+ """
+ This function create main window of Kicad to Ngspice converter
+ """
+
+ self.grid = QtGui.QGridLayout(self)
+ self.convertbtn = QtGui.QPushButton("Convert")
+ self.convertbtn.clicked.connect(self.callConvert)
+ self.cancelbtn = QtGui.QPushButton("Cancel")
+ self.cancelbtn.clicked.connect(self.close)
+ self.grid.addWidget(self.createcreateConvertWidget(),0,0)
+ self.grid.addWidget(self.convertbtn,1,1)
+ self.grid.addWidget(self.cancelbtn,1,2)
+ self.setWindowState(QtCore.Qt.WindowMaximized)
+ self.setLayout(self.grid)
+ self.setWindowTitle("Kicad To NgSpice Converter")
+ self.show()
+
+
+ def createcreateConvertWidget(self):
+ global obj_analysis
+ self.convertWindow = QtGui.QWidget()
+ self.analysisTab = QtGui.QScrollArea()
+ obj_analysis=Analysis.Analysis()
+ self.analysisTab.setWidget(obj_analysis)
+ #self.analysisTabLayout = QtGui.QVBoxLayout(self.analysisTab.widget())
+ self.analysisTab.setWidgetResizable(True)
+ global obj_source
+ self.sourceTab = QtGui.QScrollArea()
+ obj_source=Source.Source(sourcelist,sourcelisttrack)
+ self.sourceTab.setWidget(obj_source)
+ #self.sourceTabLayout = QtGui.QVBoxLayout(self.sourceTab.widget())
+ self.sourceTab.setWidgetResizable(True)
+ global obj_model
+ self.modelTab = QtGui.QScrollArea()
+ obj_model=Model.Model(schematicInfo,modelList)
+ self.modelTab.setWidget(obj_model)
+ #self.modelTabLayout = QtGui.QVBoxLayout(self.modelTab.widget())
+ self.modelTab.setWidgetResizable(True)
+ global obj_devicemodel
+ self.deviceModelTab = QtGui.QScrollArea()
+ obj_devicemodel=DeviceModel.DeviceModel(schematicInfo)
+ self.deviceModelTab.setWidget(obj_devicemodel)
+ self.deviceModelTab.setWidgetResizable(True)
+ global obj_subcircuitTab
+ self.subcircuitTab = QtGui.QScrollArea()
+ obj_subcircuitTab = SubcircuitTab.SubcircuitTab(schematicInfo)
+ self.subcircuitTab.setWidget(obj_subcircuitTab)
+ self.subcircuitTab.setWidgetResizable(True)
+
+ self.tabWidget = QtGui.QTabWidget()
+ #self.tabWidget.TabShape(QtGui.QTabWidget.Rounded)
+ self.tabWidget.addTab(self.analysisTab,"Analysis")
+ self.tabWidget.addTab(self.sourceTab,"Source Details")
+ self.tabWidget.addTab(self.modelTab,"NgSpice Model")
+ self.tabWidget.addTab(self.deviceModelTab,"Device Modeling")
+ self.tabWidget.addTab(self.subcircuitTab,"Subcircuits")
+ self.mainLayout = QtGui.QVBoxLayout()
+ self.mainLayout.addWidget(self.tabWidget)
+ #self.mainLayout.addStretch(1)
+ self.convertWindow.setLayout(self.mainLayout)
+ self.convertWindow.show()
+
+
+ return self.convertWindow
+
+ def callConvert(self):
+ """
+ Calling Convert Class Constructor
+ """
+ global schematicInfo
+ global analysisoutput
+ kicadFile = sys.argv[1]
+ (projpath,filename)=os.path.split(kicadFile)
+ project_name=os.path.basename(projpath)
+ print "PROJ PATH---",projpath
+
+
+ check=1
+ try:
+ fr=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'r')
+ temp_tree=ET.parse(fr)
+ temp_root=temp_tree.getroot()
+ except:
+ check=0
+
+
+
+ fw=open(os.path.join(projpath,project_name+"_Previous_Values.xml"),'w')
+ if check==0:
+ attr_parent=ET.Element("KicadtoNgspice")
+ if check==1:
+ attr_parent=temp_root
+
+ for child in attr_parent:
+ if child.tag=="analysis":
+ attr_parent.remove(child)
+
+ attr_analysis=ET.SubElement(attr_parent,"analysis")
+ attr_ac=ET.SubElement(attr_analysis,"ac")
+ if obj_analysis.Lin.isChecked():
+ ET.SubElement(attr_ac,"field1",name="Lin").text="true"
+ ET.SubElement(attr_ac,"field2",name="Dec").text="false"
+ ET.SubElement(attr_ac,"field3",name="Oct").text="false"
+ elif obj_analysis.Dec.isChecked():
+ ET.SubElement(attr_ac,"field1",name="Lin").text="false"
+ ET.SubElement(attr_ac,"field2",name="Dec").text="true"
+ ET.SubElement(attr_ac,"field3",name="Oct").text="false"
+ if obj_analysis.Oct.isChecked():
+ ET.SubElement(attr_ac,"field1",name="Lin").text="false"
+ ET.SubElement(attr_ac,"field2",name="Dec").text="false"
+ ET.SubElement(attr_ac,"field3",name="Oct").text="true"
+ else:
+ pass
+ ET.SubElement(attr_ac,"field4",name="Start Frequency").text= str(obj_analysis.ac_entry_var[0].text())
+ ET.SubElement(attr_ac,"field5",name="Stop Frequency").text= str(obj_analysis.ac_entry_var[1].text())
+ ET.SubElement(attr_ac,"field6",name="No. of points").text= str(obj_analysis.ac_entry_var[2].text())
+ ET.SubElement(attr_ac,"field7",name="Start Fre Combo").text= obj_analysis.ac_parameter[0]
+ ET.SubElement(attr_ac,"field8",name="Stop Fre Combo").text= obj_analysis.ac_parameter[1]
+ attr_dc=ET.SubElement(attr_analysis,"dc")
+ ET.SubElement(attr_dc,"field1",name="Source Name").text= str(obj_analysis.dc_entry_var[0].text())
+ ET.SubElement(attr_dc,"field2",name="Start").text= str(obj_analysis.dc_entry_var[1].text())
+ ET.SubElement(attr_dc,"field3",name="Increment").text= str(obj_analysis.dc_entry_var[2].text())
+ ET.SubElement(attr_dc,"field4",name="Stop").text= str(obj_analysis.dc_entry_var[3].text())
+ ET.SubElement(attr_dc,"field5",name="Operating Point").text=str(obj_analysis.check.isChecked())
+ print "OBJ_ANALYSIS.CHECK -----",obj_analysis.check.isChecked()
+ ET.SubElement(attr_dc,"field6",name="Start Combo").text= obj_analysis.dc_parameter[0]
+ ET.SubElement(attr_dc,"field7",name="Increment Combo").text=obj_analysis.dc_parameter[1]
+ ET.SubElement(attr_dc,"field8",name="Stop Combo").text= obj_analysis.dc_parameter[2]
+ attr_tran=ET.SubElement(attr_analysis,"tran")
+ ET.SubElement(attr_tran,"field1",name="Start Time").text= str(obj_analysis.tran_entry_var[0].text())
+ ET.SubElement(attr_tran,"field2",name="Step Time").text= str(obj_analysis.tran_entry_var[1].text())
+ ET.SubElement(attr_tran,"field3",name="Stop Time").text= str(obj_analysis.tran_entry_var[2].text())
+ ET.SubElement(attr_tran,"field4",name="Start Combo").text= obj_analysis.tran_parameter[0]
+ ET.SubElement(attr_tran,"field5",name="Step Combo").text= obj_analysis.tran_parameter[1]
+ ET.SubElement(attr_tran,"field6",name="Stop Combo").text= obj_analysis.tran_parameter[2]
+ print "TRAN PARAMETER 2-----",obj_analysis.tran_parameter[2]
+
+ #tree=ET.ElementTree(attr_analysis)
+ #tree.write(f)
+
+
+ if check==0:
+ attr_source=ET.SubElement(attr_parent,"source")
+ if check==1:
+ for child in attr_parent:
+ if child.tag=="source":
+ attr_source=child
+ count=1
+ grand_child_count=1
+ #global tmp_check
+ #tmp_check=0
+ for i in schematicInfo:
+ tmp_check=0
+ words=i.split(' ')
+ wordv=words[0]
+ for child in attr_source:
+ if child.tag==wordv and child.text==words[len(words)-1]:
+ tmp_check=1
+ for grand_child in child:
+ grand_child.text=str(obj_source.entry_var[grand_child_count].text())
+ grand_child_count=grand_child_count+1
+ grand_child_count=grand_child_count+1
+ if tmp_check==0:
+ words=i.split(' ')
+ wordv=words[0]
+ if wordv[0]=="v":
+ attr_var=ET.SubElement(attr_source,words[0],name="Source type")
+ attr_var.text=words[len(words)-1]
+ #ET.SubElement(attr_ac,"field1",name="Lin").text="true"
+ if words[len(words)-1]=="ac":
+ #attr_ac=ET.SubElement(attr_var,"ac")
+ ET.SubElement(attr_var,"field1",name="Amplitude").text=str(obj_source.entry_var[count].text())
+ count=count+2
+ elif words[len(words)-1]=="dc":
+ #attr_dc=ET.SubElement(attr_var,"dc")
+ ET.SubElement(attr_var,"field1",name="Value").text=str(obj_source.entry_var[count].text())
+ count=count+2
+ elif words[len(words)-1]=="sine":
+ #attr_sine=ET.SubElement(attr_var,"sine")
+ ET.SubElement(attr_var,"field1",name="Offset Value").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field2",name="Amplitude").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field3",name="Frequency").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field4",name="Delay Time").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field5",name="Damping Factor").text=str(obj_source.entry_var[count].text())
+ count=count+2
+ elif words[len(words)-1]=="pulse":
+ #attr_pulse=ET.SubElement(attr_var,"pulse")
+ ET.SubElement(attr_var,"field1",name="Initial Value").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field2",name="Pulse Value").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field3",name="Delay Time").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field4",name="Rise Time").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field5",name="Fall Time").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field5",name="Pulse width").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field5",name="Period").text=str(obj_source.entry_var[count].text())
+ count=count+2
+ elif words[len(words)-1]=="pwl":
+ #attr_pwl=ET.SubElement(attr_var,"pwl")
+ ET.SubElement(attr_var,"field1",name="Enter in pwl format").text=str(obj_source.entry_var[count].text())
+ count=count+2
+ elif words[len(words)-1]=="exp":
+ #attr_exp=ET.SubElement(attr_var,"exp")
+ ET.SubElement(attr_var,"field1",name="Initial Value").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field2",name="Pulsed Value").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field3",name="Rise Delay Time").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field4",name="Rise Time Constant").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field5",name="Fall TIme").text=str(obj_source.entry_var[count].text())
+ count=count+1
+ ET.SubElement(attr_var,"field6",name="Fall Time Constant").text=str(obj_source.entry_var[count].text())
+ count=count+2
+ else:
+ pass
+
+ #tree=ET.ElementTree(attr_source)
+ #tree.write(f1)
+
+
+
+ if check==0:
+ attr_model=ET.SubElement(attr_parent,"model")
+ if check==1:
+ for child in attr_parent:
+ if child.tag=="model":
+ attr_model=child
+ i=0
+ #tmp_check is a variable to check for duplicates in the xml file
+ tmp_check=0
+ #tmp_i is the iterator in case duplicates are there; then in that case we need to replace only the child node and not create a new parent node
+
+ for line in modelList:
+ print "i for each line in model List------",i
+ tmp_check=0
+ for rand_itr in obj_model.obj_trac.modelTrack:
+ if rand_itr[2]==line[2] and rand_itr[3]==line[3]:
+ start=rand_itr[7]
+ end=rand_itr[8]
+ i=start
+ for child in attr_model:
+ if child.text==line[2] and child.tag==line[3]:
+ for grand_child in child:
+ if i<=end:
+ grand_child.text=str(obj_model.obj_trac.model_entry_var[i].text())
+ print "STR OF MODEL----",str(obj_model.obj_trac.model_entry_var[i].text())
+ i=i+1
+ print "i incremented to ",i
+ else:
+ pass
+ tmp_check=1
+
+ if tmp_check==0:
+ attr_ui=ET.SubElement(attr_model,line[3],name="type")
+ attr_ui.text=line[2]
+ for key,value in line[7].iteritems():
+ if hasattr(value, '__iter__') and i<=end:
+ for item in value:
+ ET.SubElement(attr_ui,"field"+str(i+1),name=item).text=str(obj_model.obj_trac.model_entry_var[i].text())
+ print "STR OF MODEL----",str(obj_model.obj_trac.model_entry_var[i].text())
+ i=i+1
+ print "i incremented to ",i
+ else:
+ ET.SubElement(attr_ui,"field"+str(i+1),name=value).text=str(obj_model.obj_trac.model_entry_var[i].text())
+ print "STR OF MODEL----",str(obj_model.obj_trac.model_entry_var[i].text())
+ i=i+1
+ print "i incremented to ",i
+ #################################################################################################################
+ if check==0:
+ attr_devicemodel=ET.SubElement(attr_parent,"devicemodel")
+ if check==1:
+ for child in attr_parent:
+ if child.tag=="devicemodel":
+ del child[:]
+ attr_devicemodel=child
+ #print "Device model dict",obj_devicemodel.devicemodel_dict_beg
+ #print "Device model dict end",obj_devicemodel.devicemodel_dict_end
+ ##########################
+ for i in obj_devicemodel.devicemodel_dict_beg:
+ attr_var=ET.SubElement(attr_devicemodel,i)
+ it=obj_devicemodel.devicemodel_dict_beg[i]
+ end=obj_devicemodel.devicemodel_dict_end[i]
+ while it<=end:
+ ET.SubElement(attr_var,"field").text=str(obj_devicemodel.entry_var[it].text())
+ it=it+1
+ #####################################
+
+ """keys=obj_devicemodel.devicemodel_dict.keys()
+ n=len(keys)
+ for i in range(n):
+ thisKey=keys[i]
+ nextKey=keys[(i+1)%n]
+ nextValue=obj_devicemodel.devicemodel_dict[nextKey]
+ attr_var=ET.SubElement(attr_devicemodel,thisKey)
+ it=obj_devicemodel.devicemodel_dict[thisKey]
+ while it<=nextValue:
+ ET.SubElement(attr_var,"field").text=obj_devicemodel.entry_var[it]"""
+
+ ###################################################################################################################
+
+ if check==0:
+ attr_subcircuit=ET.SubElement(attr_parent,"subcircuit")
+ if check==1:
+ for child in attr_parent:
+ if child.tag=="subcircuit":
+ del child[:]
+ attr_subcircuit=child
+ ##########################
+ for i in obj_subcircuitTab.subcircuit_dict_beg:
+ attr_var=ET.SubElement(attr_subcircuit,i)
+ it=obj_subcircuitTab.subcircuit_dict_beg[i]
+ end=obj_subcircuitTab.subcircuit_dict_end[i]
+
+ while it<=end:
+ ET.SubElement(attr_var,"field").text=str(obj_subcircuitTab.entry_var[it].text())
+ it=it+1
+
+
+ tree=ET.ElementTree(attr_parent)
+ tree.write(fw)
+
+
+ self.obj_convert = Convert.Convert(self.obj_track.sourcelisttrack["ITEMS"],
+ self.obj_track.source_entry_var["ITEMS"],
+ schematicInfo)
+
+ try:
+ #Adding Source Value to Schematic Info
+ schematicInfo = self.obj_convert.addSourceParameter()
+
+ #Adding Model Value to schematicInfo
+ schematicInfo = self.obj_convert.addModelParameter(schematicInfo)
+
+ #Adding Device Library to SchematicInfo
+ schematicInfo = self.obj_convert.addDeviceLibrary(schematicInfo,kicadFile)
+
+ #Adding Subcircuit Library to SchematicInfo
+ schematicInfo = self.obj_convert.addSubcircuit(schematicInfo, kicadFile)
+
+ analysisoutput = self.obj_convert.analysisInsertor(self.obj_track.AC_entry_var["ITEMS"],
+ self.obj_track.DC_entry_var["ITEMS"],
+ self.obj_track.TRAN_entry_var["ITEMS"],
+ self.obj_track.set_CheckBox["ITEMS"],
+ self.obj_track.AC_Parameter["ITEMS"],
+ self.obj_track.DC_Parameter["ITEMS"],
+ self.obj_track.TRAN_Parameter["ITEMS"],
+ self.obj_track.AC_type["ITEMS"],
+ self.obj_track.op_check)
+ #print "SchematicInfo after adding Model Details",schematicInfo
+
+ #Calling netlist file generation function
+ self.createNetlistFile(schematicInfo)
+
+ self.msg = "The Kicad to Ngspice Conversion completed successfully!!!!!!"
+ QtGui.QMessageBox.information(self, "Information", self.msg, QtGui.QMessageBox.Ok)
+ self.close()
+ except Exception as e:
+ print "Exception Message: ",e
+ print "There was error while converting kicad to ngspice"
+ self.close()
+
+ # Generate .sub file from .cir.out file if it is a subcircuit
+ subPath = os.path.splitext(kicadFile)[0]
+
+ if len(sys.argv)>2:
+ if sys.argv[2] == "sub":
+ self.createSubFile(subPath)
+
+ def createNetlistFile(self,schematicInfo):
+ print "Creating Final netlist"
+ #print "INFOLINE",infoline
+ #print "OPTIONINFO",optionInfo
+ #print "Device MODEL LIST ",devicemodelList
+ #print "SUBCKT ",subcktList
+ #print "OUTPUTOPTION",outputOption
+ #print "KicadfIle",kicadFile
+
+ #checking if analysis files is present
+ (projpath,filename) = os.path.split(kicadFile)
+ analysisFileLoc = os.path.join(projpath,"analysis")
+ #print "Analysis File Location",analysisFileLoc
+ if os.path.exists(analysisFileLoc):
+ try:
+ f = open(analysisFileLoc)
+ #Read data
+ data = f.read()
+ # Close the file
+ f.close()
+
+ except :
+ print "Error While opening Project Analysis file. Please check it"
+ sys.exit()
+ else:
+ print analysisFileLoc + " does not exist"
+ sys.exit()
+
+ #Adding analysis file info to optionInfo
+ analysisData=data.splitlines()
+ for eachline in analysisData:
+ eachline=eachline.strip()
+ if len(eachline)>1:
+ if eachline[0]=='.':
+ optionInfo.append(eachline)
+ else:
+ pass
+
+ #print "Option Info",optionInfo
+ analysisOption = []
+ initialCondOption=[]
+ simulatorOption =[]
+ #includeOption=[] #Don't know why to use it
+ #model = [] #Don't know why to use it
+
+ for eachline in optionInfo:
+ words=eachline.split()
+ option=words[0]
+ if (option=='.ac' or option=='.dc' or option=='.disto' or option=='.noise' or
+ option=='.op' or option=='.pz' or option=='.sens' or option=='.tf' or
+ option=='.tran'):
+ analysisOption.append(eachline+'\n')
+
+ elif (option=='.save' or option=='.print' or option=='.plot' or option=='.four'):
+ eachline=eachline.strip('.')
+ outputOption.append(eachline+'\n')
+ elif (option=='.nodeset' or option=='.ic'):
+ initialCondOption.append(eachline+'\n')
+ elif option=='.option':
+ simulatorOption.append(eachline+'\n')
+ #elif (option=='.include' or option=='.lib'):
+ # includeOption.append(eachline+'\n')
+ #elif (option=='.model'):
+ # model.append(eachline+'\n')
+ elif option=='.end':
+ continue;
+
+
+ #Start creating final netlist cir.out file
+ outfile = kicadFile+".out"
+ out=open(outfile,"w")
+ out.writelines(infoline)
+ out.writelines('\n')
+ sections=[simulatorOption, initialCondOption, schematicInfo, analysisOption]
+ print "SECTIONS",sections
+ for section in sections:
+ if len(section) == 0:
+ continue
+ else:
+ for line in section:
+ out.writelines('\n')
+ out.writelines(line)
+
+ out.writelines('\n* Control Statements \n')
+ out.writelines('.control\n')
+ out.writelines('run\n')
+ #out.writelines(outputOption)
+ out.writelines('print allv > plot_data_v.txt\n')
+ out.writelines('print alli > plot_data_i.txt\n')
+ out.writelines('.endc\n')
+ out.writelines('.end\n')
+
+ out.close()
+
+ def createSubFile(self,subPath):
+ self.project = subPath
+ self.projName = os.path.basename(self.project)
+ if os.path.exists(self.project+".cir.out"):
+ try:
+ f = open(self.project+".cir.out")
+ except :
+ print("Error in opening .cir.out file.")
+ else:
+ print self.projName + ".cir.out does not exist. Please create a spice netlist."
+
+ # Read the data from file
+ data=f.read()
+ # Close the file
+
+ f.close()
+ newNetlist=[]
+ netlist=iter(data.splitlines())
+ for eachline in netlist:
+ eachline=eachline.strip()
+ if len(eachline)<1:
+ continue
+ words=eachline.split()
+ if eachline[2] == 'u':
+ if words[len(words)-1] == "port":
+ subcktInfo = ".subckt "+self.projName+" "
+ for i in range(2,len(words)-1):
+ subcktInfo+=words[i]+" "
+ continue
+ if words[0] == ".end" or words[0] == ".ac" or words[0] == ".dc" or words[0] == ".tran" or words[0] == '.disto' or words[0] == '.noise' or words[0] == '.op' or words[0] == '.pz' or words[0] == '.sens' or words[0] == '.tf':
+ continue
+ elif words[0] == ".control":
+ while words[0] != ".endc":
+ eachline=netlist.next()
+ eachline=eachline.strip()
+ if len(eachline)<1:
+ continue
+ words=eachline.split()
+ else:
+ newNetlist.append(eachline)
+
+ outfile=self.project+".sub"
+ out=open(outfile,"w")
+ out.writelines("* Subcircuit " + self.projName)
+ out.writelines('\n')
+ out.writelines(subcktInfo)
+ out.writelines('\n')
+
+ for i in range(len(newNetlist),0,-1):
+ newNetlist.insert(i,'\n')
+
+ out.writelines(newNetlist)
+ out.writelines('\n')
+
+ out.writelines('.ends ' + self.projName)
+ print "The subcircuit has been written in "+self.projName+".sub"
+
+
+
+#Main Function
+
+def main(args):
+ print "=================================="
+ print "Kicad to Ngspice netlist converter "
+ print "=================================="
+ global kicadFile,kicadNetlist,schematicInfo
+ global infoline,optionInfo
+ kicadFile = sys.argv[1]
+
+ #Object of Processing
+ obj_proc = PrcocessNetlist()
+
+ # Read the netlist
+ kicadNetlist = obj_proc.readNetlist(kicadFile)
+
+ # Construct parameter information
+ param = obj_proc.readParamInfo(kicadNetlist)
+
+ # Replace parameter with values
+ netlist,infoline = obj_proc.preprocessNetlist(kicadNetlist,param)
+
+ print "NETLIST ",netlist
+ print "INFOLINE",infoline
+
+ # Separate option and schematic information
+ optionInfo, schematicInfo = obj_proc.separateNetlistInfo(netlist)
+
+ print "OPTIONINFO",optionInfo
+ print "SCHEMATICINFO",schematicInfo
+
+
+ #List for storing source and its value
+ global sourcelist, sourcelisttrack
+ sourcelist=[]
+ sourcelisttrack=[]
+ schematicInfo,sourcelist = obj_proc.insertSpecialSourceParam(schematicInfo,sourcelist)
+
+ print "SOURCELIST",sourcelist
+ print "SCHEMATICINFO",schematicInfo
+
+ #List storing model detail
+ global modelList,outputOption,unknownModelList,multipleModelList
+
+ modelList = []
+ outputOption = []
+ schematicInfo,outputOption,modelList,unknownModelList,multipleModelList = obj_proc.convertICintoBasicBlocks(schematicInfo,outputOption,modelList)
+ print "Unknown Model List",unknownModelList
+ print "Multiple Model List",multipleModelList
+ print "Model List",modelList
+
+
+ app = QtGui.QApplication(args)
+ kingWindow = MainWindow()
+ #kingWindow.show() #No need to call show as we are doing it in createMainWindow
+ sys.exit(app.exec_())
+
+
+
+if __name__ == '__main__':
+ main(sys.argv)
+
+
+
+
+
+
+ \ No newline at end of file