feed下料
This commit is contained in:
@ -16,20 +16,22 @@ class FeedingProcess:
|
||||
self.camera_controller = camera_controller
|
||||
self.state = state
|
||||
self.state.feed_status = FeedStatus.FNone
|
||||
|
||||
self.settings = settings
|
||||
|
||||
def start_feeding(self):
|
||||
loc_state=self.state
|
||||
"""开始生产管片"""
|
||||
if self.state.feed_status == FeedStatus.FNone:
|
||||
self.state.feed_status = FeedStatus.FCheckM
|
||||
if loc_state.feed_status == FeedStatus.FNone:
|
||||
loc_state.feed_status = FeedStatus.FCheckM
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FCheckM:
|
||||
self.state._lower_feeding_stage = 4
|
||||
elif loc_state.feed_status == FeedStatus.FCheckM:
|
||||
loc_state._lower_feeding_stage = 4
|
||||
self.wait_for_vehicle_alignment()
|
||||
self.state.feed_status = FeedStatus.FStart
|
||||
loc_state.feed_status = FeedStatus.FStart
|
||||
print("生产已检查模车")
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FStart:
|
||||
elif loc_state.feed_status == FeedStatus.FApiCheck:
|
||||
print("生产已开始")
|
||||
time.sleep(2)
|
||||
loc_modules = MouldService.get_not_pour_artifacts()
|
||||
@ -41,7 +43,7 @@ class FeedingProcess:
|
||||
#未读取到AIP接口数据.
|
||||
self.state.current_artifact = None
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FRFID:
|
||||
elif loc_state.feed_status == FeedStatus.FRFID:
|
||||
print("生产已检查RFID")
|
||||
#RFID格式:模具编号,分块号,尺寸规格,方量
|
||||
rfid_info =''
|
||||
@ -64,14 +66,55 @@ class FeedingProcess:
|
||||
#确认是否保存到数据库
|
||||
self.state.feed_status = FeedStatus.FCheckGB
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FCheckGB:
|
||||
print("生产已检查盖板")
|
||||
elif loc_state.feed_status == FeedStatus.FCheckGB:
|
||||
print("检查盖板对齐,")
|
||||
time.sleep(10)
|
||||
self.state.feed_status = FeedStatus.FFeed
|
||||
loc_state.feed_status = FeedStatus.FUpperToLower
|
||||
#计算本次生产需要的总重量
|
||||
print(f"本次生产需要的总重量:{self.state.need_total_weight}")
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FFeed:
|
||||
self._start_feeding_stage()
|
||||
print("生产已下料")
|
||||
elif loc_state.feed_status == FeedStatus.FUpperToLower:
|
||||
print("上料斗向下料斗转移")
|
||||
#上料斗重量
|
||||
loc_state.initial_upper_weight=self.transmitter_controller.read_data(1)
|
||||
#下料斗重量
|
||||
loc_state.initial_lower_weight=self.transmitter_controller.read_data(2)
|
||||
#需要的总重量
|
||||
loc_state.need_total_weight=loc_state.current_artifact.BetonVolume*loc_state.density
|
||||
if loc_state.need_total_weight > loc_state.initial_upper_weight + loc_state.initial_lower_weight:
|
||||
# 等待上料斗重量增加(多久不够报警,可能出现F块不足的情况)
|
||||
print('重量不够,需要增加')
|
||||
return
|
||||
|
||||
if loc_state.need_total_weight>loc_state.initial_lower_weight:
|
||||
if self.state._upper_door_position != 'over_lower':
|
||||
#是否需要等待上料斗下料,如果下料斗够重量,则不需要等待
|
||||
return
|
||||
else:
|
||||
# 需要等待上料斗下料
|
||||
# 最后一块进行尾数控制
|
||||
# 最后一块F块,前面多要0.25,0.3,F块直接下料(先多下0.3后续)
|
||||
loc_FWeight=0.3*loc_state.density
|
||||
loc_feed_weight=loc_state.need_total_weight-loc_state.initial_lower_weight-loc_FWeight
|
||||
self.transfer_material_from_upper_to_lower(loc_state.initial_upper_weight,loc_state.initial_lower_weight,loc_feed_weight)
|
||||
|
||||
self.state.feed_status = FeedStatus.FFeed1
|
||||
# time.sleep(10)
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FFeed1:
|
||||
#下料
|
||||
# self._start_feeding_stage()
|
||||
print("下料1")
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FFeed2:
|
||||
#上料
|
||||
# self._start_feeding_stage()
|
||||
print("下料2")
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FFeed3:
|
||||
#下料
|
||||
# self._start_feeding_stage()
|
||||
print("下料3")
|
||||
return
|
||||
elif self.state.feed_status == FeedStatus.FFinished:
|
||||
print("生产已完成")
|
||||
@ -81,42 +124,19 @@ class FeedingProcess:
|
||||
def _start_feeding_stage(self):
|
||||
"""启动指定下料阶段"""
|
||||
"""开始分步下料"""
|
||||
if self.state._lower_feeding_stage != 0:
|
||||
print("下料已在进行中")
|
||||
return
|
||||
|
||||
print("开始分步下料过程")
|
||||
# 重置计数器
|
||||
#下料斗下料循环次数
|
||||
self.state.lower_feeding_cycle = 0
|
||||
#上料斗已下料次数
|
||||
self.state.upper_feeding_count = 0
|
||||
#上料斗最大下料次数
|
||||
self.state.upper_feeding_max = 2
|
||||
|
||||
# 第一次上料
|
||||
self.transfer_material_from_upper_to_lower()
|
||||
|
||||
# 等待模具车对齐并开始第一轮下料
|
||||
# self.state._lower_feeding_stage = 4
|
||||
# self.wait_for_vehicle_alignment()
|
||||
|
||||
def transfer_material_from_upper_to_lower(self):
|
||||
"""上料斗向下料斗下料"""
|
||||
print(f"上料斗向下料斗下料 (第 {self.state.upper_feeding_count + 1} 次)")
|
||||
|
||||
# 记录下料前的重量
|
||||
initial_upper_weight = self.transmitter_controller.read_data(1)
|
||||
|
||||
# 如果无法读取重量,直接报错
|
||||
if initial_upper_weight is None:
|
||||
raise Exception("无法读取上料斗重量传感器数据,下料操作终止")
|
||||
# 单次下料重量(kg),self.settings.single_batch_weight
|
||||
target_upper_weight = initial_upper_weight - self.settings.single_batch_weight
|
||||
target_upper_weight = max(target_upper_weight, 0) # 确保不低于0
|
||||
|
||||
print(f"上料斗初始重量: {initial_upper_weight:.2f}kg, 目标重量: {target_upper_weight:.2f}kg")
|
||||
def transfer_material_from_upper_to_lower(self,initial_upper_weight,initial_lower_weight,feed_weight):
|
||||
|
||||
"""target_upper_weight:转移后剩下的上料斗重量"""
|
||||
# 如果低于单次,全部卸掉
|
||||
_max_lower_weight=self.settings.max_lower_volume*self.state.density
|
||||
if (initial_lower_weight+feed_weight>_max_lower_weight):
|
||||
feed_weight=_max_lower_weight-initial_lower_weight
|
||||
|
||||
target_upper_weight=initial_upper_weight-feed_weight
|
||||
target_upper_weight = max(target_upper_weight, 0)
|
||||
# 确保下料斗出砼门关闭
|
||||
self.relay_controller.control(self.relay_controller.DOOR_LOWER_2, 'close')
|
||||
# 打开上料斗出砼门
|
||||
@ -125,11 +145,10 @@ class FeedingProcess:
|
||||
# 等待物料流入下料斗,基于上料斗重量变化控制
|
||||
import time
|
||||
start_time = time.time()
|
||||
timeout = 30 # 30秒超时
|
||||
# timeout = 30 # 30秒超时
|
||||
|
||||
while time.time() - start_time < timeout:
|
||||
while self.state.running:
|
||||
current_upper_weight = self.transmitter_controller.read_data(1)
|
||||
|
||||
# 如果无法读取重量,继续尝试
|
||||
if current_upper_weight is None:
|
||||
print("无法读取上料斗重量,继续尝试...")
|
||||
@ -141,26 +160,16 @@ class FeedingProcess:
|
||||
# 如果达到目标重量,则关闭上料斗出砼门
|
||||
if current_upper_weight <= target_upper_weight + 50: # 允许50kg的误差范围
|
||||
print(f"达到目标重量,当前重量: {current_upper_weight:.2f}kg")
|
||||
print(f"花费时间 {time.time() - start_time:.2f}秒")
|
||||
break
|
||||
elif time.time() - start_time > 25: # 如果25秒后重量变化过小
|
||||
weight_change = initial_upper_weight - current_upper_weight
|
||||
if weight_change < 100: # 如果重量变化小于100kg
|
||||
print("重量变化过小,可能存在堵塞,交由监控系统处理...")
|
||||
break
|
||||
|
||||
#需要增加报警处理
|
||||
print("重量变化过小,可能存在堵塞")
|
||||
time.sleep(1)
|
||||
|
||||
# 关闭上料斗出砼门
|
||||
self.relay_controller.control(self.relay_controller.DOOR_LOWER_1, 'close')
|
||||
|
||||
# 验证下料结果
|
||||
final_upper_weight = self.transmitter_controller.read_data(1)
|
||||
if final_upper_weight is not None:
|
||||
actual_transferred = initial_upper_weight - final_upper_weight
|
||||
print(f"实际下料重量: {actual_transferred:.2f}kg")
|
||||
|
||||
# 增加上料计数
|
||||
self.state.upper_feeding_count += 1
|
||||
print("上料斗下料完成")
|
||||
|
||||
def wait_for_vehicle_alignment(self):
|
||||
|
||||
Reference in New Issue
Block a user