2026-06-11 09:21:57 +08:00
|
|
|
# import matplotlib
|
|
|
|
|
# matplotlib.use('Agg')
|
|
|
|
|
# import argparse
|
|
|
|
|
# import sys
|
2026-06-05 09:34:29 +08:00
|
|
|
import time
|
|
|
|
|
from Decoder import Decoder_main
|
|
|
|
|
from PubLibrary.RunOnce import is_program_running
|
2026-06-06 09:16:49 +08:00
|
|
|
from PubLibrary.InifileHelper import IniRead
|
2026-06-06 15:53:50 +08:00
|
|
|
from logs.log import algo_log
|
2026-06-06 09:16:49 +08:00
|
|
|
|
|
|
|
|
def get_device_info(device_type):
|
|
|
|
|
|
|
|
|
|
section = f'device_type_{device_type}'
|
|
|
|
|
device_info = {
|
2026-06-06 14:40:07 +08:00
|
|
|
'sample_rate': int(IniRead(section, 'sample_rate')) if IniRead(section, 'sample_rate') is not None else 250,
|
2026-06-06 15:13:23 +08:00
|
|
|
'frame_points': int(IniRead(section, 'frame_points')) if IniRead(section, 'frame_points') is not None else 5,
|
2026-06-06 14:40:07 +08:00
|
|
|
'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_index': IniRead(section, 'channel_index') if IniRead(section, 'channel_index') is not None else None,
|
2026-06-06 09:16:49 +08:00
|
|
|
}
|
2026-06-06 14:40:07 +08:00
|
|
|
|
|
|
|
|
return device_info
|
|
|
|
|
|
2026-06-05 09:34:29 +08:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
if not is_program_running():
|
|
|
|
|
# 解析命令行参数
|
2026-06-06 14:40:07 +08:00
|
|
|
# parser = argparse.ArgumentParser(description="EEG Decoder Application")
|
|
|
|
|
# parser.add_argument('-dt', '-t','--device-type', type=int, default=None, help="Device Type")
|
2026-06-06 09:16:49 +08:00
|
|
|
# parser.add_argument('-dh', '--device-host', type=str, default=None, help="Device Host IP")
|
|
|
|
|
# parser.add_argument('-dp', '--device-port', type=int, default=None, help="Device Port")
|
|
|
|
|
# parser.add_argument('-uh', '--upper-host', type=str, default=None, help="Upper Computer Host IP")
|
|
|
|
|
# parser.add_argument('-up', '--upper-port', type=int, default=None, help="Upper Computer Port")
|
2026-06-06 14:40:07 +08:00
|
|
|
# args = parser.parse_args()
|
2026-06-05 09:34:29 +08:00
|
|
|
|
2026-06-06 09:16:49 +08:00
|
|
|
# decoder.connect(
|
|
|
|
|
# device_type=args.device_type,
|
|
|
|
|
# device_host=args.device_host,
|
|
|
|
|
# device_port=args.device_port,
|
|
|
|
|
# upper_host=args.upper_host,
|
|
|
|
|
# upper_port=args.upper_port
|
|
|
|
|
# )
|
2026-06-05 09:34:29 +08:00
|
|
|
|
2026-06-06 14:40:07 +08:00
|
|
|
device_info= get_device_info(1)
|
2026-06-08 11:56:42 +08:00
|
|
|
algo_log(f"device_info: {device_info}", level="DEBUG")
|
2026-06-06 14:40:07 +08:00
|
|
|
decoder = Decoder_main(device_info=device_info)
|
|
|
|
|
|
2026-06-05 09:34:29 +08:00
|
|
|
try:
|
|
|
|
|
decoder.start()
|
|
|
|
|
while not decoder.zmqServer.IsExitApp:
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
decoder.stop()
|