Coverage for abb_rws_client_python_rw6/highlevel/panel.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-13 22:17 +0000

1# abb_rws_client/highlevel/panel.py 

2"""High-level controller motor state for ABB RWS RobotWare 6. 

3 

4Author: Clement RACINET 

5 

6Composed operations built exclusively from atomic ``rws/`` functions. 

7No HTTP calls are made directly in this module. 

8 

9All functions are async and require an open ``RWSClient`` instance. 

10""" 

11 

12from __future__ import annotations 

13 

14from abb_rws_client_python_rw6.core.client import RWSClient 

15from abb_rws_client_python_rw6.core.logger import get_logger 

16from abb_rws_client_python_rw6.rws.panel import set_controller_state 

17 

18logger = get_logger(__name__) 

19 

20 

21async def set_motors_on(client: RWSClient) -> None: 

22 """Switch the controller to motors-on state. 

23 

24 Wraps ``set_controller_state`` with ``ctrl_state="motoron"``. 

25 

26 Route (delegated): ``POST /rw/panel/ctrlstate`` (action=setctrlstate) 

27 

28 ABB constraints: 

29 - Controller must be in AUTO mode. 

30 - No mastership required. 

31 

32 Args: 

33 client: Open ``RWSClient`` instance. 

34 

35 Returns: 

36 None. Expects HTTP 204. 

37 

38 Raises: 

39 RWSAuthenticationError: On HTTP 401. 

40 RWSNotFoundError: On HTTP 404. 

41 RWSHTTPError: On any other HTTP >= 400. 

42 

43 Example: 

44 ```python 

45 async with RWSClient(host="192.168.125.1") as client: 

46 await set_motors_on(client) 

47 ``` 

48 """ 

49 await set_controller_state( 

50 client, 

51 action="setctrlstate", 

52 ctrl_state="motoron", 

53 ) 

54 logger.debug("Motors ON") 

55 

56 

57async def set_motors_off(client: RWSClient) -> None: 

58 """Switch the controller to motors-off state. 

59 

60 Wraps ``set_controller_state`` with ``ctrl_state="motoroff"``. 

61 

62 Route (delegated): ``POST /rw/panel/ctrlstate`` (action=setctrlstate) 

63 

64 ABB constraints: 

65 - No mastership required. 

66 

67 Args: 

68 client: Open ``RWSClient`` instance. 

69 

70 Returns: 

71 None. Expects HTTP 204. 

72 

73 Raises: 

74 RWSAuthenticationError: On HTTP 401. 

75 RWSNotFoundError: On HTTP 404. 

76 RWSHTTPError: On any other HTTP >= 400. 

77 

78 Example: 

79 ```python 

80 async with RWSClient(host="192.168.125.1") as client: 

81 await set_motors_off(client) 

82 ``` 

83 """ 

84 await set_controller_state( 

85 client, 

86 action="setctrlstate", 

87 ctrl_state="motoroff", 

88 ) 

89 logger.debug("Motors OFF")