|
@@ -4,20 +4,14 @@ from utils.s7data import *
|
|
from models.data_sender import *
|
|
from models.data_sender import *
|
|
|
|
|
|
class Trace_pusher:
|
|
class Trace_pusher:
|
|
- def __init__(self, data_s7: S7data, logger: logging.Logger, sender: Sender, strand_position: list):
|
|
|
|
|
|
+ def __init__(self, data_s7: S7data, logger: logging.Logger, sender: Sender, strand_position: list, hostsend_flag=False):
|
|
self.data_s7 = data_s7
|
|
self.data_s7 = data_s7
|
|
self.logger = logger
|
|
self.logger = logger
|
|
self.sender = sender
|
|
self.sender = sender
|
|
self.strands = [[], [], [], [], [], [], [], []]
|
|
self.strands = [[], [], [], [], [], [], [], []]
|
|
self.locks = [threading.Lock() for i in range(8)]
|
|
self.locks = [threading.Lock() for i in range(8)]
|
|
self.strand_position = strand_position
|
|
self.strand_position = strand_position
|
|
-
|
|
|
|
- self.billets_wait = []
|
|
|
|
- for i in range(8):
|
|
|
|
- tmp = self.data_s7.make_point('推钢机激光')
|
|
|
|
- tmp.allow_update(False)
|
|
|
|
- tmp.set_state(False)
|
|
|
|
- self.billets_wait.append(tmp)
|
|
|
|
|
|
+ self.hostsend_flag = hostsend_flag
|
|
|
|
|
|
self.old_heatNo = "00000000"
|
|
self.old_heatNo = "00000000"
|
|
self.current_heatNo = "00000000"
|
|
self.current_heatNo = "00000000"
|
|
@@ -52,6 +46,18 @@ class Trace_pusher:
|
|
self.data_s7.make_point('L8挡板')
|
|
self.data_s7.make_point('L8挡板')
|
|
]
|
|
]
|
|
|
|
|
|
|
|
+ if self.hostsend_flag:
|
|
|
|
+ self.hostsend_barrier = [
|
|
|
|
+ self.data_s7.make_point('热送挡板[0]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[1]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[2]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[3]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[4]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[5]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[6]'),
|
|
|
|
+ self.data_s7.make_point('热送挡板[7]'),
|
|
|
|
+ ]
|
|
|
|
+
|
|
for i in range(8):
|
|
for i in range(8):
|
|
self.barrier[i].allow_update(False)
|
|
self.barrier[i].allow_update(False)
|
|
self.barrier[i].set_state(False)
|
|
self.barrier[i].set_state(False)
|
|
@@ -59,6 +65,13 @@ class Trace_pusher:
|
|
self.barrier[i].set_excite_action(lambda i=i: self.barrier_up_action(i))
|
|
self.barrier[i].set_excite_action(lambda i=i: self.barrier_up_action(i))
|
|
self.barrier[i].set_reset_action(lambda i=i: self.logger.debug(f"{i+1}流挡板关闭"))
|
|
self.barrier[i].set_reset_action(lambda i=i: self.logger.debug(f"{i+1}流挡板关闭"))
|
|
self.barrier[i].allow_update()
|
|
self.barrier[i].allow_update()
|
|
|
|
+ if self.hostsend_flag:
|
|
|
|
+ self.hostsend_barrier[i].allow_update(False)
|
|
|
|
+ self.hostsend_barrier[i].set_state(False)
|
|
|
|
+ self.hostsend_barrier[i].set_convertor(lambda data: not bool(data))
|
|
|
|
+ self.hostsend_barrier[i].set_excite_action(lambda i=i: self.hostsend_barrier_up_action(i))
|
|
|
|
+ self.hostsend_barrier[i].set_reset_action(lambda i=i: self.logger.debug(f"{i+1}流热送挡板关闭"))
|
|
|
|
+ self.hostsend_barrier[i].allow_update()
|
|
|
|
|
|
|
|
|
|
def barrier_up_action(self, i):
|
|
def barrier_up_action(self, i):
|
|
@@ -76,6 +89,47 @@ class Trace_pusher:
|
|
self.logger.error(f"[TRACE]{i+1}流挡板打开但挡板后无已计入系统的钢坯")
|
|
self.logger.error(f"[TRACE]{i+1}流挡板打开但挡板后无已计入系统的钢坯")
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
+ def hostsend_barrier_up_action(self, i):
|
|
|
|
+ with self.count_lock:
|
|
|
|
+ gp_tmp = []
|
|
|
|
+ if self.strand_position[i] <= self.pusher_left.data:
|
|
|
|
+ index = -1
|
|
|
|
+ for j in range(len(self.pusher_left_list)-1, -1, -1):
|
|
|
|
+ if self.pusher_left_list[j][0][-3] == str(i+1):
|
|
|
|
+ index = j
|
|
|
|
+ break
|
|
|
|
+ if index == -1:
|
|
|
|
+ self.logger.warning(f"[TRACE]推钢机左侧未找到{i+1}流的热送钢坯")
|
|
|
|
+ else:
|
|
|
|
+ gp_tmp = self.pusher_left_list[index]
|
|
|
|
+ self.pusher_left_list = self.pusher_left_list[:index] + self.pusher_left_list[index+1:]
|
|
|
|
+ else:
|
|
|
|
+ index = -1
|
|
|
|
+ for j in range(len(self.pusher_right_list)-1, -1, -1):
|
|
|
|
+ if self.pusher_right_list[j][0][-3] == str(i+1):
|
|
|
|
+ index = j
|
|
|
|
+ break
|
|
|
|
+ if index == -1:
|
|
|
|
+ self.logger.warning(f"[TRACE]推钢机右侧未找到{i+1}流的热送钢坯")
|
|
|
|
+ else:
|
|
|
|
+ gp_tmp = self.pusher_right_list[index]
|
|
|
|
+ self.pusher_right_list = self.pusher_right_list[:index] + self.pusher_right_list[index+1:]
|
|
|
|
+
|
|
|
|
+ if gp_tmp:
|
|
|
|
+ if not (gp_tmp[0].startswith(self.current_heatNo) or gp_tmp[0].startswith(self.old_heatNo)):
|
|
|
|
+ self.change_heat(gp_tmp)
|
|
|
|
+ self.hostsend(gp_tmp)
|
|
|
|
+
|
|
|
|
+ def change_heat(self, data):
|
|
|
|
+ # 换炉代码
|
|
|
|
+ self.old_heatNo = self.current_heatNo
|
|
|
|
+ self.old_heatData = self.current_heatData
|
|
|
|
+ self.current_heatNo = data[0][:8]
|
|
|
|
+ self.current_heatData = data[1]
|
|
|
|
+ # 上一炉终止信号在这里发
|
|
|
|
+ self.total = 0
|
|
|
|
+ self.strand = [0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
+
|
|
def arrive_cooling_bed(self, direc):
|
|
def arrive_cooling_bed(self, direc):
|
|
with self.count_lock:
|
|
with self.count_lock:
|
|
if direc == 'left':
|
|
if direc == 'left':
|
|
@@ -89,14 +143,7 @@ class Trace_pusher:
|
|
if len(self.bed_left) >= 4:
|
|
if len(self.bed_left) >= 4:
|
|
for i in self.bed_left:
|
|
for i in self.bed_left:
|
|
if not (i[0].startswith(self.current_heatNo) or i[0].startswith(self.old_heatNo)):
|
|
if not (i[0].startswith(self.current_heatNo) or i[0].startswith(self.old_heatNo)):
|
|
- # 换炉代码
|
|
|
|
- self.old_heatNo = self.current_heatNo
|
|
|
|
- self.old_heatData = self.current_heatData
|
|
|
|
- self.current_heatNo = i[0][:8]
|
|
|
|
- self.current_heatData = i[1]
|
|
|
|
- # 上一炉终止信号在这里发
|
|
|
|
- self.total = 0
|
|
|
|
- self.strand = [0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
|
|
+ self.change_heat(i)
|
|
break
|
|
break
|
|
|
|
|
|
tmp = self.bed_left
|
|
tmp = self.bed_left
|
|
@@ -114,14 +161,7 @@ class Trace_pusher:
|
|
if len(self.bed_right) >= 4:
|
|
if len(self.bed_right) >= 4:
|
|
for i in self.bed_right:
|
|
for i in self.bed_right:
|
|
if not (i[0].startswith(self.current_heatNo) or i[0].startswith(self.old_heatNo)):
|
|
if not (i[0].startswith(self.current_heatNo) or i[0].startswith(self.old_heatNo)):
|
|
- # 换炉代码
|
|
|
|
- self.old_heatNo = self.current_heatNo
|
|
|
|
- self.old_heatData = self.current_heatData
|
|
|
|
- self.current_heatNo = i[0][:8]
|
|
|
|
- self.current_heatData = i[1]
|
|
|
|
- # 上一炉终止信号在这里发
|
|
|
|
- self.total = 0
|
|
|
|
- self.strand = [0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
|
|
+ self.change_heat(i)
|
|
break
|
|
break
|
|
|
|
|
|
tmp = self.bed_right
|
|
tmp = self.bed_right
|
|
@@ -151,5 +191,15 @@ class Trace_pusher:
|
|
self.logger.info(f"{i+1}流新增钢坯存储")
|
|
self.logger.info(f"{i+1}流新增钢坯存储")
|
|
self.strands[i] = data
|
|
self.strands[i] = data
|
|
|
|
|
|
|
|
+ def hostsend(self, i):
|
|
|
|
+ ccmNo = self.current_heatData['ccmNo']
|
|
|
|
+ strandNo = i[0][9]
|
|
|
|
+ self.total += 1
|
|
|
|
+ self.strand[int(strandNo)] += 1
|
|
|
|
+ billetNo = self.current_heatNo + ccmNo + strandNo + '{:0>2}'.format(self.strand[int(strandNo)])
|
|
|
|
+ self.sender.billet_upload(self.current_heatData, billetNo, self.total, i[2], i[3], i[4], i[5])
|
|
|
|
+
|
|
|
|
+ self.logger.info(f"{self.current_heatNo}炉钢坯热送:{billetNo}")
|
|
|
|
+
|
|
|
|
|
|
# [坯号, 炉次信息, 定尺, 拉速, 开浇时间, 停浇时间]
|
|
# [坯号, 炉次信息, 定尺, 拉速, 开浇时间, 停浇时间]
|