add sleep if open impedence
This commit is contained in:
@@ -206,6 +206,9 @@ class Decoder_main(threading.Thread):
|
|||||||
self.zmqServer.state_mode = 'rest'
|
self.zmqServer.state_mode = 'rest'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if self.zmqServer.open_Impedance:
|
||||||
|
time.sleep(0.005)
|
||||||
|
continue
|
||||||
if self.decoder_class == 'ssvep' or self.decoder_class == 'pvs':
|
if self.decoder_class == 'ssvep' or self.decoder_class == 'pvs':
|
||||||
self.decoder_SSVEP()
|
self.decoder_SSVEP()
|
||||||
elif self.decoder_class == 'ssmvep':
|
elif self.decoder_class == 'ssmvep':
|
||||||
@@ -215,7 +218,7 @@ class Decoder_main(threading.Thread):
|
|||||||
else:
|
else:
|
||||||
if self.zmqServer.paradigmBuffer.GetDataLenCount() < 25:
|
if self.zmqServer.paradigmBuffer.GetDataLenCount() < 25:
|
||||||
time.sleep(0.005)
|
time.sleep(0.005)
|
||||||
continue;
|
continue
|
||||||
self.zmqServer.paradigmBuffer.getData(25)
|
self.zmqServer.paradigmBuffer.getData(25)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
algo_log(f"Decoder Loop Error: {e}")
|
algo_log(f"Decoder Loop Error: {e}")
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ class zmqServer(threading.Thread):
|
|||||||
# 转置为上位机需要的[50, 通道数]格式
|
# 转置为上位机需要的[50, 通道数]格式
|
||||||
filtered_data = filtered_data.T.astype(np.float64)
|
filtered_data = filtered_data.T.astype(np.float64)
|
||||||
send_buf = filtered_data.tobytes()
|
send_buf = filtered_data.tobytes()
|
||||||
algo_log(f"发送滤波数据,长度: {len(send_buf)}字节, filtered_data.shape: {filtered_data.shape}", level="DEBUG", record_once=True)
|
# algo_log(f"发送滤波数据,长度: {len(send_buf)}字节, filtered_data.shape: {filtered_data.shape}", level="DEBUG", record_once=True)
|
||||||
self.data_send_queue.put(send_buf)
|
self.data_send_queue.put(send_buf)
|
||||||
|
|
||||||
def _process_data_send_queue(self):
|
def _process_data_send_queue(self):
|
||||||
@@ -228,6 +228,9 @@ class zmqServer(threading.Thread):
|
|||||||
algo_log(f"无效JSON命令: {message_bytes.hex()}", level="ERROR")
|
algo_log(f"无效JSON命令: {message_bytes.hex()}", level="ERROR")
|
||||||
self.broadcast_message("error", {"code": 400, "message": "无效JSON格式"})
|
self.broadcast_message("error", {"code": 400, "message": "无效JSON格式"})
|
||||||
return
|
return
|
||||||
|
except Exception as e:
|
||||||
|
algo_log(f"_handle_cmd_message exception: {e}", level="ERROR")
|
||||||
|
return
|
||||||
|
|
||||||
algo_log(f"收到命令: {message}", level="INFO")
|
algo_log(f"收到命令: {message}", level="INFO")
|
||||||
method = message.get("method")
|
method = message.get("method")
|
||||||
@@ -418,7 +421,8 @@ class zmqServer(threading.Thread):
|
|||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
algo_log(f"服务器主循环异常: {e}", level="ERROR")
|
algo_log(f"服务器主循环异常: {str(e)}", level="ERROR")
|
||||||
|
return
|
||||||
finally:
|
finally:
|
||||||
self.running = False
|
self.running = False
|
||||||
# 优雅关闭所有资源
|
# 优雅关闭所有资源
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ EMPTY_FRAME = b""
|
|||||||
|
|
||||||
# 仿真信号配置
|
# 仿真信号配置
|
||||||
TARGET_CHANNEL = 0
|
TARGET_CHANNEL = 0
|
||||||
SIGNAL_FREQ_LIST = [3, 13]
|
SIGNAL_FREQ_LIST = [13]
|
||||||
SIGNAL_AMP = 1.8
|
SIGNAL_AMP = 1.8
|
||||||
NOISE_GAUSSIAN_AMP = 0.4
|
NOISE_GAUSSIAN_AMP = 0.4
|
||||||
NOISE_POWER50_AMP = 0.3
|
NOISE_POWER50_AMP = 0.3
|
||||||
@@ -128,8 +128,8 @@ def generate_eeg_packet(pkt_idx: int) -> np.ndarray:
|
|||||||
sig = 0.0
|
sig = 0.0
|
||||||
for freq in SIGNAL_FREQ_LIST:
|
for freq in SIGNAL_FREQ_LIST:
|
||||||
sig += SIGNAL_AMP * np.sin(2 * np.pi * freq * t_arr)
|
sig += SIGNAL_AMP * np.sin(2 * np.pi * freq * t_arr)
|
||||||
sig += NOISE_POWER50_AMP * np.sin(2 * np.pi * 50 * t_arr)
|
# sig += NOISE_POWER50_AMP * np.sin(2 * np.pi * 50 * t_arr)
|
||||||
sig += NOISE_GAUSSIAN_AMP * np.random.randn(n_point)
|
# sig += NOISE_GAUSSIAN_AMP * np.random.randn(n_point)
|
||||||
data[:, ch] = sig
|
data[:, ch] = sig
|
||||||
|
|
||||||
# 事件通道、保留通道
|
# 事件通道、保留通道
|
||||||
|
|||||||
Reference in New Issue
Block a user