stage_one
This commit is contained in:
62
vision/test_feed.py
Normal file
62
vision/test_feed.py
Normal file
@ -0,0 +1,62 @@
|
||||
import time
|
||||
from hardware.relay import RelayController
|
||||
from hardware.transmitter import TransmitterController
|
||||
from test_feed import start_feeding
|
||||
|
||||
def start_feeding():
|
||||
"""第一阶段下料:下料斗向模具车下料(低速)"""
|
||||
print("开始下料")
|
||||
# self.relay_controller.control
|
||||
loc_relay=RelayController()
|
||||
loc_mitter=TransmitterController(loc_relay)
|
||||
initial_lower_weight=loc_mitter.read_data(2)
|
||||
initial_upper_weight=loc_mitter.read_data(1)
|
||||
first_finish_weight=0
|
||||
start_time=None
|
||||
# mould_need_weight=4000
|
||||
while True:
|
||||
current_weight = loc_mitter.read_data(2)
|
||||
first_finish_weight=initial_lower_weight-current_weight
|
||||
if current_weight<500:
|
||||
#关5秒
|
||||
if start_time is None or time.time()-start_time>5:
|
||||
start_time=time.time()
|
||||
loc_relay.control_arch_lower_open()
|
||||
|
||||
if current_weight<100:
|
||||
start_time=None
|
||||
loc_relay.control_lower_close()
|
||||
break
|
||||
print(f'------------已下料: {first_finish_weight}kg-------------')
|
||||
time.sleep(1)
|
||||
|
||||
#打开上料斗出砼门,开5就,开三分之一下
|
||||
loc_relay.control_upper_open_sync(5)
|
||||
while True:
|
||||
current_upper_weight = loc_mitter.read_data(1)
|
||||
if current_upper_weight<3500:
|
||||
#关5秒
|
||||
loc_relay.control_upper_close()
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
initial_lower_weight=loc_mitter.read_data(2)
|
||||
while True:
|
||||
current_weight = loc_mitter.read_data(2)
|
||||
first_finish_weight=first_finish_weight+initial_lower_weight-current_weight
|
||||
if current_weight<500:
|
||||
#关5秒
|
||||
if start_time is None or time.time()-start_time>5:
|
||||
start_time=time.time()
|
||||
loc_relay.control_arch_lower_open()
|
||||
if current_weight<100:
|
||||
start_time=None
|
||||
loc_relay.control_lower_close()
|
||||
break
|
||||
print(f'------------已下料: {first_finish_weight}kg-------------')
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
start_feeding()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user