diff options
author | fahim | 2015-03-11 16:53:05 +0530 |
---|---|---|
committer | fahim | 2015-03-11 16:53:05 +0530 |
commit | c0e70c79a6d651cf8b3b397f866ae38485fa5ca0 (patch) | |
tree | deff1c35ec424fe336d975c519c55e7b59deaa0d /src | |
parent | 05de80920118454a0e08b6a41e6ee5eb81d09a8e (diff) | |
download | eSim-c0e70c79a6d651cf8b3b397f866ae38485fa5ca0.tar.gz eSim-c0e70c79a6d651cf8b3b397f866ae38485fa5ca0.tar.bz2 eSim-c0e70c79a6d651cf8b3b397f866ae38485fa5ca0.zip |
Subject: Added new module kicadtongspice
Description: Develope skeleton body for kicadtongspice module
Diffstat (limited to 'src')
20 files changed, 533 insertions, 2 deletions
diff --git a/src/configuration/Appconfig.py b/src/configuration/Appconfig.py index 542c0b3f..c0ea1037 100644 --- a/src/configuration/Appconfig.py +++ b/src/configuration/Appconfig.py @@ -27,7 +27,7 @@ class Appconfig(QtGui.QWidget): All configuration goes here """ #Home directory - home = os.path.join(os.path.expanduser("~"),"ecSim-Workspace") + home = os.path.join(os.path.expanduser("~"),"eSim-Workspace") default_workspace = {"workspace":home} #Current Project detail current_project = {"ProjectName":None} diff --git a/src/configuration/Appconfig.pyc b/src/configuration/Appconfig.pyc Binary files differindex 4c19546d..f8804014 100644 --- a/src/configuration/Appconfig.pyc +++ b/src/configuration/Appconfig.pyc diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 2113ff9e..00c6312f 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -141,6 +141,7 @@ def main(args): sys.exit(app.exec_()) """ appView = Application() + #QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks")) appView.show() sys.exit(app.exec_()) diff --git a/src/frontEnd/ViewManagement.py b/src/frontEnd/ViewManagement.py index c1c5a4d5..8264c033 100755 --- a/src/frontEnd/ViewManagement.py +++ b/src/frontEnd/ViewManagement.py @@ -22,6 +22,7 @@ from PyQt4 import QtCore from PyQt4 import QtGui from projManagement.Kicad import Kicad +from kicadtoNgspice.KicadtoNgspice import * class ViewManagement(QtGui.QSplitter): @@ -68,6 +69,7 @@ class ViewManagement(QtGui.QSplitter): self.conversion_btn.setIcon(QtGui.QIcon('../images/default.png')) self.conversion_btn.setIconSize(QtCore.QSize(50,50)) self.conversion_btn.setToolTip('<b>Convert Kicad to Ngspice</b>') + self.conversion_btn.clicked.connect(self.obj_kicad.openKicadToNgspice) self.grid.addWidget(self.conversion_btn,0,1) diff --git a/src/frontEnd/ViewManagement.pyc b/src/frontEnd/ViewManagement.pyc Binary files differindex 45ea0277..9c1cdf20 100644 --- a/src/frontEnd/ViewManagement.pyc +++ b/src/frontEnd/ViewManagement.pyc diff --git a/src/frontEnd/Workspace.pyc b/src/frontEnd/Workspace.pyc Binary files differindex a352cd29..6e876bf3 100644 --- a/src/frontEnd/Workspace.pyc +++ b/src/frontEnd/Workspace.pyc diff --git a/src/kicadtoNgspice/Analysis.py b/src/kicadtoNgspice/Analysis.py new file mode 100644 index 00000000..2faedf1d --- /dev/null +++ b/src/kicadtoNgspice/Analysis.py @@ -0,0 +1,76 @@ + +from PyQt4 import QtGui,QtCore +#import GroupBox + +class Analysis(QtGui.QWidget): + def __init__(self): + QtGui.QWidget.__init__(self) + + self.grid = QtGui.QGridLayout(self) + self.grid.addWidget(self.createACgroup(),0,0) + self.grid.addWidget(self.createDCgroup(),1,0) + self.grid.addWidget(self.createTRANgroup(),2,0) + + self.setLayout(self.grid) + self.show() + + + + def createACgroup(self): + self.acbox = QtGui.QGroupBox() + self.acbox.setTitle("AC") + + self.acgrid = QtGui.QGridLayout() + + self.btn1 = QtGui.QRadioButton("Radio button 1") + self.btn2 = QtGui.QRadioButton("Radio button 2") + self.acgrid.addWidget(self.btn1,0,0) + self.acgrid.addWidget(self.btn2,0,1) + + self.acbox.setStyleSheet(" \ + QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + ") + + + self.acbox.setLayout(self.acgrid) + + return self.acbox + + def createDCgroup(self): + self.dcbox = QtGui.QGroupBox() + self.dcbox.setTitle("DC") + self.dcgrid = QtGui.QGridLayout() + + self.btn3 = QtGui.QRadioButton("Radio button 3") + self.btn4 = QtGui.QRadioButton("Radio button 4") + self.dcgrid.addWidget(self.btn3,0,0) + self.dcgrid.addWidget(self.btn4,0,1) + + self.dcbox.setStyleSheet(" \ + QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + ") + + self.dcbox.setLayout(self.dcgrid) + + return self.dcbox + + def createTRANgroup(self): + self.trbox = QtGui.QGroupBox() + self.trbox.setTitle("DC") + self.trgrid = QtGui.QGridLayout() + + self.btn5 = QtGui.QRadioButton("Radio button 5") + self.btn6 = QtGui.QRadioButton("Radio button 6") + self.trgrid.addWidget(self.btn5,0,0) + self.trgrid.addWidget(self.btn6,0,1) + + self.trbox.setStyleSheet(" \ + QGroupBox { border: 1px solid gray; border-radius: 9px; margin-top: 0.5em; } \ + QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; } \ + ") + + self.trbox.setLayout(self.trgrid) + + return self.trbox
\ No newline at end of file diff --git a/src/kicadtoNgspice/Analysis.pyc b/src/kicadtoNgspice/Analysis.pyc Binary files differnew file mode 100644 index 00000000..457c7058 --- /dev/null +++ b/src/kicadtoNgspice/Analysis.pyc diff --git a/src/kicadtoNgspice/GroupBox.pyc b/src/kicadtoNgspice/GroupBox.pyc Binary files differnew file mode 100644 index 00000000..06e46189 --- /dev/null +++ b/src/kicadtoNgspice/GroupBox.pyc diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py new file mode 100644 index 00000000..b3ee8886 --- /dev/null +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -0,0 +1,93 @@ +#=============================================================================== +# +# 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 +from PyQt4 import QtGui +import TabbedWidget +import Analysis + +class MainWindow(QtGui.QMainWindow): + def __init__(self): + QtGui.QMainWindow.__init__(self) + print "Init Kicad to Ngspice" + + ''' + self.analysisTab = QtGui.QWidget() + self.sourceTab = QtGui.QWidget() + self.modelTab = QtGui.QWidget() + ''' + self.analysisTab = Analysis.Analysis() + self.sourceTab = QtGui.QWidget() + self.modelTab = QtGui.QWidget() + + + self.td = TabbedWidget.TabbedWidget() + self.td.addTab(self.analysisTab, 'Analysis Inserter') + self.td.addTab(self.sourceTab, 'Source Detail') + self.td.addTab(self.modelTab, 'Model Detail') + self.td.show() + + ''' + self.tabs = QtGui.QTabWidget() + self.testpushBTN = QtGui.QPushButton("QPushButton 1") + + + self.vbox = QtGui.QVBoxLayout() + self.vbox.addWidget(self.testpushBTN) + + + #Resize width and height + self.tabs.resize(600, 600) + + #Move QTabWidget to x:300,y:300 + self.tabs.move(300, 300) + + #Set Layout for Third Tab Page + self.modelTab.setLayout(self.vbox) + + self.tabs.addTab(self.analysisTab,"Analysis Inserter") + self.tabs.addTab(self.sourceTab,"Source Detail") + self.tabs.addTab(self.modelTab,"Model Details") + + self.tabs.setWindowTitle('Kicad to Ngspice Conversion') + self.tabs.show() + ''' + + + + + +def main(): + print "==================================" + print "Kicad to Ngspice netlist converter " + print "==================================" + + #kicadNetlist = sys.argv[1] + + + +if __name__ == '__main__': + app = QtGui.QApplication(sys.argv) + app.setApplicationName("KicadToNgspice") + app.setQuitOnLastWindowClosed(True) + window = MainWindow() + main() + sys.exit(app.exec_()) + + + +
\ No newline at end of file diff --git a/src/kicadtoNgspice/KicadtoNgspice.pyc b/src/kicadtoNgspice/KicadtoNgspice.pyc Binary files differnew file mode 100644 index 00000000..929a42de --- /dev/null +++ b/src/kicadtoNgspice/KicadtoNgspice.pyc diff --git a/src/kicadtoNgspice/Sample.py b/src/kicadtoNgspice/Sample.py new file mode 100644 index 00000000..5f562724 --- /dev/null +++ b/src/kicadtoNgspice/Sample.py @@ -0,0 +1,320 @@ +from PyQt4 import QtGui,QtCore + +import sys +import re +import datetime +################################################################ +def main(): + app = QtGui.QApplication(sys.argv) + mw = MainWindow() + sys.exit(app.exec_()) + +################################################################ +class MainWindow(QtGui.QMainWindow): + def __init__(self): + QtGui.QMainWindow.__init__(self) + + # create stuff + self.rw = ReportWidget() + self.setCentralWidget(self.rw) + self.sw = StartWindow() + self.createActions() + self.createMenus() + self.createStatusBar() + + # create progress bar + self.pb = QtGui.QProgressBar(self.statusBar()) + self.statusBar().addPermanentWidget(self.pb) + + # connections + self.connect(self.sw, QtCore.Qt.SIGNAL("okClicked"), + self.rw.create) + self.connect(self.rw.table, QtCore.Qt.SIGNAL("progressChanged"), + self.update_progress) + self.connect(self.rw.table, QtCore.Qt.SIGNAL("displayFinished"), + self.hide_progress_bar) + + # format the main window + self.setGeometry(100,100,750,550) + + # show windows + self.show() + self.sw.show() + + def update_progress(self, n, nrows): + self.pb.show() + self.pb.setRange(0, nrows) + self.pb.setValue(n) + self.statusBar().showMessage(self.tr("Parsing eventlog data...")) + + def hide_progress_bar(self): + self.pb.hide() + self.statusBar().showMessage(self.tr("Finished")) + + def about(self): + QtGui.QMessageBox.about(self, self.tr("About AIS Audit Tool"), + self.tr("AIS Audit Tool\n\n" + "%s\n" + "%s\n" + "%s" % (__author__, __version__, __date__))) + + def createActions(self): + self.exitAct = QtGui.QAction(self.tr("E&xit;"), self) + self.exitAct.setShortcut(self.tr("Ctrl+Q")) + self.exitAct.setStatusTip(self.tr("Exit the application")) + self.connect(self.exitAct, QtCore.Qt.SIGNAL("triggered()"), self, QtCore.Qt.SLOT("close()")) + + self.aboutAct = QtGui.QAction(self.tr("&About;"), self) + self.aboutAct.setStatusTip(self.tr("Show the application's About box")) + self.connect(self.aboutAct, QtCore.Qt.SIGNAL("triggered()"), self.about) + + self.aboutQtAct = QtGui.QAction(self.tr("About &Qt;"), self) + self.aboutQtAct.setStatusTip(self.tr("Show the Qt library's About box")) + self.connect(self.aboutQtAct, QtCore.Qt.SIGNAL("triggered()"), qApp, QtCore.Qt.SLOT("aboutQt()")) + + def createMenus(self): + self.fileMenu = self.menuBar().addMenu(self.tr("&File;")) + self.fileMenu.addAction(self.exitAct) + + self.helpMenu = self.menuBar().addMenu(self.tr("&Help;")) + self.helpMenu.addAction(self.aboutAct) + self.helpMenu.addAction(self.aboutQtAct) + + def createStatusBar(self): + sb = QtGui.QStatusBar() + sb.setFixedHeight(18) + self.setStatusBar(sb) + self.statusBar().showMessage(self.tr("Ready")) + +################################################################ +class StartWindow(QtGui.QWidget): + def __init__(self, *args): + QtGui.QWidget.__init__(self, *args) + + # date box + self.label_date = QtGui.QLabel() + self.label_date.setText("Set date of last audit:") + default = datetime.date.today() - datetime.timedelta(DEFAULT_DAYS_FROM_LAST_AUDIT) + self.datebox = QtGui.QDateEdit(QtCore.Qt.QDate(default.year, default.month, default.day)) + + # buttons + spacer = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) + self.button_ok = QtGui.QPushButton() + self.button_ok.setText("OK") + self.button_ok.setDefault(True) + button_cancel = QtGui.QPushButton() + button_cancel.setText("Cancel") + + # layout + layout_right = QtGui.QVBoxLayout(self) + layout_right.addWidget(self.label_date) + layout_right.addWidget(self.datebox) + layout_right.addItem(spacer) + layout_right.addWidget(self.button_ok) + layout_right.addWidget(button_cancel) + + # connections + self.connect(button_cancel, QtCore.Qt.SIGNAL("clicked(bool)"), + self.close) + self.connect(self.button_ok, QtCore.Qt.SIGNAL("clicked(bool)"), + self.ok_clicked) + + def ok_clicked(self): + self.close() + year = self.datebox.date().year() + month = self.datebox.date().month() + day = self.datebox.date().day() + dateobj = datetime.date(int(year),int(month),int(day)) + self.emit(QtCore.Qt.SIGNAL("okClicked"), dateobj) + +################################################################ +class ReportWidget(QtGui.QWidget): + def __init__(self, *args): + QtGui.QWidget.__init__(self, *args) + self.cbUsers = QtGui.QCheckBox("Hide SYSTEM users") + self.cbSorting = QtGui.QCheckBox("Sorting enabled") + self.table = MyTable() + self.textbrowser = QtGui.QTextBrowser() + self.textbrowser.setFontFamily("Courier") + self.textbrowser.setFontPointSize(10) + hlayout = QtGui.QHBoxLayout() + hlayout.addWidget(self.cbUsers) + hlayout.addWidget(self.cbSorting) + vlayout = QtGui.QVBoxLayout() + vlayout.setMargin(2) + vlayout.addLayout(hlayout) + vlayout.addWidget(self.table) + self.setLayout(vlayout) + self.setGeometry(100,100,750,550) + + # connections + self.connect(self.cbUsers, QtCore.Qt.SIGNAL("stateChanged(int)"), + self.cbUsersChanged) + self.connect(self.cbSorting, QtCore.Qt.SIGNAL("stateChanged(int)"), + self.cbSortingChanged) + + def create(self, dateobj): + """ Parses the eventlog data, displays it in a table, and + displays the user login/logout also """ + self.table.display_data(dateobj) + + def cbUsersChanged(self): + state = self.cbUsers.checkState() + if state == 0: + self.table.show_system_users() + elif state == 2: + self.table.hide_system_users() + + def cbSortingChanged(self): + state = self.cbSorting.checkState() + if state == 0: + self.table.setSortingEnabled(False) + elif state == 2: + self.table.setSortingEnabled(True) + +################################################################ +class MyTable(QtGui.QTableWidget): + """ Creates a custom table widget """ + def __init__(self, *args): + QtGui.QTableWidget.__init__(self, *args) + self.setSelectionMode(self.ContiguousSelection) + self.setGeometry(0,0,700,400) + self.setShowGrid(False) + self.other_users_list = [] + + def hide_system_users(self): + for n in self.other_users_list: + self.setRowHidden(n, True) + + def show_system_users(self): + for n in self.other_users_list: + self.setRowHidden(n, False) + + def display_data(self, dateobj): + """ Reads in data as a 2D list and formats and displays it in + the table """ + + print "Fetching data..." + ep = EventlogParser() + data = ep.parse_log(dateobj) + print "Done." + + if len(data)==0: + data = ["No data for this date range."] + + nrows = len(data) + ncols = len(data[0]) + self.setRowCount(nrows) + self.setColumnCount(ncols) + self.setHorizontalHeaderLabels(['No.', 'Date','Time','Type','Event','User','Computer']) + + for i in xrange(len(data)): + # update progress dialog + if (i%20) == 0: + self.emit(QtCore.Qt.SIGNAL("progressChanged"), i, nrows) + qApp.processEvents() + + # set each cell to be a QTableWidgetItem from the _process_row method + items = self._process_row(data[i]) + for j in range(len(items)): + self.setItem(i, j, items[j]) + self.setRowHeight(i, 16) + + # set column width first time through + if i == 0: + self.resizeColumnsToContents() + self.setColumnWidth(4, 250) + + # format column width + self.resizeColumnsToContents() + self.setColumnWidth(4, 250) + + # emit signal for finished processing + self.emit(QtCore.Qt.SIGNAL("displayFinished")) + + def _process_row(self, row): + """ Formats items in the row of the 2-D list data + Input: the row of data from the EventlogParser in a list + Returns a list of QTableWidgetItems to be one row in the table + """ + + icon = [] + for i in xrange(len(row)): + # general formatting for all cells (may be overwritten) + icon.append(QtGui.QIcon()) + computer = row[6] + + # time processing + if i == 2: + try: + hour = int(re.split(r":", row[i])[0]) + except: + raise + if hour <= EARLY_HOUR or hour >= LATE_HOUR: + backcolor_time = QtGui.QColor(0,0,102) + else: + backcolor_time = QtGui.QColor("white") + + # success or failure processing + elif i == 3: + if row[i] == "8": + row[i] = "Success" + icon[i] = QtGui.QIcon("success.png") + elif row[i] == "16": + row[i] = "Failure" + icon[i] = QtGui.QIcon("failure.png") + else: + row[i] = "Unknown" + icon[i] = QtGui.QIcon("unknown.png") + + # event processing + elif i == 4: + backcolor = QtGui.QColor("white") + if row[i] in RED_EVENTIDS: + backcolor = QtGui.QColor("red") + elif row[i] in ORANGE_EVENTIDS: + backcolor = QtGui.QColor("orange") + elif row[i] in YELLOW_EVENTIDS: + backcolor = QtGui.QColor("yellow") + elif row[i] in GREEN_EVENTIDS: + pass + elif row[i] in OTHER_EVENTIDS: + backcolor = QtGui.QColor("blue") + try: + row[i] = row[i] + ": " + EVENT_DESC[row[i]] + except: + pass + + # user processing + elif i == 5: + if row[i] in (computer, "", "SYSTEM", "NETWORK SERVICE", "LOCAL SERVICE", "ANONYMOUS LOGON"): + font = QtGui.QFont("Arial", 8) + font.setBold(False) + textcolor = QtGui.QColor("gray") + user = 'other' + else: + font = QtGui. QFont("Arial", 8) + font.setBold(True) + textcolor = QtGui.QColor("black") + user = 'user' + + # create table widget item + tableitem_list = [] + for i in xrange(len(row)): + tableitem = QtGui.QTableWidgetItem(row[i]) + if i == 2: + tableitem.setBackgroundColor(backcolor_time) + else: + tableitem.setBackgroundColor(backcolor) + tableitem.setTextColor(textcolor) + tableitem.setFont(font) + tableitem.setTextAlignment(QtCore.Qt.AlignTop) + tableitem.setToolTip(row[i]) + tableitem.setIcon(icon[i]) + tableitem_list.append(tableitem) + + return tableitem_list + +################################################################ +if __name__ == "__main__": + main() diff --git a/src/kicadtoNgspice/TabbedWidget.py b/src/kicadtoNgspice/TabbedWidget.py new file mode 100644 index 00000000..f8a37ead --- /dev/null +++ b/src/kicadtoNgspice/TabbedWidget.py @@ -0,0 +1,9 @@ +from PyQt4 import QtGui + + + +class TabbedWidget(QtGui.QTabWidget): + def __init__(self): + QtGui.QTabWidget.__init__(self) + self.setGeometry(300, 300, 800, 600) + self.setWindowTitle('Kicad to Ngspice conversion') diff --git a/src/kicadtoNgspice/TabbedWidget.pyc b/src/kicadtoNgspice/TabbedWidget.pyc Binary files differnew file mode 100644 index 00000000..535fad1b --- /dev/null +++ b/src/kicadtoNgspice/TabbedWidget.pyc diff --git a/src/kicadtoNgspice/__init__.py b/src/kicadtoNgspice/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/kicadtoNgspice/__init__.py diff --git a/src/kicadtoNgspice/__init__.pyc b/src/kicadtoNgspice/__init__.pyc Binary files differnew file mode 100644 index 00000000..ce5d7c9f --- /dev/null +++ b/src/kicadtoNgspice/__init__.pyc diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index 71e66064..ec2932a0 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -90,4 +90,24 @@ class Kicad: else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage('Please select the project first. You can either create new project or open existing project') - self.msg.setWindowTitle("Error Message")
\ No newline at end of file + self.msg.setWindowTitle("Error Message") + + def openKicadToNgspice(self): + print "Open Kicad to Ngspice Conversion" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #Validating if current project is available or not + if self.obj_validation.validateKicad(self.projDir): + print "Project is present" + #Cheking if project has .cir file or not + if self.obj_validation.validateCir(self.projDir): + print "CIR file present" + else: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Your project do not contain any Kicad netlist file for conversion') + self.msg.setWindowTitle("Error Message") + + else: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message") +
\ No newline at end of file diff --git a/src/projManagement/Kicad.pyc b/src/projManagement/Kicad.pyc Binary files differindex 273ea5d7..5b498b30 100644 --- a/src/projManagement/Kicad.pyc +++ b/src/projManagement/Kicad.pyc diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index 323b509c..33f0894f 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -58,6 +58,16 @@ class Validation: else: return True + def validateCir(self,projDir): + print "Checking if .cir file is present or not" + projName = os.path.basename(str(projDir)) + lookCir = os.path.join(str(projDir),projName+".cir") + #Check existence of project + if os.path.exists(lookCir): + return True + else: + return False + diff --git a/src/projManagement/Validation.pyc b/src/projManagement/Validation.pyc Binary files differindex 690e016e..34e4aca0 100644 --- a/src/projManagement/Validation.pyc +++ b/src/projManagement/Validation.pyc |