From 946bf32c4eff4ce235bc37e7271fa11512962011 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 31 Jan 2023 17:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8B=E5=8F=91=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/models/ftp_client.py | 70 ++++--------------------- 1 file changed, 11 insertions(+), 59 deletions(-) diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index 8044af74..8492d123 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -75,7 +75,8 @@ class FtpButton(models.Model): port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd - + remote_path = self.workorder_id.workcenter_id.machine_tool_id.ftp_remote_path + print(host, port, username, pwd, remote_path) ftp = ftp_operate.FtpController(host, port, username, pwd) # ftp.delAllfile('C://Users//马广威//Desktop//ftp') a = self.cnc_id @@ -85,7 +86,8 @@ class FtpButton(models.Model): # file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name) file_path_local = '{}/{}'.format('/nc2machine', a.display_name) - file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name) + # file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name) + file_path_remote = '{}\{}'.format(remote_path, a.display_name) with open(file_path_local, mode='wb+') as file: file.write(datas) @@ -100,66 +102,19 @@ class FtpButton(models.Model): # 补偿下发都执行完毕后,按钮标志位变为true self.button_state = True - # 新增,下发完成返回当前工单位置 - # return { - # 'name': _("工单"), - # 'view_mode': 'form', - # 'res_model': 'mrp.workorder', - # 'res_id': self.workorder_id, - # 'type': 'ir.actions.act_window', - # 'target': 'new' - # } - - # def up_all(self): - # """ - # 此函数用于将NC代码全部下发到机床 - # :return: - # """ - # # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC" - # host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host - # port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port - # username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num - # pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd - # - # ftp = ftp_operate.FtpController(host, port, username, pwd) - # # ftp.delAllfile('C://Users//马广威//Desktop//ftp') - # for item in self.cnc_ids: - # a = item.cnc_id - # print(a.display_name) - # # _logger.info(a.public) - # # _logger.info(a.display_name) - # # datas = base64.standard_b64decode(a.datas) - # # - # # # file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name) - # # # file_path_local = '{}/{}'.format('/nc2machine', a.display_name) - # # file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name) - # # # file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name) - # # - # # with open(file_path_local, mode='wb+') as file: - # # file.write(datas) - # # 存在本地的文件下发到机床 - # # _logger.info("=====================11================") - # # ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local) - # # _logger.info("=====================22================") - # # except Exception as e: - # # _logger.info("=====================================", e) - # # raise UserError('NC下发执行超时, 请检查下发状态') - def check_compensation_before_up(self): """ 下发NC代码前自动补偿三元检测偏差值 :return: """ + hongbianliang550 = self.workorder_id.workcenter_id.machine_tool_id.x_compensation_node + hongbianliang551 = self.workorder_id.workcenter_id.machine_tool_id.y_compensation_node try: temp_dict = {} - temp_dict[ - 'ns=1;s=Project_Default.Group1.Mitsubishi_NC.hongbianliang550'] = self.workorder_id.compensation_value_x - temp_dict[ - 'ns=1;s=Project_Default.Group1.Mitsubishi_NC.hongbianliang551'] = self.workorder_id.compensation_value_y + temp_dict[hongbianliang550] = self.workorder_id.compensation_value_x + temp_dict[hongbianliang551] = self.workorder_id.compensation_value_y temp = py2opcua.Py2opcua() - # temp.connect() temp.write(temp_dict) - # temp.disconnect() except Exception as e: _logger.info("=====================================", e) raise UserError('补偿值获取失败,或机床未连接,请检查') @@ -286,18 +241,15 @@ class WorkCenterBarcode(models.Model): hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node - try: temp_dict = {} temp_dict[hongbianliang550] = self.compensation_value_x temp_dict[hongbianliang551] = self.compensation_value_y print("=================================") print(temp_dict) - # temp = py2opcua.Py2opcua() - # # temp.connect() - # temp.write(temp_dict) - # self.button_compensation_state = True - # temp.disconnect() + temp = py2opcua.Py2opcua() + temp.write(temp_dict) + self.button_compensation_state = True except Exception as e: _logger.info("=====================================", e) raise UserError('补偿值获取失败,或机床未连接,请检查')