Basic matching by scripts is working. Program needs some serious clean-up
This commit is contained in:
@@ -12,8 +12,7 @@ from model import Model
|
||||
from machine import Machine
|
||||
from reference import ReferenceManager
|
||||
from sandbox import Sandbox
|
||||
from matching import Matching
|
||||
from elegant import Elegant
|
||||
from matchmaker import MatchMaker
|
||||
|
||||
|
||||
class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
@@ -34,6 +33,15 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
# initialize online model
|
||||
self.model = Model(phase=phase,parent=self)
|
||||
|
||||
# initialize modeling
|
||||
self.match = MatchMaker()
|
||||
self.UIMatchOpticsSelect.clear()
|
||||
for key in self.match.matchlist.keys():
|
||||
self.UIMatchOpticsSelect.addItem(key)
|
||||
self.UIMatchOpticsSelect.setCurrentIndex(0)
|
||||
self.updateMatchingCase()
|
||||
|
||||
|
||||
self.machine = Machine(parent = True, office = office)
|
||||
self.machine.initPVs(self.model.getElements())
|
||||
self.sandbox = Sandbox(parent = self, machine = self.machine)
|
||||
@@ -50,6 +58,8 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
# self.matching = Matching(parent=self, model=self.model, reference = self.reference)
|
||||
|
||||
# events handling
|
||||
self.UIMatchOpticsSelect.currentIndexChanged.connect(self.updateMatchingCase)
|
||||
self.UIMatchSelected.clicked.connect(self.doMatch)
|
||||
# self.actionOpen_2.triggered.connect(self.loadSettings)
|
||||
# self.actionSave.triggered.connect(self.saveSettings)
|
||||
# self.UIUpdateFromMachine.clicked.connect(self.fullUpdate)
|
||||
@@ -60,6 +70,45 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
# self.actionOpenScriptEditor.triggered.connect(self.editMatchingScript)
|
||||
# self.actionExportElegant.triggered.connect(self.exportElegant)
|
||||
|
||||
|
||||
def doMatch(self):
|
||||
"""
|
||||
match the lattice for the given matching scripts. These can be selected by the individual check boxed.
|
||||
The matching is in the order: Injector -> Athos -> Porthos -> Aramis.
|
||||
The online model is updated with the updated match values.
|
||||
:return: None
|
||||
"""
|
||||
injector = self.UIMatchInjector.isChecked()
|
||||
aramis = self.UIMatchAramis.isChecked()
|
||||
athos = self.UIMatchAthos.isChecked()
|
||||
porthos = self.UIMatchPorthos.isChecked()
|
||||
twiss = self.match.match(self.model.om,Injector = injector,Athos = athos, Aramis = aramis, Porthos = porthos)
|
||||
energy = self.model.calcEnergyProfile(twiss)
|
||||
self.plot.newData(twiss, energy)
|
||||
|
||||
|
||||
def updateMatchingCase(self):
|
||||
"""
|
||||
Update the check box for selecting the different matching steps and initial settings if reference file is present
|
||||
:return: None
|
||||
"""
|
||||
target = self.UIMatchOpticsSelect.currentText()
|
||||
self.match.initScripts(target)
|
||||
self.updateMatchingCaseScript(self.UIMatchInjector,self.match.scriptInjector)
|
||||
self.updateMatchingCaseScript(self.UIMatchAthos, self.match.scriptAthos)
|
||||
self.updateMatchingCaseScript(self.UIMatchAramis, self.match.scriptAramis)
|
||||
self.updateMatchingCaseScript(self.UIMatchPorthos, self.match.scriptPorthos)
|
||||
|
||||
def updateMatchingCaseScript(self,widget,state):
|
||||
"""
|
||||
Generalized routine to select and enable checkbox widgets
|
||||
:param widget: checkbox widget
|
||||
:param state: True or False
|
||||
:return: None
|
||||
"""
|
||||
widget.setChecked(state)
|
||||
widget.setEnabled(state)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.plot.close()
|
||||
event.accept()
|
||||
|
||||
Reference in New Issue
Block a user