class test_BatchAdd(object): def __init__(self): '''批量添加图片测试''' # 引用方法类 self.ScreenFile = Screenshots_operation("批量添加底图测试结果") self.operation = Autoit_Upper_machine_function() self.imgdis = images_dispose() self.windows_command = Command() self.path_img = self.ScreenFile.create_file("连续添加批量图片截图文件") + "\\" # 创建图片存在的文件夹 self.library_img = self.ScreenFile.create_file("连续添加后数量截图文件") + "\\" # 创建图片存在的文件夹 def batch_init(self): # 启动上位机并选择串口 self.operation.init_start() # 删除所有图片 self.operation.delete_all() def batch_add(self,firstname,name):#批量添加图片并且保存结果 self.imgdis.rename(firstname) # 更改每次图片名 images = str(self.imgdis.images_str()) # 添加图片的名字集 self.operation.batchAdd_img(images) # 批量添加图片 self.ScreenFile.window_capture(self.path_img + name) # 截取当前添加结果图 self.operation.click_addBatch_ok() path_one = str(self.path_img + 'SenseEngineCamera_Batch_%s.jpg' % 1) path_two = str(self.path_img + name) self.ScreenFile.compare_images(path_one, path_two) text = self.imgdis.get_img_text(path_two) # 获取当前截图文字 self.ScreenFile.log.logger.debug("--------%s-------" % text)
class Bin_upgrade(object): def __init__(self): # 准备数据 getConfig = datagetConfig() self.star_times = getConfig.getConfig().get("star_times") # 等待时长 # 引用方法类 self.ScreenFile = Screenshots_operation("Bin文件升级测试结果") self.udis = Udisk_dispose() self.operation = Autoit_Upper_machine_function() self.imgdis = images_dispose() self.windows_command = Command() # 创建图片文件夹 self.vension_img = self.ScreenFile.create_file( "Bin升级版本截图") + "\\" # 创建图片存在的文件夹 self.upload_img = self.ScreenFile.create_file("Bin升级上传文件截图") + "\\" self.open_img = self.ScreenFile.create_file("Bin升级打开视频流件截图") + "\\" def check_Upper_machine(self, name): ''' 查询当前版本确认上位机正常打开 :param name: :return: ''' flag = self.ScreenFile.screnn_vension(str(self.vension_img + name)) # 获取当前版本 if flag is True: pass else: self.operation.click_close() # 关闭上位机 self.operation.init_start() # 没有查询到版本重新打开上位机 def bin_upgrade(self, screen_name): ''' 升级设备并且截图,等待设备启动 :param screen_name: :return: ''' udgrade_file = bindis.udis.chose_file() # 选择当前上级文件 vension_file = udgrade_file.split("\\") bindis.ScreenFile.log.logger.debug("----当前选择版本:%s----" % vension_file[4]) self.ScreenFile.screen_upload(udgrade_file, self.upload_img + screen_name) #上传并且截图上传后图片 time.sleep(self.star_times) # 等待设备启动 def start_eUpper_machine(self, open_name): ''' 启动上位机并且截图 :param reboot_name: :return: ''' self.operation.init_start() time.sleep(5) self.ScreenFile.window_capture(self.open_img + open_name)
class test_reboot(object): def __init__(self): '''reboot测试''' # 准备数据 getConfig = datagetConfig() equipment_port = getConfig.getConfig().get("equipment_port") #获取设备串口号 self.star_times = getConfig.getConfig().get("star_times") #重启等待时长 #引用公共类 self.equipment_ser = M20_serial(port=equipment_port, baudrate=115200) self.operation = Autoit_Upper_machine_function() self.windows_command = Command() self.ScreenFile = Screenshots_operation("软重启测试结果") # 创建图片文件夹 self.reboot_img = self.ScreenFile.create_file( "M20软重启后识别图") + "\\" # 创建图片存在的文件夹 def reboot_equipment(self): ''' 重启并关闭上位机 :return: ''' #处理reboot传输 reboot = self.equipment_ser.asc_str("reboot") #print(reboot) enter = self.equipment_ser.asc_str("") time.sleep(0.02) self.equipment_ser.send_cmd(enter) self.equipment_ser.send_cmd(reboot) time.sleep(self.star_times) def start_eUpper_machine(self, reboot_name): ''' 启动上位机并且截图后关闭上位机 :param reboot_name: :return: ''' self.operation.init_start() time.sleep(3) self.ScreenFile.window_capture(self.reboot_img + reboot_name) self.operation.click_close()
class test_BatchAdd_power(object): def __init__(self): '''批量添加图片测试''' # 准备数据 getConfig = datagetConfig() power_port = getConfig.getConfig().get("relay_port")#获取继电器串口号 self.star_times = getConfig.getConfig().get("star_times")#重启等待时长 # 引用方法类 self.power_ser = M20_serial(port=power_port,baudrate =9600) self.ScreenFile = Screenshots_operation("批量添加底图测试结果") self.operation = Autoit_Upper_machine_function() self.imgdis = images_dispose() self.windows_command = Command() self.batch_power_img = self.ScreenFile.create_file("添加底图断电后重启截图文件") + "\\" # 创建图片存在的文件夹 def batch_init(self): # 启动上位机并选择串口 self.operation.init_start() # 删除所有图片 self.operation.delete_all() def batch_add(self,firstname):#批量添加图片 self.imgdis.rename(firstname) # 更改每次图片名 images = str(self.imgdis.images_str()) # 添加图片的名字集 self.operation.batchAdd_power(images) # 批量添加图片 def power_batch(self):#上下电关闭上位机并等待设备启动 self.power_ser.power_operation() self.windows_command.close_exe() time.sleep(self.power_ser.switch_time()) def start_eUpper_machine(self,power_name): ''' 启动上位机并且截图 :param reboot_name: :return: ''' self.operation.init_start() time.sleep(3) self.ScreenFile.window_capture(self.batch_power_img+power_name)
from BI_SenseEngine.windows_test_case.WindowsUpperButtonAutoit_mouse import Autoit_Upper_machine_function from BI_SenseEngine.ShareScripts.Screenshots_operation import Screenshots_operation from BI_SenseEngine.ShareScripts.images_dispose import images_dispose if __name__ == '__main__': '''批量添加图片测试''' # 准备数据 error_number = 0 successful_number = 0 text_max = 20000 # 引用方法类 ScreenFile = Screenshots_operation("单个添加底图测试结果") operation = Autoit_Upper_machine_function() imgdis = images_dispose() windows_command = Command() library_img = ScreenFile.create_file("单个添加后数量截图文件") + "\\" # 创建图片存在的文件夹 #开始测试 ScreenFile.log.logger.debug("-----------test start------------") # 启动上位机并选择串口 operation.init_start() #删除所有图片 operation.delete_all() # 开始测试 for i in range(1, text_max + 1): try: ScreenFile.log.logger.debug("--------test: %s---------" % i) operation.add_img("test_%s" % i) except Exception as e: error_number += 1 ScreenFile.log.logger.debug("------------程序错误:%s------------%s" % (e, error_number))
class operation_Camera(object): def __init__(self): # 准备数据 getConfig = datagetConfig() open_rgb = getConfig.getConfig().get("open_rgb") open_ir = getConfig.getConfig().get("open_ir") close_rgb = getConfig.getConfig().get("close_rgb") close_ir = getConfig.getConfig().get("close_ir") ai_stop = getConfig.getConfig().get("stop_reo") # 打开算法 ai_start = getConfig.getConfig().get("start_reo") # 关闭算法 eqt_port = getConfig.getConfig().get("equipment_port") # 获取设备串口号 # 引用公共方法 self.imgdis = images_dispose() self.ScreenFile = Screenshots_operation("打开关闭Camera测试结果") self.equipment_port = M20_serial(port=eqt_port, baudrate=115200) self.operation = Autoit_Upper_machine_function() self.windows_command = Command() # 处理命令ai self.open_Rgb = self.equipment_port.asc_str(open_rgb) self.open_Ir = self.equipment_port.asc_str(open_ir) self.close_Rgb = self.equipment_port.asc_str(close_rgb) self.close_Ir = self.equipment_port.asc_str(close_ir) self.stop_ai = self.equipment_port.asc_str(ai_stop) self.start_ai = self.equipment_port.asc_str(ai_start) # 创建图片存放地址 self.open_img = self.ScreenFile.create_file('打开摄像头测试结果图片') + "\\" self.close_img = self.ScreenFile.create_file('关闭摄像头测试结果图片') + "\\" def close_camera(self): ''' 关闭摄像头 :return: ''' self.equipment_port.send_cmd(self.close_Rgb) self.equipment_port.send_cmd(self.close_Ir) self.equipment_port.send_cmd(self.stop_ai) time.sleep(10) def opne_camera(self): ''' 打开摄像头 ''' self.equipment_port.send_cmd(self.open_Rgb) self.equipment_port.send_cmd(self.open_Ir) self.equipment_port.send_cmd(self.start_ai) time.sleep(5) def close_machine(self): self.operation.click_close() self.windows_command.check_close_exe() def screen_close_ir_rgb(self, close_rgb_name, close_ir_name): self.operation.init_start() time.sleep(5) self.ScreenFile.window_capture(self.close_img + close_rgb_name) #RGB截图 time.sleep(2) self.operation.switch_ir() time.sleep(1) self.close_machine() self.operation.init_start() time.sleep(6) self.ScreenFile.window_capture(self.close_img + close_ir_name) #ir截图 time.sleep(1) self.operation.switch_rgb() def screen_open_ir_rgb(self, open_rgb_name, open_ir_name): ''' 打开摄像头截图 :param open_rgb_name: :param open_ir_name: :return: ''' # 打开摄像头 self.operation.init_start() time.sleep(5) self.ScreenFile.window_capture(self.open_img + open_rgb_name) #RGB截图 time.sleep(2) self.operation.switch_ir() time.sleep(1) self.ScreenFile.window_capture(self.open_img + open_ir_name) #ir截图 time.sleep(1) self.operation.switch_rgb()