Debian Codegraph @

bindings/python/gpiod/info_event.py

raw symbols SCIP
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]>
3
4 from . import _ext
5 from .line_info import LineInfo
6 from dataclasses import dataclass
7 from enum import Enum
8
9 __all__ = "InfoEvent"
10
11
12 @dataclass(frozen=True, init=False, repr=False)
13 class InfoEvent:
14 """
15 Immutable object containing data about a single line info event.
16 """
17
18 class Type(Enum):
19 """Line status change event types."""
20
21 LINE_REQUESTED = _ext.INFO_EVENT_TYPE_LINE_REQUESTED
22 """Line has been requested."""
23 LINE_RELEASED = _ext.INFO_EVENT_TYPE_LINE_RELEASED
24 """Previously requested line has been released."""
25 LINE_CONFIG_CHANGED = _ext.INFO_EVENT_TYPE_LINE_CONFIG_CHANGED
26 """Line configuration has changed."""
27
28 event_type: Type
29 """Event type of the status change event."""
30 timestamp_ns: int
31 """Timestamp of the event."""
32 line_info: LineInfo
33 """Snapshot of line-info associated with the event."""
34
35 def __init__(self, event_type: int, timestamp_ns: int, line_info: LineInfo):
36 object.__setattr__(self, "event_type", InfoEvent.Type(event_type))
37 object.__setattr__(self, "timestamp_ns", timestamp_ns)
38 object.__setattr__(self, "line_info", line_info)
39
40 def __str__(self):
41 return "<InfoEvent type={} timestamp_ns={} line_info={}>".format(
42 self.event_type, self.timestamp_ns, self.line_info
43 )