Skip to content

Commit

Permalink
Add number of active channels to pysmurf controller check_state (#813)
Browse files Browse the repository at this point in the history
* Add number of active channels to pysmurf controller check_state

* Add docs entry for num_active_channels

* Change num_active_channels to type int

* Remove testing endpoint
  • Loading branch information
jlashner authored Jan 24, 2025
1 parent 265c0fc commit fa66216
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion socs/agents/pysmurf_controller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ def check_state(self, session, params=None):
'pysmurf_action_timestamp': Current pysmurf-action timestamp,
'stream_tag': stream-tag for the current g3 stream,
'last_update': Time that session-data was last updated,
'stream_id': Stream-id of the controlled smurf instance
'stream_id': Stream-id of the controlled smurf instance,
'num_active_channels': Number of channels outputting tones
}
"""
S, cfg = self._get_smurf_control(load_tune=False, no_dir=True)
Expand All @@ -317,6 +318,11 @@ def check_state(self, session, params=None):
kw = {'retry_on_fail': False}
while session.status in ['starting', 'running']:
try:

num_active_channels = 0
for band in range(8):
num_active_channels += len(S.which_on(band))

d = dict(
channel_mask=S.get_channel_mask(**kw).tolist(),
downsample_factor=S.get_downsample_factor(**kw),
Expand All @@ -327,6 +333,7 @@ def check_state(self, session, params=None):
stream_tag=reg.stream_tag.get(**kw, as_string=True),
last_update=time.time(),
stream_id=cfg.stream_id,
num_active_channels=num_active_channels,
)
session.data.update(d)
except (RuntimeError, epics.ca.ChannelAccessGetFailure):
Expand Down

0 comments on commit fa66216

Please sign in to comment.