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 - - - - - - - - - - - - - \ No newline at end of file diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index f3281653..8044af74 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -179,11 +179,23 @@ 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补偿值节点') # 数采配置相关 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) @@ -234,21 +246,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='_total', readonly=True) - machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_total', readonly=True) - machine_tool_status = fields.Boolean(string='在线状态', compute='_total', readonly=True) + 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='运行状态', readonly=True, default='0') + 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') - def _total(self): + @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): @@ -269,6 +301,8 @@ class WorkCenterBarcode(models.Model): except Exception as e: _logger.info("=====================================", e) raise UserError('补偿值获取失败,或机床未连接,请检查') + # 补偿执行完毕后,按钮标志位变为true + self.button_compensation_state = True def up_all(self): """ @@ -280,30 +314,36 @@ 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 - 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 = '{}\{}\{}'.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 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 @@
- +