Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BCU-Vercors
ID26
id26
Commits
e0832e21
Commit
e0832e21
authored
Oct 05, 2021
by
bliss administrator
Browse files
KeyboardInterrupt handling during traj programming
parent
618ddde4
Changes
1
Hide whitespace changes
Inline
Side-by-side
id26/controllers/fscan_controller.py
View file @
e0832e21
...
...
@@ -763,24 +763,15 @@ class ID26FScanController:
"loading trajectories"
)
#GREENLETIZE - already a greenlet but joined. must be waited anyway last timeconsuming action in the sequence.
try
:
group
.
prepare
()
# the program is loaded in PM600 here
except
RuntimeError
:
#serial.SerialTimeout.mro()
log_warning
(
self
,
'Timeout from PM600 controller while programming the trajectory sequence - will retry once.'
)
time
.
sleep
(
0.1
)
self
.
pm600
.
stop_trajectory
(
*
traj
)
#replaces EP ES commands
group
.
prepare
()
group
.
prepare
()
# the program is loaded in PM600 here
else
:
raise
RuntimeError
(
f
"
{
MONO
.
name
}
is
{
MONO
.
state
}
. cannot load trajectory."
)
if
self
.
fscan_par
[
'id_linked'
]
==
2
:
self
.
idtraj
.
_id_load_trajectory
(
_idtimebase
,
_idpositions
)
except
(
RuntimeError
,
ValueError
)
as
err
:
except
Exception
as
err
:
log_exception
(
self
,
"could not load trajectories into controllers"
...
...
@@ -808,9 +799,9 @@ class ID26FScanController:
)
print
(
"Programming trajectory on PM600"
)
print
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
)
print
(
"!!! WARNING: DO NOT CTR-C !!!"
print
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
)
#
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
#
print("!!! WARNING: DO NOT CTR-C !!!"
)
#
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
nintervals
=
self
.
fscan_par
[
'pm600_prf_intervals'
]
...
...
@@ -1186,28 +1177,29 @@ class ID26FScanController:
#self.pm600.sock.flush()
#MCL 20210325 - that takes about 100ms
try
:
try
:
self
.
pm600
.
sock
.
readline
()
#readsacknoledge of XS command that is delayed always
except
:
log_warning
(
self
,
"PM600 _cleanup : nothing (no OK) on serial line"
,
)
self
.
energy
.
sync_hard
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
log_warning
(
self
,
"Error during mono.sync_hard() ({0}) - retry once..."
.
format
(
e
)
)
#
try:
if
not
self
.
event_runtime_error
.
is_set
()
:
try
:
self
.
pm600
.
sock
.
readline
()
#readsacknoledge of XS command that is delayed always
except
:
log_debug
(
self
,
"PM600 _cleanup : nothing (no OK) on serial line"
,
)
self
.
energy
.
sync_hard
()
#
except KeyboardInterrupt as e:
#
raise e
#
except Exception as e:
#
log_warning(
#
self,
#
"Error during mono.sync_hard() ({0}) - retry once...".format(e)
#
)
#time.sleep(1)
#self.pm600.sock.flush()
self
.
pm600
.
stop_trajectory
()
self
.
pm600
.
raw_write_read
(
f
"
{
self
.
mono
.
channel
}
WP22222221
\r
"
)
self
.
energy
.
sync_hard
()
#self.pm600.stop_trajectory()
#self.pm600.raw_write_read(f"{self.mono.channel}WP22222221\r")
#self.pm600.io_command("WP22222221",self.mono.channel)
#self.energy.sync_hard()
#MCL 20210325 - that takes about 160ms
self
.
mono
.
velocity
=
self
.
mono
.
config_velocity
...
...
@@ -1294,15 +1286,18 @@ class ID26FScanController:
"FSCAN ERROR CLEANUP - aborting trajectories and resetting controller ports"
)
self
.
pm600
.
stop_trajectory
()
try
:
self
.
pm600
.
sock
.
readline
()
#readsacknoledge of XS command that is delayed always
except
:
log_warning
(
self
,
"PM600 _error_cleanup : nothing on serial line"
,
)
self
.
pm600
.
raw_write_read
(
f
"
{
self
.
mono
.
channel
}
WP22222221
\r
"
)
#no need - already n acquisition_master
self
.
pm600
.
flush
()
#sends \003 to the controller -> command buffer is cleared
#try:
# self.pm600.sock.readline() #readsacknoledge of XS command that is delayed always
#except:
# log_warning(
# self,
# "PM600 _error_cleanup : nothing on serial line",
# )
#self.pm600.raw_write_read(f"{self.mono.channel}WP22222221\r")
self
.
pm600
.
io_command
(
"WP22222221"
,
self
.
mono
.
channel
)
#no need - already in acquisition_master
#if self.idtraj is not None:
# self.idtraj._stop_trajectory()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment