|
@@ -1,126 +1,64 @@
|
|
|
-"""
|
|
|
-This is the configuration File for KCG - Kapture Control Gui
|
|
|
-For possible config settings check this file or the documentation
|
|
|
-"""
|
|
|
+import ConfigParser
|
|
|
+import ast
|
|
|
+import os
|
|
|
|
|
|
-# ------------[ Language of the GUI ]------------------
|
|
|
-# NOTE: This value will be overwritten when the language is changed in the gui-settings
|
|
|
-# possible languages:
|
|
|
-# en_GB - English
|
|
|
-# de_DE - German
|
|
|
-language ="en_GB"
|
|
|
-# ------------[ Default Data Save Location ]-----------
|
|
|
-# default_save_location: use "pwd" for current working
|
|
|
-# directory KCG will always save in a subdirectory to
|
|
|
-# this given path and save files in this directory
|
|
|
-default_save_location = "pwd"
|
|
|
-# default_subdirectory_name_format: this is the
|
|
|
-# naming scheme for the subdirectory in which the
|
|
|
-# files are saved. Format of this string:
|
|
|
-# "{tag1}text{tag2}text" etc.
|
|
|
-# possible tags:
|
|
|
-# {dateG} will produce e.g. 04.01.2015
|
|
|
-# {dateGd} will produce e.g. 04_01_2015
|
|
|
-# {dateA} will pdoduce e.g. 01-04-2015
|
|
|
-# {times} will produce e.g. 14_04
|
|
|
-# {timel} will produce e.g. 14_04_12
|
|
|
-# {d} the Day in 2 digit format
|
|
|
-# {m} the Month in 2 digit format
|
|
|
-# {y} the Year in 4 digit Format
|
|
|
-# {H} the Hour in 2 digit format
|
|
|
-# {M} the minute in 2 digit format
|
|
|
-# {S} the seconds in 2 digit format
|
|
|
-# {timestamp} unix timestamp without msec
|
|
|
-# {user} the current logged in user
|
|
|
-# {sessionname} Ask for session name at startup
|
|
|
+config = ConfigParser.ConfigParser()
|
|
|
+config.optionxform = str
|
|
|
+config.read(os.path.expanduser("~")+"/.kcg/config.cfg")
|
|
|
+defaultConfig = ConfigParser.ConfigParser()
|
|
|
+defaultConfig.optionxform = str
|
|
|
+defaultConfig.read(os.path.join(os.path.dirname(__file__), "config.cfg"))
|
|
|
|
|
|
-# {ask} always ask for a foldername
|
|
|
-#default_subdirectory_name = "{user}_{dateGd}-{timel}_{sessionname}"
|
|
|
-default_subdirectory_name = "{sessionname}"
|
|
|
-# default_subdirectory_name = 't'
|
|
|
-# reask on cancel in dialog or use {user}_{dateGd}-{timel} as default when cancel is pressed?
|
|
|
-force_ask = False
|
|
|
|
|
|
-# Show advanced table view per default? (boolean value)
|
|
|
-show_advanced_control = False
|
|
|
|
|
|
-# ------------[ EPICS Log PVs ]------------
|
|
|
-# These are PVs that will be possible to insert into log files
|
|
|
-# This variable is to be a list consisting of touples of two entries,
|
|
|
-# the first ist the Text that describes the value and the second is the EPICS PV that
|
|
|
-# holds that value
|
|
|
-epics_log_entry_pvs = [
|
|
|
- ("Beam Energy (GeV)", "A:SR:BeamInfo:01:Energy"),
|
|
|
- ("Beam Current (mA)", "A:SR:BeamInfo:01:Current"),
|
|
|
- ("Beam Lifetime (s)", "A:SR:BeamInfo:01:Lifetime"),
|
|
|
- ("Beam Lifetime (H:M:S)", "A:SR:BeamInfo:01:Lifetime:String"),
|
|
|
- ("Injection Rate (mA/s)", "A:SR:BeamInfo:01:InjRate"),
|
|
|
- ("Injection Rate (mA/5s)", "A:SR:BeamInfo:01:InjRate:5s"),
|
|
|
- ("Fill Number", "A:SR:OperationStatus:01:FillNumber")
|
|
|
-]
|
|
|
-# This pv is used to determine if epics pvs are accessible
|
|
|
-epics_test_pv = "A:SR:BeamInfo:01:Current"
|
|
|
-# Path to your epics base installation
|
|
|
-epics_base_path = "/opt/epics/base/"
|
|
|
+Machine_conf = ["bunches_per_turn", "save_header", "tRev"]
|
|
|
+Ui_conf = ["language", "default_save_location", "default_subdirectory_name", "force_ask", "show_advanced_control"]
|
|
|
+Logging_conf = ["epics_test_pv", "epics_base_path"]
|
|
|
|
|
|
-# -----------[ Default Measurement Log Entries ]------------
|
|
|
-# List of Entries that are default to save in Log
|
|
|
-# Possible Values are:
|
|
|
-# "Number of Orbits"
|
|
|
-# "Number of Skipped Orbits"
|
|
|
-# "Number of Acquisitions"
|
|
|
-# "Time between Acquisitions"
|
|
|
-# "Pilot Bunch Simulator"
|
|
|
-# "Header saved"
|
|
|
-# "T/H Delay"
|
|
|
-# "ADC 1 Delay"
|
|
|
-# "ADC 2 Delay"
|
|
|
-# "ADC 3 Delay"
|
|
|
-# "ADC 4 Delay"
|
|
|
-# All of the description text entries in epics_log_entry_pvs, see above
|
|
|
-# NOTE: These entries have to match the aforementioned strings exactly
|
|
|
+error = False
|
|
|
|
|
|
-default_log_entries = [
|
|
|
- "Number of Orbits",
|
|
|
- "Number of Skipped Orbits",
|
|
|
- "Number of Acquisitions",
|
|
|
- "Time between Acquisitions",
|
|
|
- "Fill Number",
|
|
|
- "Beam Energy (GeV)",
|
|
|
- "Beam Current (mA)"
|
|
|
-]
|
|
|
+try:
|
|
|
+ for conf in Machine_conf:
|
|
|
+ if config.has_option("Machine", conf):
|
|
|
+ globals()[conf] = ast.literal_eval(config.get('Machine', conf))
|
|
|
+ else:
|
|
|
+ print "Using default configuration value for " + conf
|
|
|
+ globals()[conf] = ast.literal_eval(defaultConfig.get("Machine", conf))
|
|
|
+ for conf in Ui_conf:
|
|
|
+ if config.has_option("Ui", conf):
|
|
|
+ globals()[conf] = ast.literal_eval(config.get('Ui', conf))
|
|
|
+ else:
|
|
|
+ globals()[conf] = ast.literal_eval(defaultConfig.get("Ui", conf))
|
|
|
+ print "Using default configuration value for " + conf
|
|
|
+ for conf in Logging_conf:
|
|
|
+ if config.has_option("Logging", conf):
|
|
|
+ globals()[conf] = ast.literal_eval(config.get('Logging', conf))
|
|
|
+ else:
|
|
|
+ globals()[conf] = ast.literal_eval(defaultConfig.get("Logging", conf))
|
|
|
+ print "Using default configuration value for " + conf
|
|
|
|
|
|
-# ------------[ Machine Settings ]-----------
|
|
|
-# Bunches per turn of accelerator (integer value)
|
|
|
-bunches_per_turn = 184
|
|
|
-# Save headerinformation in file (bool value)
|
|
|
-save_header = True
|
|
|
-# Revolution time (double value)
|
|
|
-tRev =3.6825476109875985e-07
|
|
|
+ if config.has_option("Logging", "epics_log_entry_pvs"):
|
|
|
+ globals()["epics_log_entry_pvs"] = ast.literal_eval(config.get('Logging', "epics_log_entry_pvs"))
|
|
|
+ else:
|
|
|
+ globals()["epics_log_entry_pvs"] = ast.literal_eval(defaultConfig.get('Logging', "epics_log_entry_pvs"))
|
|
|
+ print "Using default configuration value for epics_log_entry_pvs"
|
|
|
|
|
|
-# -------------------------------------------
|
|
|
-# ------------[ Look and Feel ]--------------
|
|
|
-# -------------------------------------------
|
|
|
+ if config.has_option("Logging", "default_log_entries"):
|
|
|
+ globals()["default_log_entries"] = ast.literal_eval(config.get('Logging', "default_log_entries"))
|
|
|
+ else:
|
|
|
+ globals()["default_log_entries"] = ast.literal_eval(defaultConfig.get('Logging', "default_log_entries"))
|
|
|
+ print "Using default configuration value for default_log_entries"
|
|
|
+
|
|
|
+ # -----[ Do non standard config options ]------------
|
|
|
+ if config.has_section('Misc'):
|
|
|
+ for conf, val in config.items("Misc"):
|
|
|
+ globals()[conf] = ast.literal_eval(val)
|
|
|
+
|
|
|
+ for conf, val in defaultConfig.items("Misc"):
|
|
|
+ if not conf in globals().keys():
|
|
|
+ globals()[conf] = ast.literal_eval(val)
|
|
|
+
|
|
|
+except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e:
|
|
|
+ error = True
|
|
|
+ print "There was an error parsing configuration " + str(e)
|
|
|
|
|
|
-# ------------[ Icons ]----------------------
|
|
|
-# these are locations for icons used throughout the gui
|
|
|
-newPlotLiveIcon= "icons/graph.svg"
|
|
|
-newPlotDataIcon= "icons/folder.svg"
|
|
|
-timingIcon = "icons/clock.svg"
|
|
|
-singleReadIcon = "icons/project.svg"
|
|
|
-acquireSettingsIcon = "icons/wrench.svg"
|
|
|
-startIcon = "icons/media-play-black.svg"
|
|
|
-stopIcon = "icons/media-stop.svg"
|
|
|
-logIcon = "icons/clipboard.svg"
|
|
|
-logCommentIcon = "icons/clipboard_comm.svg"
|
|
|
-guiIcon = "icons/KCG_Logo_r.png"
|
|
|
-# -----------[ End Icons ]-------------------
|
|
|
-# Style:
|
|
|
-# possible values:
|
|
|
-# Whatever you want (means default Qt Style)
|
|
|
-# blue - Blue style, has some bugs
|
|
|
-# style = 'blue'
|
|
|
-style = 'default'
|
|
|
-# -------------------------------------------
|
|
|
-# ------------[ End Look and Feel ]--------------
|
|
|
-# -------------------------------------------
|