optimize imports and cleanup code
This commit is contained in:
200
app_config.py
200
app_config.py
@@ -6,14 +6,11 @@
|
||||
# #yaml is fixed and not altened by program
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
from PyQt5 import QtCore, QtGui
|
||||
from PyQt5.QtCore import QSettings
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow
|
||||
import json
|
||||
import json,re
|
||||
import numpy as np
|
||||
|
||||
class MyJsonEncoder(json.JSONEncoder):
|
||||
@@ -636,206 +633,15 @@ verbose bits:
|
||||
for i,k in lut:
|
||||
cld[i].setValue(twk[k].get_val())
|
||||
|
||||
#def cb_save(self):
|
||||
# self._state=p.saveState()
|
||||
|
||||
#def cb_restore(self):
|
||||
# p=self._p
|
||||
# add=p['Save/Restore functionality', 'Restore State', 'Add missing items']
|
||||
# rem=p['Save/Restore functionality', 'Restore State', 'Remove extra items']
|
||||
# p.restoreState(self._state, addChildren=add, removeChildren=rem)
|
||||
|
||||
# ----------------------------- OBSOLETE -----------------------------
|
||||
|
||||
#inst_folder = Path(__file__).absolute().parent
|
||||
#config_file = inst_folder / "swissmx.yaml"
|
||||
#configs = yaml.load(config_file.read_text(),Loader=yaml.FullLoader)
|
||||
#endstation = configs["configure_for"]
|
||||
#appsconf = configs[endstation]
|
||||
#simulated = appsconf.get("simulate", False)
|
||||
#logger.info(f"configuring for endstation: {endstation.upper()}")
|
||||
|
||||
#if simulated:
|
||||
# logger.warning("SIMULATION is ACTIVE")
|
||||
#css_file = inst_folder / "swissmx.css"
|
||||
|
||||
|
||||
|
||||
#def font(name: str) -> str:
|
||||
# p = Path(__file__).absolute().parent / "fonts" / name
|
||||
# return str(p)
|
||||
|
||||
|
||||
#def logo(size: int = 0) -> str:
|
||||
# p = Path(__file__).absolute().parent / "logos" / "logo.png"
|
||||
# if size:
|
||||
# p = Path(__file__).absolute().parent / "logos" / f"tell_logo_{size}x{size}.png"
|
||||
# return str(p)
|
||||
|
||||
|
||||
# def dlg_geometry(self,obj):
|
||||
# SPN=GenericDialog.Spinner
|
||||
# app=QApplication.instance()
|
||||
# cfg=app._cfg
|
||||
# w, h = map(float,cfg.value(AppCfg.GEO_BEAM_SZ))
|
||||
# d = GenericDialog.GenericDialog(
|
||||
# title="geometry",
|
||||
# message="Enter the size of the beam in microns",
|
||||
# inputs={
|
||||
# "bw": ("beam width um" ,w,SPN(w, min=1, max=200, suffix=" \u00B5m"),),
|
||||
# "bh": ("beam height um",h,SPN(h, min=1, max=200, suffix=" \u00B5m"),),
|
||||
# },
|
||||
# )
|
||||
# if d.exec():
|
||||
# results = d.results
|
||||
# _log.info("Updating beamsize to {}".format(results))
|
||||
# bm_sz= (results["bw"], results["bh"])
|
||||
# _log.debug("types {}".format(type(w)))
|
||||
# cfg.setValue(AppCfg.GEO_BEAM_SZ, bm_sz)
|
||||
# cfg.sync()
|
||||
# bm=obj._goBeamMarker
|
||||
# bm.setSize(bm_sz)
|
||||
# #self._beammark.set_beam_size((w, h))
|
||||
#
|
||||
# def dlg_collimator_reference_positions(self):
|
||||
# SPN=GenericDialog.Spinner
|
||||
# app=QApplication.instance()
|
||||
# cfg=app._cfg
|
||||
# x_out = cfg.value(AppCfg.COL_DX , 0.0,type=float)
|
||||
# y_out = cfg.value(AppCfg.COL_DY , 0.0,type=float)
|
||||
# x_in = cfg.value(AppCfg.COL_X_IN, 0.0,type=float)
|
||||
# y_in = cfg.value(AppCfg.COL_Y_IN, 0.0,type=float)
|
||||
# d = GenericDialog.GenericDialog(
|
||||
# title="Collimator configuration",
|
||||
# message="Enter reference positions for the collimator",
|
||||
# inputs={
|
||||
# AppCfg.COL_DX: ("Collimator out deltaX", x_out, SPN(x_out, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
|
||||
# AppCfg.COL_DY: ("Collimator out deltaY", y_out, SPN(y_out, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
|
||||
# AppCfg.COL_X_IN: ("Collimator in X", x_in, SPN(x_in, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
|
||||
# AppCfg.COL_Y_IN: ("Collimator in Y", y_in, SPN(y_in, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
|
||||
# },
|
||||
# )
|
||||
# if d.exec():
|
||||
# results = d.results
|
||||
# _log.info("setting collimator reference positions {}".format(results))
|
||||
# for k, v in results.items():
|
||||
# cfg.setValue(k, v)
|
||||
# cfg.sync()
|
||||
#
|
||||
# def dlg_backlight_positions(self):
|
||||
# SPN=GenericDialog.Spinner
|
||||
# app=QApplication.instance()
|
||||
# cfg=app._cfg
|
||||
# p_in = cfg.value(AppCfg.BKLGT_IN,0,type=int)
|
||||
# p_out = cfg.value(AppCfg.BKLGT_OUT,0,type=int)
|
||||
# d = GenericDialog.GenericDialog(
|
||||
# title="Back Light configuration",
|
||||
# message="Enter reference positions for the backlight",
|
||||
# inputs={
|
||||
# AppCfg.BKLGT_IN: ("In position" , p_in , SPN(p_in, min=-30000, max=10), ),
|
||||
# AppCfg.BKLGT_OUT: ("Out position", p_out, SPN(p_out, min=-1000, max=10), ),
|
||||
# },
|
||||
# )
|
||||
# if d.exec():
|
||||
# results = d.results
|
||||
# _log.info("setting back light reference positions {}".format(results))
|
||||
# for k, v in results.items():
|
||||
# cfg.setValue(k, v)
|
||||
# cfg.sync()
|
||||
#
|
||||
# def dlg_cryojet_positions(self):
|
||||
# p_in = settings.value(CRYOJET_NOZZLE_IN, type=float)
|
||||
# p_out = settings.value(CRYOJET_NOZZLE_OUT, type=float)
|
||||
# motion_enabled = option(CRYOJET_MOTION_ENABLED)
|
||||
# d = GenericDialog(
|
||||
# title="Cryojet Nozzle Configuration",
|
||||
# message="Enter reference positions for the cryojet nozzle position",
|
||||
# inputs={
|
||||
# CRYOJET_NOZZLE_IN: ("In position", p_in, Spinner(p_in, min=3, max=15)),
|
||||
# CRYOJET_NOZZLE_OUT: ("Out position",p_out,Spinner(p_out, min=-1000, max=10),),
|
||||
# CRYOJET_MOTION_ENABLED: ("Move Cryojet in Transitions",motion_enabled,Checkbox(motion_enabled, "move cryojet"),),
|
||||
# },
|
||||
# )
|
||||
# if d.exec():
|
||||
# results = d.results
|
||||
# _log.info("setting cryojet reference positions {}".format(results))
|
||||
# for k, v in results.items():
|
||||
# settings.setValue(k, v)
|
||||
# settings.sync()
|
||||
#
|
||||
# def dlg_deltatau_parameters(self):
|
||||
# SPN=GenericDialog.Spinner
|
||||
# CB=GenericDialog.Checkbox
|
||||
# app=QApplication.instance()
|
||||
# cfg=app._cfg
|
||||
# #dt1 = cfg.value(AppCfg.DT_HOST,'SAR-CPPM-EXPMX1')
|
||||
# dt1 = cfg.value(AppCfg.DT_HOST)
|
||||
# dt2 = cfg.value(AppCfg.DT_VEL_SCL, 1, type=float)
|
||||
# dt3 = cfg.option(AppCfg.DT_SHOW_PLOTS)
|
||||
#
|
||||
# d = GenericDialog.GenericDialog(
|
||||
# title="Delta Tau Parameters",
|
||||
# message="These parameters affect the data collection.",
|
||||
# inputs={
|
||||
# AppCfg.DT_HOST:("host name (host[:port:port_gather])", dt1, QLineEdit(),),
|
||||
# AppCfg.DT_VEL_SCL: ("Velocity Scale (1=optimal, 0=zero vel at target)", dt2,SPN(dt2, min=0, max=1, suffix=""),),
|
||||
# AppCfg.DT_SHOW_PLOTS: ("show plots after collection", dt3,CB(dt3, "active"),),
|
||||
# #DELTATAU_SORT_POINTS: ("Sort pointshoot/prelocated coords", b,CB(b, "sort points"),),
|
||||
# },
|
||||
# )
|
||||
# if d.exec():
|
||||
# results = d.results
|
||||
# _log.info("setting delta tau parameters {}".format(results))
|
||||
# for k, v in results.items():
|
||||
# cfg.setValue(k, v)
|
||||
# cfg.sync()
|
||||
#
|
||||
# def dlg_tell_mount_positions(self):
|
||||
# AUTODRY_ENABLED = "tell/autodry_enabled"
|
||||
# AUTODRY_MAXMOUNTS = "tell/autodry_max_number_of_mounts"
|
||||
# AUTODRY_MAXTIME = "tell/autodry_max_time"
|
||||
#
|
||||
# SECS_HOURS = 60 * 60
|
||||
#
|
||||
# enabled = option(AUTODRY_ENABLED)
|
||||
# maxtime = settings.value(AUTODRY_MAXTIME, type=float) / SECS_HOURS
|
||||
# maxmounts = settings.value(AUTODRY_MAXMOUNTS, type=int)
|
||||
#
|
||||
# d = GenericDialog.GenericDialog(
|
||||
# title="TELL Settings",
|
||||
# message="These control some features of the TELL sample changer",
|
||||
# inputs={
|
||||
# AUTODRY_ENABLED: ("Auto dry", enabled,
|
||||
# Checkbox(enabled, "enabled")),
|
||||
# AUTODRY_MAXMOUNTS: ("Max. num. mounts between dry",maxmounts,
|
||||
# Spinner(maxmounts, decimals=0, min=1, max=100, suffix=" mounts"),),
|
||||
# AUTODRY_MAXTIME: ("Max. time between dry",maxtime,
|
||||
# Spinner(maxtime, decimals=1, min=0.5, max=5, suffix=" hours"),),
|
||||
# },
|
||||
# )
|
||||
# if d.exec():
|
||||
# results = d.results
|
||||
# _log.info("setting tell parameters {}".format(results))
|
||||
# for k, v in results.items():
|
||||
# if k == AUTODRY_MAXTIME:
|
||||
# v = v * SECS_HOURS
|
||||
# settings.setValue(k, v)
|
||||
# settings.sync()
|
||||
|
||||
# ----------------------------------------------
|
||||
|
||||
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s ')
|
||||
|
||||
import sys
|
||||
from PyQt5 import QtCore
|
||||
|
||||
app=QApplication([])
|
||||
app._cfg=AppCfg()
|
||||
|
||||
w=WndParameter(None)
|
||||
w.show()
|
||||
|
||||
|
||||
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||
QApplication.instance().exec_()
|
||||
|
||||
Reference in New Issue
Block a user