From f6f782fe337f49b1e9855bb4c5de3527cf331638 Mon Sep 17 00:00:00 2001
From: mgw <1392924357@qq.com>
Date: Sun, 29 Jan 2023 17:47:36 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B7=A5=E5=8D=95?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=BA=E5=BA=8A=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/vcs.xml | 6 -
.idea/workspace.xml | 121 ------------------
sf_machine_connect/__manifest__.py | 2 +-
sf_machine_connect/models/ftp_client.py | 41 +++++-
sf_machine_connect/views/compensation.xml | 6 +-
sf_machine_connect/views/ftp_button.xml | 3 +-
.../views/machine_info_present.xml | 22 +++-
7 files changed, 64 insertions(+), 137 deletions(-)
delete mode 100644 .idea/vcs.xml
delete mode 100644 .idea/workspace.xml
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7f..00000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 328c04dd..00000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1673428094330
-
-
- 1673428094330
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sf_machine_connect/__manifest__.py b/sf_machine_connect/__manifest__.py
index 7f116a51..8579b691 100644
--- a/sf_machine_connect/__manifest__.py
+++ b/sf_machine_connect/__manifest__.py
@@ -20,7 +20,7 @@
'views/WorkCenterBarcodes.xml',
'views/Stock_picking_Barcodes.xml',
'views/machine_monitor.xml',
- # 'views/machine_info_present.xml',
+ 'views/machine_info_present.xml',
],
'assets': {
diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py
index 1941f09a..0e06678f 100644
--- a/sf_machine_connect/models/ftp_client.py
+++ b/sf_machine_connect/models/ftp_client.py
@@ -109,6 +109,7 @@ class FtpButton(models.Model):
# 'type': 'ir.actions.act_window',
# 'target': 'new'
# }
+
# def up_all(self):
# """
# 此函数用于将NC代码全部下发到机床
@@ -144,7 +145,6 @@ class FtpButton(models.Model):
# # _logger.info("=====================================", e)
# # raise UserError('NC下发执行超时, 请检查下发状态')
-
def check_compensation_before_up(self):
"""
下发NC代码前自动补偿三元检测偏差值
@@ -234,8 +234,41 @@ class WorkCenterBarcode(models.Model):
compensation_value_x = fields.Float(string='X轴补偿值')
compensation_value_y = fields.Float(string='Y轴补偿值')
- button_compensation_state = fields.Boolean(string='是否已经补偿')
+ button_compensation_state = fields.Boolean(string='是否已经补偿', readonly=True)
+ button_up_all_state = fields.Boolean(string='是否已经全部下发', readonly=True)
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
+ machine_tool_name = fields.Char(string='机床名称', default='未知机床', compute='_run_info', readonly=True)
+ machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_run_info', readonly=True)
+ machine_tool_status = fields.Boolean(string='在线状态', compute='_run_info', readonly=True)
+ machine_tool_run_status = fields.Selection([('0', '关机中'), ('1', '加工中'), ('2', '加工中'), ('3', '等待中')],
+ string='运行状态', compute='_run_info', readonly=True, default='0')
+ machine_tool_timestamp = fields.Datetime('时间戳', compute='_run_info', readonly=True)
+ machine_tool_time_on = fields.Char('总在线时长', compute='_run_info', readonly=True)
+ machine_tool_time_on_now = fields.Char('本次在线时长', compute='_run_info', readonly=True)
+ machine_tool_tool_num = fields.Integer('当前刀具', compute='_run_info', readonly=True)
+ machine_tool_program = fields.Char('当前程序', compute='_run_info', readonly=True)
+ machine_tool_machine_ip = fields.Char('机床IP', compute='_run_info', readonly=True)
+ machine_tool_cut_status = fields.Selection([('0', '未切削'), ('1', '切削中'), ('2', '切削中'), ('3', '切削中')],
+ string='切削状态', compute='_run_info', readonly=True, default='0')
+ machine_tool_compensation_value_x = fields.Char('x补偿值', compute='_run_info', readonly=True)
+ machine_tool_compensation_value_y = fields.Char('y补偿值', compute='_run_info', readonly=True)
+
+ @api.depends('workcenter_id.machine_tool_id.timestamp')
+ def _run_info(self):
+ # self.machine_tool_name = '1号机床'
+ self.machine_tool_name = self.workcenter_id.machine_tool_id.name
+ self.machine_tool_type_id = self.workcenter_id.machine_tool_id.type_id.name
+ self.machine_tool_status = self.workcenter_id.machine_tool_id.status
+ self.machine_tool_run_status = self.workcenter_id.machine_tool_id.run_status
+ self.machine_tool_timestamp = self.workcenter_id.machine_tool_id.timestamp
+ self.machine_tool_time_on = self.workcenter_id.machine_tool_id.time_on
+ self.machine_tool_time_on_now = self.workcenter_id.machine_tool_id.time_on_now
+ self.machine_tool_tool_num = self.workcenter_id.machine_tool_id.tool_num
+ self.machine_tool_program = self.workcenter_id.machine_tool_id.program
+ self.machine_tool_machine_ip = self.workcenter_id.machine_tool_id.machine_ip
+ self.machine_tool_cut_status = self.workcenter_id.machine_tool_id.cut_status
+ self.machine_tool_compensation_value_x = self.compensation_value_x
+ self.machine_tool_compensation_value_y = self.compensation_value_y
def compensation(self):
@@ -256,6 +289,8 @@ class WorkCenterBarcode(models.Model):
except Exception as e:
_logger.info("=====================================", e)
raise UserError('补偿值获取失败,或机床未连接,请检查')
+ # 补偿执行完毕后,按钮标志位变为true
+ self.button_compensation_state = True
def up_all(self):
"""
@@ -291,6 +326,8 @@ class WorkCenterBarcode(models.Model):
# except Exception as e:
# _logger.info("=====================================", e)
# raise UserError('NC下发执行超时, 请检查下发状态')
+ # 下发都执行完毕后,按钮标志位变为true
+ self.button_up_all_state = True
def get__state(self):
pay_time = str(datetime.now())
diff --git a/sf_machine_connect/views/compensation.xml b/sf_machine_connect/views/compensation.xml
index 4a2e6e69..cddeba78 100644
--- a/sf_machine_connect/views/compensation.xml
+++ b/sf_machine_connect/views/compensation.xml
@@ -12,10 +12,14 @@
-
+
+
+
diff --git a/sf_machine_connect/views/ftp_button.xml b/sf_machine_connect/views/ftp_button.xml
index c8bf8caa..e56ea01a 100644
--- a/sf_machine_connect/views/ftp_button.xml
+++ b/sf_machine_connect/views/ftp_button.xml
@@ -11,9 +11,10 @@
-
+
diff --git a/sf_machine_connect/views/machine_info_present.xml b/sf_machine_connect/views/machine_info_present.xml
index 97928af7..816921a3 100644
--- a/sf_machine_connect/views/machine_info_present.xml
+++ b/sf_machine_connect/views/machine_info_present.xml
@@ -5,12 +5,24 @@
mrp.workorder
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 60e044ec9bcf35912eb7884848b8f4652f77c26d Mon Sep 17 00:00:00 2001
From: mgw <1392924357@qq.com>
Date: Mon, 30 Jan 2023 15:14:36 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9C=BA=E5=BA=8Aftp?=
=?UTF-8?q?=E8=B7=AF=E5=BE=84=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_machine_connect/models/ftp_client.py | 16 ++++++++++------
sf_machine_connect/views/machine_monitor.xml | 1 +
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py
index 0e06678f..bad3d625 100644
--- a/sf_machine_connect/models/ftp_client.py
+++ b/sf_machine_connect/models/ftp_client.py
@@ -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)
diff --git a/sf_machine_connect/views/machine_monitor.xml b/sf_machine_connect/views/machine_monitor.xml
index 20374e6f..45711a8b 100644
--- a/sf_machine_connect/views/machine_monitor.xml
+++ b/sf_machine_connect/views/machine_monitor.xml
@@ -107,6 +107,7 @@
+
From 4e57c76c6371b596db800a94ce9d039d8f32642f Mon Sep 17 00:00:00 2001
From: mgw <1392924357@qq.com>
Date: Mon, 30 Jan 2023 17:38:53 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E6=9C=BA=E5=BA=8A=E5=AF=B9=E8=B1=A1?=
=?UTF-8?q?=E4=B8=8A=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E9=87=87=E9=9B=86?=
=?UTF-8?q?=E8=8A=82=E7=82=B9=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_machine_connect/models/ftp_client.py | 11 +++++++++++
sf_machine_connect/views/machine_monitor.xml | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py
index bad3d625..723ddcdc 100644
--- a/sf_machine_connect/models/ftp_client.py
+++ b/sf_machine_connect/models/ftp_client.py
@@ -185,6 +185,17 @@ class Machine_ftp(models.Model):
y_compensation_node = fields.Char('y补偿值节点')
# 数采配置相关
machine_ip = fields.Char('机床IP')
+ machine_signed = fields.Char('刷新间隔')
+ machine_status = fields.Char('机床在线状态')
+ machine_time_on = fields.Char('机床总在线时长')
+ machine_tool_num = fields.Char('机床当前刀具')
+ machine_program = fields.Char('机床当前程序')
+ machine_run_status = fields.Char('机床运行状态')
+ machine_run_time = fields.Char('机床总运行时长')
+ machine_cut_time = fields.Char('机床总切削时长')
+ machine_cut_status = fields.Char('机床切削状态')
+ machine_emg_status = fields.Char('机床急停状态')
+ machine_mode = fields.Char('机床操作模式')
# 机床采集项目
timestamp = fields.Datetime('时间戳', readonly=True)
diff --git a/sf_machine_connect/views/machine_monitor.xml b/sf_machine_connect/views/machine_monitor.xml
index 45711a8b..e90e8856 100644
--- a/sf_machine_connect/views/machine_monitor.xml
+++ b/sf_machine_connect/views/machine_monitor.xml
@@ -115,6 +115,17 @@
+
+
+
+
+
+
+
+
+
+
+
From 51c89f5c6b85ffa9627ae78dfc6f5ad47b4a86cc Mon Sep 17 00:00:00 2001
From: mgw <1392924357@qq.com>
Date: Tue, 31 Jan 2023 10:27:57 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=8C=E4=B8=BA=E4=B8=80=E9=94=AE=E4=B8=8B?=
=?UTF-8?q?=E5=8F=91=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_machine_connect/models/ftp_client.py | 43 +++++++++++++------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py
index 723ddcdc..8044af74 100644
--- a/sf_machine_connect/models/ftp_client.py
+++ b/sf_machine_connect/models/ftp_client.py
@@ -185,7 +185,7 @@ class Machine_ftp(models.Model):
y_compensation_node = fields.Char('y补偿值节点')
# 数采配置相关
machine_ip = fields.Char('机床IP')
- machine_signed = fields.Char('刷新间隔')
+ machine_signed = fields.Char('机床刷新间隔')
machine_status = fields.Char('机床在线状态')
machine_time_on = fields.Char('机床总在线时长')
machine_tool_num = fields.Char('机床当前刀具')
@@ -318,29 +318,30 @@ class WorkCenterBarcode(models.Model):
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
- print(a.display_name)
- _logger.info(a.public)
- _logger.info(a.display_name)
- datas = base64.standard_b64decode(a.datas)
+ try:
+ 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)
- file_path_remote = '{}\{}'.format(remote_path, a.display_name)
+ # 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)
+ 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)
+ 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下发执行超时, 请检查下发状态')
+ except Exception as e:
+ _logger.info("=====================================", e)
+ raise UserError('NC下发执行超时, 请检查下发状态')
# 下发都执行完毕后,按钮标志位变为true
self.button_up_all_state = True