Commit adfb2fea authored by bliss administrator's avatar bliss administrator
Browse files

more debug, event_runtime_error moved at _error_cleanup beginning, restore...

more debug, event_runtime_error moved at _error_cleanup beginning, restore velocity on error cleanup for phase before the scan run
parent a948c62d
......@@ -335,7 +335,11 @@ class ID26FScanController:
self._last_scan ['init_duration'] = duration
self.event_trajectory_started.clear()
log_debug(
self,
'EVENT Trajectory Started CLEARED',
)
if energy_start >= energy_end:
raise ValueError(
f"FSCAN: Energy must go incrementing. start ({energy_start}) end ({energy_end})"
......@@ -355,7 +359,6 @@ class ID26FScanController:
)
if abs(self.energy.position-energy_start)>self.energy.tolerance:
with cleanup (self.mono, restore_list=(cleanup_axis.VEL,)):
self.mono.velocity = self.fscan_par["mono_move_back_speed_steps"] / self.mono.steps_per_unit
self.energy.move(energy_start, wait=False)
......@@ -1171,7 +1174,7 @@ class ID26FScanController:
self.energy.sync_hard()
#MCL 20210325 - that takes about 160ms
if self.fscan_par['mono_move_back'] == 0 or not self.event_trajectory_started.is_set() or self.event_runtime_error.is_set():
if self.fscan_par['mono_move_back'] == 0 or self.event_runtime_error.is_set() or not self.event_trajectory_started.is_set():
self.mono.velocity = self.mono.config_velocity
#MCL 20210325 - that s only for u35a variable speed trajectories
......@@ -1186,7 +1189,11 @@ class ID26FScanController:
if self.fscan_par['mono_move_back'] == 1 and self.event_trajectory_started.is_set() and not self.event_runtime_error.is_set():
self.event_trajectory_started.clear()
log_debug(
self,
'EVENT Trajectory Started CLEARED',
)
if self.greenlet_authorised:
self.greenlet_move_back = gevent.spawn(self._move_back)
else:
......@@ -1195,6 +1202,10 @@ class ID26FScanController:
else:
self.event_runtime_error.clear()
self.event_trajectory_started.clear()
log_debug(
self,
'EVENT Trajectory Started AND Runtime Error CLEARED',
)
log_debug(
self,
......@@ -1243,20 +1254,27 @@ class ID26FScanController:
"_error_cleanup ..."
)
self.event_runtime_error.set()
log_debug(
self,
'EVENT Runtime Error SET',
)
if self.event_trajectory_started.is_set():
print(
"FSCAN ERROR CLEANUP - aborting trajectories and resetting controller ports"
)
self.pm600.stop_trajectory()
#sends \003 to the controller -> command buffer is cleared
self.pm600.flush()
#sends \003 to the controller -> command buffer is cleared
#try:
#try:
# self.pm600.sock.readline() #readsacknoledge of XS command that is delayed always
#except:
# log_warning(
# log_debug(
# self,
# "_error_cleanup : nothing on serial line",
# )
# "_cleanup : nothing on serial line",
# )
self.pm600.io_command("WP22222221",self.mono.channel)
......@@ -1264,7 +1282,6 @@ class ID26FScanController:
#if self.idtraj is not None:
# self.idtraj._stop_trajectory()
self.event_runtime_error.set()
if self.fscan_par['id_sync']:
self._reset_id_sync()
......@@ -1493,35 +1510,22 @@ class FscanAcquisitionMaster(MusstAcquisitionMaster):
self.event = event
def prepare(self):
#time0=time.time()
super().prepare()
#print (f'{self.__class__} took {time.time()-time0} sec. to prepare musst.')
#time0=time.time()
self.idtraj._move_to_start()
#print (f'{self.__class__} took {time.time()-time0} sec. to prepare idtraj.')
def start(self):
#time0=time.time()
super().start()
#print (f'{self.__class__} took {time.time()-time0} sec. to start musst.')
#time0=time.time()
# ok - WA put that seq before the undu move because it will WA0
self.event.set()
log_debug(
self.pm600,
'EVENT Trajectory Started SET',
)
self.pm600.start_trajectory(*self.monotraj)
#print (f'{self.__class__} took {time.time()-time0} sec. to start pm600.')
#time0=time.time()
self.idtraj._start_trajectory()
#print (f'{self.__class__} took {time.time()-time0} sec. to start idtraj.')
def stop(self):
#time0=time.time()
super().stop()
#print (f'{self.__class__} took {time.time()-time0} sec. to stop musst.')
#time0=time.time()
self.idtraj._stop_trajectory()
#print (f'{self.__class__} took {time.time()-time0} sec. to stop idtraj.')
class IDlinkedConstantVelocity():
def __init__(self, id_tracker_parameters):
......
......@@ -107,30 +107,31 @@ def fscan(
"mono is {0}".format(FSCAN.mono.state)
)
nbpoints, exp_time, duration, id_parameters = FSCAN.prepare (
with cleanup (FSCAN.mono, restore_list=(cleanup_axis.VEL,), error_cleanup=True):
nbpoints, exp_time, duration, id_parameters = FSCAN.prepare (
energy_start, energy_end, duration, energy_step
)
print('Starting here.')
print(f"@{time.time()-time0:.3f}s")
)
print('Starting here.')
print(f"@{time.time()-time0:.3f}s")
log_debug(
log_debug(
FSCAN,
"mono is {0}".format(FSCAN.mono.state)
)
)
group = FSCAN.program_trajectories(
group = FSCAN.program_trajectories(
energy_start,
energy_end,
duration,
energy_step,
) # from 600us to some seconds for PM600
print('after programming of trajetory.')
print(f"@{time.time()-time0:.3f}s")
) # from 600us to some seconds for PM600
print('after programming of trajetory.')
print(f"@{time.time()-time0:.3f}s")
# the data acquisition takes longer because of delay (0.5s) between MUSST start and actual motion of mono:
nbpoints_musst = int(nbpoints + 0.7 / exp_time)
# the data acquisition takes longer because of delay (0.5s) between MUSST start and actual motion of mono:
nbpoints_musst = int(nbpoints + 0.7 / exp_time)
chain = FSCAN.acquisition_chain(
chain = FSCAN.acquisition_chain(
exp_time,
0,
nbpoints_musst,
......@@ -138,44 +139,44 @@ def fscan(
*counters,
id_speed_dict=id_parameters,
id_sync=FSCAN_PAR["id_sync"],
)
print('after aqcuisition chain definition.')
print(f"@{time.time()-time0:.3f}s")
)
print('after aqcuisition chain definition.')
print(f"@{time.time()-time0:.3f}s")
scan_info_dict = {
scan_info_dict = {
"title": f"fscan {energy_start} {energy_end} {duration} {energy_step}",
"start": energy_start,
"stop": energy_end,
"npoints": nbpoints,
"type": "fscan",
"count_time": exp_time,
}
}
scan_info = ScanInfo()
scan_info.update(scan_info_dict)
scan_info = ScanInfo()
scan_info.update(scan_info_dict)
xname = 'hdh_energy'
scan_info.add_curve_plot( x=xname )
xname = 'hdh_energy'
scan_info.add_curve_plot( x=xname )
scan_info.set_channel_meta(
scan_info.set_channel_meta(
xname,
start=energy_start,
stop=energy_end,
points=nbpoints,
)
)
#============================
#============================
scan = Scan(
scan = Scan(
chain,
name="fscan",
scan_info=scan_info,
save=save,
data_watch_callback=FScanDisplay("elapsed_time"),
)
)
print(f"Ready to run scan @{time.time()-time0:.3f}s")
print(f"Ready to run scan @{time.time()-time0:.3f}s")
with cleanup(FSCAN._cleanup):
with cleanup(FSCAN._error_cleanup, error_cleanup=True):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment