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

[WIP] Generic data recorder #1478

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions doc/source/devel/howto_recorders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Sardana provides the following standard recorders (grouped by types):
* JsonRecorder [*]
* OutputRecorder

* generic [*]
.. TODO Need to document the implementation and configuration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need at least one blank line before the .. TODO comment otherwise travis complains



[*] Scan Framework provides mechanisms to enable and select this recorders using
the environment variables.

Expand Down
25 changes: 25 additions & 0 deletions src/sardana/macroserver/scan/gscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def __init__(self, macro, generator=None, moveables=[], env={},
# The Output recorder (if any)
json_recorder = self._getJsonRecorder()

# The Generic Data recorders (if any)
data_recorders = self._getDataRecorders()

# The File recorders (if any)
file_recorders = self._getFileRecorders()

Expand All @@ -360,6 +363,8 @@ def __init__(self, macro, generator=None, moveables=[], env={},

data_handler.addRecorder(output_recorder)
data_handler.addRecorder(json_recorder)
for data_recorder in data_recorders:
data_handler.addRecorder(data_recorder)
for file_recorder in file_recorders:
data_handler.addRecorder(file_recorder)
data_handler.addRecorder(shm_recorder)
Expand Down Expand Up @@ -457,6 +462,26 @@ def _getJsonRecorder(self):
self.info('JsonRecorder is not defined. Use "senv JsonRecorder '
'True" to enable it')

def _getDataRecorders(self):

try:
data_recorders = self.macro.getEnv('DataRecorder')
except InterruptException:
raise
except Exception as e:
self.debug('DataRecorder is not defined. Use "senv DataRecorder '
'with the recorder class name (or a list).')
return []

if isinstance(data_recorders, str):
data_recorders = [data_recorders]

_rec_list = []
for rec in data_recorders:
_obj = self._rec_manager.getRecorderClass(rec)(macro=self.macro)
_rec_list.append(_obj)
return _rec_list

def _getOutputRecorder(self):
cols = None
output_block = False
Expand Down