Commit f17f702a authored by Jose Tiago Macara Coutinho's avatar Jose Tiago Macara Coutinho
Browse files

scan: fix counter order bug

parent a4cc57fd
......@@ -59,13 +59,8 @@ class StepScanDataWatch(object):
point_nb = self._last_point_display
for point_nb in range(self._last_point_display,min_nb_points):
motor_channels = [self._channel_name_2_channel.get(channel_name)
for channel_name in self._motors_name]
values = [channel.get(point_nb) for channel in motor_channels]
motor_channels = set(motor_channels)
values.extend((channel.get(point_nb)
for channel in self._channel_name_2_channel.values()
if channel not in motor_channels))
values = dict([(ch_name, ch.get(point_nb))
for ch_name, ch in self._channel_name_2_channel.iteritems()])
send(current_module,"scan_data",
self._scan_info,values)
if min_nb_points is not None:
......
......@@ -129,13 +129,14 @@ class ScanListener:
header = self.HEADER.format(column_header=header,
estimation_str=estimation_str,
**scan_info)
self.col_templ = ["{{0: >{width}}}".format(width=col_len)
self.col_templ = ["{{0: >{width}g}}".format(width=col_len)
for col_len in col_lens]
print_(header)
def __on_scan_data(self, scan_info, values):
elapsed_time = time.time() - scan_info['start_time_stamp']
values = [elapsed_time] + values[1:]
elapsed_time = values['timestamp'] - scan_info['start_time_stamp']
counter_values = [values[c.name] for c in scan_info['counters']]
values = [elapsed_time] + counter_values
if scan_info['type'] == 'ct':
# ct is actually a timescan(npoints=1).
norm_values = numpy.array(values) / scan_info['count_time']
......
......@@ -72,18 +72,32 @@ def stdout_redirected(client_uuid, new_stdout):
def init_scans_callbacks(interpreter, output_queue):
def new_scan_callback(scan_info, root_path, scan_actuators, npoints, counters_list):
def new_scan_callback(scan_info):
scan_actuators = scan_info['motors']
if len(scan_actuators) > 1:
scan_actuators = scan_actuators[1:]
output_queue.put((interpreter.get_last_client_uuid(), {"scan_id": scan_info["node_name"], "filename": root_path,
"scan_actuators": scan_actuators, "npoints": npoints,
"counters": counters_list}))
data = (interpreter.get_last_client_uuid(),
{"scan_id": scan_info["node_name"],
"filename": scan_info['root_path'],
"scan_actuators": [actuator.name for actuator in scan_actuators],
"npoints": scan_info['npoints'],
"counters": [ct.name for ct in scan_info['counters']]})
output_queue.put(data)
def update_scan_callback(scan_info, values):
value_list = [values[m.name] for m in scan_info['motors']]
value_list += [values[c.name] for c in scan_info['counters']]
if scan_info["type"] != "timescan":
values = values[1:]
output_queue.put((interpreter.get_last_client_uuid(), {"scan_id": scan_info["node_name"], "values":values}))
value_list = value_list[1:]
data = (interpreter.get_last_client_uuid(),
{"scan_id": scan_info["node_name"],
"values":value_list})
output_queue.put(data)
def scan_end_callback(scan_info):
output_queue.put((interpreter.get_last_client_uuid(), {"scan_id": scan_info["node_name"]}))
data = (interpreter.get_last_client_uuid(),
{"scan_id": scan_info["node_name"]})
output_queue.put(data)
# keep callbacks references
output_queue.callbacks["scans"]["new"] = new_scan_callback
......
......@@ -54,7 +54,7 @@ def test_scan_callbacks(beacon):
def on_scan_new(scan_info):
res["new"] = True
def on_scan_data(scan_info, values):
res["values"].append(values[1])
res["values"].append(values[counter.name])
def on_scan_end(scan_info):
res["end"] = 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