Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nghdl/src/createKicadLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import os
import xml.etree.cElementTree as ET
from PyQt5 import QtWidgets
from PyQt6 import QtWidgets

class AutoSchematic(QtWidgets.QWidget):

Expand All @@ -20,7 +20,7 @@ def __init__(self, parent, modelname):
inst_dir + '/KiCad/share/kicad/symbols/eSim_Nghdl.kicad_sym'
else:
self.kicad_nghdl_sym = \
'/Users/thethtarshwesin/Documents/KiCad/6.0/symbols/eSim_Nghdl.kicad_sym'
'/usr/share/kicad/symbols/eSim_Nghdl.kicad_sym'
self.parser = Appconfig.parser_nghdl

def createKicadSymbol(self):
Expand All @@ -40,9 +40,9 @@ def createKicadSymbol(self):
''' already exist. Do you want to overwrite it?</b><br/>
If yes press ok, else cancel it and ''' +
'''change the name of your vhdl file.''',
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel
)
if ret == QtWidgets.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
print("Overwriting existing libraries")
self.getPortInformation()
self.createXML()
Expand All @@ -57,7 +57,7 @@ def createKicadSymbol(self):
self.parent, "Error", '''<b>A standard library already ''' +
'''exists with this name.</b><br/><b>Please change the ''' +
'''name of your vhdl file and upload it again.</b>''',
QtWidgets.QMessageBox.Ok
QtWidgets.QMessageBox.StandardButton.Ok
)

# quit()
Expand Down Expand Up @@ -433,7 +433,7 @@ def createSym(self):
"Symbol details for this model were added to "
"<b>eSim_Nghdl.kicad_sym</b> successfully."
),
QtWidgets.QMessageBox.Ok
QtWidgets.QMessageBox.StandardButton.Ok
)


Expand Down
3 changes: 1 addition & 2 deletions nghdl/src/model_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def __init__(self, file):
if os.name == 'nt':
self.home = os.path.join('library', 'config')
else:
# self.home = os.expanduser('~')
self.home = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) # direcotory: Resources/
self.home = os.path.expanduser('~')

self.parser = ConfigParser()
self.parser.read(os.path.join(
Expand Down
79 changes: 50 additions & 29 deletions nghdl/src/ngspice_ghdl.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#! /Users/thethtarshwesin/Desktop/eSim-2.5/esim-venv/bin/python3
#!/usr/bin/env python3

# This file create the GUI to install code model in the Ngspice.

import os
import sys
import shutil
import subprocess
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt6 import QtGui, QtCore, QtWidgets
from configparser import ConfigParser
from Appconfig import Appconfig
from createKicadLibrary import AutoSchematic
Expand Down Expand Up @@ -39,6 +39,7 @@ def __init__(self):
print(fileopen.read())
fileopen.close()
self.file_list = [] # to keep the supporting files
self.filename = ''
self.errorFlag = False # to keep the check of "make install" errors
self.initUI()

Expand All @@ -60,7 +61,7 @@ def initUI(self):
self.termedit.setReadOnly(1)
pal = QtGui.QPalette()
bgc = QtGui.QColor(0, 0, 0)
pal.setColor(QtGui.QPalette.Base, bgc)
pal.setColor(QtGui.QPalette.ColorRole.Base, bgc)
self.termedit.setPalette(pal)
self.termedit.setStyleSheet("QTextEdit {color:white}")

Expand Down Expand Up @@ -139,9 +140,9 @@ def createModelDirectory(self):
"<b>This model already exist. Do you want to " +
"overwrite it?</b><br/> If yes press ok, else cancel it and " +
"change the name of your vhdl file.",
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel
)
if ret == QtWidgets.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
print("Overwriting existing model " + self.modelname)
if os.name == 'nt':
cmd = "rmdir " + self.modelname + "/s /q"
Expand Down Expand Up @@ -234,7 +235,7 @@ def createModelFiles(self):
self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME')
subprocess.call(self.msys_home + "/usr/bin/bash.exe " +
path + "/DUTghdl/compile.sh", shell=True)
subprocess.call(self.msys_hoscme + "/usr/bin/bash.exe -c " +
subprocess.call(self.msys_home + "/usr/bin/bash.exe -c " +
"'chmod a+x start_server.sh'", shell=True)
subprocess.call(self.msys_home + "/usr/bin/bash.exe -c " +
"'chmod a+x sock_pkg_create.sh'", shell=True)
Expand All @@ -249,11 +250,14 @@ def createModelFiles(self):
# Slot to redirect stdout and stderr to window console
@QtCore.pyqtSlot()
def readAllStandard(self):
proc = self.sender()
if not isinstance(proc, QtCore.QProcess):
return
self.termedit.append(
str(self.process.readAllStandardOutput().data(), encoding='utf-8')
str(proc.readAllStandardOutput().data(), encoding='utf-8')
)
stderror = self.process.readAllStandardError()
if stderror.toUpper().contains(b"ERROR"):
stderror = proc.readAllStandardError()
if stderror.toUpper().contains(QtCore.QByteArray(b"ERROR")):
self.errorFlag = True
self.termedit.append(str(stderror.data(), encoding='utf-8'))

Expand All @@ -265,22 +269,21 @@ def runMake(self):

try:
if os.name == 'nt':
# path to msys bin directory where make is located
self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME')
cmd = self.msys_home + "/mingw64/bin/mingw32-make.exe"
else:
cmd = " make"
cmd = "make"

print("Running Make command in " + path_icm)
path = os.getcwd() # noqa
self.process = QtCore.QProcess(self)
self.process.start(cmd)
print("make command process pid ---------- >", self.process.pid())

self.process.readyReadStandardOutput.connect(self.readAllStandard)
self.process.readyReadStandardError.connect(self.readAllStandard)
if os.name == "nt":
self.process.finished.connect(self.createSchematicLib)
self.process \
.readyReadStandardOutput.connect(self.readAllStandard)
else:
self.process.finished.connect(self.runMakeInstall)
self.process.start(cmd)
print("make command process pid ---------- >", self.process.processId())

except BaseException:
print("There is error in 'make' ")
Expand All @@ -291,27 +294,38 @@ def runMakeInstall(self):
try:
if os.name == 'nt':
self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME')
cmd = self.msys_home + "/mingw64/bin/mingw32-make.exe install"
prog = self.msys_home + "/mingw64/bin/mingw32-make.exe"
args = ["install"]
else:
cmd = " make install"
prog = "make"
args = ["install"]
print("Running Make Install")
path = os.getcwd() # noqa
try:
self.process.close()
except BaseException:
pass

self.process = QtCore.QProcess(self)
self.process.start(cmd)
self.process.finished.connect(self.createSchematicLib)
self.process.readyReadStandardOutput.connect(self.readAllStandard)
self.process.readyReadStandardError.connect(self.readAllStandard)
self.process.finished.connect(self.createSchematicLib)
self.process.start(prog, args)
os.chdir(self.cur_dir)

except BaseException:
print("There is error in 'make install' ")
sys.exit()

def createSchematicLib(self):
try:
self._createSchematicLib()
except Exception as e:
print("createSchematicLib exception:", e)
import traceback
traceback.print_exc()
QtWidgets.QMessageBox.critical(
self, 'Error', 'Library creation failed: ' + str(e)
)
self.uploadbtn.setEnabled(True)
self.exitbtn.setEnabled(True)

def _createSchematicLib(self):
if os.name == "nt":
shutil.copy("ghdl/ghdl.cm", "../../../../lib/ngspice/")

Expand All @@ -333,13 +347,19 @@ def createSchematicLib(self):
'''To create Schematic Library of your model, ''' +
'''use NGHDL through <b>eSim</b> '''
)
self.uploadbtn.setEnabled(True)
self.exitbtn.setEnabled(True)

def uploadModel(self):
print("Upload button clicked")
try:
self.process.close()
except BaseException:
pass
if not self.filename:
QtWidgets.QMessageBox.warning(
self, 'No File', 'Use Browse to select a .vhdl file first.')
return
try:
self.file_extension = os.path.splitext(str(self.filename))[1]
print("Uploaded File extension :" + self.file_extension)
Expand All @@ -348,12 +368,13 @@ def uploadModel(self):
self.checkSupportFiles()
if self.file_extension == ".vhdl":
self.errorFlag = False
self.uploadbtn.setEnabled(False)
self.exitbtn.setEnabled(False)
self.termedit.append('<b style="color:yellow">Processing... do not close until Symbol Added dialog appears.</b>')
self.createModelDirectory()
self.addingModelInModpath()
self.createModelFiles()
self.runMake()
if os.name != 'nt':
self.runMakeInstall()
else:
QtWidgets.QMessageBox.information(
self, 'Message', '''<b>Important Message.</b><br/>''' +
Expand Down Expand Up @@ -439,7 +460,7 @@ def main():
# Mainwindow() object must be assigned to a variable.
# Otherwise, it is destroyed as soon as it gets created.
w = Mainwindow() # noqa
sys.exit(app.exec_())
sys.exit(app.exec())


if __name__ == '__main__':
Expand Down
6 changes: 5 additions & 1 deletion src/configuration/Appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class Appconfig(QtWidgets.QWidget):
)
workspace_check, home = file.readline().split(' ', 1)
file.close()
except IOError:
except (IOError, ValueError):
# ValueError: workspace.txt was truncated/empty (e.g. an interrupted
# write left it blank), so "<check> <home>".split(' ', 1) cannot unpack
# into two names. Fall back to the default workspace instead of letting
# the exception escape the class body and abort startup.
home = os.path.join(os.path.expanduser("~"), "eSim-Workspace")
workspace_check = 0

Expand Down
2 changes: 1 addition & 1 deletion src/converter/browseSchematic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

def browse_path(self, text_box):
file_dialog = QFileDialog() # a dialog that allows the user to select files or directories
file_dialog.setFileMode(QFileDialog.AnyFile)
file_dialog.setFileMode(QFileDialog.FileMode.AnyFile)
file_dialog.setNameFilter("Supported Files (*.sch *.asc *.slb *.asy);;ASY Files (*.asy)") # Include all supported extensions
file_dialog.exec() # Execute the dialog

Expand Down
2 changes: 1 addition & 1 deletion src/frontEnd/Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def dev_docs(self):
webbrowser.open("https://esim.readthedocs.io/en/latest/index.html")

@QtCore.pyqtSlot(QtCore.QProcess.ExitStatus, int)
def plotSimulationData(self, exitCode, exitStatus):
def plotSimulationData(self, exitStatus, exitCode):
"""Enables interaction for new simulation and
displays the plotter dock where graphs can be plotted.
"""
Expand Down
19 changes: 10 additions & 9 deletions src/frontEnd/ProjectExplorer.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ def addTreeNode(self, parents, children):

def openMenu(self, position):
indexes = self.treewidget.selectedIndexes()
if len(indexes) > 0:
level = 0
index = indexes[0]
while index.parent().isValid():
index = index.parent()
level += 1
if not indexes:
return

level = 0
index = indexes[0]
while index.parent().isValid():
index = index.parent()
level += 1

menu = QtWidgets.QMenu()
if level == 0:
Expand All @@ -139,7 +141,7 @@ def openMenu(self, position):
snapshot = menu.addAction(self.tr("Snapshot"))
snapshot.triggered.connect(self.takeSnapshot)

menu.exec_(self.treewidget.viewport().mapToGlobal(position))
menu.exec(self.treewidget.viewport().mapToGlobal(position))

def openProject(self):
self.indexItem = self.treewidget.currentIndex()
Expand Down Expand Up @@ -292,7 +294,7 @@ def renameProject(self):

newBaseFileName, ok = QtWidgets.QInputDialog.getText(
self, 'Rename Project', 'Project Name:',
QtWidgets.QLineEdit.Normal, self.baseFileName
QtWidgets.QLineEdit.EchoMode.Normal, self.baseFileName
)

if ok and newBaseFileName:
Expand Down Expand Up @@ -474,4 +476,3 @@ def takeSnapshot(self):
self.time_explorer.add_snapshot(file_name, formatted_time)
else:
print(f"Snapshot taken: {snapshot_path}")
msg.exec()
4 changes: 2 additions & 2 deletions src/frontEnd/TerminalUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, qProcess, args):
self.iconDir = "../../images"

# Load the ui file
uic.loadUi("TerminalUi.ui", self)
uic.loadUi(os.path.join(os.path.dirname(__file__), "TerminalUi.ui"), self)

# Define Our Widgets
self.progressBar = self.findChild(
Expand Down Expand Up @@ -94,7 +94,7 @@ def cancelSimulation(self):
def redoSimulation(self):
"""This function reruns the ngspice simulation
"""
self.Flag = "Flase"
self.Flag = False
self.cancelSimulationButton.setEnabled(True)
self.redoSimulationButton.setEnabled(False)

Expand Down
6 changes: 5 additions & 1 deletion src/frontEnd/TimeExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import shutil
import json
from PyQt5 import QtWidgets
from PyQt6 import QtWidgets

class TimeExplorer(QtWidgets.QWidget):

Expand Down Expand Up @@ -81,6 +81,8 @@ def load_last_snapshots(self):
def clear_snapshots(self):
selected = self.treewidget.selectedItems()
project_name = self.current_project["ProjectName"]
if not project_name:
return
snapshot_dir = os.path.join(self.user_home, ".esim", "history", project_name)

if selected:
Expand Down Expand Up @@ -125,6 +127,8 @@ def restore_snapshots(self):
selected_items = self.treewidget.selectedItems()

project_name = self.current_project["ProjectName"]
if not project_name:
return
snapshot_dir = os.path.join(self.user_home, ".esim", "history", project_name)

if not os.path.exists(snapshot_dir):
Expand Down
Loading