del train
This commit is contained in:
@@ -21,6 +21,10 @@ class zmqServer(threading.Thread):
|
||||
self.device_info = device_info
|
||||
|
||||
self.host = host
|
||||
|
||||
test_host = "10.200.27.140"
|
||||
self.host = test_host
|
||||
|
||||
self.cmd_port = cmd_port # 命令交互端口:收JSON命令 + 返JSON结果
|
||||
self.data_port = data_port # 数据交互端口:收二进制原始脑电 + 返二进制滤波结果
|
||||
self.running = False
|
||||
@@ -105,14 +109,14 @@ class zmqServer(threading.Thread):
|
||||
|
||||
def interval_init(self, decoder_class):
|
||||
if decoder_class == 'ssmvep':
|
||||
interval_epoch = ast.literal_eval(IniRead('system', 'SSMVEP_IntervalEpoch'))
|
||||
self.interval_epoch = [int(i * self.device_info['sample_rate']) for i in interval_epoch]
|
||||
interval_epoch = ast.literal_eval(IniRead('system', 'SSMVEP_IntervalEpoch')) # [0.2, 2.2]
|
||||
self.interval_epoch = [int(i * self.device_info['sample_rate']) for i in interval_epoch] # [50, 550]
|
||||
self.train_epoch = [
|
||||
int(self.interval_epoch[0]),
|
||||
int(self.interval_epoch[1] + 0.1 * self.device_info['sample_rate'])
|
||||
]
|
||||
self.latency = (self.interval_epoch[1] + 0.1 * self.device_info['sample_rate']) // 5
|
||||
self.train_latency = (self.train_epoch[1] + 0.1 * self.device_info['sample_rate']) // 5
|
||||
] # [50, 575]
|
||||
self.latency = (self.interval_epoch[1] + 0.1 * self.device_info['sample_rate']) // 5 #115包, 575个点
|
||||
self.train_latency = (self.train_epoch[1] + 0.1 * self.device_info['sample_rate']) // 5 #120包 600个点
|
||||
|
||||
elif decoder_class == 'mi':
|
||||
interval_epoch = ast.literal_eval(IniRead('system', 'MI_IntervalEpoch'))
|
||||
@@ -246,8 +250,6 @@ class zmqServer(threading.Thread):
|
||||
self.decoder_switch = True
|
||||
elif method == "train":
|
||||
self.state_mode = 'train'
|
||||
self.StartTrain = True
|
||||
self.currentLabel = params
|
||||
elif method == "predict":
|
||||
self.state_mode = 'predict'
|
||||
if params == 1: #开始解码
|
||||
@@ -322,22 +324,24 @@ class zmqServer(threading.Thread):
|
||||
def detect_event(self, samples):
|
||||
self.pack_contain_event = False
|
||||
# 第65通道为事件通道
|
||||
events = samples[-2].tolist()
|
||||
for idx, event in enumerate(events):
|
||||
if int(event) in self.events:
|
||||
new_key = "".join(
|
||||
[
|
||||
str(event),
|
||||
datetime.datetime.now().strftime("%Y-%m-%d \
|
||||
-%H-%M-%S"),
|
||||
]
|
||||
)
|
||||
if event == self.predict_event:
|
||||
self.count_events[new_key] = self.latency + 1
|
||||
else:
|
||||
self.count_events[new_key] = self.train_latency + 1
|
||||
self.event_inner_idx = idx
|
||||
self.pack_contain_event = True
|
||||
event = int(samples[-2][0])
|
||||
# for idx, event in enumerate(events):
|
||||
if event in self.events:
|
||||
new_key = "".join(
|
||||
[
|
||||
str(event),
|
||||
datetime.datetime.now().strftime("%Y-%m-%d \
|
||||
-%H-%M-%S"),
|
||||
]
|
||||
)
|
||||
self.currentLabel = event
|
||||
if event == self.predict_event:
|
||||
self.count_events[new_key] = self.latency + 1
|
||||
else:
|
||||
self.count_events[new_key] = self.train_latency + 1
|
||||
self.event_inner_idx = self.device_info['frame_points'] - 1
|
||||
# algo_log(f"事件检测到: {event},索引: {idx}", level="DEBUG")
|
||||
self.pack_contain_event = True
|
||||
|
||||
# 倒计时并清理过期事件
|
||||
drop_items = []
|
||||
|
||||
Reference in New Issue
Block a user