def writeAllPathInfo(ver_path_map): ''' 把新的版本--路径信息写入到数据库,会覆盖原先数据库中的path信息 :param ver_path_map: 格式如 { 'V01': {1: {'version': 'V01_17_16}, 'path': 'G:/sigmatek/...'}, 2: {xxx}, ...,}, 'V02': {1: {}, 2: {}, ...} ... } :return: ''' # 提前备份一个soft.db文件,万一写烂给留条后路撤退 db_cpy_name = 'soft_cpy.db' db_cpy_path = os.path.join(os.path.dirname(SOFTWARE_VERSION_INFO_DB_PATH), db_cpy_name) shutil.copyfile(SOFTWARE_VERSION_INFO_DB_PATH, db_cpy_path) t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } print('开始向数据库写入path信息') for ver_type in ver_path_map: t_vers[ver_type].auto_commit = False for ver_id, ver_info in ver_path_map[ver_type].items(): if ver_info['version'] == t_vers[ver_type].displayBriefData( ver_id, 'version')[0]: # print('Writing: %s -- %s' % (ver_info['version'], ver_info['path'])) t_vers[ver_type].modifyLine(ver_id, path=ver_info['path']) t_vers[ver_type].commitData() t_vers[ver_type].auto_commit = True print('path信息写入数据库成功') return
def markToRefresh(table_name, ids): t_soft = TableManager(table_name, SOFTWARE_VERSION_INFO_DB_PATH) if isinstance(ids, int): t_soft.modifyLine(ids, torefresh='1') elif isinstance(ids, tuple) or isinstance(ids, list) or isinstance(ids, set): # 多次commit很耗费性能,需要避免 t_soft.auto_commit = False for id in ids: t_soft.modifyLine(id, torefresh='1') t_soft.commitData() t_soft.auto_commit = True
def startUpdate(self): ''' 将getUpdateInfo返回的数据,传入该函数,进行数据库写入更新操作 ''' if self.running_update: print('其他人正在更新') while self.running_update: # 等待其他线程操作完成 pass return True else: if self.vers_ready_to_append is None: return False self.running_update = True try: t_soft = TableManager(self.table_name, self.version_db_path) t_soft.auto_commit = False for new_vers in self.vers_ready_to_append: t_soft.appendLine(client=new_vers[0], version=new_vers[1], date=new_vers[2], base=new_vers[3], record=new_vers[4], reason=new_vers[5], remark=new_vers[6], author=new_vers[7], path='') t_soft.commitData() t_soft.auto_commit = True self.vers_ready_to_append = None return True except: return False finally: self.running_update = False
def _getAllVersionsId(): t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } return { 'V01': t_vers['V01'].getAllId('version', desc=True), 'V02': t_vers['V02'].getAllId('version', desc=True), 'V03V04': t_vers['V03V04'].getAllId('version', desc=True), 'V05': t_vers['V05'].getAllId('version', desc=True), 'T05': t_vers['T05'].getAllId('version', desc=True) }
def getVersion(): ''' 根据请求的版本类型以及版本区间(不是数据库的id号)返回版本数据 当某个版本类型下的所有版本数据按一定顺序(这里按名字降序排列)后,取 位于第start_seq和end_seq之间的版本数据 :return 格式如 {'itemsNum': 123, 'items': {'client': xxx, 'version': xxx , ...}} ''' soft_type = request.args.get('softType') start_seq = int(request.args.get('start')) end_seq = int(request.args.get('end')) table_name = 't_' + soft_type t_soft = TableManager(table_name, SOFTWARE_VERSION_INFO_DB_PATH) ret_data = {'itemsNum': len(ALL_VERS_ID[soft_type]), 'items': {}} key = 0 for soft_id in ALL_VERS_ID[soft_type][start_seq:end_seq]: # 即使end_seq超过ALL_VERS_ID的长度也无所谓,不会影响结果 ret_data['items'][key] = t_soft.displayDetailedData(soft_id) key += 1 return jsonify(ret_data)
def getUpdateInfo(self): ''' 对比数据库与xls文件,获得需要更新的软件版本 对比逻辑:取各自(client, version, author),若三者一致视为同版本,否则视为待添加的新版本 注意table_name和sheet_name必须对应, 比如t_V05对应V05! :returns 成功打开xls文件并进行对比后,返回格式为 [ (client, version, date, base, record, reason, remark, author), (client, version, date, base, record, reason, remark, author), ... ] 如果没有更新返回空list 如果因为无法xls等失败则返回None ''' if self.running_update: return 0 if not os.path.isfile(self.version_xls_path): print('xls文件路径有误!!!') self.vers_ready_to_append = None return -1 try: workbook = xlrd.open_workbook(self.version_xls_path) sheet = workbook.sheet_by_name(self.sheet_name) except (FileNotFoundError, xlrd.biffh.XLRDError) as e: print(e) self.vers_ready_to_append = None return -1 t_soft = TableManager(self.table_name, self.version_db_path) ids = t_soft.getAllId() softs_existed = [] for id in ids: # 3重验证,防止版本号重复的版本无法录入 client, version, author = t_soft.displayBriefData(id, 'client', 'version', 'author') softs_existed.append((client, version, author)) self.vers_ready_to_append = [] for i in range(1, sheet.nrows): temp = sheet.row_values(i) client = temp[0] version = temp[1] author = temp[7] if version and (client, version, author) not in softs_existed: self.vers_ready_to_append.append(sheet.row_values(i)[:8]) return self.vers_ready_to_append
def getBigIo(): # 获取大机选配CIO021或CIO011的IO点配置信息 # 数据返回格式为{'name': 'CIO021(或CIO011)', ios: {'di3': '83--开门', ..., 'do2': '113--润滑马达2'}} cio021_io = { 'di3': 83, 'di4': 84, 'di5': 85, 'di6': 97, 'di7': 98, 'di8': 99, 'do1': 97, 'do2': 98, 'do3': 113 } if request.args.get('type').upper() == 'VE2': ret_data = {'name': 'CIO011', 'ios': {}} else: ret_data = {'name': 'CIO021', 'ios': {}} t_di = TableManager('digital_input', IO_INFO_DB_PATH) t_do = TableManager('digital_output', IO_INFO_DB_PATH) for k, v in cio021_io.items(): if k.startswith('di'): ret_data['ios'][k] = str(v) + '--' + t_di.displayBriefData( v, 'CName')[0] if k.startswith('do'): ret_data['ios'][k] = str(v) + '--' + t_do.displayBriefData( v, 'CName')[0] return jsonify(ret_data)
def handleRefresh(): ''' 对数据库内所有表的内容进行搜索,对torefresh字段被写1的数据行的path字段清空 :return: 处理的版本数量 ''' count = 0 t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } for soft_type in t_vers: ids = t_vers[soft_type].searchDataByKey(torefresh='1') t_vers[soft_type].auto_commit = False for id in ids: t_vers[soft_type].modifyLine(id, path='', torefresh='') count += 1 t_vers[soft_type].commitData() t_vers[soft_type].auto_commit = True return count
def searchVersion(): search_str = request.args.get('text') ret_data = {'itemsNum': 0, 'items': {}} if search_str == '': return jsonify(ret_data) t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } keywords = re.split(r'\s+', search_str) key = 0 ver_list = [] for soft_type in t_vers: ids_for_each_keyword = [] for keyword in keywords: # 在表中搜索1个关键字 ids_for_each_keyword.append(t_vers[soft_type].searchDataInTable( keyword, 'path')) # 取多个关键字获得到重合id部分,即筛选出符合多个条件的数据 ids = ids_for_each_keyword[0] for i in range(1, len(ids_for_each_keyword)): ids = tuple(soft_id for soft_id in ids if soft_id in ids_for_each_keyword[i]) ret_data['itemsNum'] += len(ids) # for soft_id in ids: # ret_data['items'][key] = t_vers[soft_type].displayDetailedData(soft_id) # key += 1 for soft_id in ids: ver_list.append(t_vers[soft_type].displayDetailedData(soft_id)) # 将搜索得到的版本号进行降序排序 ver_list = sorted(ver_list, key=lambda x: x['version'], reverse=True) seq_list = list(i for i in range(1, ret_data['itemsNum'] + 1)) ret_data['items'] = dict(zip(seq_list, ver_list)) return jsonify(ret_data)
def _createVersDict(): ''' 从数据库文件获取到所有的软件版本,返回一个dict变量,里面不包含任何path信息 :return: 格式如 { 'V01': {1: {'version': 'V01_17_16}, 'path': ''}, 2: {xxx}, ...,}, 'V02': {1: {}, 2: {}, ...} ... } ''' vers_dict = {'V01': {}, 'V02': {}, 'V03V04': {}, 'V05': {}, 'T05': {}} t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } for key in vers_dict: for id in t_vers[key].getAllId(): ver = t_vers[key].displayBriefData(id, 'version')[0] vers_dict[key][id] = {'version': ver, 'path': ''} return vers_dict
def getAllVerPathInfo(): ''' 从数据库文件获取到所有的软件版本及对应的path信息,返回一个dict变量 :return: 格式如 { 'V01': {1: {'version': 'V01_17_16}, 'path': 'G:/sigmatek/...'}, 2: {xxx}, ...,}, 'V02': {1: {}, 2: {}, ...} ... } ''' ver_path_map = {'V01': {}, 'V02': {}, 'V03V04': {}, 'V05': {}, 'T05': {}} t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } for key in ver_path_map: for id in t_vers[key].getAllId(): ver, path = t_vers[key].displayBriefData(id, 'version', 'path') ver_path_map[key][id] = {'version': ver, 'path': path} return ver_path_map
def _createEmptyPathVersDict(): ''' 从数据库中获取出所有path字段为空的数据 :return: 格式如 { 'V01': {1: {'version': 'V01_17_16}, 'path': ''}, 2: {xxx}, ...,}, 'V02': {1: {}, 2: {}, ...} ... } ''' ver_path_map = {'V01': {}, 'V02': {}, 'V03V04': {}, 'V05': {}, 'T05': {}} t_vers = { 'V01': TableManager('t_V01', SOFTWARE_VERSION_INFO_DB_PATH), 'V02': TableManager('t_V02', SOFTWARE_VERSION_INFO_DB_PATH), 'V03V04': TableManager('t_V03V04', SOFTWARE_VERSION_INFO_DB_PATH), 'V05': TableManager('t_V05', SOFTWARE_VERSION_INFO_DB_PATH), 'T05': TableManager('t_T05', SOFTWARE_VERSION_INFO_DB_PATH) } for key in ver_path_map: for id in t_vers[key].getAllId(): ver, path = t_vers[key].displayBriefData(id, 'version', 'path') if path == '': ver_path_map[key][id] = {'version': ver, 'path': ''} return ver_path_map
def _getIoAmount(): t_ios = { 'di': TableManager('digital_input', IO_INFO_DB_PATH), 'do': TableManager('digital_output', IO_INFO_DB_PATH), 'ai': TableManager('analog_input', IO_INFO_DB_PATH), 'ao': TableManager('analog_output', IO_INFO_DB_PATH), 'ti': TableManager('temperature_input', IO_INFO_DB_PATH), 'to': TableManager('temperature_output', IO_INFO_DB_PATH) } return { 'di': len(t_ios['di'].getAllId()), 'do': len(t_ios['do'].getAllId()), 'ai': len(t_ios['ai'].getAllId()), 'ao': len(t_ios['ao'].getAllId()), 'ti': len(t_ios['ti'].getAllId()), 'to': len(t_ios['to'].getAllId()) }
def getIo(): io_type = request.args.get('type') start_id = int(request.args.get('start')) end_id = int(request.args.get('end')) # io_type可以是'di', 'do', 'ai', 'ao', 'ti', 'to' if io_type == 'di': t_io = TableManager('digital_input', IO_INFO_DB_PATH) elif io_type == 'do': t_io = TableManager('digital_output', IO_INFO_DB_PATH) elif io_type == 'ai': t_io = TableManager('analog_input', IO_INFO_DB_PATH) elif io_type == 'ao': t_io = TableManager('analog_output', IO_INFO_DB_PATH) elif io_type == 'ti': t_io = TableManager('temperature_input', IO_INFO_DB_PATH) else: t_io = TableManager('temperature_output', IO_INFO_DB_PATH) ret_data = {} ret_data['amount'] = IOS_AMOUNT[io_type] ret_data['ios'] = {} if start_id > end_id or start_id > ret_data['amount']: return jsonify(ret_data) if end_id > ret_data['amount']: end_id = ret_data['amount'] for id in range(start_id, end_id + 1): ret_data['ios'][str(id)] = t_io.displayBriefData(id, 'CName')[0] return jsonify(ret_data)
class IOMaker: def __init__(self, imm_type, board_1_modules_ios=None, board_2_modules_ios=None, big=False, evaluation_num=None, production_num=None, type_string=None, customer=None, safety_standard=None, technical_clause=None, dual_inj=False, external_hotrunner_num=0, energy_dee=False, varan_conn_module_pos=0, psg_hotrunner=False): ''' imm_type: 'ZEs', 'ZE', 'VE2', 'VE2s' board_1_modules_ios: [['CTO163', {'DO3': OutputID, ...}], ['CDM163', {'DI5': InputID, ...}], ...] board_2_modules_ios: [['CTO163', {'DO3': OutputID, ...}], ['CDM163', {'DI5': InputID, ...}], ...] ''' self.path_db = IO_INFO_DB_PATH self.t_di = TableManager('digital_input', self.path_db) self.t_do = TableManager('digital_output', self.path_db) self.t_ai = TableManager('Analog_input', self.path_db) self.t_ao = TableManager('Analog_output', self.path_db) self.t_ti = TableManager('Temperature_input', self.path_db) self.t_to = TableManager('Temperature_output', self.path_db) self.t_func_list = TableManager('FuncOutput_List', self.path_db) self.imm_type = imm_type self.board_1_modules_ios = None self.board_2_modules_ios = None self.big = big self.evaluation_num = evaluation_num self.production_num = production_num self.type_string = type_string self.customer = customer self.safety_standard = safety_standard self.technical_clause = technical_clause self.dual_inj = dual_inj self.energy_dee = energy_dee self.psg_hotrunner = psg_hotrunner if external_hotrunner_num > 0: self.external_hot_runner_cai888_configuration = { 'TI1': self.t_ti.displayBriefData(1, 'CName', 'EName'), 'TI2': self.t_ti.displayBriefData(2, 'CName', 'EName'), 'TI3': self.t_ti.displayBriefData(3, 'CName', 'EName'), 'TI4': self.t_ti.displayBriefData(4, 'CName', 'EName'), 'TI5': self.t_ti.displayBriefData(5, 'CName', 'EName'), 'TI6': self.t_ti.displayBriefData(6, 'CName', 'EName'), 'TI7': self.t_ti.displayBriefData(7, 'CName', 'EName'), 'TI8': self.t_ti.displayBriefData(8, 'CName', 'EName'), 'TO1': self.t_to.displayBriefData(1, 'CName', 'EName'), 'TO2': self.t_to.displayBriefData(2, 'CName', 'EName'), 'TO3': self.t_to.displayBriefData(3, 'CName', 'EName'), 'TO4': self.t_to.displayBriefData(4, 'CName', 'EName'), 'TO5': self.t_to.displayBriefData(5, 'CName', 'EName'), 'TO6': self.t_to.displayBriefData(6, 'CName', 'EName'), 'TO7': self.t_to.displayBriefData(7, 'CName', 'EName'), 'TO8': self.t_to.displayBriefData(8, 'CName', 'EName') } else: # 如果没有开启外置热流道,无需专门获取cai888的配点信息 self.external_hot_runner_cai888_configuration = None self.varan_conn_module_pos = varan_conn_module_pos # 根据IO的id,在数据库中查找出对应IO的中英文名称 if board_1_modules_ios is not None: self.board_1_modules_ios = board_1_modules_ios.copy() for module in self.board_1_modules_ios: for io in module[1]: io_id = int(module[1][io]) if str(io).upper().startswith('DI'): module[1][io] = self.t_di.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('DO'): module[1][io] = self.t_do.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AI'): module[1][io] = self.t_ai.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AO'): module[1][io] = self.t_ao.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TI'): module[1][io] = self.t_ti.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TO'): module[1][io] = self.t_to.displayBriefData( io_id, 'CName', 'EName') if board_2_modules_ios is not None: self.board_2_modules_ios = board_2_modules_ios.copy() for module in self.board_2_modules_ios: for io in module[1]: io_id = int(module[1][io]) if str(io).upper().startswith('DI'): module[1][io] = self.t_di.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('DO'): module[1][io] = self.t_do.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AI'): module[1][io] = self.t_ai.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AO'): module[1][io] = self.t_ao.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TI'): module[1][io] = self.t_ti.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TO'): module[1][io] = self.t_to.displayBriefData( io_id, 'CName', 'EName') self.xlsxObj = IOFile(imm_type=self.imm_type, main_board_modules=self.board_1_modules_ios, board_1_modules=self.board_2_modules_ios, big=self.big, evaluation_num=self.evaluation_num, production_num=self.production_num, type_string=self.type_string, customer=self.customer, safety_standard=self.safety_standard, technical_clause=self.technical_clause, dual_inj=self.dual_inj, external_hotrunner_num=external_hotrunner_num, energy_dee=self.energy_dee, varan_conn_module_pos=varan_conn_module_pos, psg_hotrunner=self.psg_hotrunner) # 修改主底板默认点位,每个点位的修改都用一个方法特殊处理 def func1ToInjSignal(self): io_type = 'DO' origin_io_name = '功能点1' new_io_cname, new_io_ename = ('注射开始', 'Inject Start') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name, new_io_cname=new_io_cname, new_io_ename=new_io_ename) def func2ToChargeSignal(self): io_type = 'DO' origin_io_name = '功能点2' new_io_cname, new_io_ename = ('储料开始', 'Charge Start') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name, new_io_cname=new_io_cname, new_io_ename=new_io_ename) def func1Config(self, value): io_type = 'DO' origin_io_name = '功能点1' new_io_cname, new_io_ename = self.t_func_list.displayBriefData( value + 1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name, new_io_cname=new_io_cname, new_io_ename=new_io_ename) def func2Config(self, value): io_type = 'DO' origin_io_name = '功能点2' new_io_cname, new_io_ename = self.t_func_list.displayBriefData( value + 1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name, new_io_cname=new_io_cname, new_io_ename=new_io_ename) def nozzleToValve(self): io_type = 'DO' io_id1 = 41 origin_io_name1 = '喷嘴开' new_io_cname1, new_io_ename1 = self.t_do.displayBriefData( io_id1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name1, new_io_cname=new_io_cname1, new_io_ename=new_io_ename1) io_id2 = 42 origin_io_name2 = '喷嘴关' new_io_cname2, new_io_ename2 = self.t_do.displayBriefData( io_id2, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name2, new_io_cname=new_io_cname2, new_io_ename=new_io_ename2) def e73Safety(self): io_type = 'DI' io_id1 = 110 origin_io_name1 = '模内压' new_io_cname1, new_io_ename1 = self.t_di.displayBriefData( io_id1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name1, new_io_cname=new_io_cname1, new_io_ename=new_io_ename1) io_id2 = 111 origin_io_name2 = '开门止' new_io_cname2, new_io_ename2 = self.t_di.displayBriefData( io_id2, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name2, new_io_cname=new_io_cname2, new_io_ename=new_io_ename2) def moldSlider(self): io_type = 'DI' io_id1 = 73 origin_io_name1 = '模内压' new_io_cname1, new_io_ename1 = self.t_di.displayBriefData( io_id1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name1, new_io_cname=new_io_cname1, new_io_ename=new_io_ename1) def func1_to_progo1(self): io_type = 'DO' io_id1 = 73 origin_io_name1 = '功能点1' new_io_cname1, new_io_ename1 = self.t_do.displayBriefData( io_id1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name1, new_io_cname=new_io_cname1, new_io_ename=new_io_ename1) def func2_to_progo2(self): io_type = 'DO' io_id1 = 74 origin_io_name1 = '功能点2' new_io_cname1, new_io_ename1 = self.t_do.displayBriefData( io_id1, 'CName', 'EName') self.xlsxObj.modifyDefaultIO(io_type=io_type, origin_io_name=origin_io_name1, new_io_cname=new_io_cname1, new_io_ename=new_io_ename1) def createFile(self, path): self.xlsxObj.modifyImmInfo() self.xlsxObj.copyMainBoardModulesInfo() self.xlsxObj.copyMainBoardModules() self.xlsxObj.copyBoard1ModulesInfo() self.xlsxObj.copyBoard1Modules() self.xlsxObj.copyExternalHotrunnerInfo() self.xlsxObj.copyExternalHotrunnerModule( self.external_hot_runner_cai888_configuration) self.xlsxObj.copyEnergyModuleInfo() self.xlsxObj.saveAs(path)
def __init__(self, imm_type, board_1_modules_ios=None, board_2_modules_ios=None, big=False, evaluation_num=None, production_num=None, type_string=None, customer=None, safety_standard=None, technical_clause=None, dual_inj=False, external_hotrunner_num=0, energy_dee=False, varan_conn_module_pos=0, psg_hotrunner=False): ''' imm_type: 'ZEs', 'ZE', 'VE2', 'VE2s' board_1_modules_ios: [['CTO163', {'DO3': OutputID, ...}], ['CDM163', {'DI5': InputID, ...}], ...] board_2_modules_ios: [['CTO163', {'DO3': OutputID, ...}], ['CDM163', {'DI5': InputID, ...}], ...] ''' self.path_db = IO_INFO_DB_PATH self.t_di = TableManager('digital_input', self.path_db) self.t_do = TableManager('digital_output', self.path_db) self.t_ai = TableManager('Analog_input', self.path_db) self.t_ao = TableManager('Analog_output', self.path_db) self.t_ti = TableManager('Temperature_input', self.path_db) self.t_to = TableManager('Temperature_output', self.path_db) self.t_func_list = TableManager('FuncOutput_List', self.path_db) self.imm_type = imm_type self.board_1_modules_ios = None self.board_2_modules_ios = None self.big = big self.evaluation_num = evaluation_num self.production_num = production_num self.type_string = type_string self.customer = customer self.safety_standard = safety_standard self.technical_clause = technical_clause self.dual_inj = dual_inj self.energy_dee = energy_dee self.psg_hotrunner = psg_hotrunner if external_hotrunner_num > 0: self.external_hot_runner_cai888_configuration = { 'TI1': self.t_ti.displayBriefData(1, 'CName', 'EName'), 'TI2': self.t_ti.displayBriefData(2, 'CName', 'EName'), 'TI3': self.t_ti.displayBriefData(3, 'CName', 'EName'), 'TI4': self.t_ti.displayBriefData(4, 'CName', 'EName'), 'TI5': self.t_ti.displayBriefData(5, 'CName', 'EName'), 'TI6': self.t_ti.displayBriefData(6, 'CName', 'EName'), 'TI7': self.t_ti.displayBriefData(7, 'CName', 'EName'), 'TI8': self.t_ti.displayBriefData(8, 'CName', 'EName'), 'TO1': self.t_to.displayBriefData(1, 'CName', 'EName'), 'TO2': self.t_to.displayBriefData(2, 'CName', 'EName'), 'TO3': self.t_to.displayBriefData(3, 'CName', 'EName'), 'TO4': self.t_to.displayBriefData(4, 'CName', 'EName'), 'TO5': self.t_to.displayBriefData(5, 'CName', 'EName'), 'TO6': self.t_to.displayBriefData(6, 'CName', 'EName'), 'TO7': self.t_to.displayBriefData(7, 'CName', 'EName'), 'TO8': self.t_to.displayBriefData(8, 'CName', 'EName') } else: # 如果没有开启外置热流道,无需专门获取cai888的配点信息 self.external_hot_runner_cai888_configuration = None self.varan_conn_module_pos = varan_conn_module_pos # 根据IO的id,在数据库中查找出对应IO的中英文名称 if board_1_modules_ios is not None: self.board_1_modules_ios = board_1_modules_ios.copy() for module in self.board_1_modules_ios: for io in module[1]: io_id = int(module[1][io]) if str(io).upper().startswith('DI'): module[1][io] = self.t_di.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('DO'): module[1][io] = self.t_do.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AI'): module[1][io] = self.t_ai.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AO'): module[1][io] = self.t_ao.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TI'): module[1][io] = self.t_ti.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TO'): module[1][io] = self.t_to.displayBriefData( io_id, 'CName', 'EName') if board_2_modules_ios is not None: self.board_2_modules_ios = board_2_modules_ios.copy() for module in self.board_2_modules_ios: for io in module[1]: io_id = int(module[1][io]) if str(io).upper().startswith('DI'): module[1][io] = self.t_di.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('DO'): module[1][io] = self.t_do.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AI'): module[1][io] = self.t_ai.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('AO'): module[1][io] = self.t_ao.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TI'): module[1][io] = self.t_ti.displayBriefData( io_id, 'CName', 'EName') if str(io).upper().startswith('TO'): module[1][io] = self.t_to.displayBriefData( io_id, 'CName', 'EName') self.xlsxObj = IOFile(imm_type=self.imm_type, main_board_modules=self.board_1_modules_ios, board_1_modules=self.board_2_modules_ios, big=self.big, evaluation_num=self.evaluation_num, production_num=self.production_num, type_string=self.type_string, customer=self.customer, safety_standard=self.safety_standard, technical_clause=self.technical_clause, dual_inj=self.dual_inj, external_hotrunner_num=external_hotrunner_num, energy_dee=self.energy_dee, varan_conn_module_pos=varan_conn_module_pos, psg_hotrunner=self.psg_hotrunner)
def getOutputItems(): t_func_list = TableManager('FuncOutput_List', IO_INFO_DB_PATH) ret_data = [] for each_id in t_func_list.getAllId(): ret_data.append(t_func_list.displayBriefData(each_id, 'CName')[0]) return jsonify(ret_data)