summaryrefslogtreecommitdiff
path: root/src/pspicetoKicad/ImportPspice.py
blob: 3134601d2f40ad33d265813935e76015313cff79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from PyQt4 import QtGui,QtCore
from configuration.Appconfig import Appconfig
import os
import platform

class ImportPspiceLibrary(QtGui.QWidget):
    """
    This is used to import the Pspice Library and convert it inot Kicad library
    """
    def __init__(self):
        super(ImportPspiceLibrary, self).__init__()
        self.obj_Appconfig = Appconfig()
        
    def imortLib(self):
        self.home = os.path.expanduser("~")
        self.libLocation = QtGui.QFileDialog.getOpenFileName(self,"open",self.home)
        self.obj_Appconfig.print_info('File selected : '+self.libLocation)
        
        #Create command to run
        self.cmd = "../pspicetoKicad/libConverter "+self.libLocation
        os.system(str(self.cmd))
        
    
    
class ConvertPspiceKicad(QtGui.QWidget):
    """
    This is used to convert Pspice schematic into Kicad schematic
    """
    def __init__(self):
        super(ConvertPspiceKicad, self).__init__()
        self.obj_Appconfig = Appconfig()
    
    def runConverter(self):
        self.obj_Appconfig.print_info('Running PSPICE to Kicad converter')
        self.home = os.path.expanduser("~")
        self.pspiceSchFileLoc = QtGui.QFileDialog.getOpenFileName(self,"open",self.home)
        self.pspiceSchFileName = os.path.basename(str(self.pspiceSchFileLoc))
        self.worspace_loc = self.obj_Appconfig.default_workspace['workspace']
        self.outputDir = os.path.join(self.worspace_loc,self.pspiceSchFileName)
        
        #Create command to be run
        if platform.system() == 'Linux':
            #Check for 32 or 64 bit
            if platform.architecture()[0] == '64bit':
                self.cmd = "../pspicetoKicad/schConverter64 "+self.pspiceSchFileLoc+" "+self.outputDir
            else:
                self.cmd = "../pspicetoKicad/schConverter32 "+self.pspiceSchFileLoc+" "+self.outputDir
                          
        elif platform.system() == 'Windows':
            print "Needs to include for Windows"
               
        #Running command
        self.status =  os.system(str(self.cmd))
        
               
        if self.status == 0:
            self.msg = QtGui.QMessageBox()
            self.msgContent = "Successfully converted PSPICE schematic to Kicad Schematic.<br/>\
            Project is available in eSim workspace at <b>"+self.outputDir+"</b>.<br\>\
            You can open the project from eSim workspace"
            self.msg.setTextFormat(QtCore.Qt.RichText)
            self.msg.setText(self.msgContent)
            self.msg.setWindowTitle("Message")
            self.obj_Appconfig.print_info(self.msgContent)
            self.msg.exec_()
            
        else:
            self.msg = QtGui.QErrorMessage(None)
            self.msg.showMessage('Error while converting PSPICE schematic to Kicad Schematic')
            self.obj_Appconfig.print_error('Error while converting PSPICE schematic to Kicad Schematic')
            self.msg.setWindowTitle("Error Message")