Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
MNT #109 log more content
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jun 27, 2019
1 parent b52659b commit 6f848d3
Show file tree
Hide file tree
Showing 28 changed files with 181 additions and 194 deletions.
2 changes: 1 addition & 1 deletion profile_bluesky/startup/00-startup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
print(__file__)
logger.info(__file__)

from bluesky import RunEngine
from bluesky.utils import get_history
Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/01-databroker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""set up the data broker (db)"""

Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/02-pyepics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

'''
ensure that PyEpics is available
Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/09-imports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""gather all the imports here"""

Expand Down
22 changes: 11 additions & 11 deletions profile_bluesky/startup/10-devices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""
Set up custom or complex devices
Expand Down Expand Up @@ -120,9 +120,9 @@ def check_position(self):
message = "Feedback is very close to its limits."
if email_notices.notify_on_feedback:
self._send_emails(subject, message)
print("!"*15)
print(subject, message)
print("!"*15)
logger.warning("!"*15)
logger.warning(subject, message)
logger.warning("!"*15)


class ApsPssShutterWithStatus(APS_devices.ApsPssShutterWithStatus):
Expand Down Expand Up @@ -162,7 +162,7 @@ def wait_for_state(self, target, timeout=10, poll_s=0.01):
while self.pss_state.get() not in target:
time.sleep(poll_s)
# elapsed = time.time() - t0
# print(f"waiting {elapsed}s : value={self.pss_state.value}")
# logger.debug(f"waiting {elapsed}s : value={self.pss_state.value}")
if poll_s < self._poll_s_max_:
poll_s *= self._poll_factor_ # progressively longer
if expiration is not None and time.time() > expiration:
Expand Down Expand Up @@ -634,10 +634,10 @@ class Linkam_CI94(APS_devices.ProcessController):
# dsc = Component(EpicsSignalRO, "dsc", kind="omitted") # calc

def record_signal(self):
"""write signal to the console AND SPEC file"""
"""write signal to the logger AND SPEC file"""
global specwriter
msg = f"{self.controller_name} signal: {self.value:.2f}{self.units.value}"
print(msg)
logger.info(msg)
specwriter._cmt("event", msg)
return msg

Expand Down Expand Up @@ -677,10 +677,10 @@ class Linkam_T96(APS_devices.ProcessController):
vacuum_status = Component(EpicsSignalRO, "vacuumStatus_RBV", kind="omitted")

def record_signal(self):
"""write signal to the console AND SPEC file"""
"""write signal to the logger AND SPEC file"""
global specwriter
msg = f"{self.controller_name} signal: {self.value:.2f}{self.units.value}"
print(msg)
logger.info(msg)
specwriter._cmt("event", msg)
return msg

Expand All @@ -694,7 +694,7 @@ def set_target(self, target, wait=True, timeout=None, timeout_fail=False):

msg = f"Set {self.controller_name} to {set_point:.2f}{self.units.value}"
specwriter._cmt("event", msg)
print(msg)
logger.info(msg)

if wait:
yield from self.wait_until_settled(
Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/11-motors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""motors, stages, positioners, ..."""

Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/19-constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""
instrument constants
Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/20-detectors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""various detectors"""

Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/21-aps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""
aps
Expand Down
14 changes: 7 additions & 7 deletions profile_bluesky/startup/21-filters_shutters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""filters & shutters"""

Expand All @@ -20,13 +20,13 @@
name="usaxs_shutter")

else:
print("!"*30)
logger.warning("!"*30)
if operations_in_9idc():
print("Session started when APS not operating.")
logger.warning("Session started when APS not operating.")
else:
print("Session started when 9ID-C is not operating.")
print("Using simulators for FE_shutter and mono_shutter.")
print("!"*30)
logger.warning("Session started when 9ID-C is not operating.")
logger.warning("Using simulators for FE_shutter and mono_shutter.")
logger.warning("!"*30)
FE_shutter = SimulatedApsPssShutterWithStatus(name="FE_shutter")
mono_shutter = SimulatedApsPssShutterWithStatus(name="mono_shutter")
usaxs_shutter = SimulatedApsPssShutterWithStatus(name="usaxs_shutter")
Expand Down
14 changes: 7 additions & 7 deletions profile_bluesky/startup/21-signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""
signals
Expand Down Expand Up @@ -30,31 +30,31 @@

connect_delay_s = 1
while not mono_shutter.pss_state.connected:
print(f"Waiting {connect_delay_s}s for mono shutter PV to connect")
logger.info(f"Waiting {connect_delay_s}s for mono shutter PV to connect")
time.sleep(connect_delay_s)


if aps.inUserOperations:
sd.monitors.append(aps.current)
# suspend when current < 2 mA
# resume 100s after current > 10 mA
print("Installing suspender for low APS current.")
logger.info("Installing suspender for low APS current.")
suspend_APS_current = bluesky.suspenders.SuspendFloor(aps.current, 2, resume_thresh=10, sleep=100)
RE.install_suspender(suspend_APS_current)

# remove comment if likely to use this suspender (issue #170)
# suspend_FE_shutter = bluesky.suspenders.SuspendFloor(FE_shutter.pss_state, 1)
# RE.install_suspender(suspend_FE_shutter)

print(f"mono shutter connected = {mono_shutter.pss_state.connected}")
logger.info(f"mono shutter connected = {mono_shutter.pss_state.connected}")
# remove comment if likely to use this suspender (issue #170)
# suspend_mono_shutter = bluesky.suspenders.SuspendFloor(mono_shutter.pss_state, 1)

print("Defining suspend_BeamInHutch. Install/remove in scan plans as desired.")
logger.info("Defining suspend_BeamInHutch. Install/remove in scan plans as desired.")
suspend_BeamInHutch = bluesky.suspenders.SuspendBoolLow(BeamInHutch)
# be more judicious when to use this suspender (only within scan plans) -- see #180
# RE.install_suspender(suspend_BeamInHutch)
# print("BeamInHutch suspender installed")
# logger.info("BeamInHutch suspender installed")

else:
# simulators
Expand Down
9 changes: 4 additions & 5 deletions profile_bluesky/startup/22-amplifiers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""
detectors, amplifiers, and related support
Expand Down Expand Up @@ -367,7 +367,6 @@ def getScalerChannelPvname(scaler_channel):
msg += f" +/- {g.background_error.value}"

logger.info(msg)
print(msg)

scaler.stage_sigs = stage_sigs["scaler"]
yield from bps.mv(
Expand Down Expand Up @@ -474,7 +473,7 @@ def _scaler_autoscale_(controls, count_time=0.05, max_iterations=9):
)

if not complete and aps.inUserOperations: # bailed out early from loop
print(f"converged={converged}")
logger.warning(f"converged={converged}")
msg = f"FAILED TO FIND CORRECT GAIN IN {max_iterations} AUTOSCALE ITERATIONS"
if RE.state != "idle": # don't raise if in summarize_plan()
raise AutoscaleError(msg)
Expand Down Expand Up @@ -505,7 +504,7 @@ def autoscale_amplifiers(controls, shutter=None, count_time=0.05, max_iterations
max_iterations=max_iterations)
except AutoscaleError as exc:
emsg = f"{exc} - will continue despite warning"
logger.info(emsg)
logger.warning(emsg)


# ------------
Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/24-detector_data_file_names.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""
replace BlueSky file name scheme when used with area detector
Expand Down
4 changes: 2 additions & 2 deletions profile_bluesky/startup/24-overrides_hdf5.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""override certain apstools.devices"""

Expand Down
6 changes: 3 additions & 3 deletions profile_bluesky/startup/25-alta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""Apogee Alta detector"""

Expand Down Expand Up @@ -45,4 +45,4 @@ class MyAltaDetector(SingleTrigger, AreaDetector):
alta_det.read_attrs.append("hdf1")
except TimeoutError as exc_obj:
msg = f"Timeout connecting with {nm} ({prefix})"
print(msg)
logger.warning(msg)
6 changes: 3 additions & 3 deletions profile_bluesky/startup/25-blackfly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""PointGrey BlackFly detector"""

Expand All @@ -20,4 +20,4 @@ class MyPointGreyDetector(SingleTrigger, AreaDetector):
blackfly_det = MyPointGreyDetector(prefix, name="blackfly_det")
except TimeoutError as exc_obj:
msg = f"Timeout connecting with {nm} ({prefix})"
print(msg)
logger.warning(msg)
8 changes: 4 additions & 4 deletions profile_bluesky/startup/25-pilatus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""Pilatus detector"""

Expand Down Expand Up @@ -40,7 +40,7 @@ class MyPilatusDetector(SingleTrigger, AreaDetector):
saxs_det.read_attrs.append("hdf1")
except TimeoutError as exc_obj:
msg = f"Timeout connecting with {nm} ({prefix})"
print(msg)
logger.warning(msg)

try:
nm = "Pilatus 200kw"
Expand All @@ -49,4 +49,4 @@ class MyPilatusDetector(SingleTrigger, AreaDetector):
waxs_det.read_attrs.append("hdf1")
except TimeoutError as exc_obj:
msg = f"Timeout connecting with {nm} ({prefix})"
print(msg)
logger.warning(msg)
6 changes: 3 additions & 3 deletions profile_bluesky/startup/25-simdetector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""ADSimDetector"""

Expand Down Expand Up @@ -34,4 +34,4 @@ class MySimDetector(SingleTrigger, AreaDetector):
adsimdet = MySimDetector(prefix, name="adsimdet")
except TimeoutError as exc_obj:
msg = f"Timeout connecting with {nm} ({prefix})"
print(msg)
logger.warning(msg)
8 changes: 4 additions & 4 deletions profile_bluesky/startup/28-protection_plc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
print(__file__)
print(resource_usage(os.path.split(__file__)[-1]))
logger.info(__file__)
logger.debug(resource_usage(os.path.split(__file__)[-1]))

"""detector protection PLC"""

Expand Down Expand Up @@ -44,7 +44,7 @@ def wait_for_interlock(self, verbose=True):
yield from bps.sleep(self.SLEEP_POLL_s)
if verbose:
elapsed = time.time()-t0
print(msg % elapsed)
logger.info(msg, elapsed)
yield from bps.null() # always yield at least one Msg

def stop_if_tripped(self, verbose=True):
Expand All @@ -53,7 +53,7 @@ def stop_if_tripped(self, verbose=True):
else:
msg = self.tripped_text
if verbose:
print(msg)
logger.warning(msg)
yield from bps.mv(
ti_filter_shutter, "close",
user_data.collection_in_progress, 0, # notify the GUI and others
Expand Down
Loading

0 comments on commit 6f848d3

Please sign in to comment.