Skip to content

Commit acea100

Browse files
committed
Remote control API: added run/stop/import macro methods
1 parent f6af834 commit acea100

File tree

3 files changed

+63
-8
lines changed

3 files changed

+63
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Version 0.9.0 ##
44

5-
DataLab Simple Client is fully compatible with **DataLab 0.11.0** and above.
5+
DataLab Simple Client is fully compatible with **DataLab 0.13.0** and above.
66
With older versions of the DataLab server, some features may not work.
77

88
💥 Changes:
@@ -13,6 +13,9 @@ With older versions of the DataLab server, some features may not work.
1313
* Thus, when creating a `SimpleRemoteProxy` instance, the connection to the
1414
server is now established automatically by default (i.e. same behavior as
1515
DataLab's `cdl.proxy.RemoteProxy` class)
16+
* `get_object_titles` method now accepts "macro" as panel name and returns
17+
the list of macro titles
18+
* New `run_macro`, `stop_macro` and `import_macro_from_file` methods
1619

1720
## Version 0.8.1 ##
1821

cdlclient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
from cdlclient.remote import SimpleRemoteProxy # noqa: F401
1919

2020
__version__ = "0.9.0"
21-
__required_server_version__ = "0.11.0"
21+
__required_server_version__ = "0.13.0"
2222
__docurl__ = "https://cdlclient.readthedocs.io/en/latest/"
2323
__homeurl__ = "https://github.com/Codra-Ingenierie-Informatique/DataLabSimpleClient/"

cdlclient/baseproxy.py

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,11 @@ def get_object_titles(self, panel: str | None = None) -> list[str]:
301301
Objects are sorted by group number and object index in group.
302302
303303
Args:
304-
panel (str | None): panel name (valid values: "signal", "image").
305-
If None, current panel is used.
304+
panel: panel name (valid values: "signal", "image", "macro").
305+
If None, current data panel is used (i.e. signal or image panel).
306306
307307
Returns:
308-
list[str]: list of object titles
308+
List of object titles
309309
310310
Raises:
311311
ValueError: if panel not found
@@ -390,6 +390,32 @@ def add_label_with_title(
390390
If None, current panel is used.
391391
"""
392392

393+
@abc.abstractmethod
394+
def run_macro(self, number_or_title: int | str | None = None) -> None:
395+
"""Run macro.
396+
397+
Args:
398+
number: Number of the macro (starting at 1). Defaults to None (run
399+
current macro, or does nothing if there is no macro).
400+
"""
401+
402+
@abc.abstractmethod
403+
def stop_macro(self, number_or_title: int | str | None = None) -> None:
404+
"""Stop macro.
405+
406+
Args:
407+
number: Number of the macro (starting at 1). Defaults to None (stop
408+
current macro, or does nothing if there is no macro).
409+
"""
410+
411+
@abc.abstractmethod
412+
def import_macro_from_file(self, filename: str) -> None:
413+
"""Import macro from file
414+
415+
Args:
416+
filename: Filename.
417+
"""
418+
393419
@abc.abstractmethod
394420
def calc(self, name: str, param: gds.DataSet | None = None) -> gds.DataSet:
395421
"""Call compute function ``name`` in current panel's processor.
@@ -636,11 +662,11 @@ def get_object_titles(self, panel: str | None = None) -> list[str]:
636662
Objects are sorted by group number and object index in group.
637663
638664
Args:
639-
panel (str | None): panel name (valid values: "signal", "image").
640-
If None, current panel is used.
665+
panel: panel name (valid values: "signal", "image", "macro").
666+
If None, current data panel is used (i.e. signal or image panel).
641667
642668
Returns:
643-
list[str]: list of object titles
669+
List of object titles
644670
645671
Raises:
646672
ValueError: if panel not found
@@ -675,3 +701,29 @@ def add_label_with_title(
675701
If None, current panel is used.
676702
"""
677703
self._cdl.add_label_with_title(title, panel)
704+
705+
def run_macro(self, number_or_title: int | str | None = None) -> None:
706+
"""Run macro.
707+
708+
Args:
709+
number: Number of the macro (starting at 1). Defaults to None (run
710+
current macro, or does nothing if there is no macro).
711+
"""
712+
self._cdl.run_macro(number_or_title)
713+
714+
def stop_macro(self, number_or_title: int | str | None = None) -> None:
715+
"""Stop macro.
716+
717+
Args:
718+
number: Number of the macro (starting at 1). Defaults to None (stop
719+
current macro, or does nothing if there is no macro).
720+
"""
721+
self._cdl.stop_macro(number_or_title)
722+
723+
def import_macro_from_file(self, filename: str) -> None:
724+
"""Import macro from file
725+
726+
Args:
727+
filename: Filename.
728+
"""
729+
return self._cdl.import_macro_from_file(filename)

0 commit comments

Comments
 (0)