Commit 0e46d37f authored by Michael Büsch's avatar Michael Büsch

gui: Enable extended instructions via menu item

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 19559867
......@@ -54,12 +54,17 @@ class CpuConfigDialog(QDialog):
"entry-variables", self)
self.layout().addWidget(self.obTempCheckBox, 2, 0, 1, 2)
self.extInsnsCheckBox = QCheckBox("Enable extended "
"non-standard instructions", self)
self.layout().addWidget(self.extInsnsCheckBox, 3, 0, 1, 2)
self.closeButton = QPushButton("Close", self)
self.layout().addWidget(self.closeButton, 3, 1)
self.layout().addWidget(self.closeButton, 4, 1)
self.accuCombo.currentIndexChanged.connect(self.__configChanged)
self.mnemonicsCombo.currentIndexChanged.connect(self.__configChanged)
self.obTempCheckBox.stateChanged.connect(self.__configChanged)
self.extInsnsCheckBox.stateChanged.connect(self.__configChanged)
self.closeButton.released.connect(self.accept)
#FIXME this should be loaded from .awlpro file
......@@ -88,6 +93,7 @@ class CpuConfigDialog(QDialog):
mnemonics = self.mnemonicsCombo.itemData(self.mnemonicsCombo.currentIndex())
nrAccus = self.accuCombo.itemData(self.accuCombo.currentIndex())
obTempEnabled = self.obTempCheckBox.checkState() == Qt.Checked
extInsnsEnabled = self.extInsnsCheckBox.checkState() == Qt.Checked
specs = self.simClient.getCpuSpecs()
if specs:
......@@ -95,6 +101,7 @@ class CpuConfigDialog(QDialog):
specs.setNrAccus(nrAccus)
self.simClient.setCpuSpecs(specs)
self.simClient.enableOBTempPresets(obTempEnabled)
self.simClient.enableExtendedInsns(extInsnsEnabled)
def __configChanged(self):
if self.__updateBlocked:
......
......@@ -34,11 +34,11 @@ class MainWidget(QWidget):
dirtyChanged = Signal(bool)
runStateChanged = Signal(int)
def __init__(self, parent=None, enableExtInstructions=False):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setLayout(QGridLayout(self))
self.__initSim(enableExtInstructions)
self.simClient = GuiAwlSimClient()
self.cpuConfigDialog = CpuConfigDialog(self, self.simClient)
self.coreConfigDialog = CoreConfigDialog(self, self.simClient)
......@@ -60,10 +60,6 @@ class MainWidget(QWidget):
self.cpuWidget.runStateChanged.connect(self.__runStateChanged)
self.runStateChanged.connect(self.codeEdit.runStateChanged)
def __initSim(self, enableExtInsns):
self.simClient = GuiAwlSimClient()
self.simClient.enableExtendedInsns(enableExtInsns)
def isDirty(self):
return self.dirty
......@@ -140,23 +136,21 @@ class MainWindow(QMainWindow):
@classmethod
def start(cls,
qApplication = None,
initialAwlSource = None,
enableExtendedInstructions = False):
initialAwlSource = None):
if not qApplication:
qApplication = QApplication(sys.argv)
mainwnd = cls(qApplication,
initialAwlSource,
enableExtendedInstructions)
initialAwlSource)
mainwnd.show()
return mainwnd
def __init__(self, qApplication, awlSource=None, enableExtInstructions=False):
def __init__(self, qApplication, awlSource=None):
QMainWindow.__init__(self)
self.qApplication = qApplication
self.setWindowTitle("S7 AWL/STL simulator v%d.%d" %\
self.setWindowTitle("Awlsim - AWL/STL PLC simulator v%d.%d" %\
(VERSION_MAJOR, VERSION_MINOR))
self.setCentralWidget(MainWidget(self, enableExtInstructions))
self.setCentralWidget(MainWidget(self))
self.setMenuBar(QMenuBar(self))
......
......@@ -3,7 +3,7 @@
#
# AWL simulator - GUI
#
# Copyright 2012-2013 Michael Buesch <m@bues.ch>
# Copyright 2012-2014 Michael Buesch <m@bues.ch>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -34,11 +34,10 @@ def usage():
printInfo("%s [OPTIONS] [AWL-source]" % sys.argv[0])
printInfo("")
printInfo("Options:")
printInfo(" -x|--extended-insns Enable extended instructions")
printInfo(" -h|--help Print this help text")
def main():
opt_awlSource = None
opt_extInsns = False
try:
(opts, args) = getopt.getopt(sys.argv[1:],
......@@ -52,8 +51,6 @@ def main():
if o in ("-h", "--help"):
usage()
return 0
if o in ("-x", "--extended-insns"):
opt_extInsns = True
if args:
if len(args) == 1:
opt_awlSource = args[0]
......@@ -61,8 +58,7 @@ def main():
usage()
return 1
mainwnd = MainWindow.start(initialAwlSource = opt_awlSource,
enableExtendedInstructions = opt_extInsns)
mainwnd = MainWindow.start(initialAwlSource = opt_awlSource)
return mainwnd.runEventLoop()
if __name__ == "__main__":
......
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