2026-06-05 09:34:29 +08:00
|
|
|
import matplotlib
|
|
|
|
|
matplotlib.use('Agg')
|
|
|
|
|
import argparse
|
|
|
|
|
import sys
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
def get_device_info(device_type):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
section = f'device_type_{device_type}'
|
|
|
|
|
device_info = {
|
|
|
|
|
'device_sample_rate': int(IniRead(section, 'sample_rate')) if IniRead(section, 'sample_rate') is not None else 250,
|
|
|
|
|
|
|
|
|
|
''
|
|
|
|
|
}
|
2026-06-05 09:34:29 +08:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
if not is_program_running():
|
|
|
|
|
# 解析命令行参数
|
|
|
|
|
parser = argparse.ArgumentParser(description="EEG Decoder Application")
|
2026-06-06 09:16:49 +08:00
|
|
|
parser.add_argument('-dt', '-t','--device-type', type=int, default=None, help="Device Type")
|
|
|
|
|
# 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-05 09:34:29 +08:00
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
2026-06-06 09:16:49 +08:00
|
|
|
device_info= get_device_info(args.device_type)
|
|
|
|
|
|
2026-06-05 09:34:29 +08:00
|
|
|
|
2026-06-06 09:16:49 +08:00
|
|
|
decoder = Decoder_main(device_info=device_info)
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
decoder.start()
|
|
|
|
|
while not decoder.zmqServer.IsExitApp:
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
decoder.stop()
|