from comm_thread import class_comm_master_thread
from comm_device import class_comm_device
from menu_base import class_device_menu
import sys
if sys.platform.startswith('win'):
    import menu_key as KEY
else :
    import menu_key2 as KEY

g_comm_addr_list : list = []
g_key_thread = KEY.class_menu_key_thread()
g_comm_thread = 1

def register_device_remap_info(device_remap, 
                               comm_device : class_comm_device= None, 
                               comm_thread : class_comm_master_thread = None,
                               device_menu : class_device_menu = None) :

    device_remap_comm_addr = [device_remap, comm_device, comm_thread, device_menu]
    g_comm_addr_list.append(device_remap_comm_addr)

#从device_remap匹配到实际工作线程与通讯信息
def search_device_remap_infos(device_remap) :
    for item in g_comm_addr_list :
        if item[0] == device_remap :
            return item[1], item[2], item[3]
    return None, None, None