Commit 2f78a0a4 authored by Michael Büsch's avatar Michael Büsch

gui: Add exception state

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent b9b4fbe0
......@@ -76,6 +76,7 @@ class CpuWidget(QWidget):
STATE_INIT = EnumGen.item
STATE_LOAD = EnumGen.item
STATE_RUN = EnumGen.item
STATE_EXCEPTION = EnumGen.item
EnumGen.end
def __init__(self, mainWidget, parent=None):
......@@ -224,8 +225,6 @@ class CpuWidget(QWidget):
self.__setState(self.STATE_INIT)
self.runButton.setChecked(True)
self.runButton.setEnabled(False) # Redraws the radio button
self.runButton.setEnabled(True)
project = self.mainWidget.getProject()
awlSources = self.mainWidget.projectWidget.getAwlSources()
......@@ -282,11 +281,13 @@ class CpuWidget(QWidget):
client.loadCode(awlSource)
client.setRunState(True)
except AwlParserError as e:
self.__setState(self.STATE_EXCEPTION)
MessageBox.handleAwlParserError(self, e)
self.stop()
client.shutdown()
return
except AwlSimError as e:
self.__setState(self.STATE_EXCEPTION)
MessageBox.handleAwlSimError(self,
"Error while loading code", e)
self.stop()
......@@ -308,6 +309,7 @@ class CpuWidget(QWidget):
# Process GUI events
QApplication.processEvents(QEventLoop.AllEvents)
except AwlSimError as e:
self.__setState(self.STATE_EXCEPTION)
MessageBox.handleAwlSimError(self,
"Error while executing code", e)
self.stop()
......
......@@ -643,9 +643,10 @@ class EditWidget(QPlainTextEdit):
self.__updateGeo()
__runStateToText = {
CpuWidget.STATE_STOP : "-- CPU STOPPED --",
CpuWidget.STATE_INIT : "Initializing simulator...",
CpuWidget.STATE_LOAD : "Loading code...",
CpuWidget.STATE_STOP : "-- CPU STOPPED --",
CpuWidget.STATE_INIT : "Initializing simulator...",
CpuWidget.STATE_LOAD : "Loading code...",
CpuWidget.STATE_EXCEPTION : "ERROR. CPU halted.",
}
def __repaintHeaderWidget(self, ev):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment