def __init__(self, name, data, event): super().__init__(name=name) # 调用父类(超类)的__init__()方法 # 初始化日志类 # self.__logger = Logger('log/mech.log', logging.DEBUG, logging.ERROR) # 外部通讯参数 self.__queue = data # 用于向外部传输队列数 self.__event = event # 用于触发外部事件 # 控制线程参数初始化 self.__flag = threading.Event() # 用于暂停线程的标识 self.__flag.set() # 设置为True,默认线程运行 self.__running = threading.Event() # 用于停止线程的标识 self.__running.set() # 将running设置为True # 获取系统参数 self.__system_config = system_params() self.__device, self.__bps = self.__system_config.get_serial_server_info( ) print("device = ", self.__device) print("bps = ", self.__bps) # 串口的初始化 self.__tty = tty(port=self.__device, bps=self.__bps) # 获取Serial服务器的运行方式 self.__policy = self.__system_config.get_serial_server_protocol() # 服务器不同的协议处理方式 self.__serial_server_protocol_treat = { "echo": self.echo, "power": self.monitor }
def mac_verify(mac): system_config = system_params() license_eth = system_config.get_license_eth() print("license_eth = ", license_eth) mac_info = system_config.get_eth_mac(license_eth) if mac == mac_info: return True return False
def __init__(self, name, data, event): super().__init__(name=name) # 调用父类(超类)的__init__()方法 # 初始化日志类 self.__logger = SingleLogger() # 外部通讯参数 self.__queue = data # 用于向外部传输队列数 self.__event = event # 用于触发外部事件 # 控制线程参数初始化 self.__flag = threading.Event() # 用于暂停线程的标识 self.__flag.set() # 设置为True,默认线程运行 self.__running = threading.Event() # 用于停止线程的标识 self.__running.set() # 将running设置为True # 获取系统参数 self.__system_config = system_params() # CAN分析仪的初始化 vid, pid = self.__system_config.get_can_analyzer_info() self.__canfd = CanAnalyze_ZLG(vid, pid) self.__canfd.StartAll() # 协议初始化 self.protocol = ModuleProtocol() # 获取CAN服务器的运行方式 self.__policy = self.__system_config.get_can_protocol() self.__logger.debug("can protocol = %s" % self.__policy) # 服务器不同的协议处理方式 self.__canfd_protocol_treat = { "echo": self.echo, "monitor": self.monitor, "uds": self.uds } # 每个CAN通道的变量 self.msg = dict() # 每个CAN通道的数据bytearray self.start_flag = dict() # 每个CAN通道的数据魔术字状态 # CAN Tree self.__can_node_info = self.__system_config.get_can_all_module_info() # CAN服务器的状态机 ('idle', 'echo', 'monitor', 'uds') self.state = 'idle'
def kylin_main(): single_logger = SingleLogger() single_logger.info('--主线程开始--') app = MechIIApp() queue = Queue() event = threading.Event() # 创建Module Server独立线程 single_logger.info("Module Server Start...") module_server_thread = ModuleServerThread("ModuleServer", queue, event) module_server_thread.start() # 创建CAN Server独立线程 system_config = system_params() vid, pid = system_config.get_can_analyzer_info() if vid != 0 and pid != 0: single_logger.info("CAN Server Start...") can_server_thread = CANServerThread("CANServer", queue, event) can_server_thread.start() app.MainLoop()
def __init__(self, name, data, event): super().__init__(name=name) # 调用父类(超类)的__init__()方法 # 初始化日志类 self.__logger = SingleLogger() # 外部通讯参数 self.__queue = data # 用于向外部传输队列数 self.__event = event # 用于触发外部事件 # 控制线程参数初始化 self.__flag = threading.Event() # 用于暂停线程的标识 self.__flag.clear() # 设置为False self.__running = threading.Event() # 用于停止线程的标识 self.__running.set() # 将running设置为True # 获取Module Server的IP和Port system_config = system_params() self.__ip, self.__port = system_config.get_module_server_info() self.__logger.debug("ip = %s" % self.__ip) self.__logger.debug("port = %s" % self.__port)
def __init__(self): system_config = system_params() if not DevicesInfo.__devices_info: DevicesInfo.__devices_info = system_config.get_devices_info()
# aescryptor = AesCrypt(passwd,AES.MODE_ECB,"") # ECB模式 en_text = aescryptor.aesencrypt(text) with open(file_path, "wb+") as licFile: licFile.write(en_text) licFile.close() print("生成license成功!") pass if __name__ == "__main__": # 改变当前工作目录到上一级目录 os.chdir("../") system_config = system_params() license_eth = system_config.get_license_eth() print("license_eth = ", license_eth) license_path = system_config.get_license_path() print("license_path = ", license_path) file_path = license_path + os.sep + "license.lic" print("file path = ", file_path) mac_info = system_config.get_eth_mac(license_eth) date = datetime.datetime.now() detester = date.strftime('%Y-%m-%d') text = mac_info + '_' + detester aes_encrypt(text)