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