Skip to content

Commit

Permalink
Merge pull request #17 from CerebusOSS/14_simple_design_improvements
Browse files Browse the repository at this point in the history
Expose monitor state
  • Loading branch information
cboulay authored Nov 22, 2024
2 parents 5bf7e75 + 497a106 commit 447d9b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pycbsdk/cbhw/device/nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ def _handle_nplay(self, pkt):
self._config["nplay"] = pkt

def _handle_procmon(self, pkt):
arrival_time = time.time()
update_interval = max(pkt.header.time - self._monitor_state["time"], 1)
pkt_delta = self.pkts_received - self._monitor_state["pkts_received"]

Expand All @@ -492,6 +493,7 @@ def _handle_procmon(self, pkt):
"counter": pkt.counter if has_counter else -1,
"time": pkt.header.time,
"pkts_received": self.pkts_received,
"sys_time": arrival_time,
}

def _handle_log(self, pkt):
Expand Down Expand Up @@ -1129,6 +1131,9 @@ def get_transport(self, force_refresh=False) -> int:
self.set_transport("CHECK", True, timeout=0.5)
return self._config["transport"]

def get_monitor_state(self) -> dict:
return self._monitor_state.copy()

def reset(self) -> int:
print("TODO: reset NSP proctime to 0")
return 0
Expand Down
4 changes: 4 additions & 0 deletions src/pycbsdk/cbsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ def get_runlevel(device: NSPDevice) -> CBRunLevel:
return device.get_runlevel()


def get_monitor_state(device: NSPDevice) -> dict:
return device.get_monitor_state()


def register_event_callback(
device: NSPDevice, channel_type: CBChannelType, func: Callable[[Structure], None]
):
Expand Down

0 comments on commit 447d9b9

Please sign in to comment.