diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index 9da4c5d9..322180e1 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -157,12 +157,13 @@ class Machine_ftp(models.Model): time_on_now = fields.Char('本次在线时长', readonly=True) tool_num = fields.Integer('当前刀具', readonly=True) program = fields.Char('当前程序', readonly=True) - run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '等待中')], string='运行状态', + run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '加工中')], string='运行状态', readonly=True, default='0') run_time = fields.Char('总运行时长', readonly=True) cut_time = fields.Char('总切削时长', readonly=True) cut_status = fields.Selection([('0', '未切削'), ('1', '切削中'), ('2', '切削中'), ('3', '切削中')], string='切削状态', readonly=True, default='0') + spindle_speed = fields.Char('主轴转速', readonly=True) tool_num_process_time1 = fields.Char('刀位1', readonly=True, default='0') tool_num_process_time2 = fields.Char('刀位2', readonly=True, default='0') @@ -259,17 +260,17 @@ class WorkCenterBarcode(models.Model): :return: """ # 一键下发前删除机床上的全部程序 - # try: - # filepath = '/nc2machine' - # del_list = os.listdir(filepath) - # _logger.info("=====================================", del_list) - # for f in del_list: - # file_path = os.path.join(filepath, f) - # if os.path.isfile(file_path): - # os.remove(file_path) - # except Exception as e: - # _logger.info("=====================================", e) - # raise UserError('程序删除失败,请重试') + try: + filepath = '/nc2machine' + del_list = os.listdir(filepath) + _logger.info("=====================================%s" % del_list) + for f in del_list: + file_path = os.path.join(filepath, f) + if os.path.isfile(file_path): + os.remove(file_path) + except Exception as e: + _logger.info("=====================================", e) + raise UserError('程序删除失败,请重试') # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC" try: self.compensation() @@ -281,8 +282,12 @@ class WorkCenterBarcode(models.Model): username = self.workcenter_id.machine_tool_id.ftp_num pwd = self.workcenter_id.machine_tool_id.ftp_pwd remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path - print(host, port, username, pwd, remote_path) + _logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd)) ftp = ftp_operate.FtpController(host, port, username, pwd) + _logger.info("=====================1777777777111================") + + + try: for item in self.cnc_ids: a = item.cnc_id diff --git a/sf_machine_connect/views/machine_monitor.xml b/sf_machine_connect/views/machine_monitor.xml index e90e8856..7c43960d 100644 --- a/sf_machine_connect/views/machine_monitor.xml +++ b/sf_machine_connect/views/machine_monitor.xml @@ -12,7 +12,7 @@ - + @@ -24,79 +24,108 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -126,6 +155,7 @@ + diff --git a/sf_machine_connect/wizard/action_up.py b/sf_machine_connect/wizard/action_up.py index 4975409e..e72fa5ff 100644 --- a/sf_machine_connect/wizard/action_up.py +++ b/sf_machine_connect/wizard/action_up.py @@ -26,7 +26,18 @@ class UpSelectWizard(models.TransientModel): def confirm_up(self): - + # 合并下发前删除机床上的全部程序 + try: + filepath = '/nc2machine' + del_list = os.listdir(filepath) + _logger.info("=====================================%s" % del_list) + for f in del_list: + file_path = os.path.join(filepath, f) + if os.path.isfile(file_path): + os.remove(file_path) + except Exception as e: + _logger.info("=====================================", e) + raise UserError('程序删除失败,请重试') host = self.workcenter_id.machine_tool_id.ftp_host port = self.workcenter_id.machine_tool_id.ftp_port username = self.workcenter_id.machine_tool_id.ftp_num @@ -35,6 +46,8 @@ class UpSelectWizard(models.TransientModel): print(host, port, username, pwd, remote_path) ftp = ftp_operate.FtpController(host, port, username, pwd) sequence_collect = [] + file_path_local = '' + file_path_remote = '' try: # 给文件名 begin_name1 = self.program_ids[0].cnc_id.display_name.split('-') @@ -61,12 +74,12 @@ class UpSelectWizard(models.TransientModel): with open(file_path_local, mode='ab+') as file: file.write(datas) - # 存在本地的文件下发到机床 - _logger.info("==========存在服务器成功,准备下发===========") - ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local) - _logger.info("======%s下发成功======" % a.display_name) # 下发成功标识 item.button_state = True + + # 存在本地的文件下发到机床 + _logger.info("==========存在服务器成功,准备下发===========") + ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local) ftp.close_ftp() up_time = str(datetime.now()) @@ -78,6 +91,8 @@ class UpSelectWizard(models.TransientModel): }) _logger.info("==============合并下发成功==============") except Exception as e: + for item in self.program_ids: + item.button_state = False _logger.info("=====================================", e) raise UserError('NC下发执行超时, 请检查下发状态')