本文整理匯總了Python中recorder.Recorder.acknowledge_new_data方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.acknowledge_new_data方法的具體用法?Python Recorder.acknowledge_new_data怎麽用?Python Recorder.acknowledge_new_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recorder.Recorder
的用法示例。
在下文中一共展示了Recorder.acknowledge_new_data方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import acknowledge_new_data [as 別名]
def start(self):
# Init the amp
print 'Initializing the amp...'
recorder = Recorder('lslamp', params.FREQ_S, params.LEN_REC_BUF_SEC, params.NUM_CHANNELS)
thread_rec = threading.Thread(target=recorder.record)
thread_rec.start()
# Start plotting
plt.show()
#thread_plot = threading.Thread(target=self.plot_live)
#thread_plot.start()
# Get and display data from the amp
counter = 0
while not is_terminate_requested:
data_last_chunk = recorder.get_new_data(params.LEN_DATA_CHUNK_READ, params.AMP_WAIT_SEC)
recorder.acknowledge_new_data()
print 'recorder.new_data_counter:', recorder.new_data_counter
#print 'data_last_chunk.shape: ', data_last_chunk.shape
# Position the older data to the beginning of the buffer
self.X_buf[0:(self.len_buf - params.LEN_DATA_CHUNK_READ)]\
= self.X_buf[params.LEN_DATA_CHUNK_READ:]
# Insert the new data into the buffer
self.X_buf[(self.len_buf - params.LEN_DATA_CHUNK_READ):]\
= data_last_chunk
#i_row_from = int((counter*params.LEN_DATA_CHUNK_READ) % self.len_buf)
#i_row_to = int(((counter+1)*params.LEN_DATA_CHUNK_READ) % self.len_buf)
#if i_row_to == 0:
# i_row_to = self.len_buf
#print 'i_row_from, i_row_to:', i_row_from, i_row_to
#self.X_buf[i_row_from: i_row_to] = data_last_chunk
#print 'X_buf[i_row_from: i_row_to]:\n', self.X_buf[i_row_from: i_row_to]
if counter % 2 == 0:
self.plot_live()
counter += 1
# End of while
# Stop the amp
recorder.stop_recording()
示例2: cursor_func
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import acknowledge_new_data [as 別名]
#.........這裏部分代碼省略.........
cursor_color_arr_ud = np.flipud(cursor_color_arr_raw)
cursor_color_arr_ud_convd = signal.convolve(cursor_color_arr_ud.T, conv_window.T).T
cursor_color_arr_final = np.flipud(cursor_color_arr_ud_convd[0:cursor_color_arr_raw.shape[0], :])
if False:
plt.figure()
plt.plot(cursor_color_arr_raw)
#plt.plot(cursor_color_arr_ud[:, 0])
#plt.plot(cursor_color_arr_ud_convd[:, 0])
plt.plot(cursor_color_arr_final)
#plt.legend(['raw', 'ud', 'ud_convd', 'final'])
plt.show()
# Initialize the amplifier
if not is_simulation_mode:
print 'Initializing the amp...'
recorder = Recorder('lslamp', freq_sampling, params.LEN_REC_BUF_SEC, num_signal_channels)
thread_rec = threading.Thread(target=recorder.record)
thread_rec.start()
# Cursor control loop
X_raw_buf_live = np.zeros((int(freq_sampling*params.LEN_REC_BUF_SEC), num_signal_channels))
label_buf_live = np.zeros((int(freq_sampling*params.LEN_REC_BUF_SEC), num_event_types))
counter = 0
#while True:
while counter < (params.LEN_REC_SEC * freq_sampling / params.LEN_DATA_CHUNK_READ):
print 'counter: ', counter
# Clear the canvas
win.delete('all')
if not is_simulation_mode:
# Wait for new data and get it
data_last_chunk = recorder.get_new_data(params.LEN_DATA_CHUNK_READ, params.AMP_WAIT_SEC)
recorder.acknowledge_new_data()
print 'recorder.new_data_counter:', recorder.new_data_counter
else:
time.sleep(1.0 / (freq_sampling/params.LEN_DATA_CHUNK_READ))
data_last_chunk = 1000.0 * np.random.rand(int(params.LEN_DATA_CHUNK_READ), num_signal_channels)
#print 'Random data_last_chunk size:', data_last_chunk
# Insert the new sample into our time series
i_row_lb = int((counter+len_padding)*params.LEN_DATA_CHUNK_READ)
i_row_ub = int((counter+len_padding+1)*params.LEN_DATA_CHUNK_READ)
X_raw_buf_live[i_row_lb:i_row_ub, :] = data_last_chunk
#print 'data_last_chunk:', data_last_chunk
label_buf_live[i_row_lb:i_row_ub, :]\
= cursor_event_list[counter % int(params.LEN_PERIOD_SEC * freq_sampling / params.LEN_DATA_CHUNK_READ)]
# Calculating cursor step
i_row_ub = int((counter+len_padding+1)*params.LEN_DATA_CHUNK_READ)
i_row_lb = i_row_ub - int(window_size_in_samples)
if i_row_lb >= 0:
#print 'i_row_lb, i_row_ub:', i_row_lb, i_row_ub
#print 'X_raw_buf_live[i_row_lb:i_row_ub, :].shape:', X_raw_buf_live[i_row_lb:i_row_ub, :].shape
if is_control_mode:
X_window = utils.preprocess(X_raw_buf_live[i_row_lb:i_row_ub, :], scaler)
X_in = TimeSeriesBatchIterator.create_X_instance(X_window, conv_dim=1)
X_in = X_in.reshape(1, X_in.shape[0], X_in.shape[1])
#print 'X_window.shape:', X_window.shape
#print 'X_in.shape:', X_in.shape
cursor_step = calc_cursor_step(nnet, X_in.astype(np.float32))
else:
#X_window = X_raw_buf_live[i_row_lb:i_row_ub, :]
cursor_step = 0
cursor_pos = cursor_pos_prev + np.array([cursor_step, 0])