新增机床ftp路径配置

This commit is contained in:
mgw
2023-01-30 15:14:36 +08:00
parent f6f782fe33
commit 60e044ec9b
2 changed files with 11 additions and 6 deletions

View File

@@ -179,6 +179,7 @@ class Machine_ftp(models.Model):
ftp_pwd = fields.Char('ftp密码')
ftp_host = fields.Char('ftp地址')
ftp_port = fields.Integer('ftp端口')
ftp_remote_path = fields.Char('机床ftp路径')
# 补偿值写入相关
x_compensation_node = fields.Char('x补偿值节点')
y_compensation_node = fields.Char('y补偿值节点')
@@ -302,8 +303,9 @@ class WorkCenterBarcode(models.Model):
port = self.workcenter_id.machine_tool_id.ftp_port
username = self.workcenter_id.machine_tool_id.ftp_num
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
print(host, port, username, pwd)
# ftp = ftp_operate.FtpController(host, port, username, pwd)
remote_path = self.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')
for item in self.cnc_ids:
a = item.cnc_id
@@ -313,15 +315,17 @@ class WorkCenterBarcode(models.Model):
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_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)
file_path_remote = '{}\{}'.format(remote_path, 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("=====================11================")
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
# _logger.info("=====================22================")
# except Exception as e:
# _logger.info("=====================================", e)

View File

@@ -107,6 +107,7 @@
<field name="ftp_pwd"/>
<field name="ftp_host"/>
<field name="ftp_port"/>
<field name="ftp_remote_path"/>
</group>
<group string="补偿值相关">
<field name="x_compensation_node"/>