Writing from sandbox to machine - initial code
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import sys
|
||||
import json
|
||||
from datetime import datetime
|
||||
import time
|
||||
import webbrowser
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from PyQt5 import QtWidgets,QtGui
|
||||
@@ -50,11 +49,21 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
self.actionOpen_2.triggered.connect(self.loadSettings)
|
||||
self.actionSave.triggered.connect(self.saveSettings)
|
||||
self.UIUpdateFromMachine.clicked.connect(self.fullUpdate)
|
||||
self.actionHelp.triggered.connect(self.openGit)
|
||||
self.actionAbout.triggered.connect(self.about)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.plot.close()
|
||||
event.accept()
|
||||
|
||||
def about(self):
|
||||
QtWidgets.QMessageBox.about(self, "Optics Tool",
|
||||
"Version:%s\nContact: Sven Reiche\nEmail: sven.reiche@psi.ch" % self.version)
|
||||
|
||||
def openGit(self):
|
||||
webbrowser.open("https://gitea.psi.ch/reiche/opticstool")
|
||||
|
||||
|
||||
def saveSettings(self):
|
||||
options = QtWidgets.QFileDialog.Options()
|
||||
options |= QtWidgets.QFileDialog.DontUseNativeDialog
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
1) Mark in matching list groups with reference points
|
||||
|
||||
3) export to machine for magnet settings
|
||||
2) make matching targets editable
|
||||
4) export elegant lattice
|
||||
5) support of other reference files -> fill up the selection list
|
||||
6) matching
|
||||
8) Elegant support?
|
||||
10) Prepare several settings files
|
||||
11) About and website support
|
||||
|
||||
|
||||
|
||||
22
machine.py
22
machine.py
@@ -1,6 +1,6 @@
|
||||
import re
|
||||
import numpy as np
|
||||
from epics import PV
|
||||
from epics import PV,caput_many
|
||||
|
||||
class Machine:
|
||||
def __init__(self, parent=None, office=False):
|
||||
@@ -43,6 +43,26 @@ class Machine:
|
||||
else:
|
||||
self.PVs={ele:PV(ele, auto_monitor=False) for ele in self.PVNames}
|
||||
|
||||
def setMagnets(self,vals):
|
||||
pvs=[]
|
||||
val=[]
|
||||
for ele in vals.keys():
|
||||
val.append(vals[ele])
|
||||
if 'MQUA' in ele or 'MQSK' in ele:
|
||||
pvs.append(ele+':K1L-SET')
|
||||
if 'MSEX' in ele:
|
||||
pvs.append(ele + ':K2L-SET')
|
||||
if 'MBND' in ele:
|
||||
pvs.append(ele + ':K0L-SET')
|
||||
if self.offline:
|
||||
print('####################################')
|
||||
print('Program is in offline mode')
|
||||
print('Any machine settings ar enot applied')
|
||||
return
|
||||
caput_many(pvs,val)
|
||||
|
||||
|
||||
|
||||
def getMachineStatus(self):
|
||||
print('offline:',self.offline)
|
||||
if self.offline:
|
||||
|
||||
16
sandbox.py
16
sandbox.py
@@ -19,6 +19,22 @@ class Sandbox:
|
||||
self.parent.SB2ModMag.clicked.connect(self.updateModelEvent)
|
||||
self.parent.Mach2ModUnd.clicked.connect(self.updateModelEvent)
|
||||
self.parent.SB2ModUnd.clicked.connect(self.updateModelEvent)
|
||||
self.parent.SB2MachineMag.clicked.connect(self.updateMachine)
|
||||
|
||||
def updateMachine(self):
|
||||
vals = self.getSBbyCol(self.parent.MagSB,1)
|
||||
self.parent.machine.setMagnets(vals)
|
||||
self.updateSandbox()
|
||||
|
||||
def getSBbyCol(self, sb,col):
|
||||
vals={}
|
||||
for i in range(sb.rowCount()):
|
||||
field=str(sb.item(i,0).text())
|
||||
val = str(sb.item(i, col).text())
|
||||
if val == '---':
|
||||
continue
|
||||
vals[field]=float(val)
|
||||
return vals
|
||||
|
||||
def updateModelEvent(self):
|
||||
if self.parent.sender() is self.parent.Mach2ModMag:
|
||||
|
||||
@@ -511,12 +511,12 @@ class Ui_OpticsGUI(object):
|
||||
self.actionExport_Magnet_Settings = QtWidgets.QAction(OpticsGUI)
|
||||
self.actionExport_Magnet_Settings.setEnabled(False)
|
||||
self.actionExport_Magnet_Settings.setObjectName("actionExport_Magnet_Settings")
|
||||
self.actionInfo = QtWidgets.QAction(OpticsGUI)
|
||||
self.actionInfo.setEnabled(True)
|
||||
self.actionInfo.setObjectName("actionInfo")
|
||||
self.actionWebsite = QtWidgets.QAction(OpticsGUI)
|
||||
self.actionWebsite.setEnabled(False)
|
||||
self.actionWebsite.setObjectName("actionWebsite")
|
||||
self.actionAbout = QtWidgets.QAction(OpticsGUI)
|
||||
self.actionAbout.setEnabled(True)
|
||||
self.actionAbout.setObjectName("actionAbout")
|
||||
self.actionHelp = QtWidgets.QAction(OpticsGUI)
|
||||
self.actionHelp.setEnabled(True)
|
||||
self.actionHelp.setObjectName("actionHelp")
|
||||
self.actionLoad_Settings_from_Model = QtWidgets.QAction(OpticsGUI)
|
||||
self.actionLoad_Settings_from_Model.setEnabled(True)
|
||||
self.actionLoad_Settings_from_Model.setObjectName("actionLoad_Settings_from_Model")
|
||||
@@ -595,8 +595,8 @@ class Ui_OpticsGUI(object):
|
||||
self.menuFile.addAction(self.actionSave)
|
||||
self.menuFile.addSeparator()
|
||||
self.menuFile.addAction(self.actionQuit)
|
||||
self.menuHelp.addAction(self.actionInfo)
|
||||
self.menuHelp.addAction(self.actionWebsite)
|
||||
self.menuHelp.addAction(self.actionAbout)
|
||||
self.menuHelp.addAction(self.actionHelp)
|
||||
self.menubar.addAction(self.menuFile.menuAction())
|
||||
self.menubar.addAction(self.menuHelp.menuAction())
|
||||
|
||||
@@ -690,8 +690,8 @@ class Ui_OpticsGUI(object):
|
||||
self.actionQuit.setText(_translate("OpticsGUI", "Quit"))
|
||||
self.actionExport_Lattice.setText(_translate("OpticsGUI", "Export Lattice..."))
|
||||
self.actionExport_Magnet_Settings.setText(_translate("OpticsGUI", "Export Magnet Settings..."))
|
||||
self.actionInfo.setText(_translate("OpticsGUI", "Info..."))
|
||||
self.actionWebsite.setText(_translate("OpticsGUI", "Website..."))
|
||||
self.actionAbout.setText(_translate("OpticsGUI", "About..."))
|
||||
self.actionHelp.setText(_translate("OpticsGUI", "Help.."))
|
||||
self.actionLoad_Settings_from_Model.setText(_translate("OpticsGUI", "Load Settings from Model"))
|
||||
self.actionUpdate_Model.setText(_translate("OpticsGUI", "Update Model"))
|
||||
self.actionLoad_Settings_from_Machine.setText(_translate("OpticsGUI", "Load Settings from Machine"))
|
||||
|
||||
@@ -821,8 +821,8 @@
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionInfo"/>
|
||||
<addaction name="actionWebsite"/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="actionHelp"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuHelp"/>
|
||||
@@ -913,20 +913,20 @@
|
||||
<string>Export Magnet Settings...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInfo">
|
||||
<action name="actionAbout">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Info...</string>
|
||||
<string>About...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWebsite">
|
||||
<action name="actionHelp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Website...</string>
|
||||
<string>Help..</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoad_Settings_from_Model">
|
||||
|
||||
Reference in New Issue
Block a user