Change instance variables to class variables

This commit is contained in:
Triston Armstrong 2021-09-21 10:55:01 -05:00
parent 01844b188a
commit f7371ce7c4

View File

@ -1,5 +1,5 @@
import ProcessorDevice import ProcessorDevice
from typing import Optional, Union from typing import Callable, Optional, Union
class eBUSDevice(): class eBUSDevice():
@ -34,18 +34,9 @@ class eBUSDevice():
- `Online` - (Event) Triggers when the device comes online. The callback takes two Parameters. The first one is the extronlib.device instance triggering the event and the second one is a string ('Online'). - `Online` - (Event) Triggers when the device comes online. The callback takes two Parameters. The first one is the extronlib.device instance triggering the event and the second one is a string ('Online').
- `SleepChanged` - (Event) Triggers when sleep state changes. The callback takes two Parameters. The first one is the eBUSDevice instance triggering the event and the second one is a string ('Asleep' | 'Awake'). - `SleepChanged` - (Event) Triggers when sleep state changes. The callback takes two Parameters. The first one is the eBUSDevice instance triggering the event and the second one is a string ('Asleep' | 'Awake').
""" """
def __init__(self, Host: object, DeviceAlias: str) -> None:
"""
eBUSDevice class constructor.
---
Parameters: InactivityChanged = None
- Host (`object`) - handle to Extron ProcessorDevice to which the eBUSDevice is connected
- DeviceAlias (`string`) - Device Alias of the Extron device
"""
self.InactivityChanged: callable = None
""" """
Event: Event:
- Triggers at times specified by SetInactivityTime() after state transition of inactivity timer. - Triggers at times specified by SetInactivityTime() after state transition of inactivity timer.
@ -68,7 +59,7 @@ class eBUSDevice():
Note: Note:
Applies to EBP models only. Applies to EBP models only.
""" """
self.SleepChanged: callable = None SleepChanged = None
""" """
Event: Event:
- Triggers when sleep state changes. - Triggers when sleep state changes.
@ -81,47 +72,57 @@ class eBUSDevice():
print('{} Sleep State Changed: {}'.format(Panel.DeviceAlias, state)) print('{} Sleep State Changed: {}'.format(Panel.DeviceAlias, state))
``` ```
""" """
self.LidChanged: callable = None LidChanged = None
""" """
Event: Event:
- Triggers when the Lid state changes. - Triggers when the Lid state changes.
- The callback takes two arguments. The first one is the eBUSDevice instance triggering the event and the second is the current lid state ('Opened' or 'Closed'). - The callback takes two arguments. The first one is the eBUSDevice instance triggering the event and the second is the current lid state ('Opened' or 'Closed').
""" """
self.Offline: callable = None Offline = None
""" """
Event: Event:
- Triggers when the device goes offline. - Triggers when the device goes offline.
- The callback takes two arguments. The first one is the extronlib.device instance triggering the event and the second one is a string ('Offline'). - The callback takes two arguments. The first one is the extronlib.device instance triggering the event and the second one is a string ('Offline').
""" """
self.Online: callable = None Online = None
""" """
Event: Event:
- Triggers when the device comes online. - Triggers when the device comes online.
- The callback takes two arguments. The first one is the extronlib.device instance triggering the event and the second one is a string ('Online'). - The callback takes two arguments. The first one is the extronlib.device instance triggering the event and the second one is a string ('Online').
""" """
self.SleepTimerEnabled: bool = False SleepTimerEnabled: bool = False
self.DeviceAlias: str = DeviceAlias DeviceAlias: str = ''
self.Host: ProcessorDevice = Host Host = None
""" Handle to the Extron ProcessorDevice to which the eBUSDevice is connected. """ """ Handle to the Extron ProcessorDevice to which the eBUSDevice is connected. """
self.InactivityTime: int = 0 InactivityTime: int = 0
"""Seconds since last activity. """Seconds since last activity.
Note: Note:
- 0 = Active, Nonzero = Time of inactivity. - 0 = Active, Nonzero = Time of inactivity.
- Applies to EBP models only. - Applies to EBP models only.
""" """
self.SleepState: str = '' SleepState: str = ''
""" the current sleep state of the device ('Asleep', 'Awake')""" """ the current sleep state of the device ('Asleep', 'Awake')"""
self.PartNumber: str = '' PartNumber: str = ''
self.ModelName: str = '' ModelName: str = ''
self.LidState: str = '' LidState: str = ''
"""the current lid state ('Opened' or 'Closed')""" """the current lid state ('Opened' or 'Closed')"""
self.SleepTimer: int = 0 SleepTimer: int = 0
""" sleep timer timeout""" """ sleep timer timeout"""
self.ID: int = 0 ID: int = 0
"""devices ID (set by DIP switch)""" """devices ID (set by DIP switch)"""
def __init__(self, Host: object, DeviceAlias: str) -> None:
"""
eBUSDevice class constructor.
---
Parameters:
- Host (`object`) - handle to Extron ProcessorDevice to which the eBUSDevice is connected
- DeviceAlias (`string`) - Device Alias of the Extron device
"""
def Click(self, count: int=1, interval: int=None) -> None: def Click(self, count: int=1, interval: int=None) -> None:
""" Play default buzzer sound on applicable device """ Play default buzzer sound on applicable device