def _build_grant(grant: DBGrant) -> Grant: last_heartbeat = _to_timestamp(grant.last_heartbeat_request_time) return Grant( id=grant.grant_id, state=grant_state_mapping[grant.state.name], heartbeat_interval_sec=grant.heartbeat_interval, last_heartbeat_timestamp=last_heartbeat, )
def with_grant( self, grant_id: str, state: GrantState, hb_interval_sec: int, last_hb_ts: int, ) -> ActiveModeCbsdBuilder: if not self.grants: self.grants = [] grant = Grant( id=grant_id, state=state, heartbeat_interval_sec=hb_interval_sec, last_heartbeat_timestamp=last_hb_ts, ) self.grants.append(grant) return self
def with_grant( self, grant_id: str, state: GrantState, hb_interval_sec: int, last_hb_ts: int, low_frequency_hz: int = 3500, high_frequency_hz: int = 3700, ) -> ActiveModeCbsdBuilder: grant = Grant( id=grant_id, state=state, heartbeat_interval_sec=hb_interval_sec, last_heartbeat_timestamp=last_hb_ts, low_frequency_hz=low_frequency_hz, high_frequency_hz=high_frequency_hz, ) self.grants.append(grant) return self