fix 提取数据不成功

This commit is contained in:
2026-06-14 10:25:56 +08:00
parent c27e250fad
commit 7f7760c1b6
4 changed files with 69 additions and 50 deletions

View File

@@ -17,6 +17,10 @@ LABEL_CMD_ADDR = 'tcp://127.0.0.1:8101' # 接收来自上位机范式的标签
# 发送间隔: 每包 5 采样点 / 250Hz = 20ms
PKT_INTERVAL = N_SAMPLES_PER_PKT / FS
POINT_PER_3S = FS * 3 # 750
# 3秒对应的总包数关键每150包 = 3s
PKT_PER_3S = POINT_PER_3S // N_SAMPLES_PER_PKT # 150
def build_packet(global_sample_idx):
"""
@@ -34,6 +38,16 @@ def build_packet(global_sample_idx):
# Ch64: 标签值通道,初始化为 0
event = np.zeros((N_SAMPLES_PER_PKT, 1), dtype=np.float64)
current_pkt_idx = global_sample_idx // N_SAMPLES_PER_PKT
# 判断是否为 3s 整数倍对应的包
if current_pkt_idx % PKT_PER_3S == 0:
# 当前是第 N 个3s节点1、2、1、2...交替
cycle_num = (current_pkt_idx // PKT_PER_3S) % 2
if cycle_num == 0:
event[0, 0] = 1.0
else:
event[0, 0] = 2.0
# Ch65: 标签序号通道,初始化为 0
label_idx = np.zeros((N_SAMPLES_PER_PKT, 1), dtype=np.float64)