Commit 55e85f32 authored by GUILLOU Perceval's avatar GUILLOU Perceval

Counters filter in ScanDisplay and fixes

parent 1e7eb5c2
Pipeline #10640 passed with stages
in 90 minutes and 57 seconds
......@@ -35,7 +35,6 @@ __all__ = [
"ct",
"DEFAULT_CHAIN",
"plotselect",
"scan_display_filter",
"cen",
"goto_cen",
"peak",
......@@ -1350,25 +1349,6 @@ def plotselect(*counters):
plot_select.set(counter_names)
def scan_display_filter(*counters):
"""
Select counter(s) which will be displayed in scan output. If no counters are given, it clears the filter list.
"""
current_session = session.get_current()
display_select = HashSetting("%s:scan_display_filter" % current_session.name)
if counters == ():
display_select.clear()
else:
counter_names = dict()
for cnt in counters:
fullname = cnt.fullname
fullname = fullname.replace(".", ":", 1)
if not fullname.find(":") > -1:
fullname = "{cnt_name}:{cnt_name}".format(cnt_name=fullname)
counter_names[fullname] = cnt.alias_or_name
display_select.set(counter_names)
def _remove_real_dependent_of_calc(motors):
"""
remove real motors if depend of a calc axis
......
......@@ -673,8 +673,8 @@ class BaseHashSetting:
cnx = self._cnx()
cnx.delete(self._name)
def copy(self):
return self.get()
# def copy(self):
# return self.get()
@write_decorator_dict
def set(self, values):
......@@ -1239,7 +1239,6 @@ class ParametersWardrobe(metaclass=ParametersType):
**self._get_redis_single_set(self._sets[0]),
**{attr: getattr(self, attr) for attr in self._property_attributes},
}
return all_params
def from_dict(self, d):
"""
......
......@@ -27,6 +27,7 @@ from bliss.common.axis import Axis
from bliss.common.event import dispatcher
from bliss.config.settings import HashSetting
from bliss.scanning.scan import set_scan_watch_callbacks
from bliss.scanning.scan import ScanDisplay
if sys.platform not in ["win32", "cygwin"]:
......@@ -299,10 +300,10 @@ class ScanDataListener:
self.scan_is_running = None
self.counter_selection = []
self.exit_read_fd = exit_read_fd
self.scan_display = ScanDisplay(self.session_name)
def update_counter_selection(self):
ps = HashSetting(f"{self.session_name}:scan_display_filter")
self.counter_selection = list(ps.keys())
self.counter_selection = self.scan_display.counters
def get_selected_counters(self, counter_names):
if not self.counter_selection:
......
......@@ -352,23 +352,32 @@ class ScanSaving(ParametersWardrobe):
class ScanDisplay(ParametersWardrobe):
SLOTS = []
def __init__(self):
def __init__(self, session=None):
"""
This class represents the display parameters for scans for a session.
"""
keys = dict()
_change_to_obj_marshalling(keys)
if session is None:
cs = _current_session()
session_name = cs.name if cs is not None else "default"
else:
session_name = session
super().__init__(
"%s:scan_display_params" % self.session,
default_values={"auto": False, "motor_position": True},
property_attributes=("session",),
"%s:scan_display_params" % session_name,
default_values={"auto": False, "motor_position": True, "_counters": []},
property_attributes=("session", "counters"),
not_removable=("auto", "motor_position"),
**keys,
)
self.add("_session_name", session_name)
def __dir__(self):
keys = super().__dir__()
return keys + ["session", "auto"]
return keys + ["session", "auto", "counters"]
def __repr__(self):
return super().__repr__()
......@@ -376,8 +385,30 @@ class ScanDisplay(ParametersWardrobe):
@property
def session(self):
""" This give the name of the current session or default if no current session is defined """
session = _current_session()
return session.name if session is not None else "default"
return self._session_name
@property
def counters(self):
return self._counters
@counters.setter
def counters(self, counters_selection):
"""
Select counter(s) which will be displayed in scan output. If no counters are given, it clears the filter list.
"""
if counters_selection in [[], (), "All", "all", None, ""]:
self._counters = []
else:
cnts = []
for cnt in counters_selection:
fullname = cnt.fullname
fullname = fullname.replace(".", ":", 1)
if not fullname.find(":") > -1:
fullname = "{cnt_name}:{cnt_name}".format(cnt_name=fullname)
cnts.append(fullname)
self._counters = cnts
def _get_channels_dict(acq_object, channels_dict):
......
......@@ -56,10 +56,10 @@ i.e. configuration objects defined in the session are initialized,
then the setup file is executed. Finally the prompt returns to user.
`-h` option allows to get an overview of other commad-line features.
`-h` option allows to get an overview of other command-line features.
% bliss -h
Usage: bliss [-l | --log-level=<log_level>] [-s <name> | --session=<name>]
Usage: bliss [-l | --log-level=<log_level>] [-s <name> | --session=<name>] [--no-tmux]
bliss [-v | --version]
bliss [-c <name> | --create=<name>]
bliss [-d <name> | --delete=<name>]
......@@ -75,6 +75,7 @@ then the setup file is executed. Finally the prompt returns to user.
-c, --create=<session_name> Create a new session with the given name
-d, --delete=<session_name> Delete the given session
-h, --help Show help screen and exit
--no-tmux Deactivate Tmux usage
--show-sessions Display sessions and tree of sub-sessions
--show-sessions-only Display available sessions names only
......
......@@ -9,7 +9,7 @@ provided to easily and interactively execute BLISS *commands* and
Use `-h` flag to get help about bliss command line interface:
% bliss -h
Usage: bliss [-l | --log-level=<log_level>] [-s <name> | --session=<name>]
Usage: bliss [-l | --log-level=<log_level>] [-s <name> | --session=<name>] [--no-tmux]
bliss [-v | --version]
bliss [-c <name> | --create=<name>]
bliss [-d <name> | --delete=<name>]
......@@ -24,6 +24,7 @@ Use `-h` flag to get help about bliss command line interface:
-c, --create=<session_name> Create a new session with the given name
-d, --delete=<session_name> Delete the given session
-h, --help Show help screen and exit
--no-tmux Deactivate Tmux usage
--show-sessions Display available sessions and tree of sub-sessions
--show-sessions-only Display available sessions names only
......@@ -40,21 +41,32 @@ Use `-v` or `--version` option to get the current version of a BLISS installatio
`--log-level` or `-l` defines the logging level of the command line interface.
### Sessions
Use `-s` to start an existing session:
Use `-s` or `--show-sessions` option to get the list of available sessions:
% bliss -s test_session
__ __ __
|__) | | /__` /__`
|__) |__ | .__/ .__/
Welcome to BLISS version 1e7eb5c2 running on PCGUILLOU (in bliss_env Conda environment)
Copyright (c) ESRF, 2015-2018
Use `--show-sessions` option to get the list of available sessions:
% bliss --show-sessions
Available BLISS sessions are:
cyril
flint
lima_test_session
test_session
Other commands are also displaying the available sessions:
% bliss --show-sessions-only
% bliss -s
#### Automatic creation of a new session
Use `bliss --create` or `bliss -c` to create the skeleton of a new session:
Use `--create` or `-c` to create the skeleton of a new session:
bliss -c eh1
% bliss -c eh1
......@@ -65,9 +77,15 @@ Use `bliss --create` or `bliss -c` to create the skeleton of a new session:
#### Removing an existing session
`bliss --delete` or `bliss -d` removes an existing session:
`--delete` or `-d` removes an existing session:
* session YAML file
* setup file
* default session script (see above)
#### Deactivating Tmux (terminal multiplexer) usage
Use `--no-tmux` to start a Bliss session without the Tmux terminal multiplexer.
In a Bliss session without Tmux, the scans output won't be printed in a separated window and will be shown in the main command line window.
% bliss -s test_session --no-tmux
\ No newline at end of file
......@@ -11,6 +11,7 @@ import sys
from bliss.data import start_listener
from bliss.common import scans
from bliss.scanning.scan import ScanDisplay
import subprocess
import gevent
......@@ -37,6 +38,8 @@ def grab_lines(
def test_a2scan_display(session):
""" PERFORM TESTS TO CHECK THE OUTPUT DISPLAYED BY THE ScanDataListener FOR THE DIFFERENT STANDARD SCANS"""
sd = ScanDisplay(session.name)
# put scan file in a different tmp directory or use SAVE = False
# env_dict, session_obj = session
# env_dict["SCAN_SAVING"].base_path = str(scan_tmpdir)
......@@ -182,7 +185,7 @@ def test_a2scan_display(session):
# print(' finished')
# ============= START THE A2SCAN (filtered counters) ================
scans.scan_display_filter(diode4) # show only diode4
sd.counters = (diode4,) # show only diode4
lines = []
# print('Start a2scan(robz, 0, 9, roby, 10, 19, 10, 0.01, diode4, diode5) ...', end='', flush=True)
s = scans.a2scan(
......@@ -242,7 +245,7 @@ def test_a2scan_display(session):
# print(' finished')
# ============= START THE ASCAN ===================================
scans.scan_display_filter() # reset filtering, i.e show all
sd.counters = () # reset filtering, i.e show all
lines = []
# print('Start ascan(roby, 0, 9, 10, 0.1, diode4, diode5) ...', end='', flush=True)
s = scans.ascan(roby, 0, 9, 10, 0.1, diode4, diode5, save=False)
......
Markdown is supported
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