Support for different phases. Settings have to match the loaded phase

This commit is contained in:
2026-01-21 14:41:19 +01:00
parent 7b7e6ff771
commit b7cdc435d0
23 changed files with 6599 additions and 236 deletions

View File

@@ -37,14 +37,11 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
self.model = Model(phase=phase,parent=self)
# initialize modeling
self.match = MatchMaker(signal=self.sigStatus)
self.match = MatchMaker(signal=self.sigStatus,phase=phase)
self.UIMatchOpticsSelect.clear()
for key in self.match.matchlist.keys():
self.UIMatchOpticsSelect.addItem(key)
if phase == 0:
self.UIMatchOpticsSelect.setCurrentIndex(0)
else:
self.UIMatchOpticsSelect.setCurrentIndex(1)
self.UIMatchOpticsSelect.setCurrentIndex(0)
self.updateMatchingCase()
@@ -114,6 +111,7 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
listitem.setBackground(color)
self.UIReportMatchResult.addItem(listitem)
def updateMatchingCase(self):
"""
Update the check box for selecting the different matching steps and initial settings if reference file is present
@@ -125,6 +123,8 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
self.updateMatchingCaseScript(self.UIMatchAthos, self.match.scriptAthos)
self.updateMatchingCaseScript(self.UIMatchAramis, self.match.scriptAramis)
self.updateMatchingCaseScript(self.UIMatchPorthos, self.match.scriptPorthos)
if not self.match.settings is None:
self.loadSettingsdirect(self.match.settings)
def updateMatchingCaseScript(self,widget,state):
"""
@@ -189,6 +189,7 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
self.saveSettingdirect(fileName)
def loadSettings(self):
options = QtWidgets.QFileDialog.Options()
options |= QtWidgets.QFileDialog.DontUseNativeDialog
@@ -198,12 +199,22 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
if not fileName:
return
self.loadSettingsdirect(fileName)
self.match.referencePoints.clear()
self.match.referencePoints['swissfel$start'] = {'Twiss': self.model.startTwiss,'Label': 'Start'}
self.reference.initReferencePoints(self.match)
def loadSettingsdirect(self,fileName):
with open(fileName, 'r', encoding='utf-8') as f:
settings = json.load(f)
self.model.loadSettings(settings)
self.status('Reference loaded')
status=self.model.loadSettings(settings)
if status:
print('Reference loaded from file %s' % fileName)
self.status('Reference file loaded')
else:
print('Reference cannot be loaded from file %s' % fileName)
print('Missing or mismatched phase of settings file with model')
self.status('Phase Mismatch in Setting')
def saveSettingsdirect(self,fileName):
settings = self.model.getSettings()