Commit d22b9d9f authored by Allvey's avatar Allvey

矿卡型号控制,修复BUG

parent 8cc6dd61
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -47,6 +47,9 @@ class DumpInfo(WalkManage):
self.period_map_para_load()
self.period_walk_para_load()
# 参数初始化
self.para_period_update()
def get_unloading_time(self):
return self.unloading_time
......
......@@ -47,6 +47,9 @@ class ExcavatorInfo(WalkManage):
self.period_map_para_load()
self.period_walk_para_load()
# 参数初始化
self.para_period_update()
# def period_map_para_load(self):
# # 关系映射
# self.excavator_uuid_to_index_dict = device_map.excavator_uuid_to_index_dict
......@@ -177,7 +180,7 @@ class ExcavatorInfo(WalkManage):
def update_excavator_material(self):
for excavator_id in dynamic_excavator_set:
load_area_id = session_mysql.query(Dispatch).filter_by(exactor_id=excavator_id).first().load_area_id
excavator_material_id = session_postgre.query(DiggerArea).filter_by(Id=load_area_id).first().Material
excavator_material_id = session_postgre.query(DiggingWorkArea).filter_by(Id=load_area_id).first().Material
self.excavator_material[excavator_id] = excavator_material_id
def para_period_update(self):
......
......@@ -42,6 +42,14 @@ class TruckInfo(WalkManage):
# self.sim_truck_ava_time = np.zeros(self.dynamic_truck_num)
# 矿卡有效载重
self.payload = np.zeros(self.dynamic_truck_num)
# 矿卡时速
self.empty_speed = {}
self.heavy_speed = {}
# 矿卡长宽
self.geo_length = {}
self.geo_width = {}
# 矿卡型号
self.size = {}
# 矿卡当前行程(第一列为出发地序号, 第二列为目的地序号)
self.truck_current_trip = np.full((self.dynamic_truck_num, 2), -1)
# 矿卡挖机绑定关系
......@@ -68,6 +76,8 @@ class TruckInfo(WalkManage):
self.period_map_para_load()
self.period_walk_para_load()
self.para_period_update()
# def period_map_para_load(self):
# # 关系映射
# self.excavator_uuid_to_index_dict = device_map.excavator_uuid_to_index_dict
......@@ -118,6 +128,12 @@ class TruckInfo(WalkManage):
def get_payload(self):
return self.payload
def get_width(self):
return self.geo_width
def get_length(self):
return self.geo_length
################################################ short term update ################################################
# 更新矿卡当前任务
......@@ -327,6 +343,8 @@ class TruckInfo(WalkManage):
logger.error("读取矿卡有效载重异常-矿卡型号信息缺失")
logger.error(es)
print(self.payload)
def update_truck_priority(self):
self.truck_priority = np.zeros(self.dynamic_truck_num)
......@@ -399,7 +417,6 @@ class TruckInfo(WalkManage):
logger.error(es)
def update_truck_dump_exclude(self):
pass
def update_truck_material(self):
......@@ -470,6 +487,17 @@ class TruckInfo(WalkManage):
if dump_material_id != material:
self.dump_material_bind_modify[truck_index][dump_index] = 1000000
def update_truck_spec(self):
for truck_id in dynamic_truck_set:
self.size[truck_id] = session_mysql.query(Equipment).filter_by(id=truck_id).first().equipment_spec
def update_truck_size(self):
self.update_truck_spec()
for truck_id in dynamic_truck_set:
truck_spec_id = self.size[truck_id]
self.geo_length[truck_id] = session_mysql.query(EquipmentSpec).filter_by(id=truck_spec_id).first().length
self.geo_width[truck_spec_id] = session_mysql.query(EquipmentSpec).filter_by(id=truck_spec_id).first().width
# print("-------------------------------------------")
# print("truck")
# print(self.truck_uuid_to_index_dict)
......@@ -482,6 +510,15 @@ class TruckInfo(WalkManage):
# print(dynamic_dump_set)
# print(self.dump_material_bind_modify)
def update_truck_speed(self):
for truck_id in dynamic_truck_set:
self.empty_speed[truck_id] = session_mysql.query(EquipmentSpec.max_speed). \
Join(Equipment, EquipmentSpec.id == Equipment.equipment_spec). \
filter(Equipment.id == truck_id).first()
self.heavy_speed[truck_id] = session_mysql.query(EquipmentSpec.max_speed). \
Join(Equipment, EquipmentSpec.id == Equipment.equipment_spec). \
filter(Equipment.id == truck_id).first()
def para_period_update(self):
# print("Para truck update!")
......
......@@ -11,6 +11,7 @@ from settings import *
from static_data_process import *
from settings import *
from para_config import *
from equipment.truck import TruckInfo
M = 1000000
......@@ -22,7 +23,9 @@ class PathPlanner(WalkManage):
# 路段集合
self.lane_set = {}
# 车辆长度(暂)
self.truck_length = 113
self.truck = TruckInfo()
self.truck.update_truck_size()
self.truck_length = float(sum(self.truck.get_length().values())) / len(self.truck.get_length())
# 装载区数量
self.num_of_load_area = len(set(update_load_area()))
# 卸载区数量
......
......@@ -537,9 +537,12 @@ class Dispatcher(WalkManage):
# 卸载设备卸载时间
unloading_time = self.dump.get_unloading_time()
# 路网信息
walk_time_park_to_excavator = walk_manage.get_walk_time_park_to_excavator()
walk_time_to_dump = walk_manage.get_walk_time_to_dump()
walk_time_to_excavator = walk_manage.get_walk_time_to_excavator()
walk_time_park_to_excavator = walk_manage.get_walk_time_park_to_excavator() \
* (empty_speed / self.truck.empty_speed[truck_id])
walk_time_to_dump = walk_manage.get_walk_time_to_dump() * \
(heavy_speed / self.truck.heavy_speed[truck_id])
walk_time_to_excavator = walk_manage.get_walk_time_to_excavator() * \
(empty_speed / self.truck.empty_speed[truck_id])
# 出入场时间
loading_task_time = self.excavator.get_loading_task_time()
......
#!E:\Pycharm Projects\Waytous
# -*- coding: utf-8 -*-
# @Time : 2021/8/24 14:56
# @Author : Opfer
# @Site :
# @File : schedule_test.py
# @Software: PyCharm
import datetime
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.jobstores.memory import MemoryJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
def my_job(id='my_job'):
print(id, '-->', datetime.datetime.now())
jobstores = {'default': MemoryJobStore()}
executors = {'default': ThreadPoolExecutor(10)}
job_defaults = {'coalesce': False, 'max_instances': 10}
scheduler = BlockingScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults)
scheduler.add_job(my_job, args=['job_interval'], id='ins1', trigger='interval', seconds=5)
scheduler.add_job(my_job, args=['job_interval'], id='ins2', trigger='interval', seconds=5)
if __name__ == '__main__':
try:
scheduler.start()
except SystemExit:
print('exit')
exit()
\ No newline at end of file
......@@ -324,11 +324,17 @@ class EquipmentSpec(Base):
id = Column(VARCHAR(36), primary_key=True)
capacity = Column(Integer)
mining_abililty = Column(Float)
length = Column(Float)
width = Column(Float)
max_speed = Column(Float)
def __init__(self, id, capacity, mining_abililty):
def __init__(self, id, capacity, mining_abililty, length, width, max_speed):
self.id = id
self.capacity = capacity
self.mining_abililty = mining_abililty
self.length = length
self.width = width
self.max_speed = max_speed
class LoadInfo(Base):
__tablename__ = 'sys_loadinfo'
......@@ -393,6 +399,7 @@ class DumpArea(Base):
self.Disabled = Disabled
self.Material = Material
class DiggingWorkArea(Base):
__tablename__ = 'Geo_DiggingWorkArea'
......
This diff is collapsed.
......@@ -196,7 +196,7 @@ def traffic_flow_plan():
return res["var_x"], res["var_y"]
traffic_flow_plan()
# traffic_flow_plan()
# end = time.time()
# print("used {:.5}s".format(end-start))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment