@@ -75,7 +75,8 @@ def __init__( # pylint: disable=too-many-arguments,super-init-not-called
75
75
self .__long_click_delay = long_click_delay
76
76
77
77
self .__notifier = aiotools .AioNotifier ()
78
- self .__region = aiotools .AioExclusiveRegion (AtxIsBusyError , self .__notifier )
78
+ self .__power_region = aiotools .AioExclusiveRegion (AtxIsBusyError , self .__notifier )
79
+ self .__reset_region = aiotools .AioExclusiveRegion (AtxIsBusyError , self .__notifier )
79
80
80
81
self .__line_req : (gpiod .LineRequest | None ) = None
81
82
@@ -122,9 +123,15 @@ def sysprep(self) -> None:
122
123
)
123
124
124
125
async def get_state (self ) -> dict :
126
+ power_busy = self .__power_region .is_busy ()
127
+ reset_busy = self .__reset_region .is_busy ()
125
128
return {
126
129
"enabled" : True ,
127
- "busy" : self .__region .is_busy (),
130
+ "busy" : (power_busy or reset_busy ),
131
+ "acts" : {
132
+ "power" : power_busy ,
133
+ "reset" : reset_busy ,
134
+ },
128
135
"leds" : {
129
136
"power" : self .__reader .get (self .__power_led_pin ),
130
137
"hdd" : self .__reader .get (self .__hdd_led_pin ),
@@ -175,28 +182,28 @@ async def power_reset_hard(self, wait: bool) -> None:
175
182
# =====
176
183
177
184
async def click_power (self , wait : bool ) -> None :
178
- await self .__click ("power" , self .__power_switch_pin , self .__click_delay , wait )
185
+ await self .__click ("power" , self .__power_region , self . __power_switch_pin , self .__click_delay , wait )
179
186
180
187
async def click_power_long (self , wait : bool ) -> None :
181
- await self .__click ("power_long" , self .__power_switch_pin , self .__long_click_delay , wait )
188
+ await self .__click ("power_long" , self .__power_region , self . __power_switch_pin , self .__long_click_delay , wait )
182
189
183
190
async def click_reset (self , wait : bool ) -> None :
184
- await self .__click ("reset" , self .__reset_switch_pin , self .__click_delay , wait )
191
+ await self .__click ("reset" , self .__reset_region , self . __reset_switch_pin , self .__click_delay , wait )
185
192
186
193
# =====
187
194
188
195
async def __get_power (self ) -> bool :
189
196
return (await self .get_state ())["leds" ]["power" ]
190
197
191
198
@aiotools .atomic_fg
192
- async def __click (self , name : str , pin : int , delay : float , wait : bool ) -> None :
199
+ async def __click (self , name : str , region : aiotools . AioExclusiveRegion , pin : int , delay : float , wait : bool ) -> None :
193
200
if wait :
194
- with self . __region :
201
+ with region :
195
202
await self .__inner_click (name , pin , delay )
196
203
else :
197
204
await aiotools .run_region_task (
198
205
f"Can't perform ATX { name } click or operation was not completed" ,
199
- self . __region , self .__inner_click , name , pin , delay ,
206
+ region , self .__inner_click , name , pin , delay ,
200
207
)
201
208
202
209
@aiotools .atomic_fg
0 commit comments