32
32
33
33
from .types import Edid
34
34
from .types import Edids
35
+ from .types import Dummies
35
36
from .types import Color
36
37
from .types import Colors
37
38
from .types import PortNames
@@ -68,14 +69,15 @@ def __init__(self) -> None:
68
69
# =====
69
70
class Switch : # pylint: disable=too-many-public-methods
70
71
__X_EDIDS = "edids"
72
+ __X_DUMMIES = "dummies"
71
73
__X_COLORS = "colors"
72
74
__X_PORT_NAMES = "port_names"
73
75
__X_ATX_CP_DELAYS = "atx_cp_delays"
74
76
__X_ATX_CPL_DELAYS = "atx_cpl_delays"
75
77
__X_ATX_CR_DELAYS = "atx_cr_delays"
76
78
77
79
__X_ALL = frozenset ([
78
- __X_EDIDS , __X_COLORS , __X_PORT_NAMES ,
80
+ __X_EDIDS , __X_DUMMIES , __X_COLORS , __X_PORT_NAMES ,
79
81
__X_ATX_CP_DELAYS , __X_ATX_CPL_DELAYS , __X_ATX_CR_DELAYS ,
80
82
])
81
83
@@ -105,6 +107,12 @@ def __x_set_edids(self, edids: Edids, save: bool=True) -> None:
105
107
if save :
106
108
self .__save_notifier .notify ()
107
109
110
+ def __x_set_dummies (self , dummies : Dummies , save : bool = True ) -> None :
111
+ self .__chain .set_dummies (dummies )
112
+ self .__cache .set_dummies (dummies )
113
+ if save :
114
+ self .__save_notifier .notify ()
115
+
108
116
def __x_set_colors (self , colors : Colors , save : bool = True ) -> None :
109
117
self .__chain .set_colors (colors )
110
118
self .__cache .set_colors (colors )
@@ -236,6 +244,7 @@ async def set_port_params(
236
244
self ,
237
245
port : int ,
238
246
edid_id : (str | None )= None ,
247
+ dummy : (bool | None )= None ,
239
248
name : (str | None )= None ,
240
249
atx_click_power_delay : (float | None )= None ,
241
250
atx_click_power_long_delay : (float | None )= None ,
@@ -250,15 +259,16 @@ async def set_port_params(
250
259
edids .assign (port , edid_id )
251
260
self .__x_set_edids (edids )
252
261
253
- for (key , value ) in [
254
- (self .__X_PORT_NAMES , name ),
255
- (self .__X_ATX_CP_DELAYS , atx_click_power_delay ),
256
- (self .__X_ATX_CPL_DELAYS , atx_click_power_long_delay ),
257
- (self .__X_ATX_CR_DELAYS , atx_click_reset_delay ),
262
+ for (reset , key , value ) in [
263
+ (None , self .__X_DUMMIES , dummy ), # None can't be used now
264
+ ("" , self .__X_PORT_NAMES , name ),
265
+ (0 , self .__X_ATX_CP_DELAYS , atx_click_power_delay ),
266
+ (0 , self .__X_ATX_CPL_DELAYS , atx_click_power_long_delay ),
267
+ (0 , self .__X_ATX_CR_DELAYS , atx_click_reset_delay ),
258
268
]:
259
269
if value is not None :
260
270
new = getattr (self .__cache , f"get_{ key } " )()
261
- new [port ] = (value or None ) # None == reset to default
271
+ new [port ] = (None if value == reset else value ) # Value or reset default
262
272
getattr (self , f"_Switch__x_set_{ key } " )(new )
263
273
264
274
# =====
@@ -375,7 +385,7 @@ async def __systask_storage(self) -> None:
375
385
prevs = dict .fromkeys (self .__X_ALL )
376
386
while True :
377
387
await self .__save_notifier .wait ()
378
- while (await self .__save_notifier .wait (5 )):
388
+ while not (await self .__save_notifier .wait (5 )):
379
389
pass
380
390
while True :
381
391
try :
0 commit comments