pd9427
This commit is contained in:
@ -17,7 +17,8 @@ from vision.camera_picture import save_camera_picture
|
||||
from busisness.blls import ArtifactBll,PDRecordBll
|
||||
from busisness.models import ArtifactInfoModel,PDRecordModel
|
||||
from service.mould_service import app_web_service
|
||||
from core.system_state import SystemState,FeedStatus,Upper_Door_Position
|
||||
from core.system_state import SystemState,FeedStatus,Upper_Door_Position,PD_StatusEnum
|
||||
from core.core_utils import CoreUtils
|
||||
from dataclasses import asdict
|
||||
import json
|
||||
import math
|
||||
@ -301,6 +302,9 @@ class VisualCallback:
|
||||
def _arch_loop(self):
|
||||
"""破拱线程"""
|
||||
while self._is_running:
|
||||
if self._is_finish:
|
||||
time.sleep(2)
|
||||
continue
|
||||
try:
|
||||
current_time = time.time()
|
||||
# 检查下料斗破拱(只有在下料过程中才检查)
|
||||
@ -314,8 +318,9 @@ class VisualCallback:
|
||||
if (_weight_changed< 200) and \
|
||||
(current_time - self._last_arch_time) >= 2:
|
||||
self._last_arch_time = current_time
|
||||
print('---------------------第一阶段振动5秒(小于200KG)-----------------')
|
||||
self.relay_feed.control_arch_lower_open_sync(5)
|
||||
print('---------------------第一阶段振动3秒(小于200KG)-----------------')
|
||||
if self._current_angle>25:
|
||||
self.relay_feed.control_arch_lower_open_sync(3)
|
||||
self._last_arch_one_weight = _arch_weight
|
||||
continue
|
||||
self._last_arch_one_weight = _arch_weight
|
||||
@ -345,8 +350,9 @@ class VisualCallback:
|
||||
if (_weight_changed < 100) and \
|
||||
(current_time - self._last_arch_time) >= 2:
|
||||
self._last_arch_time = current_time
|
||||
print('---------------------第三阶段振动5秒(小于100KG)-----------------')
|
||||
self.relay_feed.control_arch_lower_open_sync(5)
|
||||
print('---------------------第三阶段振动3秒(小于100KG)-----------------')
|
||||
if self._current_angle>25:
|
||||
self.relay_feed.control_arch_lower_open_sync(3)
|
||||
self._last_arch_three_weight = _arch_weight
|
||||
continue
|
||||
self._last_arch_three_weight = _arch_weight
|
||||
@ -379,7 +385,8 @@ class VisualCallback:
|
||||
(current_time - self._last_arch_time) >= 2:
|
||||
self._last_arch_time = current_time
|
||||
print(f'---------------------第五阶段振动3秒(小于{_min_arch_weight}kg))-----------------')
|
||||
self.relay_feed.control_arch_lower_open_sync(3)
|
||||
if self._current_angle>25:
|
||||
self.relay_feed.control_arch_lower_open_sync(3)
|
||||
self._last_arch_five_weight = _arch_weight
|
||||
continue
|
||||
self._last_arch_five_weight = _arch_weight
|
||||
@ -475,7 +482,7 @@ class VisualCallback:
|
||||
|
||||
def _run_feed(self):
|
||||
_is_api_request=True
|
||||
while True:
|
||||
while self.state.running:
|
||||
# print("------------已启动----------------")
|
||||
if self._is_feed_start:
|
||||
|
||||
@ -490,15 +497,23 @@ class VisualCallback:
|
||||
_is_aligned=self._aligned_get_times(1)
|
||||
if _is_aligned:
|
||||
_is_api_request=True
|
||||
if self.state.pd_status==PD_StatusEnum.PD_Ready:
|
||||
self.state.pd_status=PD_StatusEnum.PD_TimeOut
|
||||
print('------------启动程序后,进入第一块-------------')
|
||||
self._is_first_module=False
|
||||
self._mould_before_aligned=True
|
||||
if self._cur_mould_model:
|
||||
self.state._db_mould_status={
|
||||
self.state.current_mould=self._cur_mould_model
|
||||
self.state.current_block_number=CoreUtils.get_number_by_mould_code(self._cur_mould_model.MouldCode)
|
||||
self.state._db_mould_status={
|
||||
'mould_code':self._cur_mould_model.MouldCode,
|
||||
'status':2,
|
||||
'weight':0,
|
||||
}
|
||||
else:
|
||||
self.state.current_mould=None
|
||||
self.state.current_block_number=''
|
||||
|
||||
|
||||
_current_weight=self.transmitter_controller.read_data(2)
|
||||
if _current_weight:
|
||||
@ -508,6 +523,8 @@ class VisualCallback:
|
||||
return
|
||||
|
||||
self.state._feed_status=FeedStatus.FCheckGB
|
||||
# if not self.state.current_block_number=='F':
|
||||
# self.state.pd_status=PD_StatusEnum.PD_Ready
|
||||
# self.is_start_visual=True
|
||||
self.run_feed_all()
|
||||
elif self._is_finish and self._is_finish_ratio>=0.7:
|
||||
@ -519,6 +536,8 @@ class VisualCallback:
|
||||
if _is_not_aligned:
|
||||
#标志位
|
||||
self._mould_before_aligned=False
|
||||
print('------------连续盖板未对齐完成,进入派单标志-------------')
|
||||
self.state.pd_status=PD_StatusEnum.PD_Ready
|
||||
#print('------------连续盖板未对齐-------------')
|
||||
else:
|
||||
if _is_api_request:
|
||||
@ -529,6 +548,19 @@ class VisualCallback:
|
||||
print('------------进入连续生产-------------')
|
||||
self._mould_before_aligned=True
|
||||
_is_api_request=True
|
||||
if self.state.pd_status==PD_StatusEnum.PD_Ready:
|
||||
self.state.pd_status=PD_StatusEnum.PD_TimeOut
|
||||
if self._cur_mould_model:
|
||||
self.state.current_mould=self._cur_mould_model
|
||||
self.state.current_block_number=CoreUtils.get_number_by_mould_code(self._cur_mould_model.MouldCode)
|
||||
self.state._db_mould_status={
|
||||
'mould_code':self._cur_mould_model.MouldCode,
|
||||
'status':2,
|
||||
'weight':0,
|
||||
}
|
||||
else:
|
||||
self.state.current_mould=None
|
||||
self.state.current_block_number=''
|
||||
|
||||
_current_weight=self.transmitter_controller.read_data(2)
|
||||
if not _current_weight:
|
||||
@ -545,6 +577,9 @@ class VisualCallback:
|
||||
self.init_val()
|
||||
self._init_lower_weight=_current_weight
|
||||
self.state._feed_status=FeedStatus.FCheckGB
|
||||
# if not self.state.current_block_number=='F':
|
||||
#这里需要判断状态是否发送完成,如果没发送完成,应该报警(时间太长),
|
||||
# self.state.pd_status=PD_StatusEnum.PD_Ready
|
||||
self.run_feed_all()
|
||||
|
||||
# else:
|
||||
@ -665,9 +700,9 @@ class VisualCallback:
|
||||
self._mould_need_weight=0.54*2416
|
||||
need_total_weight=self._mould_need_weight
|
||||
if initial_lower_weight>100:
|
||||
self.state._feed_status=FeedStatus.FFeed5
|
||||
self.state.vf_status=2
|
||||
if not self._is_finish:
|
||||
self.state._feed_status=FeedStatus.FFeed5
|
||||
self.state.vf_status=2
|
||||
self.is_start_visual=True
|
||||
self._is_feed_stage=5
|
||||
while not self._is_finish:
|
||||
@ -716,11 +751,13 @@ class VisualCallback:
|
||||
first_finish_weight=0
|
||||
self._mould_need_weight=1.91*2416
|
||||
need_total_weight=self._mould_need_weight
|
||||
if self._is_finish:
|
||||
return
|
||||
# start_time=None
|
||||
self.is_start_visual=True
|
||||
self.state._feed_status=FeedStatus.FFeed1
|
||||
self.state.vf_status=1
|
||||
if initial_lower_weight>100:
|
||||
self.is_start_visual=True
|
||||
#下料斗的料全部下完
|
||||
self._is_feed_stage=1
|
||||
while not self._is_finish:
|
||||
@ -745,6 +782,8 @@ class VisualCallback:
|
||||
self.close_lower_door_visual()
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
self.is_start_visual=False
|
||||
_current_lower_weight=loc_mitter.read_data(2)
|
||||
if _current_lower_weight is None:
|
||||
print("-------下料斗重量异常---------")
|
||||
@ -759,7 +798,8 @@ class VisualCallback:
|
||||
#print('------------上料斗未就位----------------')
|
||||
# print('------------上料斗未就位----------------')
|
||||
time.sleep(1)
|
||||
|
||||
if self._is_finish:
|
||||
return
|
||||
if self.plc_data in self.plc_valid_data:
|
||||
print(f'------------上料斗就位(上料斗往下料斗阶段)-------------')
|
||||
#打开上料斗出砼门,开5就,开三分之一下
|
||||
@ -801,6 +841,8 @@ class VisualCallback:
|
||||
else:
|
||||
loc_relay.control_upper_close_sync(6+loc_time_count)
|
||||
self.state._upper_door_closed=0
|
||||
if self._is_finish:
|
||||
return
|
||||
self.is_start_visual=True
|
||||
initial_lower_weight=loc_mitter.read_data(2)
|
||||
if initial_lower_weight is None:
|
||||
@ -828,14 +870,17 @@ class VisualCallback:
|
||||
break
|
||||
# print(f'------------已下料: {first_finish_weight+second_finish_weight}kg-------------')
|
||||
time.sleep(0.5)
|
||||
self.is_start_visual=False
|
||||
_current_lower_weight=loc_mitter.read_data(2)
|
||||
if _current_lower_weight is None:
|
||||
print("-------下料斗重量异常(第二次下到模)---------")
|
||||
return
|
||||
first_finish_weight=first_finish_weight+initial_lower_weight-_current_lower_weight
|
||||
|
||||
print(f'------------已下料(第二次): {first_finish_weight}kg-------------')
|
||||
print(f'------------已下料(第二次): {first_finish_weight}kg-------------')
|
||||
|
||||
if self._is_finish:
|
||||
return
|
||||
self._is_feed_stage=0
|
||||
if self.plc_data in self.plc_valid_data:
|
||||
self.state._upper_door_closed=2
|
||||
@ -1147,7 +1192,7 @@ class VisualCallback:
|
||||
if self._is_feed_stage==1 or self._is_feed_stage==3:
|
||||
#根据溢料状态动态调整目标角度
|
||||
if overflow_detected == "大堆料":
|
||||
if not self.state.mould_vibrate_status:
|
||||
if not self.state._mould_vibrate_status:
|
||||
TARGET_ANGLE = 15.0 # 临时控制变频器堆料时很小
|
||||
else:
|
||||
TARGET_ANGLE = 35.0 # 大堆料时控制在15度左右
|
||||
@ -1379,11 +1424,13 @@ class VisualCallback:
|
||||
# print(f"[数据回调] 数值: 0x{data:02X} | 十进制: {data:3d} | 二进制: {binary}")
|
||||
self.plc_data=data
|
||||
if self.plc_data in self.plc_valid_data:
|
||||
if self.state._upper_door_position!=Upper_Door_Position.ZDS:
|
||||
if self.state._upper_door_position!=Upper_Door_Position.ZDS:
|
||||
self.state._upper_door_position=Upper_Door_Position.ZDS
|
||||
self.relay_controller.control(self.relay_controller.UPPER_TO_ZD, 'close')
|
||||
elif self.plc_data in self.plc_valid_data_jbl:
|
||||
if self.state._upper_door_position!=Upper_Door_Position.JBL:
|
||||
self.state._upper_door_position=Upper_Door_Position.JBL
|
||||
self.relay_controller.control(self.relay_controller.UPPER_TO_JBL, 'close')
|
||||
else:
|
||||
if self.state._upper_door_position!=Upper_Door_Position.Returning:
|
||||
self.state._upper_door_position=Upper_Door_Position.Returning
|
||||
@ -1415,14 +1462,20 @@ class VisualCallback:
|
||||
|
||||
def get_current_mould(self):
|
||||
"""获取当前要浇筑的管片"""
|
||||
# if self.state.pd_status==PD_StatusEnum.PD_Ready:
|
||||
# self.state.pd_status=PD_StatusEnum.PD_TimeOut
|
||||
_not_poured=app_web_service.get_not_pour_artifacts()
|
||||
if _not_poured is not None and len(_not_poured)>=1:
|
||||
_cur_poured_model=_not_poured[-1]
|
||||
if _cur_poured_model.MouldCode:
|
||||
self._cur_mould_model=_cur_poured_model
|
||||
self.state.current_mould=_cur_poured_model
|
||||
# self.state.current_mould=_cur_poured_model
|
||||
# self.state.current_block_number=CoreUtils.get_number_by_mould_code(_cur_poured_model.MouldCode)
|
||||
print(f'当前要浇筑的管片 {json.dumps(asdict(_cur_poured_model), ensure_ascii=False)}')
|
||||
else:
|
||||
self._cur_mould_model=None
|
||||
# self.state.current_mould=None
|
||||
# self.state.current_block_number=''
|
||||
print('当前没有未浇筑的管片')
|
||||
|
||||
def __del__(self):
|
||||
|
||||
Reference in New Issue
Block a user