0209整理
This commit is contained in:
97
tests/pd_system.py
Normal file
97
tests/pd_system.py
Normal file
@ -0,0 +1,97 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import threading
|
||||
import time
|
||||
import queue
|
||||
from core.system_state import SystemState,FeedStatus
|
||||
from hardware.relay import RelayController
|
||||
from hardware.inverter import InverterController
|
||||
from hardware.transmitter import TransmitterController
|
||||
from config.ini_manager import ini_manager
|
||||
from hardware.upper_plc import OmronFinsPollingService
|
||||
from vision.visual_callback_dq import VisualCallback
|
||||
from opc.opcua_client_feed import OpcuaClientFeed
|
||||
from busisness.blls import ArtifactBll,PDRecordBll
|
||||
from busisness.models import ArtifactInfoModel,PDRecordModel
|
||||
|
||||
|
||||
class FeedingControlSystem:
|
||||
def __init__(self):
|
||||
print('FeedingControlSystem初始化')
|
||||
self.pd_record_bll=PDRecordBll()
|
||||
|
||||
|
||||
def send_pd_data(self):
|
||||
"""
|
||||
发送PD数据到OPC队列
|
||||
"""
|
||||
# 构建PD数据
|
||||
_cur_mould='SHR2B1-13'
|
||||
'F块L1块需要设置重量'
|
||||
_weight=0
|
||||
_pdrecords = self.pd_record_bll.get_last_pds(_cur_mould)
|
||||
if _pdrecords:
|
||||
_pdrecord=_pdrecords[0]
|
||||
if _pdrecord.TaskID:
|
||||
if _pdrecord.BlockNumber=='F':
|
||||
print(f'{_pdrecord.MouldCode} F块,不发送派单数据')
|
||||
print(f'{_pdrecord.MouldCode} F块,不发送派单数据')
|
||||
print(f'{_pdrecord.MouldCode} F块,不发送派单数据')
|
||||
return True
|
||||
_fact_volumn=self.get_fact_volumn(_pdrecord.MouldCode,_pdrecord.BlockNumber,_weight)
|
||||
if _fact_volumn>0:
|
||||
_pdrecord.FBetonVolume=_fact_volumn
|
||||
print(f'{_pdrecord.MouldCode}-{_pdrecord.BlockNumber} 实际派单方量:{_fact_volumn},{_fact_volumn},{_fact_volumn}')
|
||||
print(f'{_pdrecord.MouldCode}-{_pdrecord.BlockNumber} 实际派单方量:{_fact_volumn},{_fact_volumn},{_fact_volumn}')
|
||||
print(f'{_pdrecord.MouldCode}-{_pdrecord.BlockNumber} 实际派单方量:{_fact_volumn},{_fact_volumn},{_fact_volumn}')
|
||||
# self.state._pd_data=_pdrecord
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
print(f'{_pdrecord.MouldCode} 未获取到数据-(等待扫码)')
|
||||
return False
|
||||
else:
|
||||
print(f'接口数据异常')
|
||||
return False
|
||||
|
||||
def get_fact_volumn(self,mould_code:str,block_number:str='',_weight:float=0) -> float:
|
||||
"""获取实际派单发量"""
|
||||
_now_volumn=0
|
||||
_pd_volumn=0
|
||||
|
||||
print(f'get_fact_volumn当前重量:{_weight}')
|
||||
_now_volumn=_weight/2500
|
||||
if not block_number and '-' in mould_code:
|
||||
block_number = mould_code.split('-')[0][-2:]
|
||||
if block_number=='B1':
|
||||
_pd_volumn=1.9
|
||||
if _weight>750:
|
||||
#留0.3
|
||||
_pd_volumn=_pd_volumn-_now_volumn+0.3
|
||||
if _pd_volumn<1:
|
||||
_pd_volumn=1
|
||||
|
||||
if block_number in ['B2','B3']:
|
||||
_pd_volumn=1.9
|
||||
elif block_number=='L1':
|
||||
_pd_volumn=2.0
|
||||
elif block_number=='L2':
|
||||
#多F块后面剩下的,大约500,那下完F后多的就可以减去
|
||||
_pd_volumn=2
|
||||
# if _weight>1300:
|
||||
_pd_volumn=_pd_volumn-_now_volumn+0.5
|
||||
if _pd_volumn>2.1:
|
||||
_pd_volumn=2.1
|
||||
elif _pd_volumn<0.8:
|
||||
_pd_volumn=0.8
|
||||
|
||||
return round(_pd_volumn,1)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
system = FeedingControlSystem()
|
||||
|
||||
system.send_pd_data()
|
||||
Reference in New Issue
Block a user