-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgeneric_signal.py
More file actions
41 lines (33 loc) · 933 Bytes
/
Copy pathgeneric_signal.py
File metadata and controls
41 lines (33 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Generic Signal implementation,
used for defining inputs and outputs
"""
from abc import ABC
from threading import Event
from typing import Type
class GenericSignal(ABC): # pylint: disable=too-few-public-methods
"""
Generic Signal class used to implement any other signal class
"""
def __init__(self):
"""
Initialization method
"""
self.computed = Event()
self.ports = []
def set_computed(self):
"""
After signal is computed the computed flag should be set
"""
self.computed.set()
def wait_till_compute(self, timeout=None):
"""
Blocking call, waits until the signal is computed
"""
self.computed.wait(timeout)
def register_port(self, port: Type["Port"], device):
"""
Registers the port to the signal,
TODO: disconnecting
"""
self.ports.append(port)