From c19d2338775920f02dc86c2463879517d6c95825 Mon Sep 17 00:00:00 2001 From: Eyantra698Sumanto Date: Tue, 11 Jan 2022 15:30:23 +0530 Subject: Adding search option for OpenModelica --- src/ngspicetoModelica/ModelicaUI.py | 31 +++++++++++++++++++++++++----- src/ngspicetoModelica/NgspicetoModelica.py | 2 +- src/ngspicetoModelica/__init__.py | 0 3 files changed, 27 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/ngspicetoModelica/ModelicaUI.py mode change 100644 => 100755 src/ngspicetoModelica/NgspicetoModelica.py mode change 100644 => 100755 src/ngspicetoModelica/__init__.py diff --git a/src/ngspicetoModelica/ModelicaUI.py b/src/ngspicetoModelica/ModelicaUI.py old mode 100644 new mode 100755 index 6cd736b7..ecf15bd2 --- a/src/ngspicetoModelica/ModelicaUI.py +++ b/src/ngspicetoModelica/ModelicaUI.py @@ -28,7 +28,7 @@ class OpenModelicaEditor(QtWidgets.QWidget): self.FileEdit.setText(self.ngspiceNetlist) self.grid.addWidget(self.FileEdit, 0, 0) - self.browsebtn = QtWidgets.QPushButton("Browse") + self.browsebtn = QtWidgets.QPushButton("Browse .cir.out") self.browsebtn.clicked.connect(self.browseFile) self.grid.addWidget(self.browsebtn, 0, 1) @@ -40,10 +40,30 @@ class OpenModelicaEditor(QtWidgets.QWidget): self.loadOMbtn.clicked.connect(self.callOMEdit) self.grid.addWidget(self.loadOMbtn, 3, 1) + + self.OMPathtext = QtWidgets.QLineEdit() + self.OMPathtext.setText("") + self.grid.addWidget(self.OMPathtext, 4, 0) + + self.OMPathbrowsebtn = QtWidgets.QPushButton("Browse OM") + self.OMPathbrowsebtn.clicked.connect(self.OMPathbrowseFile) + self.grid.addWidget(self.OMPathbrowsebtn, 4, 1) + # self.setGeometry(300, 300, 350, 300) self.setLayout(self.grid) self.show() + def OMPathbrowseFile(self): + temp = QtCore.QDir.toNativeSeparators( + QtWidgets.QFileDialog.getExistingDirectory( + self, "Open Open Modelica Directory", "home" + ) + ) + + if temp: + self.OMPath = temp + self.OMPathtext.setText(self.OMPath) + def browseFile(self): temp = QtCore.QDir.toNativeSeparators( QtWidgets.QFileDialog.getOpenFileName( @@ -215,17 +235,18 @@ class OpenModelicaEditor(QtWidgets.QWidget): ) def callOMEdit(self): - - if self.obj_validation.validateTool("OMEdit"): + + try: modelFiles = glob.glob(self.modelicaNetlist) modelFiles = ' '.join(file for file in modelFiles) - self.cmd2 = "OMEdit " + modelFiles + self.cmd2 = self.OMPath+"/OMEdit " + modelFiles + print(self.cmd2) self.obj_workThread2 = Worker.WorkerThread(self.cmd2) self.obj_workThread2.start() print("OMEdit called") self.obj_appconfig.print_info("OMEdit called") - else: + except BaseException: self.msg = QtWidgets.QMessageBox() self.msgContent = ( "There was an error while opening OMEdit.
" diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py old mode 100644 new mode 100755 index 4df65c8d..6951e3c8 --- a/src/ngspicetoModelica/NgspicetoModelica.py +++ b/src/ngspicetoModelica/NgspicetoModelica.py @@ -344,7 +344,7 @@ class NgMoConverter: stat = self.mappingData["Sources"][sourceType][typ[0]] +\ ' ' + compName + '(offset = ' +\ self.getUnitVal(typ[1]) +\ - ', V = ' + self.getUnitVal(words[4]) + ', freqHz = ' +\ + ', V = ' + self.getUnitVal(words[4]) + ', f = ' +\ self.getUnitVal(words[5]) + ', startTime = ' +\ self.getUnitVal(words[6]) + ', phase = ' +\ self.getUnitVal(theta[0]) + ');' diff --git a/src/ngspicetoModelica/__init__.py b/src/ngspicetoModelica/__init__.py old mode 100644 new mode 100755 -- cgit