added a timeout counter, also as fake channel
This commit is contained in:
@ -26,14 +26,18 @@ class BSCache:
|
||||
|
||||
|
||||
def run(self, running):
|
||||
timeout_counter = 0
|
||||
configs = self.channels.values()
|
||||
with source(channels=configs, receive_timeout=self.timeout) as src:
|
||||
while running.is_set():
|
||||
msg = src.receive()
|
||||
if msg is None:
|
||||
timeout_counter += 1
|
||||
print("receive timed out", timeout_counter)
|
||||
continue
|
||||
data = repack(msg)
|
||||
if data:
|
||||
data["toc"] = timeout_counter
|
||||
yield data
|
||||
|
||||
|
||||
@ -42,7 +46,7 @@ class BSCache:
|
||||
|
||||
|
||||
def get_var(self, name, modulo=None, offset=None):
|
||||
if name != "pid" and name not in self.channels:
|
||||
if name not in ["pid", "toc"] and name not in self.channels:
|
||||
if not is_available(name):
|
||||
raise ValueError(f"channel {name} is not available")
|
||||
cfg = make_channel_config(name, modulo, offset)
|
||||
|
Reference in New Issue
Block a user