mx-bluesky 1.2.0__py3-none-any.whl → 1.4.1a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. mx_bluesky/__init__.py +8 -3
  2. mx_bluesky/__main__.py +12 -7
  3. mx_bluesky/_version.py +2 -2
  4. mx_bluesky/beamlines/i04/callbacks/murko_callback.py +14 -4
  5. mx_bluesky/beamlines/i04/thawing_plan.py +49 -11
  6. mx_bluesky/beamlines/i24/serial/__init__.py +3 -0
  7. mx_bluesky/beamlines/i24/serial/dcid.py +19 -21
  8. mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +69 -91
  9. mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +2 -5
  10. mx_bluesky/beamlines/i24/serial/fixed_target/ft_utils.py +0 -1
  11. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +111 -143
  12. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +141 -222
  13. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +7 -216
  14. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +18 -17
  15. mx_bluesky/beamlines/i24/serial/log.py +58 -49
  16. mx_bluesky/beamlines/i24/serial/parameters/constants.py +0 -1
  17. mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +3 -3
  18. mx_bluesky/beamlines/i24/serial/run_extruder.sh +30 -5
  19. mx_bluesky/beamlines/i24/serial/run_fixed_target.sh +30 -5
  20. mx_bluesky/beamlines/i24/serial/run_serial.py +24 -8
  21. mx_bluesky/beamlines/i24/serial/setup_beamline/ca.py +0 -2
  22. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +79 -81
  23. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +9 -20
  24. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +26 -28
  25. mx_bluesky/beamlines/i24/serial/write_nexus.py +11 -11
  26. mx_bluesky/common/__init__.py +0 -0
  27. mx_bluesky/common/device_setup_plans/read_hardware_for_setup.py +14 -0
  28. mx_bluesky/common/external_interaction/config_server.py +46 -0
  29. mx_bluesky/common/parameters/components.py +258 -0
  30. mx_bluesky/common/parameters/constants.py +138 -0
  31. mx_bluesky/common/parameters/gridscan.py +94 -0
  32. mx_bluesky/common/parameters/robot_load.py +16 -0
  33. mx_bluesky/common/plans/__init__.py +1 -0
  34. mx_bluesky/common/plans/do_fgs.py +121 -0
  35. mx_bluesky/common/utils/log.py +118 -0
  36. mx_bluesky/{hyperion → common/utils}/tracing.py +2 -2
  37. mx_bluesky/hyperion/__main__.py +13 -10
  38. mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +31 -26
  39. mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +6 -12
  40. mx_bluesky/hyperion/device_setup_plans/setup_oav.py +6 -12
  41. mx_bluesky/hyperion/device_setup_plans/setup_panda.py +5 -6
  42. mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +49 -18
  43. mx_bluesky/hyperion/device_setup_plans/smargon.py +6 -6
  44. mx_bluesky/hyperion/device_setup_plans/utils.py +2 -2
  45. mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +4 -4
  46. mx_bluesky/hyperion/experiment_plans/__init__.py +4 -0
  47. mx_bluesky/hyperion/experiment_plans/change_aperture_then_move_plan.py +83 -0
  48. mx_bluesky/hyperion/experiment_plans/common/xrc_result.py +47 -0
  49. mx_bluesky/hyperion/experiment_plans/experiment_registry.py +9 -9
  50. mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +145 -161
  51. mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +56 -22
  52. mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +52 -10
  53. mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +21 -20
  54. mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +11 -14
  55. mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +2 -2
  56. mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +40 -21
  57. mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +19 -19
  58. mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +21 -21
  59. mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +51 -13
  60. mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +24 -7
  61. mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +5 -6
  62. mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +1 -2
  63. mx_bluesky/hyperion/external_interaction/callbacks/common/abstract_event.py +66 -0
  64. mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +1 -1
  65. mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +30 -25
  66. mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +29 -12
  67. mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +1 -1
  68. mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +1 -1
  69. mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +7 -4
  70. mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +5 -3
  71. mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +28 -20
  72. mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/nexus_callback.py +5 -4
  73. mx_bluesky/hyperion/external_interaction/config_server.py +11 -28
  74. mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +1 -1
  75. mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +1 -1
  76. mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +2 -2
  77. mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +1 -1
  78. mx_bluesky/hyperion/log.py +0 -84
  79. mx_bluesky/hyperion/parameters/components.py +4 -251
  80. mx_bluesky/hyperion/parameters/constants.py +22 -119
  81. mx_bluesky/hyperion/parameters/gridscan.py +35 -74
  82. mx_bluesky/hyperion/parameters/load_centre_collect.py +16 -11
  83. mx_bluesky/hyperion/parameters/rotation.py +23 -10
  84. mx_bluesky/hyperion/utils/utils.py +17 -0
  85. mx_bluesky/hyperion/utils/validation.py +5 -6
  86. {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/METADATA +36 -33
  87. {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/RECORD +91 -81
  88. {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/WHEEL +1 -1
  89. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +0 -161
  90. mx_bluesky/example.py +0 -19
  91. mx_bluesky/hyperion/parameters/robot_load.py +0 -16
  92. {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/LICENSE +0 -0
  93. {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/entry_points.txt +0 -0
  94. {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/top_level.txt +0 -0
@@ -4,9 +4,7 @@ This version changed to python3 March2020 by RLO
4
4
  """
5
5
 
6
6
  import json
7
- import logging
8
7
  import re
9
- import shutil
10
8
  import sys
11
9
  import time
12
10
  from pathlib import Path
@@ -15,30 +13,22 @@ from time import sleep
15
13
 
16
14
  import bluesky.plan_stubs as bps
17
15
  import numpy as np
18
- from blueapi.core import MsgGenerator
19
- from dodal.beamlines import i24
16
+ from bluesky.utils import MsgGenerator
20
17
  from dodal.common import inject
21
18
  from dodal.devices.i24.beamstop import Beamstop, BeamstopPositions
22
19
  from dodal.devices.i24.dual_backlight import BacklightPositions, DualBacklight
23
20
  from dodal.devices.i24.i24_detector_motion import DetectorMotion
24
21
  from dodal.devices.i24.pmac import PMAC, EncReset, LaserSettings
25
22
 
26
- from mx_bluesky.beamlines.i24.serial import log
27
- from mx_bluesky.beamlines.i24.serial.fixed_target import (
28
- i24ssx_Chip_Mapping_py3v1 as mapping,
29
- )
30
- from mx_bluesky.beamlines.i24.serial.fixed_target import (
31
- i24ssx_Chip_StartUp_py3v1 as startup,
32
- )
33
- from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import (
34
- ChipType,
35
- Fiducials,
36
- MappingType,
23
+ from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import ChipType, Fiducials
24
+ from mx_bluesky.beamlines.i24.serial.log import (
25
+ SSX_LOGGER,
26
+ _read_visit_directory_from_file,
27
+ log_on_entry,
37
28
  )
38
29
  from mx_bluesky.beamlines.i24.serial.parameters import get_chip_format
39
30
  from mx_bluesky.beamlines.i24.serial.parameters.constants import (
40
31
  CS_FILES_PATH,
41
- FULLMAP_PATH,
42
32
  LITEMAP_PATH,
43
33
  PARAM_FILE_NAME,
44
34
  PARAM_FILE_PATH_FT,
@@ -49,8 +39,6 @@ from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_detector import (
49
39
  get_detector_type,
50
40
  )
51
41
 
52
- logger = logging.getLogger("I24ssx.chip_manager")
53
-
54
42
  # An approximation of the chip size for the move during fiducials alignment.
55
43
  CHIP_MOVES = {
56
44
  ChipType.Oxford: 25.40,
@@ -65,22 +53,15 @@ PUMP_REPEAT_PV = pv.me14e_gp4
65
53
  MAP_FILEPATH_PV = pv.me14e_gp5
66
54
 
67
55
 
68
- def setup_logging():
69
- # Log should now change name daily.
70
- logfile = time.strftime("i24fixedtarget_%d%B%y.log").lower()
71
- log.config(logfile)
72
-
73
-
74
- @log.log_on_entry
56
+ @log_on_entry
75
57
  def initialise_stages(
76
58
  pmac: PMAC = inject("pmac"),
77
59
  ) -> MsgGenerator:
78
60
  """Initialise the portable stages PVs, usually used only once right after setting \
79
61
  up the stages either after use at different facility.
80
62
  """
81
- setup_logging()
82
63
  group = "initialise_stages"
83
- logger.info("Setting velocity, acceleration and limits for stages")
64
+ SSX_LOGGER.info("Setting velocity, acceleration and limits for stages")
84
65
 
85
66
  yield from bps.abs_set(pmac.x.velocity, 20, group=group)
86
67
  yield from bps.abs_set(pmac.y.velocity, 20, group=group)
@@ -110,18 +91,21 @@ def initialise_stages(
110
91
  caput(pv.pilat_cbftemplate, 0)
111
92
 
112
93
  sleep(0.1)
113
- logger.info("Clearing General Purpose PVs 1-120")
94
+ SSX_LOGGER.info("Clearing General Purpose PVs 1-120")
114
95
  for i in range(4, 120):
96
+ if i == 100:
97
+ # Do not clear visit PV
98
+ continue
115
99
  pvar = "ME14E-MO-IOC-01:GP" + str(i)
116
100
  caput(pvar, 0)
117
101
  sys.stdout.write(".")
118
102
  sys.stdout.flush()
119
103
 
120
- logger.info("Initialisation of the stages complete")
104
+ SSX_LOGGER.info("Initialisation of the stages complete")
121
105
  yield from bps.wait(group=group)
122
106
 
123
107
 
124
- @log.log_on_entry
108
+ @log_on_entry
125
109
  def write_parameter_file(
126
110
  detector_stage: DetectorMotion,
127
111
  ) -> MsgGenerator:
@@ -129,7 +113,9 @@ def write_parameter_file(
129
113
  # Create directory if it doesn't yet exist.
130
114
  param_path.mkdir(parents=True, exist_ok=True)
131
115
 
132
- logger.info(f"Writing Parameter File: {(param_path / PARAM_FILE_NAME).as_posix()}")
116
+ SSX_LOGGER.info(
117
+ f"Writing Parameter File: {(param_path / PARAM_FILE_NAME).as_posix()}"
118
+ )
133
119
 
134
120
  filename = caget(pv.me14e_chip_name)
135
121
  det_type = yield from get_detector_type(detector_stage)
@@ -146,12 +132,12 @@ def write_parameter_file(
146
132
  # Note for future reference. Appending underscore causes more hassle and
147
133
  # high probability of users accidentally overwriting data. Use a dash
148
134
  filename = filename + "-"
149
- logger.debug(
135
+ SSX_LOGGER.debug(
150
136
  f"Requested filename ends in a number. Appended dash: {filename}"
151
137
  )
152
138
 
153
139
  params_dict = {
154
- "visit": log._read_visit_directory_from_file().as_posix(), # noqa
140
+ "visit": _read_visit_directory_from_file().as_posix(), # noqa
155
141
  "directory": caget(pv.me14e_filepath),
156
142
  "filename": filename,
157
143
  "exposure_time_s": caget(pv.me14e_exptime),
@@ -172,14 +158,9 @@ def write_parameter_file(
172
158
  with open(param_path / PARAM_FILE_NAME, "w") as f:
173
159
  json.dump(params_dict, f, indent=4)
174
160
 
175
- logger.info("Information written to file \n")
176
- logger.info(pformat(params_dict))
161
+ SSX_LOGGER.info("Information written to file \n")
162
+ SSX_LOGGER.info(pformat(params_dict))
177
163
 
178
- if map_type == MappingType.Full:
179
- # This step creates some header files (.addr, .spec), containing the parameters,
180
- # that are only needed when full mapping is in use.
181
- logger.info("Full mapping in use. Running start up now.")
182
- startup.run()
183
164
  yield from bps.null()
184
165
 
185
166
 
@@ -207,13 +188,12 @@ def scrape_pvar_file(fid: str, pvar_dir: Path = PVAR_FILE_PATH):
207
188
  return block_start_list
208
189
 
209
190
 
210
- @log.log_on_entry
191
+ @log_on_entry
211
192
  def define_current_chip(
212
193
  chipid: str = "oxford",
213
194
  pmac: PMAC = inject("pmac"),
214
195
  ) -> MsgGenerator:
215
- setup_logging()
216
- logger.debug("Run load stock map for just the first block")
196
+ SSX_LOGGER.debug("Run load stock map for just the first block")
217
197
  yield from load_stock_map("Just The First Block")
218
198
  """
219
199
  Not sure what this is for:
@@ -221,43 +201,41 @@ def define_current_chip(
221
201
  caput(pv.me14e_gp2, 1)
222
202
  """
223
203
  chip_type = int(caget(CHIPTYPE_PV))
224
- logger.info(f"Chip type:{chip_type} Chipid:{chipid}")
204
+ SSX_LOGGER.info(f"Chip type:{chip_type} Chipid:{chipid}")
225
205
  if chipid == "oxford":
226
206
  caput(CHIPTYPE_PV, 0)
227
207
 
228
208
  with open(PVAR_FILE_PATH / f"{chipid}.pvar") as f:
229
- logger.info(f"Opening {chipid}.pvar")
209
+ SSX_LOGGER.info(f"Opening {chipid}.pvar")
230
210
  for line in f.readlines():
231
211
  if line.startswith("#"):
232
212
  continue
233
213
  line_from_file = line.rstrip("\n")
234
- logger.info(f"{line_from_file}")
214
+ SSX_LOGGER.info(f"{line_from_file}")
235
215
  yield from bps.abs_set(pmac.pmac_string, line_from_file)
236
216
 
237
217
 
238
- @log.log_on_entry
218
+ @log_on_entry
239
219
  def save_screen_map() -> MsgGenerator:
240
- setup_logging()
241
220
  litemap_path: Path = LITEMAP_PATH
242
221
  litemap_path.mkdir(parents=True, exist_ok=True)
243
222
 
244
- logger.info(f"Saving {litemap_path.as_posix()} currentchip.map")
223
+ SSX_LOGGER.info(f"Saving {litemap_path.as_posix()} currentchip.map")
245
224
  with open(litemap_path / "currentchip.map", "w") as f:
246
- logger.debug("Printing only blocks with block_val == 1")
225
+ SSX_LOGGER.debug("Printing only blocks with block_val == 1")
247
226
  for x in range(1, 82):
248
- block_str = "ME14E-MO-IOC-01:GP%i" % (x + 10)
227
+ block_str = f"ME14E-MO-IOC-01:GP{x + 10:d}"
249
228
  block_val = int(caget(block_str))
250
229
  if block_val == 1:
251
- logger.info("%s %d" % (block_str, block_val))
252
- line = "%02dstatus P3%02d1 \t%s\n" % (x, x, block_val)
230
+ SSX_LOGGER.info(f"{block_str} {block_val:d}")
231
+ line = f"{x:02d}status P3{x:02d}1 \t{block_val}\n"
253
232
  f.write(line)
254
233
  yield from bps.null()
255
234
 
256
235
 
257
- @log.log_on_entry
236
+ @log_on_entry
258
237
  def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
259
- setup_logging()
260
- logger.info("Uploading Parameters for Oxford Chip to the GeoBrick")
238
+ SSX_LOGGER.info("Uploading Parameters for Oxford Chip to the GeoBrick")
261
239
  caput(CHIPTYPE_PV, 0)
262
240
  width = 8
263
241
 
@@ -266,8 +244,8 @@ def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
266
244
  raise FileNotFoundError(f"The file {map_file} has not yet been created")
267
245
 
268
246
  with open(map_file) as f:
269
- logger.info(f"Chipid {ChipType.Oxford}")
270
- logger.info(f"width {width}")
247
+ SSX_LOGGER.info(f"Chipid {ChipType.Oxford}")
248
+ SSX_LOGGER.info(f"width {width}")
271
249
  x = 1
272
250
  for line in f.readlines()[: width**2]:
273
251
  cols = line.split()
@@ -288,41 +266,16 @@ def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
288
266
  yield from bps.abs_set(pmac.pmac_string, s, wait=True)
289
267
  sleep(0.02)
290
268
 
291
- logger.warning("Automatic Setting Mapping Type to Lite has been disabled")
292
- logger.debug("Upload parameters done.")
293
- yield from bps.null()
294
-
295
-
296
- @log.log_on_entry
297
- def upload_full(pmac: PMAC | None = None) -> MsgGenerator:
298
- setup_logging()
299
- if not pmac:
300
- pmac = i24.pmac()
301
-
302
- map_file: Path = FULLMAP_PATH / "currentchip.full"
303
- if not map_file.exists():
304
- raise FileNotFoundError(f"The file {map_file} has not yet been created")
305
- with open(map_file) as fh:
306
- f = fh.readlines()
307
-
308
- for _i in range(len(f) // 2):
309
- pmac_list = []
310
- for _j in range(2):
311
- pmac_list.append(f.pop(0).rstrip("\n"))
312
- writeline = " ".join(pmac_list)
313
- logger.info(f"{writeline}")
314
- yield from bps.abs_set(pmac.pmac_string, writeline, wait=True)
315
- yield from bps.sleep(0.02)
316
- logger.debug("Upload fullmap done")
269
+ SSX_LOGGER.warning("Automatic Setting Mapping Type to Lite has been disabled")
270
+ SSX_LOGGER.debug("Upload parameters done.")
317
271
  yield from bps.null()
318
272
 
319
273
 
320
- @log.log_on_entry
274
+ @log_on_entry
321
275
  def load_stock_map(map_choice: str = "clear") -> MsgGenerator:
322
276
  # TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/122
323
- setup_logging()
324
- logger.info("Adjusting Lite Map EDM Screen")
325
- logger.debug("Please wait, adjusting lite map")
277
+ SSX_LOGGER.info("Adjusting Lite Map EDM Screen")
278
+ SSX_LOGGER.debug("Please wait, adjusting lite map")
326
279
  #
327
280
  r33 = [19, 18, 17, 26, 31, 32, 33, 24, 25]
328
281
  r55 = [9, 10, 11, 12, 13, 16, 27, 30, 41, 40, 39, 38, 37, 34, 23, 20] + r33
@@ -505,25 +458,24 @@ def load_stock_map(map_choice: str = "clear") -> MsgGenerator:
505
458
  map_dict["half1"] = half1
506
459
  map_dict["half2"] = half2
507
460
 
508
- logger.info("Clearing GP 10-74") # Actually 11-44
461
+ SSX_LOGGER.info("Clearing GP 10-74") # Actually 11-44
509
462
  for i in range(1, 65):
510
463
  pvar = "ME14E-MO-IOC-01:GP" + str(i + 10)
511
464
  caput(pvar, 0)
512
465
  sys.stdout.write(".")
513
466
  sys.stdout.flush()
514
- logger.info("Map cleared")
515
- logger.info(f"Loading Map Choice {map_choice}")
467
+ SSX_LOGGER.info("Map cleared")
468
+ SSX_LOGGER.info(f"Loading Map Choice {map_choice}")
516
469
  for i in map_dict[map_choice]:
517
470
  pvar = "ME14E-MO-IOC-01:GP" + str(i + 10)
518
471
  caput(pvar, 1)
519
- logger.debug("Load stock map done.")
472
+ SSX_LOGGER.debug("Load stock map done.")
520
473
  yield from bps.null()
521
474
 
522
475
 
523
- @log.log_on_entry
476
+ @log_on_entry
524
477
  def load_lite_map() -> MsgGenerator:
525
- setup_logging()
526
- logger.debug("Run load stock map with 'clear' setting.")
478
+ SSX_LOGGER.debug("Run load stock map with 'clear' setting.")
527
479
  yield from load_stock_map("clear")
528
480
  # fmt: off
529
481
  # Oxford_block_dict is wrong (columns and rows need to flip) added in script below to generate it automatically however kept this for backwards compatiability/reference
@@ -540,7 +492,7 @@ def load_lite_map() -> MsgGenerator:
540
492
  # fmt: on
541
493
  chip_type = int(caget(CHIPTYPE_PV))
542
494
  if chip_type in [ChipType.Oxford, ChipType.OxfordInner]:
543
- logger.info("Oxford Block Order")
495
+ SSX_LOGGER.info("Oxford Block Order")
544
496
  rows = ["A", "B", "C", "D", "E", "F", "G", "H"]
545
497
  columns = list(range(1, 10))
546
498
  btn_names = {}
@@ -559,20 +511,20 @@ def load_lite_map() -> MsgGenerator:
559
511
  elif flip is True:
560
512
  z = 8 - (y + 1)
561
513
  else:
562
- logger.warning("Problem in Chip Grid Creation")
514
+ SSX_LOGGER.warning("Problem in Chip Grid Creation")
563
515
  break
564
516
  button_name = str(row) + str(column)
565
517
  lab_num = x * 8 + z
566
- label = "%02.d" % (lab_num + 1)
518
+ label = f"{lab_num + 1:02d}"
567
519
  btn_names[button_name] = label
568
520
  block_dict = btn_names
569
521
  else:
570
522
  raise ValueError(f"{chip_type=} unrecognised")
571
523
 
572
524
  litemap_fid = f"{caget(MAP_FILEPATH_PV)}.lite"
573
- logger.info("Please wait, loading LITE map")
574
- logger.debug("Loading Lite Map")
575
- logger.info("Opening %s" % (LITEMAP_PATH / litemap_fid))
525
+ SSX_LOGGER.info("Please wait, loading LITE map")
526
+ SSX_LOGGER.debug("Loading Lite Map")
527
+ SSX_LOGGER.info("Opening %s" % (LITEMAP_PATH / litemap_fid))
576
528
  with open(LITEMAP_PATH / litemap_fid) as fh:
577
529
  f = fh.readlines()
578
530
  for line in f:
@@ -581,57 +533,37 @@ def load_lite_map() -> MsgGenerator:
581
533
  yesno = entry[1]
582
534
  block_num = block_dict[block_name]
583
535
  pvar = "ME14E-MO-IOC-01:GP" + str(int(block_num) + 10)
584
- logger.info(f"Block: {block_name} \tScanned: {yesno} \tPVAR: {pvar}")
585
- logger.debug("Load lite map done")
586
- yield from bps.null()
587
-
588
-
589
- @log.log_on_entry
590
- def load_full_map() -> MsgGenerator:
591
- setup_logging()
592
- params = startup.read_parameter_file()
593
-
594
- fullmap_fid = FULLMAP_PATH / f"{caget(MAP_FILEPATH_PV)}.spec"
595
- logger.info(f"Opening {fullmap_fid}")
596
- mapping.plot_file(fullmap_fid, params.chip.chip_type.value)
597
- mapping.convert_chip_to_hex(fullmap_fid, params.chip.chip_type.value)
598
- shutil.copy2(fullmap_fid.with_suffix(".full"), FULLMAP_PATH / "currentchip.full")
599
- logger.info(
600
- "Copying {} to {}".format(
601
- fullmap_fid.with_suffix(".full"), FULLMAP_PATH / "currentchip.full"
602
- )
603
- )
604
- logger.debug("Load full map done")
536
+ SSX_LOGGER.info(f"Block: {block_name} \tScanned: {yesno} \tPVAR: {pvar}")
537
+ SSX_LOGGER.debug("Load lite map done")
605
538
  yield from bps.null()
606
539
 
607
540
 
608
- @log.log_on_entry
541
+ @log_on_entry
609
542
  def moveto(place: str = "origin", pmac: PMAC = inject("pmac")) -> MsgGenerator:
610
- setup_logging()
611
- logger.info(f"Move to: {place}")
543
+ SSX_LOGGER.info(f"Move to: {place}")
612
544
  if place == Fiducials.zero:
613
- logger.info("Chip aspecific move.")
545
+ SSX_LOGGER.info("Chip aspecific move.")
614
546
  yield from bps.trigger(pmac.to_xyz_zero)
615
547
  return
616
548
 
617
549
  chip_type = ChipType(int(caget(CHIPTYPE_PV)))
618
- logger.info(f"Chip type is {chip_type}")
550
+ SSX_LOGGER.info(f"Chip type is {chip_type}")
619
551
  if chip_type not in list(ChipType):
620
- logger.warning("Unknown chip_type move")
552
+ SSX_LOGGER.warning("Unknown chip_type move")
621
553
  return
622
554
 
623
- logger.info(f"{str(chip_type)} Move")
555
+ SSX_LOGGER.info(f"{str(chip_type)} Move")
624
556
  chip_move = CHIP_MOVES[chip_type]
625
557
 
626
558
  if place == Fiducials.origin:
627
- yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0)
559
+ yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
628
560
  if place == Fiducials.fid1:
629
- yield from bps.mv(pmac.x, chip_move, pmac.y, 0.0)
561
+ yield from bps.mv(pmac.x, chip_move, pmac.y, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
630
562
  if place == Fiducials.fid2:
631
- yield from bps.mv(pmac.x, 0.0, pmac.y, chip_move)
563
+ yield from bps.mv(pmac.x, 0.0, pmac.y, chip_move) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
632
564
 
633
565
 
634
- @log.log_on_entry
566
+ @log_on_entry
635
567
  def moveto_preset(
636
568
  place: str,
637
569
  pmac: PMAC = inject("pmac"),
@@ -639,15 +571,13 @@ def moveto_preset(
639
571
  backlight: DualBacklight = inject("backlight"),
640
572
  det_stage: DetectorMotion = inject("detector_motion"),
641
573
  ) -> MsgGenerator:
642
- setup_logging()
643
-
644
574
  # Non Chip Specific Move
645
575
  if place == "zero":
646
- logger.info(f"Moving to {place}")
576
+ SSX_LOGGER.info(f"Moving to {place}")
647
577
  yield from bps.trigger(pmac.to_xyz_zero)
648
578
 
649
579
  elif place == "load_position":
650
- logger.info("load position")
580
+ SSX_LOGGER.info("load position")
651
581
  yield from bps.abs_set(
652
582
  beamstop.pos_select, BeamstopPositions.ROBOT, group=place
653
583
  )
@@ -656,9 +586,9 @@ def moveto_preset(
656
586
  yield from bps.wait(group=place)
657
587
 
658
588
  elif place == "collect_position":
659
- logger.info("collect position")
589
+ SSX_LOGGER.info("collect position")
660
590
  caput(pv.me14e_filter, 20)
661
- yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0, pmac.z, 0.0)
591
+ yield from bps.mv(pmac.x, 0.0, pmac.y, 0.0, pmac.z, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
662
592
  yield from bps.abs_set(
663
593
  beamstop.pos_select, BeamstopPositions.DATA_COLLECTION, group=place
664
594
  )
@@ -666,53 +596,52 @@ def moveto_preset(
666
596
  yield from bps.wait(group=place)
667
597
 
668
598
  elif place == "microdrop_position":
669
- logger.info("microdrop align position")
670
- yield from bps.mv(pmac.x, 6.0, pmac.y, -7.8, pmac.z, 0.0)
599
+ SSX_LOGGER.info("microdrop align position")
600
+ yield from bps.mv(pmac.x, 6.0, pmac.y, -7.8, pmac.z, 0.0) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
671
601
 
672
602
 
673
- @log.log_on_entry
603
+ @log_on_entry
674
604
  def laser_control(laser_setting: str, pmac: PMAC = inject("pmac")) -> MsgGenerator:
675
- setup_logging()
676
- logger.info(f"Move to: {laser_setting}")
605
+ SSX_LOGGER.info(f"Move to: {laser_setting}")
677
606
  if laser_setting == "laser1on": # these are in laser edm
678
- logger.info("Laser 1 /BNC2 shutter is open")
607
+ SSX_LOGGER.info("Laser 1 /BNC2 shutter is open")
679
608
  # Use M712 = 0 if triggering on falling edge. M712 =1 if on rising edge
680
609
  # Be sure to also change laser1off
681
610
  # caput(pv.me14e_pmac_str, ' M712=0 M711=1')
682
611
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_ON, wait=True)
683
612
 
684
613
  elif laser_setting == "laser1off":
685
- logger.info("Laser 1 shutter is closed")
614
+ SSX_LOGGER.info("Laser 1 shutter is closed")
686
615
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_OFF, wait=True)
687
616
 
688
617
  elif laser_setting == "laser2on":
689
- logger.info("Laser 2 / BNC3 shutter is open")
618
+ SSX_LOGGER.info("Laser 2 / BNC3 shutter is open")
690
619
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_ON, wait=True)
691
620
 
692
621
  elif laser_setting == "laser2off":
693
- logger.info("Laser 2 shutter is closed")
622
+ SSX_LOGGER.info("Laser 2 shutter is closed")
694
623
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_OFF, wait=True)
695
624
 
696
625
  elif laser_setting == "laser1burn":
697
626
  led_burn_time = caget(pv.me14e_gp103)
698
- logger.info("Laser 1 on")
699
- logger.info(f"Burn time is {led_burn_time} s")
627
+ SSX_LOGGER.info("Laser 1 on")
628
+ SSX_LOGGER.info(f"Burn time is {led_burn_time} s")
700
629
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_ON, wait=True)
701
- yield from bps.sleep(led_burn_time)
702
- logger.info("Laser 1 off")
630
+ yield from bps.sleep(float(led_burn_time))
631
+ SSX_LOGGER.info("Laser 1 off")
703
632
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_1_OFF, wait=True)
704
633
 
705
634
  elif laser_setting == "laser2burn":
706
635
  led_burn_time = caget(pv.me14e_gp109)
707
- logger.info("Laser 2 on")
708
- logger.info(f"burntime {led_burn_time} s")
636
+ SSX_LOGGER.info("Laser 2 on")
637
+ SSX_LOGGER.info(f"burntime {led_burn_time} s")
709
638
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_ON, wait=True)
710
- yield from bps.sleep(led_burn_time)
711
- logger.info("Laser 2 off")
639
+ yield from bps.sleep(float(led_burn_time))
640
+ SSX_LOGGER.info("Laser 2 off")
712
641
  yield from bps.abs_set(pmac.laser, LaserSettings.LASER_2_OFF, wait=True)
713
642
 
714
643
 
715
- @log.log_on_entry
644
+ @log_on_entry
716
645
  def scrape_mtr_directions(motor_file_path: Path = CS_FILES_PATH):
717
646
  with open(motor_file_path / "motor_direction.txt") as f:
718
647
  lines = f.readlines()
@@ -726,13 +655,12 @@ def scrape_mtr_directions(motor_file_path: Path = CS_FILES_PATH):
726
655
  mtr3_dir = float(line.split("=")[1])
727
656
  else:
728
657
  continue
729
- logger.debug(f"mt1_dir {mtr1_dir} mtr2_dir {mtr2_dir} mtr3_dir {mtr3_dir}")
658
+ SSX_LOGGER.debug(f"mt1_dir {mtr1_dir} mtr2_dir {mtr2_dir} mtr3_dir {mtr3_dir}")
730
659
  return mtr1_dir, mtr2_dir, mtr3_dir
731
660
 
732
661
 
733
- @log.log_on_entry
662
+ @log_on_entry
734
663
  def fiducial(point: int = 1, pmac: PMAC = inject("pmac")) -> MsgGenerator:
735
- setup_logging()
736
664
  scale = 10000.0 # noqa: F841
737
665
 
738
666
  mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions(CS_FILES_PATH)
@@ -743,18 +671,18 @@ def fiducial(point: int = 1, pmac: PMAC = inject("pmac")) -> MsgGenerator:
743
671
 
744
672
  output_param_path = PARAM_FILE_PATH_FT
745
673
  output_param_path.mkdir(parents=True, exist_ok=True)
746
- logger.info(f"Writing Fiducial File {output_param_path}/fiducial_{point}.txt")
747
- logger.info("MTR\tRBV\tRAW\tCorr\tf_value")
748
- logger.info("MTR1\t%1.4f\t%i" % (rbv_1, mtr1_dir))
749
- logger.info("MTR2\t%1.4f\t%i" % (rbv_2, mtr2_dir))
750
- logger.info("MTR3\t%1.4f\t%i" % (rbv_3, mtr3_dir))
674
+ SSX_LOGGER.info(f"Writing Fiducial File {output_param_path}/fiducial_{point}.txt")
675
+ SSX_LOGGER.info("MTR\tRBV\tRAW\tCorr\tf_value")
676
+ SSX_LOGGER.info(f"MTR1\t{rbv_1:1.4f}\t{mtr1_dir:d}")
677
+ SSX_LOGGER.info(f"MTR2\t{rbv_2:1.4f}\t{mtr2_dir:d}")
678
+ SSX_LOGGER.info(f"MTR3\t{rbv_3:1.4f}\t{mtr3_dir:d}")
751
679
 
752
680
  with open(output_param_path / f"fiducial_{point}.txt", "w") as f:
753
681
  f.write("MTR\tRBV\tCorr\n")
754
- f.write("MTR1\t%1.4f\t%i\n" % (rbv_1, mtr1_dir))
755
- f.write("MTR2\t%1.4f\t%i\n" % (rbv_2, mtr2_dir))
756
- f.write("MTR3\t%1.4f\t%i" % (rbv_3, mtr3_dir))
757
- logger.info(f"Fiducial {point} set.")
682
+ f.write(f"MTR1\t{rbv_1:1.4f}\t{mtr1_dir:d}\n")
683
+ f.write(f"MTR2\t{rbv_2:1.4f}\t{mtr2_dir:d}\n")
684
+ f.write(f"MTR3\t{rbv_3:1.4f}\t{mtr3_dir:d}")
685
+ SSX_LOGGER.info(f"Fiducial {point} set.")
758
686
  yield from bps.null()
759
687
 
760
688
 
@@ -769,7 +697,7 @@ def scrape_mtr_fiducials(
769
697
  return f_x, f_y, f_z
770
698
 
771
699
 
772
- @log.log_on_entry
700
+ @log_on_entry
773
701
  def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
774
702
  """
775
703
  Coordinate system.
@@ -800,28 +728,27 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
800
728
  This should be measured in situ prior to expriment, ie. measure by hand using
801
729
  opposite and adjacent RBV after calibration of scale factors.
802
730
  """
803
- setup_logging()
804
731
  chip_type = int(caget(CHIPTYPE_PV))
805
732
  fiducial_dict = {}
806
733
  fiducial_dict[0] = [25.400, 25.400]
807
734
  fiducial_dict[1] = [24.600, 24.600]
808
735
  fiducial_dict[2] = [25.400, 25.400]
809
736
  fiducial_dict[3] = [18.25, 18.25]
810
- logger.info(f"Chip type is {chip_type} with size {fiducial_dict[chip_type]}")
737
+ SSX_LOGGER.info(f"Chip type is {chip_type} with size {fiducial_dict[chip_type]}")
811
738
 
812
739
  mtr1_dir, mtr2_dir, mtr3_dir = scrape_mtr_directions()
813
740
  f1_x, f1_y, f1_z = scrape_mtr_fiducials(1)
814
741
  f2_x, f2_y, f2_z = scrape_mtr_fiducials(2)
815
- logger.info(f"mtr1 direction: {mtr1_dir}")
816
- logger.info(f"mtr2 direction: {mtr2_dir}")
817
- logger.info(f"mtr3 direction: {mtr3_dir}")
742
+ SSX_LOGGER.info(f"mtr1 direction: {mtr1_dir}")
743
+ SSX_LOGGER.info(f"mtr2 direction: {mtr2_dir}")
744
+ SSX_LOGGER.info(f"mtr3 direction: {mtr3_dir}")
818
745
 
819
746
  # Scale parameters saved in json file
820
747
  try:
821
748
  with open(CS_FILES_PATH / "cs_maker.json") as fh:
822
749
  cs_info = json.load(fh)
823
750
  except json.JSONDecodeError:
824
- logger.error("Invalid JSON file.")
751
+ SSX_LOGGER.error("Invalid JSON file.")
825
752
  raise
826
753
 
827
754
  try:
@@ -837,7 +764,7 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
837
764
  int(cs_info["Sz_dir"]),
838
765
  )
839
766
  except KeyError:
840
- logger.error("Wrong or missing key in the cs json file.")
767
+ SSX_LOGGER.error("Wrong or missing key in the cs json file.")
841
768
  raise
842
769
 
843
770
  def check_dir(val):
@@ -854,21 +781,21 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
854
781
  Sz2 = f2_x / fiducial_dict[chip_type][1]
855
782
  Sz = Sz_dir * ((Sz1 + Sz2) / 2)
856
783
  Cz = np.sqrt(1 - Sz**2)
857
- logger.info(f"Sz1 , {Sz1:1.4f}, {np.degrees(np.arcsin(Sz1)):1.4f}")
858
- logger.info(f"Sz2 , {Sz2:1.4f}, {np.degrees(np.arcsin(Sz2)):1.4f}")
859
- logger.info(f"Sz , {Sz:1.4f}, {np.degrees(np.arcsin(Sz)):1.4f}")
860
- logger.info(f"Cz , {Cz:1.4f}, {np.degrees(np.arcsin(Cz)):1.4f}")
784
+ SSX_LOGGER.info(f"Sz1 , {Sz1:1.4f}, {np.degrees(np.arcsin(Sz1)):1.4f}")
785
+ SSX_LOGGER.info(f"Sz2 , {Sz2:1.4f}, {np.degrees(np.arcsin(Sz2)):1.4f}")
786
+ SSX_LOGGER.info(f"Sz , {Sz:1.4f}, {np.degrees(np.arcsin(Sz)):1.4f}")
787
+ SSX_LOGGER.info(f"Cz , {Cz:1.4f}, {np.degrees(np.arcsin(Cz)):1.4f}")
861
788
  # Rotation Around Y
862
789
  Sy = Sy_dir * f1_z / fiducial_dict[chip_type][0]
863
790
  Cy = np.sqrt(1 - Sy**2)
864
- logger.info(f"Sy , {Sy:1.4f}, {np.degrees(np.arcsin(Sy)):1.4f}")
865
- logger.info(f"Cy , {Cy:1.4f}, {np.degrees(np.arcsin(Cy)):1.4f}")
791
+ SSX_LOGGER.info(f"Sy , {Sy:1.4f}, {np.degrees(np.arcsin(Sy)):1.4f}")
792
+ SSX_LOGGER.info(f"Cy , {Cy:1.4f}, {np.degrees(np.arcsin(Cy)):1.4f}")
866
793
  # Rotation Around X
867
794
  # If stages upsidedown (I24) change sign of Sx
868
795
  Sx = Sx_dir * f2_z / fiducial_dict[chip_type][1]
869
796
  Cx = np.sqrt(1 - Sx**2)
870
- logger.info(f"Sx , {Sx:1.4f}, {np.degrees(np.arcsin(Sx)):1.4f}")
871
- logger.info(f"Cx , {Cx:1.4f}, {np.degrees(np.arcsin(Cx)):1.4f}")
797
+ SSX_LOGGER.info(f"Sx , {Sx:1.4f}, {np.degrees(np.arcsin(Sx)):1.4f}")
798
+ SSX_LOGGER.info(f"Cx , {Cx:1.4f}, {np.degrees(np.arcsin(Cx)):1.4f}")
872
799
 
873
800
  x1factor = mtr1_dir * scalex * (Cy * Cz)
874
801
  y1factor = mtr2_dir * scaley * (-1.0 * Cx * Sz)
@@ -882,15 +809,15 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
882
809
  y3factor = mtr2_dir * scaley * ((Cx * Sy * Sz) + (Sx * Cz))
883
810
  z3factor = mtr3_dir * scalez * (Cx * Cy)
884
811
 
885
- logger.info(f"Skew being used is: {skew:1.4f}")
812
+ SSX_LOGGER.info(f"Skew being used is: {skew:1.4f}")
886
813
  s1 = np.degrees(np.arcsin(Sz1))
887
814
  s2 = np.degrees(np.arcsin(Sz2))
888
815
  rot = np.degrees(np.arcsin((Sz1 + Sz2) / 2))
889
816
  calc_skew = (s1 - rot) - (s2 - rot)
890
- logger.info(f"s1:{s1:1.4f} s2:{s2:1.4f} rot:{rot:1.4f}")
891
- logger.info(f"Calculated rotation from current fiducials is: {rot:1.4f}")
892
- logger.info(f"Calculated Skew from current fiducials is: {calc_skew:1.4f}")
893
- logger.info("Calculated Skew has been known to have the wrong sign")
817
+ SSX_LOGGER.info(f"s1:{s1:1.4f} s2:{s2:1.4f} rot:{rot:1.4f}")
818
+ SSX_LOGGER.info(f"Calculated rotation from current fiducials is: {rot:1.4f}")
819
+ SSX_LOGGER.info(f"Calculated Skew from current fiducials is: {calc_skew:1.4f}")
820
+ SSX_LOGGER.info("Calculated Skew has been known to have the wrong sign")
894
821
 
895
822
  sinD = np.sin((skew / 2) * (np.pi / 180))
896
823
  cosD = np.cos((skew / 2) * (np.pi / 180))
@@ -902,44 +829,43 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
902
829
  cs1 = f"#1->{new_x1factor:+1.3f}X{new_y1factor:+1.3f}Y{z1factor:+1.3f}Z"
903
830
  cs2 = f"#2->{new_x2factor:+1.3f}X{new_y2factor:+1.3f}Y{z2factor:+1.3f}Z"
904
831
  cs3 = f"#3->{x3factor:+1.3f}X{y3factor:+1.3f}Y{z3factor:+1.3f}Z"
905
- logger.info(f"PMAC strings. \ncs1: {cs1} \ncs2: {cs2}cs3: {cs3}")
906
- logger.info(
832
+ SSX_LOGGER.info(f"PMAC strings. \ncs1: {cs1} \ncs2: {cs2}cs3: {cs3}")
833
+ SSX_LOGGER.info(
907
834
  """These next values should be 1.
908
835
  This is the sum of the squares of the factors divided by their scale."""
909
836
  )
910
837
  sqfact1 = np.sqrt(x1factor**2 + y1factor**2 + z1factor**2) / scalex
911
838
  sqfact2 = np.sqrt(x2factor**2 + y2factor**2 + z2factor**2) / scaley
912
839
  sqfact3 = np.sqrt(x3factor**2 + y3factor**2 + z3factor**2) / scalez
913
- logger.info(f"{sqfact1:1.4f} \n {sqfact2:1.4f} \n {sqfact3:1.4f}")
914
- logger.debug("Long wait, please be patient")
840
+ SSX_LOGGER.info(f"{sqfact1:1.4f} \n {sqfact2:1.4f} \n {sqfact3:1.4f}")
841
+ SSX_LOGGER.debug("Long wait, please be patient")
915
842
  yield from bps.trigger(pmac.to_xyz_zero)
916
843
  sleep(2.5)
917
844
  yield from set_pmac_strings_for_cs(pmac, {"cs1": cs1, "cs2": cs2, "cs3": cs3})
918
845
  yield from bps.trigger(pmac.to_xyz_zero)
919
- sleep(0.1)
846
+ sleep(2.5)
920
847
  yield from bps.trigger(pmac.home, wait=True)
921
- sleep(0.1)
922
- logger.debug(f"Chip_type is {chip_type}")
848
+ sleep(2.5)
849
+ SSX_LOGGER.debug(f"Chip_type is {chip_type}")
923
850
  if chip_type == 0:
924
851
  yield from bps.abs_set(pmac.pmac_string, "!x0.4y0.4", wait=True)
925
- sleep(0.1)
852
+ sleep(2.5)
926
853
  yield from bps.trigger(pmac.home, wait=True)
927
854
  else:
928
855
  yield from bps.trigger(pmac.home, wait=True)
929
- logger.debug("CSmaker done.")
856
+ SSX_LOGGER.debug("CSmaker done.")
930
857
  yield from bps.null()
931
858
 
932
859
 
933
860
  def cs_reset(pmac: PMAC = inject("pmac")) -> MsgGenerator:
934
861
  """Used to clear CS when using Custom Chip"""
935
- setup_logging()
936
862
  cs1 = "#1->10000X+0Y+0Z"
937
863
  cs2 = "#2->+0X-10000Y+0Z"
938
864
  cs3 = "#3->0X+0Y-10000Z"
939
865
  strg = "\n".join([cs1, cs2, cs3])
940
866
  print(strg)
941
867
  yield from set_pmac_strings_for_cs(pmac, {"cs1": cs1, "cs2": cs2, "cs3": cs3})
942
- logger.debug("CSreset Done")
868
+ SSX_LOGGER.debug("CSreset Done")
943
869
  yield from bps.null()
944
870
 
945
871
 
@@ -964,16 +890,15 @@ def set_pmac_strings_for_cs(pmac: PMAC, cs_str: dict):
964
890
  yield from bps.abs_set(pmac.pmac_string, cs_str["cs3"], wait=True)
965
891
 
966
892
 
967
- @log.log_on_entry
893
+ @log_on_entry
968
894
  def pumpprobe_calc() -> MsgGenerator:
969
895
  # TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/122
970
- setup_logging()
971
- logger.info("Calculate and show exposure and dwell time for each option.")
896
+ SSX_LOGGER.info("Calculate and show exposure and dwell time for each option.")
972
897
  exptime = float(caget(pv.me14e_exptime))
973
898
  pumpexptime = float(caget(pv.me14e_gp103))
974
899
  movetime = 0.008
975
- logger.info(f"X-ray exposure time {exptime}")
976
- logger.info(f"Laser dwell time {pumpexptime}")
900
+ SSX_LOGGER.info(f"X-ray exposure time {exptime}")
901
+ SSX_LOGGER.info(f"Laser dwell time {pumpexptime}")
977
902
  repeat1 = 2 * 20 * (movetime + (pumpexptime + exptime) / 2)
978
903
  repeat2 = 4 * 20 * (movetime + (pumpexptime + exptime) / 2)
979
904
  repeat3 = 6 * 20 * (movetime + (pumpexptime + exptime) / 2)
@@ -988,48 +913,42 @@ def pumpprobe_calc() -> MsgGenerator:
988
913
  ):
989
914
  rounded = round(repeat, 4)
990
915
  caput(pv_name, rounded)
991
- logger.info(f"Repeat ({pv_name}): {rounded} s")
992
- logger.debug("PP calculations done")
916
+ SSX_LOGGER.info(f"Repeat ({pv_name}): {rounded} s")
917
+ SSX_LOGGER.debug("PP calculations done")
993
918
  yield from bps.null()
994
919
 
995
920
 
996
- @log.log_on_entry
921
+ @log_on_entry
997
922
  def block_check(pmac: PMAC = inject("pmac")) -> MsgGenerator:
998
- setup_logging()
999
923
  # TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/117
1000
924
  caput(pv.me14e_gp9, 0)
1001
925
  while True:
1002
926
  if int(caget(pv.me14e_gp9)) == 0:
1003
927
  chip_type = int(caget(CHIPTYPE_PV))
1004
928
  if chip_type == ChipType.Minichip:
1005
- logger.info("Oxford mini chip in use.")
929
+ SSX_LOGGER.info("Oxford mini chip in use.")
1006
930
  block_start_list = scrape_pvar_file("minichip_oxford.pvar")
1007
931
  elif chip_type == ChipType.Custom:
1008
- logger.error("This is a custom chip, no block check available!")
932
+ SSX_LOGGER.error("This is a custom chip, no block check available!")
1009
933
  raise ValueError(
1010
934
  "Chip type set to 'custom', which has no block check."
1011
935
  "If not using a custom chip, please double check chip in the GUI."
1012
936
  )
1013
937
  else:
1014
- logger.warning("Default is Oxford chip block start list.")
938
+ SSX_LOGGER.warning("Default is Oxford chip block start list.")
1015
939
  block_start_list = scrape_pvar_file("oxford.pvar")
1016
940
  for entry in block_start_list:
1017
941
  if int(caget(pv.me14e_gp9)) != 0:
1018
- logger.warning("Block Check Aborted")
942
+ SSX_LOGGER.warning("Block Check Aborted")
1019
943
  sleep(1.0)
1020
944
  break
1021
945
  block, x, y = entry
1022
- logger.debug(f"Block: {block} -> (x={x} y={y})")
946
+ SSX_LOGGER.debug(f"Block: {block} -> (x={x} y={y})")
1023
947
  yield from bps.abs_set(pmac.pmac_string, f"!x{x}y{y}", wait=True)
1024
948
  time.sleep(0.4)
1025
949
  else:
1026
- logger.warning("Block Check Aborted due to GP 9 not equalling 0")
950
+ SSX_LOGGER.warning("Block Check Aborted due to GP 9 not equalling 0")
1027
951
  break
1028
952
  break
1029
- logger.debug("Block check done")
953
+ SSX_LOGGER.debug("Block check done")
1030
954
  yield from bps.null()
1031
-
1032
-
1033
- # setup_logging now called in all functions.
1034
- # TODO See logging issue on blueapi
1035
- # https://github.com/DiamondLightSource/blueapi/issues/494