Accept Merge Request #110: (feature/整理代码,更新下发代码 -> develop)
Merge Request: 整理代码,更新下发代码 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/110
This commit is contained in:
@@ -75,7 +75,8 @@ class FtpButton(models.Model):
|
|||||||
port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
|
port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
|
||||||
username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
|
username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
|
||||||
pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd
|
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 = ftp_operate.FtpController(host, port, username, pwd)
|
||||||
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
||||||
a = self.cnc_id
|
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 = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||||
file_path_local = '{}/{}'.format('/nc2machine', 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:
|
with open(file_path_local, mode='wb+') as file:
|
||||||
file.write(datas)
|
file.write(datas)
|
||||||
@@ -100,66 +102,19 @@ class FtpButton(models.Model):
|
|||||||
# 补偿下发都执行完毕后,按钮标志位变为true
|
# 补偿下发都执行完毕后,按钮标志位变为true
|
||||||
self.button_state = 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):
|
def check_compensation_before_up(self):
|
||||||
"""
|
"""
|
||||||
下发NC代码前自动补偿三元检测偏差值
|
下发NC代码前自动补偿三元检测偏差值
|
||||||
:return:
|
: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:
|
try:
|
||||||
temp_dict = {}
|
temp_dict = {}
|
||||||
temp_dict[
|
temp_dict[hongbianliang550] = self.workorder_id.compensation_value_x
|
||||||
'ns=1;s=Project_Default.Group1.Mitsubishi_NC.hongbianliang550'] = self.workorder_id.compensation_value_x
|
temp_dict[hongbianliang551] = self.workorder_id.compensation_value_y
|
||||||
temp_dict[
|
|
||||||
'ns=1;s=Project_Default.Group1.Mitsubishi_NC.hongbianliang551'] = self.workorder_id.compensation_value_y
|
|
||||||
temp = py2opcua.Py2opcua()
|
temp = py2opcua.Py2opcua()
|
||||||
# temp.connect()
|
|
||||||
temp.write(temp_dict)
|
temp.write(temp_dict)
|
||||||
# temp.disconnect()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
_logger.info("=====================================", e)
|
||||||
raise UserError('补偿值获取失败,或机床未连接,请检查')
|
raise UserError('补偿值获取失败,或机床未连接,请检查')
|
||||||
@@ -286,18 +241,15 @@ class WorkCenterBarcode(models.Model):
|
|||||||
|
|
||||||
hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node
|
hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node
|
||||||
hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node
|
hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node
|
||||||
|
|
||||||
try:
|
try:
|
||||||
temp_dict = {}
|
temp_dict = {}
|
||||||
temp_dict[hongbianliang550] = self.compensation_value_x
|
temp_dict[hongbianliang550] = self.compensation_value_x
|
||||||
temp_dict[hongbianliang551] = self.compensation_value_y
|
temp_dict[hongbianliang551] = self.compensation_value_y
|
||||||
print("=================================")
|
print("=================================")
|
||||||
print(temp_dict)
|
print(temp_dict)
|
||||||
# temp = py2opcua.Py2opcua()
|
temp = py2opcua.Py2opcua()
|
||||||
# # temp.connect()
|
temp.write(temp_dict)
|
||||||
# temp.write(temp_dict)
|
self.button_compensation_state = True
|
||||||
# self.button_compensation_state = True
|
|
||||||
# temp.disconnect()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
_logger.info("=====================================", e)
|
||||||
raise UserError('补偿值获取失败,或机床未连接,请检查')
|
raise UserError('补偿值获取失败,或机床未连接,请检查')
|
||||||
|
|||||||
Reference in New Issue
Block a user