update
This commit is contained in:
@@ -189,7 +189,7 @@ class Decoder_main(threading.Thread):
|
|||||||
self.b_notch, self.a_notch = signal.iirnotch(50 / (self.device_info['sample_rate']/2), 30) # 50Hz工频陷波,250是采样率,30是质量因子
|
self.b_notch, self.a_notch = signal.iirnotch(50 / (self.device_info['sample_rate']/2), 30) # 50Hz工频陷波,250是采样率,30是质量因子
|
||||||
self.b_design = signal.firwin(65, [bandPass_low / (self.device_info['sample_rate']/2), bandPass_high / (self.device_info['sample_rate']/2)], pass_zero=False) # 设计8-30Hz带通滤波器
|
self.b_design = signal.firwin(65, [bandPass_low / (self.device_info['sample_rate']/2), bandPass_high / (self.device_info['sample_rate']/2)], pass_zero=False) # 设计8-30Hz带通滤波器
|
||||||
fileName = 'Model_' + datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
|
fileName = 'Model_' + datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
|
||||||
filePath = './online_Models/'
|
filePath = os.path.join(get_root_path(), MODEL_FOLDER) + os.sep
|
||||||
for old_pth in glob.glob(os.path.join(filePath, '*.pth')):
|
for old_pth in glob.glob(os.path.join(filePath, '*.pth')):
|
||||||
os.remove(old_pth)
|
os.remove(old_pth)
|
||||||
self.modelPath = ''.join([filePath, fileName, '.pth'])
|
self.modelPath = ''.join([filePath, fileName, '.pth'])
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import json
|
|||||||
import queue
|
import queue
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
# from Device.SunnyLinker import SunnyLinker64
|
# from Device.SunnyLinker import SunnyLinker64
|
||||||
from dataBuffer import ParadigmRingBuffer
|
from Zmq.dataBuffer import ParadigmRingBuffer
|
||||||
from filterProcess import FilterRingBuffer
|
from Zmq.filterProcess import FilterRingBuffer
|
||||||
from PubLibrary.InifileHelper import IniRead
|
from PubLibrary.InifileHelper import IniRead
|
||||||
from logs.log import algo_log
|
from logs.log import algo_log
|
||||||
|
|
||||||
@@ -42,15 +42,14 @@ class zmqServer(threading.Thread):
|
|||||||
self.context = zmq.Context()
|
self.context = zmq.Context()
|
||||||
# 指令通道 (8099) - ROUTER:短JSON命令,低频率
|
# 指令通道 (8099) - ROUTER:短JSON命令,低频率
|
||||||
self.cmd_socket = self.context.socket(zmq.ROUTER)
|
self.cmd_socket = self.context.socket(zmq.ROUTER)
|
||||||
self.cmd_socket.setsockopt(zmq.RCVHWM, 100) # 指令不需要大缓存,100条足够
|
# 通用套接字选项:仍在 SocketOption 中
|
||||||
self.cmd_socket.setsockopt(zmq.SNDHWM, 100)
|
self.cmd_socket.setsockopt(zmq.SocketOption.RCVHWM, 100)
|
||||||
self.cmd_socket.setsockopt(zmq.TCP_NODELAY, 1) # 禁用Nagle算法,降低指令延迟
|
self.cmd_socket.setsockopt(zmq.SocketOption.SNDHWM, 100)
|
||||||
self.cmd_socket.bind(f"tcp://{self.host}:{cmd_port}")
|
self.cmd_socket.bind(f"tcp://{self.host}:{cmd_port}")
|
||||||
|
|
||||||
# 数据通道 (8100) - ROUTER:高频脑电二进制流
|
# 数据通道 (8100) - ROUTER:高频脑电二进制流
|
||||||
self.data_socket = self.context.socket(zmq.ROUTER)
|
self.data_socket = self.context.socket(zmq.ROUTER)
|
||||||
self.data_socket.setsockopt(zmq.RCVHWM, 500) # 500包=10秒缓存,足够应对短时卡顿
|
self.data_socket.setsockopt(zmq.SocketOption.RCVHWM, 500)
|
||||||
self.data_socket.setsockopt(zmq.TCP_NODELAY, 1) # 禁用Nagle算法,减少数据传输延迟
|
|
||||||
self.data_socket.bind(f"tcp://{self.host}:{data_port}")
|
self.data_socket.bind(f"tcp://{self.host}:{data_port}")
|
||||||
|
|
||||||
# Poller 轮训器(保持不变)
|
# Poller 轮训器(保持不变)
|
||||||
@@ -287,14 +286,14 @@ class zmqServer(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.running = True
|
self.running = True
|
||||||
print(f"ZMQ Server started - CMD Port: {self.cmd_port}, DATA Port: {self.data_port}")
|
algo_log(f"algo ZMQ Server started - CMD Port: {self.cmd_port}, DATA Port: {self.data_port}", level="INFO")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while self.running:
|
while self.running:
|
||||||
# 1. 处理发送队列(命令端口广播)
|
# 1. 处理发送队列(命令端口广播)
|
||||||
self._process_send_queue()
|
self._process_send_queue()
|
||||||
|
|
||||||
# 2. 轮训监听两个Socket的输入事件(10ms超时,避免阻塞)
|
# 2. 轮训监听两个Socket的输入事件
|
||||||
socks = dict(self.poller.poll(50))
|
socks = dict(self.poller.poll(50))
|
||||||
|
|
||||||
# 处理命令端口消息
|
# 处理命令端口消息
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ def get_device_info(device_type):
|
|||||||
section = f'device_type_{device_type}'
|
section = f'device_type_{device_type}'
|
||||||
device_info = {
|
device_info = {
|
||||||
'sample_rate': int(IniRead(section, 'sample_rate')) if IniRead(section, 'sample_rate') is not None else 250,
|
'sample_rate': int(IniRead(section, 'sample_rate')) if IniRead(section, 'sample_rate') is not None else 250,
|
||||||
|
'frame_points': int(IniRead(section, 'frame_points')) if IniRead(section, 'frame_points') is not None else 5,
|
||||||
'channel_nums': int(IniRead(section, 'channel_nums')) if IniRead(section, 'channel_nums') is not None else 66,
|
'channel_nums': int(IniRead(section, 'channel_nums')) if IniRead(section, 'channel_nums') is not None else 66,
|
||||||
'channel_names': IniRead(section, 'channel_names') if IniRead(section, 'channel_names') is not None else None,
|
'channel_names': IniRead(section, 'channel_names') if IniRead(section, 'channel_names') is not None else None,
|
||||||
'channel_index': IniRead(section, 'channel_index') if IniRead(section, 'channel_index') is not None else None,
|
'channel_index': IniRead(section, 'channel_index') if IniRead(section, 'channel_index') is not None else None,
|
||||||
|
|||||||
Reference in New Issue
Block a user