Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Add ascanct parameter output #1652

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/sardana/macroserver/recorders/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def __init__(self, stream, cols=None, number_fmt='%8.4f', col_width=8,
cols = None
self._columns = cols
self._output_block = output_block
self._header_shown = False

def _startRecordList(self, recordlist):
starttime = recordlist.getEnvironValue('starttime').ctime()
Expand Down Expand Up @@ -215,9 +216,7 @@ def _startRecordList(self, recordlist):
self._scan_line_t = [(col_names[0], '%%(%s)8d' % col_names[0])]
self._scan_line_t += [(name, cell_t_number % name)
for name in col_names[1:]]

self._stream()._output(header)
self._stream()._flushOutput()
self._header = header

def _endRecordList(self, recordlist):
self._stream()._flushOutput()
Expand Down Expand Up @@ -245,9 +244,14 @@ def _endRecordList(self, recordlist):
info_string = 'Scan #%s ended at %s, taking %s. ' + \
'Dead time %.1f%% (setup time %.1f%%, motion dead time %.1f%%)'
self._stream().info(info_string % (serialno, endtime, totaltime,
deadtime_perc, setuptime_perc, motiontime_perc))
deadtime_perc, setuptime_perc, motiontime_perc))

def _writeRecord(self, record):
if not self._header_shown:
# show column headers
self._stream()._output(self._header)
self._stream()._flushOutput()
self._header_shown = True
cells = []
for i, (name, cell) in enumerate(self._scan_line_t):
cell_data = record.data[name]
Expand Down
41 changes: 41 additions & 0 deletions src/sardana/macroserver/scan/gscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
from taurus.core.util.threadpool import ThreadPool
from taurus.core.util.event import CallableRef
from taurus.core.tango.tangovalidator import TangoDeviceNameValidator
from taurus.console import Alignment
from taurus.console.list import List

from sardana.sardanathreadpool import OmniWorker
from sardana.util.tree import BranchNode, LeafNode, Tree
Expand Down Expand Up @@ -2477,6 +2479,14 @@ def _go_through_waypoints(self):
self.on_waypoints_end()
return

# a table of motor settings
# ("u" is short for "unit", to save space)
motor_table = List(["Motor", "Velocity[u/s]", "Acceleration[s]",
"Deceleration[s]", "Start[u]", "End[u]"],
header_separator=None,
text_alignment=[Alignment.HCenter] * 6,
max_col_width=[-1] * 6)

# prepare motor(s) to move with their maximum velocity
for path in motion_paths:
motor = path.moveable
Expand All @@ -2487,6 +2497,13 @@ def _go_through_waypoints(self):
'end: %f; ' % path.final_pos +
'ds: %f' % (path.final_pos -
path.initial_pos))
cell_format = "%g" # TODO is this the proper format to use?
motor_table.appendRow([motor.getName(),
cell_format % path.max_vel,
cell_format % path.max_vel_time,
cell_format % path.min_vel_time,
cell_format % path.initial_pos,
cell_format % path.final_pos])
attributes = OrderedDict(velocity=path.max_vel,
acceleration=path.max_vel_time,
deceleration=path.min_vel_time)
Expand All @@ -2500,6 +2517,11 @@ def _go_through_waypoints(self):
msg = "Error when configuring scan motion (%s)" % e
raise ScanException(msg)

self.macro.output("")
for line in motor_table.genOutput():
self.macro.output(line)
self.macro.output("")

if macro.isStopped():
self.on_waypoints_end()
return
Expand Down Expand Up @@ -2610,6 +2632,25 @@ def on_waypoints_end(self, restore_positions=None):
self.join_thread_pool()
self.macro.debug("All data events are processed")

# Note: The commented out code below works, but due to an issue with
# output of the last measurement point, it should not be enabled yet.
# See https://github.com/sardana-org/sardana/issues/1651

# # Output the restored motor settings
# out = List(["Motor", "Velocity", "Acceleration", "Deceleration"],
# header_separator=None,
# text_alignment=[Alignment.HCenter] * 4,
# max_col_width=[-1] * 4)
# cell_format = "%g"
# for motor_backup in self._backup:
# out.appendRow([motor_backup["moveable"].getName(),
# cell_format % motor_backup["velocity"],
# cell_format % motor_backup["acceleration"],
# cell_format % motor_backup["deceleration"]])
# self.macro.output("")
# for line in out.genOutput():
# self.macro.output(line)

def scan_loop(self):
macro = self.macro
# manager = macro.getManager()
Expand Down