async def main(): # Setup the SLM to run LAeq SLM_Setup_LAeq(host) # Get ID and object of sequence, the data for the wanted logging mode ID, sequence = seq.get_sequence(host, sequenceId) # Get URI for stream uri = stream.setup_stream(host, ip, ID, "Test") # Get datatype of the logging data data_type = sequence["DataType"] # Start a measurement. This is needed to obtain data from the device meas.start_pause_measurement(host, True) # Initilize a MovingLeq object to handle the data. # This example uses a 10s moving leq (assuming 1s logging) leq_10_mov = MovingLeq(10) # Create lambda function to use for the stream message. In this example is a function # call used msg_func = lambda msg: print_LAeq_mov(msg, data_type, leq_10_mov) # Initilize and run the websocket to retrive data await webSocket.next_async_websocket(uri, msg_func)
def streamInit(self): SLM_Setup_LAeq(host) self.ID, self.sequence = seq.get_sequence(host, sequenceID) # Get datatype of the logging data self.data_type = self.sequence["DataType"] # Get URI for stream self.uri = stream.setup_stream(host,ip,self.ID,"LAeqStream") # Start a measurement. This is needed to obtain data from the device meas.start_pause_measurement(host,True)
def streamInit(self): self.IDs = [] self.sequences = [] self.sequenceFuncs = [] for x in sequenceNames: ID, sequence = seq.get_sequence(host, getSequenceID(host, x)) self.IDs.append(ID) self.sequences.append(sequence) self.sequenceFuncs.append( MovingLeq(10, storedata=True, windowSize=100)) self.uri = stream.setup_stream(host, ip, self.IDs, "MultipleSequences") # Start a measurement. This is needed to obtain data from the device meas.start_pause_measurement(host, True)
async def main(): IDs = [] sequences = [] sequenceFuncs = [] for x in sequenceNames: ID, sequence = seq.get_sequence(host, getSequenceID(host, x)) IDs.append(ID) sequences.append(sequence) sequenceFuncs.append(MovingLeq(10, storedata=True)) uri = stream.setup_stream(host, ip, IDs, "MultipleSequences") # Start a measurement. This is needed to obtain data from the device meas.start_pause_measurement(host,True) msg_func = lambda msg : print_data(msg, IDs, sequences, sequenceFuncs) await webSocket.next_async_websocket(uri, msg_func)
self.ax.set_xlabel("Frequency band [Hz]") self.fig.autofmt_xdate() self.fig.tight_layout() self.fig.canvas.mpl_connect('close_event', on_close) def _update(self, i): for bar in self.ax.containers: bar.remove() self.ax.bar(self.freq, self.dataHandler.CPB_values, width=.99, color='#1f77b4') def startAnimation(self): self.ani = FuncAnimation(self.fig, self._update, interval=1000) def on_close(event): stream_handler.stopStream() sys.exit(0) if __name__ == "__main__": ID, sequence = seq.get_sequence(host, getSequenceID(host, "CPBLAeq")) CPB_LAeq = CPB_SLM(sequence) stream_handler = streamHandler(CPB_LAeq, "CPB test", ID) stream_handler.streamInit() fig = FigureHandler(CPB_LAeq) threading.Thread(target=stream_handler.startStream).start() fig.startAnimation() plt.show()