修正合并下发bug

This commit is contained in:
mgw
2023-03-10 18:18:12 +08:00
parent e576a8f98d
commit 7074911b6e
3 changed files with 142 additions and 92 deletions

View File

@@ -157,12 +157,13 @@ class Machine_ftp(models.Model):
time_on_now = fields.Char('本次在线时长', readonly=True) time_on_now = fields.Char('本次在线时长', readonly=True)
tool_num = fields.Integer('当前刀具', readonly=True) tool_num = fields.Integer('当前刀具', readonly=True)
program = fields.Char('当前程序', readonly=True) program = fields.Char('当前程序', readonly=True)
run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '等待')], string='运行状态', run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '加工')], string='运行状态',
readonly=True, default='0') readonly=True, default='0')
run_time = fields.Char('总运行时长', readonly=True) run_time = fields.Char('总运行时长', readonly=True)
cut_time = fields.Char('总切削时长', readonly=True) cut_time = fields.Char('总切削时长', readonly=True)
cut_status = fields.Selection([('0', '未切削'), ('1', '切削中'), ('2', '切削中'), ('3', '切削中')], string='切削状态', cut_status = fields.Selection([('0', '未切削'), ('1', '切削中'), ('2', '切削中'), ('3', '切削中')], string='切削状态',
readonly=True, default='0') readonly=True, default='0')
spindle_speed = fields.Char('主轴转速', readonly=True)
tool_num_process_time1 = fields.Char('刀位1', readonly=True, default='0') tool_num_process_time1 = fields.Char('刀位1', readonly=True, default='0')
tool_num_process_time2 = fields.Char('刀位2', readonly=True, default='0') tool_num_process_time2 = fields.Char('刀位2', readonly=True, default='0')
@@ -259,17 +260,17 @@ class WorkCenterBarcode(models.Model):
:return: :return:
""" """
# 一键下发前删除机床上的全部程序 # 一键下发前删除机床上的全部程序
# try: try:
# filepath = '/nc2machine' filepath = '/nc2machine'
# del_list = os.listdir(filepath) del_list = os.listdir(filepath)
# _logger.info("=====================================", del_list) _logger.info("=====================================%s" % del_list)
# for f in del_list: for f in del_list:
# file_path = os.path.join(filepath, f) file_path = os.path.join(filepath, f)
# if os.path.isfile(file_path): if os.path.isfile(file_path):
# os.remove(file_path) os.remove(file_path)
# except Exception as e: except Exception as e:
# _logger.info("=====================================", e) _logger.info("=====================================", e)
# raise UserError('程序删除失败,请重试') raise UserError('程序删除失败,请重试')
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC" # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
try: try:
self.compensation() self.compensation()
@@ -281,8 +282,12 @@ class WorkCenterBarcode(models.Model):
username = self.workcenter_id.machine_tool_id.ftp_num username = self.workcenter_id.machine_tool_id.ftp_num
pwd = self.workcenter_id.machine_tool_id.ftp_pwd pwd = self.workcenter_id.machine_tool_id.ftp_pwd
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
print(host, port, username, pwd, remote_path) _logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd))
ftp = ftp_operate.FtpController(host, port, username, pwd) ftp = ftp_operate.FtpController(host, port, username, pwd)
_logger.info("=====================1777777777111================")
try: try:
for item in self.cnc_ids: for item in self.cnc_ids:
a = item.cnc_id a = item.cnc_id

View File

@@ -12,7 +12,7 @@
<notebook> <notebook>
<page string="机床监控"> <page string="机床监控">
<!-- <group string="监控">--> <!-- <group string="监控">-->
<group> <group col='12'>
<field name="timestamp"/> <field name="timestamp"/>
<field name="signed"/> <field name="signed"/>
<field name="status"/> <field name="status"/>
@@ -24,79 +24,108 @@
<!-- <field name="cut_time"/>--> <!-- <field name="cut_time"/>-->
<field name="program"/> <field name="program"/>
<field name="tool_num"/> <field name="tool_num"/>
<!-- <div class="o_address_format">--> <field name="spindle_speed"/>
<!-- <label for="tool_num_process_time1" string="刀位1"/>-->
<!-- <field name="tool_num_process_time1" class="o_form_label"/>--> </group>
<!-- <span>&amp;nbsp;</span>--> <group string='刀位统计' col='8'>
<!-- <label for="tool_num_process_time2" string="刀位1"/>--> <field name="tool_num_process_time1"/>
<!-- <field name="tool_num_process_time2" class="o_form_label"/>--> <field name="tool_num_process_time2"/>
<!-- <span>&amp;nbsp;</span>--> <field name="tool_num_process_time3"/>
<!-- <label for="tool_num_process_time3" string="刀位1"/>--> <field name="tool_num_process_time4"/>
<!-- <field name="tool_num_process_time3" class="o_form_label"/>--> <field name="tool_num_process_time5"/>
<!-- <span>&amp;nbsp;</span>--> <field name="tool_num_process_time6"/>
<!-- <label for="tool_num_process_time4" string="刀位1"/>--> <field name="tool_num_process_time7"/>
<!-- <field name="tool_num_process_time4" class="o_form_label"/>--> <field name="tool_num_process_time8"/>
<!-- <div></div>--> <field name="tool_num_process_time9"/>
<!-- <label for="tool_num_process_time5" string="刀位1"/>--> <field name="tool_num_process_time10"/>
<!-- <field name="tool_num_process_time5" class="o_form_label"/>--> <field name="tool_num_process_time11"/>
<!-- <span>&amp;nbsp;</span>--> <field name="tool_num_process_time12"/>
<!-- <label for="tool_num_process_time6" string="刀位1"/>--> <field name="tool_num_process_time13"/>
<!-- <field name="tool_num_process_time6" class="o_form_label"/>--> <field name="tool_num_process_time14"/>
<!-- <span>&amp;nbsp;</span>--> <field name="tool_num_process_time15"/>
<!-- <label for="tool_num_process_time7" string="刀位1"/>--> <field name="tool_num_process_time16"/>
<!-- <field name="tool_num_process_time7" class="o_form_label"/>--> <field name="tool_num_process_time17"/>
<!-- <span>&amp;nbsp;</span>--> <field name="tool_num_process_time18"/>
<!-- <label for="tool_num_process_time8" string="刀位1"/>--> <field name="tool_num_process_time19"/>
<!-- <field name="tool_num_process_time8" class="o_form_label"/>--> <field name="tool_num_process_time20"/>
<!-- <div></div>--> <field name="tool_num_process_time21"/>
<!-- <label for="tool_num_process_time9" string="刀位1"/>--> <field name="tool_num_process_time22"/>
<!-- <field name="tool_num_process_time9" class="o_form_label"/>--> <field name="tool_num_process_time23"/>
<!-- <span>&amp;nbsp;</span>--> <field name="tool_num_process_time24"/>
<!-- <label for="tool_num_process_time10" string="刀位1"/>-->
<!-- <field name="tool_num_process_time10" class="o_form_label"/>--> <!-- <div class="o_address_format"> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time1" string="刀位1"/> -->
<!-- <label for="tool_num_process_time11" string="刀位1"/>--> <!-- <field name="tool_num_process_time1" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time11" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time2" string="刀位2"/> -->
<!-- <label for="tool_num_process_time12" string="刀位1"/>--> <!-- <field name="tool_num_process_time2" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time12" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <div></div>--> <!-- <label for="tool_num_process_time3" string="刀位3"/> -->
<!-- <label for="tool_num_process_time13" string="刀位1"/>--> <!-- <field name="tool_num_process_time3" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time13" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time4" string="刀位4"/> -->
<!-- <label for="tool_num_process_time14" string="刀位1"/>--> <!-- <field name="tool_num_process_time4" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time14" class="o_form_label"/>--> <!-- <div></div> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time5" string="刀位5"/> -->
<!-- <label for="tool_num_process_time15" string="刀位1"/>--> <!-- <field name="tool_num_process_time5" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time15" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time6" string="刀位6"/> -->
<!-- <label for="tool_num_process_time16" string="刀位1"/>--> <!-- <field name="tool_num_process_time6" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time16" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <div></div>--> <!-- <label for="tool_num_process_time7" string="刀位7"/> -->
<!-- <label for="tool_num_process_time17" string="刀位1"/>--> <!-- <field name="tool_num_process_time7" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time17" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time8" string="刀位8"/> -->
<!-- <label for="tool_num_process_time18" string="刀位1"/>--> <!-- <field name="tool_num_process_time8" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time18" class="o_form_label"/>--> <!-- <div></div> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time9" string="刀位9"/> -->
<!-- <label for="tool_num_process_time19" string="刀位1"/>--> <!-- <field name="tool_num_process_time9" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time19" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time10" string="刀位10"/> -->
<!-- <label for="tool_num_process_time20" string="刀位1"/>--> <!-- <field name="tool_num_process_time10" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time20" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <div></div>--> <!-- <label for="tool_num_process_time11" string="刀位11"/> -->
<!-- <label for="tool_num_process_time21" string="刀位1"/>--> <!-- <field name="tool_num_process_time11" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time21" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time12" string="刀位12"/> -->
<!-- <label for="tool_num_process_time22" string="刀位1"/>--> <!-- <field name="tool_num_process_time12" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time22" class="o_form_label"/>--> <!-- <div></div> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time13" string="刀位13"/> -->
<!-- <label for="tool_num_process_time23" string="刀位1"/>--> <!-- <field name="tool_num_process_time13" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time23" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- <span>&amp;nbsp;</span>--> <!-- <label for="tool_num_process_time14" string="刀位14"/> -->
<!-- <label for="tool_num_process_time24" string="刀位1"/>--> <!-- <field name="tool_num_process_time14" class="o_form_label"/> -->
<!-- <field name="tool_num_process_time24" class="o_form_label"/>--> <!-- <span>&amp;nbsp;</span> -->
<!-- </div>--> <!-- <label for="tool_num_process_time15" string="刀位15"/> -->
<!-- <field name="tool_num_process_time15" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time16" string="刀位16"/> -->
<!-- <field name="tool_num_process_time16" class="o_form_label"/> -->
<!-- <div></div> -->
<!-- <label for="tool_num_process_time17" string="刀位17"/> -->
<!-- <field name="tool_num_process_time17" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time18" string="刀位18"/> -->
<!-- <field name="tool_num_process_time18" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time19" string="刀位19"/> -->
<!-- <field name="tool_num_process_time19" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time20" string="刀位20"/> -->
<!-- <field name="tool_num_process_time20" class="o_form_label"/> -->
<!-- <div></div> -->
<!-- <label for="tool_num_process_time21" string="刀位21"/> -->
<!-- <field name="tool_num_process_time21" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time22" string="刀位22"/> -->
<!-- <field name="tool_num_process_time22" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time23" string="刀位23"/> -->
<!-- <field name="tool_num_process_time23" class="o_form_label"/> -->
<!-- <span>&amp;nbsp;</span> -->
<!-- <label for="tool_num_process_time24" string="刀位24"/> -->
<!-- <field name="tool_num_process_time24" class="o_form_label"/> -->
<!-- </div> -->
</group> </group>
</page> </page>
<page string="机床配置"> <page string="机床配置">
@@ -126,6 +155,7 @@
<field name="machine_cut_status"/> <field name="machine_cut_status"/>
<field name="machine_emg_status"/> <field name="machine_emg_status"/>
<field name="machine_mode"/> <field name="machine_mode"/>
<field name="machine_spindle_speed"/>
</group> </group>
</group> </group>

View File

@@ -26,7 +26,18 @@ class UpSelectWizard(models.TransientModel):
def confirm_up(self): def confirm_up(self):
# 合并下发前删除机床上的全部程序
try:
filepath = '/nc2machine'
del_list = os.listdir(filepath)
_logger.info("=====================================%s" % del_list)
for f in del_list:
file_path = os.path.join(filepath, f)
if os.path.isfile(file_path):
os.remove(file_path)
except Exception as e:
_logger.info("=====================================", e)
raise UserError('程序删除失败,请重试')
host = self.workcenter_id.machine_tool_id.ftp_host host = self.workcenter_id.machine_tool_id.ftp_host
port = self.workcenter_id.machine_tool_id.ftp_port port = self.workcenter_id.machine_tool_id.ftp_port
username = self.workcenter_id.machine_tool_id.ftp_num username = self.workcenter_id.machine_tool_id.ftp_num
@@ -35,6 +46,8 @@ class UpSelectWizard(models.TransientModel):
print(host, port, username, pwd, 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)
sequence_collect = [] sequence_collect = []
file_path_local = ''
file_path_remote = ''
try: try:
# 给文件名 # 给文件名
begin_name1 = self.program_ids[0].cnc_id.display_name.split('-') begin_name1 = self.program_ids[0].cnc_id.display_name.split('-')
@@ -61,12 +74,12 @@ class UpSelectWizard(models.TransientModel):
with open(file_path_local, mode='ab+') as file: with open(file_path_local, mode='ab+') as file:
file.write(datas) file.write(datas)
# 下发成功标识
item.button_state = True
# 存在本地的文件下发到机床 # 存在本地的文件下发到机床
_logger.info("==========存在服务器成功,准备下发===========") _logger.info("==========存在服务器成功,准备下发===========")
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local) ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
_logger.info("======%s下发成功======" % a.display_name)
# 下发成功标识
item.button_state = True
ftp.close_ftp() ftp.close_ftp()
up_time = str(datetime.now()) up_time = str(datetime.now())
@@ -78,6 +91,8 @@ class UpSelectWizard(models.TransientModel):
}) })
_logger.info("==============合并下发成功==============") _logger.info("==============合并下发成功==============")
except Exception as e: except Exception as e:
for item in self.program_ids:
item.button_state = False
_logger.info("=====================================", e) _logger.info("=====================================", e)
raise UserError('NC下发执行超时, 请检查下发状态') raise UserError('NC下发执行超时, 请检查下发状态')