basic runner setup changed
This commit is contained in:
@@ -421,11 +421,11 @@ class DocumentController(QObject):
|
||||
if old != new:
|
||||
self.undo_stack.push(EditGraphParametersCommand(self, old, new))
|
||||
|
||||
def compile_active_graph(self) -> None:
|
||||
def compose_active_graph(self) -> None:
|
||||
component = self.active_component
|
||||
if component is None or component.implementation_kind != "graph":
|
||||
raise ValueError("Open a graph component before compiling")
|
||||
self.simulation.compile(component.to_dict())
|
||||
raise ValueError("Open a graph component before composing")
|
||||
self.simulation.compose(component.to_dict())
|
||||
|
||||
def run_simulation(self) -> None:
|
||||
component = self.active_component
|
||||
|
||||
@@ -41,11 +41,11 @@ class Ui_MainWindow(object):
|
||||
icon1 = QIcon()
|
||||
icon1.addFile(u":/icons/icons/configure.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
self.actionGraphParameters.setIcon(icon1)
|
||||
self.actionCompile = QAction(MainWindow)
|
||||
self.actionCompile.setObjectName(u"actionCompile")
|
||||
self.actionCompose = QAction(MainWindow)
|
||||
self.actionCompose.setObjectName(u"actionCompose")
|
||||
icon2 = QIcon()
|
||||
icon2.addFile(u":/icons/icons/run-build.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
self.actionCompile.setIcon(icon2)
|
||||
self.actionCompose.setIcon(icon2)
|
||||
self.actionRunSimulation = QAction(MainWindow)
|
||||
self.actionRunSimulation.setObjectName(u"actionRunSimulation")
|
||||
icon3 = QIcon()
|
||||
@@ -435,7 +435,7 @@ class Ui_MainWindow(object):
|
||||
self.menuHelp.addAction(self.actionAboutQt)
|
||||
self.menuSimulation.addAction(self.actionSimulationSettings)
|
||||
self.menuSimulation.addAction(self.actionGraphParameters)
|
||||
self.menuSimulation.addAction(self.actionCompile)
|
||||
self.menuSimulation.addAction(self.actionCompose)
|
||||
self.menuSimulation.addAction(self.actionRunSimulation)
|
||||
self.fileToolbar.addAction(self.actionNew)
|
||||
self.fileToolbar.addAction(self.actionOpen)
|
||||
@@ -451,7 +451,7 @@ class Ui_MainWindow(object):
|
||||
self.cameraToolbar.addAction(self.actionCenterView)
|
||||
self.simulationToolbar.addAction(self.actionSimulationSettings)
|
||||
self.simulationToolbar.addAction(self.actionGraphParameters)
|
||||
self.simulationToolbar.addAction(self.actionCompile)
|
||||
self.simulationToolbar.addAction(self.actionCompose)
|
||||
self.simulationToolbar.addAction(self.actionRunSimulation)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
@@ -472,12 +472,12 @@ class Ui_MainWindow(object):
|
||||
#if QT_CONFIG(statustip)
|
||||
self.actionGraphParameters.setStatusTip(QCoreApplication.translate("MainWindow", u"Edit parameters throughout the active graph", None))
|
||||
#endif // QT_CONFIG(statustip)
|
||||
self.actionCompile.setText(QCoreApplication.translate("MainWindow", u"Compile", None))
|
||||
self.actionCompose.setText(QCoreApplication.translate("MainWindow", u"Compose", None))
|
||||
#if QT_CONFIG(statustip)
|
||||
self.actionCompile.setStatusTip(QCoreApplication.translate("MainWindow", u"Compile the active graph for simulation", None))
|
||||
self.actionCompose.setStatusTip(QCoreApplication.translate("MainWindow", u"Compose the active graph as an OpenModelica model", None))
|
||||
#endif // QT_CONFIG(statustip)
|
||||
#if QT_CONFIG(shortcut)
|
||||
self.actionCompile.setShortcut(QCoreApplication.translate("MainWindow", u"F5", None))
|
||||
self.actionCompose.setShortcut(QCoreApplication.translate("MainWindow", u"F5", None))
|
||||
#endif // QT_CONFIG(shortcut)
|
||||
self.actionRunSimulation.setText(QCoreApplication.translate("MainWindow", u"Run", None))
|
||||
#if QT_CONFIG(statustip)
|
||||
|
||||
@@ -166,7 +166,7 @@ class MainWindow(QMainWindow):
|
||||
self.show_simulation_settings
|
||||
)
|
||||
self.ui.actionGraphParameters.triggered.connect(self.show_graph_parameters)
|
||||
self.ui.actionCompile.triggered.connect(self.compile_active_graph)
|
||||
self.ui.actionCompose.triggered.connect(self.compose_active_graph)
|
||||
self.ui.actionRunSimulation.triggered.connect(self.run_simulation)
|
||||
self.document_controller.undo_stack.canUndoChanged.connect(self.ui.actionUndo.setEnabled)
|
||||
self.document_controller.undo_stack.canRedoChanged.connect(self.ui.actionRedo.setEnabled)
|
||||
@@ -239,12 +239,12 @@ class MainWindow(QMainWindow):
|
||||
QMessageBox.warning(self, "Cannot change graph parameters", str(error))
|
||||
|
||||
@Slot()
|
||||
def compile_active_graph(self) -> None:
|
||||
def compose_active_graph(self) -> None:
|
||||
try:
|
||||
self.document_controller.compile_active_graph()
|
||||
self.document_controller.compose_active_graph()
|
||||
except ValueError as error:
|
||||
self.log.error("Compile failed: %s", error)
|
||||
QMessageBox.warning(self, "Cannot compile", str(error))
|
||||
self.log.error("Composition failed: %s", error)
|
||||
QMessageBox.warning(self, "Cannot compose", str(error))
|
||||
|
||||
@Slot()
|
||||
def run_simulation(self) -> None:
|
||||
@@ -281,7 +281,7 @@ class MainWindow(QMainWindow):
|
||||
self._set_graph_controls_visible(False)
|
||||
self.ui.actionSimulationSettings.setEnabled(False)
|
||||
self.ui.actionGraphParameters.setEnabled(False)
|
||||
self.ui.actionCompile.setEnabled(False)
|
||||
self.ui.actionCompose.setEnabled(False)
|
||||
self.ui.actionRunSimulation.setEnabled(False)
|
||||
self._update_edit_actions()
|
||||
return
|
||||
@@ -292,7 +292,7 @@ class MainWindow(QMainWindow):
|
||||
is_graph = component.implementation_kind == "graph"
|
||||
self.ui.actionSimulationSettings.setEnabled(is_graph)
|
||||
self.ui.actionGraphParameters.setEnabled(is_graph)
|
||||
self.ui.actionCompile.setEnabled(is_graph)
|
||||
self.ui.actionCompose.setEnabled(is_graph)
|
||||
self.ui.actionRunSimulation.setEnabled(is_graph)
|
||||
self.ui.workspaceModeLabel.setText("Graph" if is_graph else "Text")
|
||||
self.ui.workspaceStack.setCurrentWidget(
|
||||
@@ -760,6 +760,7 @@ class MainWindow(QMainWindow):
|
||||
event.ignore()
|
||||
return
|
||||
self.settings.setValue("window/geometry", self.saveGeometry())
|
||||
self.simulation.shutdown()
|
||||
self.log.info("BEdit closed")
|
||||
self.application_logger.removeHandler(self.log_handler)
|
||||
event.accept()
|
||||
|
||||
@@ -20,6 +20,8 @@ def _saved_instance_state(instance) -> dict:
|
||||
def reload_simulation(current):
|
||||
"""Reload the simulation package and return a fresh state-preserving instance."""
|
||||
saved_state = _saved_instance_state(current)
|
||||
saved_state.pop("openmodelica", None)
|
||||
current.shutdown(wait=True)
|
||||
importlib.invalidate_caches()
|
||||
package = importlib.import_module(SIMULATION_PACKAGE)
|
||||
discovered: list[ModuleType] = []
|
||||
@@ -30,4 +32,5 @@ def reload_simulation(current):
|
||||
package = importlib.reload(package)
|
||||
replacement = package.Simulation()
|
||||
vars(replacement).update(saved_state)
|
||||
replacement.openmodelica.configure(replacement.openmodelica_path)
|
||||
return replacement
|
||||
|
||||
Reference in New Issue
Block a user