File indexing completed on 2025-01-18 10:17:18
0001
0002
0003
0004
0005
0006 import zmq
0007 import numpy as np
0008 from indraMessage import IndraMessage
0009 from monitoringObjects import *
0010
0011
0012 numChans = 80
0013
0014
0015 class StreamSubscriber:
0016 """Class to handle INDRA Streaming"""
0017
0018 def __init__(self, plot_type = 'Occupancy', port = 5557, thresh = 100, nrows = 2, ncols = 2):
0019 self.plot_type = plot_type
0020 self.port = port
0021 self.thresh = thresh
0022 self.nrows = nrows
0023 self.ncols = ncols
0024 self.context = zmq.Context()
0025 self.subscriber = self.context.socket(zmq.SUB)
0026 self.subscriber.setsockopt(zmq.SUBSCRIBE, b'')
0027 self.subscriber.connect('tcp://127.0.0.1:%d' % self.port)
0028 print('\nSubscribing to JANA ZMQ Messages on socket tcp://127.0.0.1:%d\n' % self.port)
0029
0030 if self.plot_type == 'Occupancy':
0031 self.mon_fig = OccupancyFig()
0032 self.hit_cntr = np.zeros(numChans)
0033 if self.plot_type == 'Waveform':
0034 self.mon_fig = WaveformFig(self.nrows, self.ncols)
0035
0036 while True:
0037
0038 self.jana_msg = self.subscriber.recv()
0039
0040 self.jevent = IndraMessage(self.jana_msg)
0041
0042 if self.plot_type == 'Occupancy':
0043 self.mon_plots = OccupancyPlot(self.jevent.data_dict, self.thresh, self.mon_fig, self.hit_cntr)
0044 if self.plot_type == 'Waveform':
0045 self.mon_plots = WaveformPlot(self.jevent.data_dict, self.thresh, self.mon_fig.get_num_rows(),
0046 self.mon_fig.get_num_cols(), self.mon_fig.get_fig_obj(),
0047 self.mon_fig.get_axs_obj(), self.mon_fig.get_chan_list())