Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling-v3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张晓彤
integrated-scheduling-v3
Commits
9b576902
Commit
9b576902
authored
May 11, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
启动异常检测&任务状态修正
parent
2cd49cca
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
199 deletions
+40
-199
config.json
config.json
+0
-6
dispatcher.py
dispatcher.py
+25
-20
truck.py
equipment/truck.py
+5
-5
group_control.py
group_control/group_control.py
+2
-2
path_plannner.py
path_plan/path_plannner.py
+4
-4
priority_control_2.py
path_plan/priority_control_2.py
+0
-158
realtime_dispatch.py
realtime_dispatch.py
+4
-4
No files found.
config.json
View file @
9b576902
{
"para"
:
{
<<<<<<<
HEAD
"log_path"
:
"E:
\\
Pycharm Projects
\\
Waytous
\\
"
,
"empty_speed"
:
25
,
"heavy_speed"
:
22
,
=======
"log_path"
:
"/usr/local/fleet-log/dispatch"
,
"empty_speed"
:
17
,
"heavy_speed"
:
17
,
>>>>>>>
new
"dump_target_mass"
:
5000
,
"excavator_target_mass"
:
5000
},
...
...
dispatcher.py
View file @
9b576902
...
...
@@ -347,7 +347,7 @@ class Dispatcher(WalkManage):
excavator_uuid_to_name_dict
=
get_value
(
"excavator_uuid_to_name_dict"
)
self
.
logger
.
info
(
f
"目的地:{excavator_uuid_to_name_dict[self.excavator.excavator_index_to_uuid_dict[target]]}"
)
if
task
in
[
0
,
1
,
2
]:
if
task
in
[
0
,
1
]:
# 矿卡空载行驶或正在入场
################################################ 矿卡空载 ###############################################
try
:
...
...
@@ -424,7 +424,7 @@ class Dispatcher(WalkManage):
dump_uuid_to_name_dict
=
get_value
(
"dump_uuid_to_name_dict"
)
self
.
logger
.
info
(
f
"目的地:{dump_uuid_to_name_dict[self.dump.dump_index_to_uuid_dict[target]]}"
)
elif
task
in
[
3
,
4
,
5
]:
elif
task
in
[
3
,
4
]:
# 卡车重载行驶或正在入场
################################################ 矿卡重载 ###############################################
try
:
...
...
@@ -618,11 +618,11 @@ class Dispatcher(WalkManage):
record
=
{
"truckId"
:
self
.
truck
.
truck_index_to_uuid_dict
[
i
]}
task
=
self
.
truck
.
get_truck_current_task
()[
self
.
truck
.
truck_index_to_uuid_dict
[
i
]]
except
Exception
as
es
:
self
.
logger
.
error
(
"
truck_id,group_id,record,task出错
"
)
self
.
logger
.
error
(
"
调度结果写入异常-读取矿卡信息异常(uuid, group id, task)
"
)
self
.
logger
.
error
(
es
)
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
,
2
]:
# 卡车空载或在装载区出场前, 可变更卸载目的地
try
:
item
=
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
DeviceMap
.
dump_index_to_uuid_dict
[
Seq
[
i
][
1
]],
...
...
@@ -642,7 +642,10 @@ class Dispatcher(WalkManage):
"
%
b
%
d,
%
Y
%
I:
%
M:
%
S
%
p"
)
redis5
.
set
(
self
.
truck
.
truck_index_to_uuid_dict
[
i
],
str
(
json
.
dumps
(
record
)))
elif
task
in
heavy_task_set
:
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡空载"
)
elif
task
in
[
3
,
4
,
5
]:
# 卡车重载或在卸载区出场前, 可变更装载目的地
try
:
item
=
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
DeviceMap
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]],
...
...
@@ -661,6 +664,8 @@ class Dispatcher(WalkManage):
"
%
b
%
d,
%
Y
%
I:
%
M:
%
S
%
p"
)
redis5
.
set
(
self
.
truck
.
truck_index_to_uuid_dict
[
i
],
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡重载"
)
elif
task
==
-
2
:
try
:
try
:
...
...
@@ -671,14 +676,14 @@ class Dispatcher(WalkManage):
group_id
=
group_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
())
print
(
Seq
)
print
(
Seq
[
i
][
1
])
print
(
DeviceMap
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]])
self
.
logger
.
info
(
Seq
)
self
.
logger
.
info
(
Seq
[
i
][
1
])
self
.
logger
.
info
(
DeviceMap
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]])
print
(
"item"
)
self
.
logger
.
info
(
"item"
)
print
(
item
.
id
,
item
.
truck_id
,
item
.
exactor_id
,
item
.
dump_id
)
except
Exception
as
es
:
self
.
logger
.
error
(
"
task-2,error01
"
)
self
.
logger
.
error
(
"
调度结果写入异常-矿卡故障或备停区-调度计划读取异常
"
)
try
:
record
[
"exactorId"
]
=
item
.
exactor_id
...
...
@@ -694,17 +699,17 @@ class Dispatcher(WalkManage):
redis5
.
set
(
self
.
truck
.
truck_index_to_uuid_dict
[
i
],
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"
task-2,error02
"
)
self
.
logger
.
error
(
"
调度结果写入异常-矿卡故障或备停区-redis写入异常
"
)
self
.
logger
.
error
(
es
)
except
Exception
as
es
:
self
.
logger
.
error
(
"
task为-2时error
"
)
self
.
logger
.
error
(
"
调度结果写入异常-矿卡故障或备停区
"
)
self
.
logger
.
error
(
es
)
else
:
pass
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常
-redis写入异常
"
)
self
.
logger
.
error
(
"调度结果写入异常"
)
self
.
logger
.
error
(
f
"调度结果:{Seq}"
)
self
.
logger
.
error
(
es
)
...
...
@@ -775,19 +780,19 @@ class PreSchedule:
excavator_avl_ls
=
[[]
for
_
in
range
(
dynamic_excavator_num
)]
dump_avl_ls
=
[[]
for
_
in
range
(
dumps
)]
self
.
logger
.
info
(
"update_truck_reach_time-trucks"
)
self
.
logger
.
info
(
trucks
)
#
self.logger.info("update_truck_reach_time-trucks")
#
self.logger.info(trucks)
for
i
in
range
(
trucks
):
task
=
truck_current_task
[
self
.
truck
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
truck_current_trip
[
i
][
1
]
self
.
logger
.
info
(
"update_truck_reach_time-truck_current_trip"
)
self
.
logger
.
info
(
truck_current_trip
)
if
task
in
[
0
,
1
]:
#
self.logger.info("update_truck_reach_time-truck_current_trip")
#
self.logger.info(truck_current_trip)
if
task
in
[
0
,
1
]:
# 卡车空载行驶或正在入场
reach_time
=
truck_reach_excavator
[
i
]
excavator_avl_ls
[
end_area_index
]
.
append
(
[
reach_time
,
i
,
end_area_index
]
)
elif
task
in
[
3
,
4
]:
elif
task
in
[
3
,
4
]:
# 卡车重载行驶或正在入场
reach_time
=
truck_reach_dump
[
i
]
dump_avl_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
elif
task
==
-
2
:
...
...
equipment/truck.py
View file @
9b576902
...
...
@@ -183,7 +183,7 @@ class TruckInfo(WalkManage):
# 判断是否为矿卡
if
device_type
==
1
:
task
=
self
.
truck_current_task
[
item
]
if
task
in
heavy_task_set
:
if
task
in
[
3
,
4
,
5
]:
# 矿卡重载行驶或仍未出场
if
str_to_byte
(
"lastLoadTime"
)
in
key_value_dict
.
keys
():
# 若最后装载时间存在
last_load_time_tmp
=
eval
(
byte_to_str
(
key_value_dict
[
str_to_byte
(
"lastLoadTime"
)]))
tmp_time
=
datetime
.
strptime
(
last_load_time_tmp
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
...
...
@@ -206,7 +206,7 @@ class TruckInfo(WalkManage):
# print("相对last_load_time", self.relative_last_load_time[item])
self
.
logger
.
info
(
"相对last_load_time"
)
self
.
logger
.
info
(
self
.
relative_last_load_time
[
item
])
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
,
2
]:
# 矿卡空载行驶或仍未出场
if
str_to_byte
(
"lastUnloadTime"
)
in
key_value_dict
.
keys
():
last_unload_time_tmp
=
eval
(
key_value_dict
[
str_to_byte
(
"lastUnloadTime"
)])
tmp_time
=
datetime
.
strptime
(
last_unload_time_tmp
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
...
...
@@ -277,7 +277,7 @@ class TruckInfo(WalkManage):
try
:
# 若矿卡状态为空运
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
,
2
]:
# 矿卡空载或仍未出装载区
last_unload_time
=
self
.
relative_last_unload_time
[
self
.
truck_index_to_uuid_dict
[
i
]
]
...
...
@@ -312,7 +312,7 @@ class TruckInfo(WalkManage):
# # 目的地矿卡数加一
# self.excavator_hold_truck_num[end_eqp_index] = self.excavator_hold_truck_num[end_eqp_index] + 1
# 若矿卡状态为重载
elif
task
in
heavy_task_set
:
elif
task
in
[
3
,
4
,
5
]:
# 矿卡重载或仍未出卸载区
# print("读取重载行程")
# print(item.exactor_id, item.dump_id)
last_load_time
=
self
.
relative_last_load_time
[
...
...
@@ -383,7 +383,7 @@ class TruckInfo(WalkManage):
.
filter_by
(
truck_id
=
truck_id
,
isdeleted
=
0
)
.
first
()
)
if
task
in
empty_task_set
+
heavy_task_set
and
item
is
None
:
if
task
in
empty_task_set
+
heavy_task_set
and
item
is
None
:
# 矿卡处于正常工作状态, 但查询不到派车计划
raise
Exception
(
f
"矿卡 {truck_id} 配对关系异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
"配对关系异常"
)
...
...
group_control/group_control.py
View file @
9b576902
...
...
@@ -119,11 +119,11 @@ class Group(WalkManage):
end_area_index
=
truck_current_trip
[
i
][
1
]
start_area_index
=
truck_current_trip
[
i
][
0
]
if
task
in
heavy_task_set
:
if
task
in
[
3
,
4
]:
# 矿卡空载或正在入场装载区
self
.
goto_dump_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
actual_goto_dump_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
]:
# 矿卡重载或正在入场卸载区
self
.
goto_excavator_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
actual_goto_excavator_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
...
...
path_plan/path_plannner.py
View file @
9b576902
...
...
@@ -349,7 +349,7 @@ class LaneInfo:
# used lane, 存在行驶矿卡的路段
tmp_lane_set
=
[]
#
try:
try
:
# 初始化
for
lane_id
in
lane_set
:
self
.
lane_speed_dict
[
str
(
lane_id
)]
=
0
...
...
@@ -385,9 +385,9 @@ class LaneInfo:
for
lane
in
lane_trucks_dict
:
self
.
lane_speed_dict
[
lane
]
=
self
.
lane_speed_dict
[
lane
]
/
lane_trucks_dict
[
lane
]
#
except Exception as es:
#
logger.error("路段实时速度计算异常")
#
logger.error(es)
except
Exception
as
es
:
logger
.
error
(
"路段实时速度计算异常"
)
logger
.
error
(
es
)
return
self
.
lane_speed_dict
...
...
path_plan/priority_control_2.py
deleted
100644 → 0
View file @
2cd49cca
#!E:\Pycharm Projects\Waytous
# -*- coding: utf-8 -*-
# @Time : 2021/9/3 14:44
# @Author : Opfer
# @Site :
# @File : priority_control.py
# @Software: PyCharm
from
equipment.truck
import
*
from
equipment.dump
import
*
from
equipment.excavator
import
*
from
para_config
import
*
from
path_plan.topo_graph
import
*
class
PriorityController
():
def
__init__
(
self
,
dump
,
excavator
,
truck
):
# 设备类
self
.
dump
=
dump
self
.
excavator
=
excavator
self
.
truck
=
truck
# 获取日志器
self
.
logger
=
get_logger
(
"zxt.prio"
)
def
weighted_walk_calc
(
self
):
"""
计算运输路线权重, 权重影响因素:设备优先级, 物料优先级,
:return:
walk_weight: 卸载-装载区 路网权重
park_walk_weight: 备停区-装载区 路网权重
"""
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
walk_to_excavator_weight
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
walk_to_dump_weight
=
np
.
ones
((
dynamic_excavator_num
,
dynamic_dump_num
))
excavator_priority
=
self
.
excavator
.
excavator_priority_coefficient
excavator_material_priority
=
self
.
excavator
.
excavator_material_priority
dump_priority
=
self
.
dump
.
dump_priority_coefficient
dump_material_priority
=
np
.
ones
(
dynamic_dump_num
)
park_walk_weight
=
np
.
ones
((
park_num
,
dynamic_excavator_num
))
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
if
not
rule6
.
disabled
:
for
dump_id
in
dynamic_dump_set
:
for
excavator_id
in
dynamic_excavator_set
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_inedx
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_to_excavator_weight
[
dump_index
][
excavator_inedx
]
+=
excavator_priority
[
excavator_inedx
]
walk_to_dump_weight
[
excavator_inedx
][
dump_index
]
+=
dump_priority
[
dump_index
]
park_walk_weight
=
park_walk_weight
*
self
.
excavator
.
excavator_priority_coefficient
rule7
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
7
)
.
first
()
if
not
rule7
.
disabled
:
for
dump_id
in
dynamic_dump_set
:
for
excavator_id
in
dynamic_excavator_set
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_inedx
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_to_excavator_weight
[
dump_index
][
excavator_inedx
]
+=
excavator_material_priority
[
excavator_inedx
]
walk_to_dump_weight
[
excavator_inedx
][
dump_index
]
+=
dump_material_priority
[
dump_index
]
park_walk_weight
=
park_walk_weight
*
self
.
excavator
.
excavator_material_priority
try
:
walk_to_excavator_weight
=
walk_to_excavator_weight
-
(
walk_to_excavator_weight
.
min
()
-
1
)
walk_to_dump_weight
=
walk_to_dump_weight
-
(
walk_to_dump_weight
.
min
()
-
1
)
park_walk_weight
=
park_walk_weight
-
(
park_walk_weight
.
min
()
-
1
)
except
Exception
as
es
:
self
.
logger
.
errro
(
es
)
self
.
logger
.
error
(
"优先级归一化异常"
)
return
walk_to_excavator_weight
,
walk_to_dump_weight
,
park_walk_weight
def
walk_available_calc
(
self
):
"""
计算路网可通行性(物料, 地图, 分组三者综合)
:return:
walk_available: 路网可通行性(dump_num, excavator_num)
"""
map_walk_available
=
self
.
update_map_walk_available
()
group_walk_available
=
self
.
update_group_walk_available
()
material_walk_available
=
self
.
update_material_walk_available
()
walk_available
=
map_walk_available
*
group_walk_available
*
material_walk_available
return
walk_available
def
update_group_walk_available
(
self
):
"""
计算调度分组间的路网可通行性, 不同分组间路网不可通行
:return:
group_walk_available: 调度分组路网可通行性矩阵(dump_num, excavator_num)
"""
group_walk_available
=
np
.
zeros
((
get_value
(
"dynamic_dump_num"
),
get_value
(
"dynamic_excavator_num"
)))
for
dump_id
in
get_value
(
"dynamic_dump_set"
):
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
):
item
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
exactor_id
=
excavator_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
if
item
is
not
None
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_index
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
group_walk_available
[
dump_index
][
excavator_index
]
=
1
return
group_walk_available
def
update_material_walk_available
(
self
):
"""
更新物料兼容性下路网可通行性
:return:
walk_available: 物料兼容路网可通行性矩阵(dump_num, excavator_num)
"""
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
walk_available
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
try
:
for
dump_id
in
dynamic_dump_set
:
for
excavator_id
in
dynamic_excavator_set
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_inedx
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
# 两设备处理物料不同, 相关路网不可通行
if
self
.
excavator
.
excavator_material
[
excavator_id
]
!=
self
.
dump
.
dump_material
[
dump_id
]:
walk_available
[
dump_index
][
excavator_inedx
]
=
0
except
Exception
as
es
:
self
.
logger
.
info
(
es
)
self
.
logger
.
info
(
"error-12"
)
return
walk_available
def
update_map_walk_available
(
self
):
"""
更新物理路网可通行性
:return:
walk_available: 物理路网可通行性矩阵(dump_num, excavator_num)
"""
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
walk_available
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
walk_manage
.
period_walk_para_update
()
for
dump_index
in
range
(
dynamic_dump_num
):
for
excavator_index
in
range
(
dynamic_excavator_num
):
if
walk_manage
.
distance_to_excavator
[
dump_index
][
excavator_index
]
>
M
/
2
:
walk_available
[
dump_index
][
excavator_index
]
=
0
return
walk_available
realtime_dispatch.py
View file @
9b576902
...
...
@@ -19,7 +19,7 @@ from dispatcher import Dispatcher, PreSchedule
def
process
(
dispatcher
):
#
try:
try
:
# 更新周期参数
logger
.
info
(
"#####################################周期更新开始#####################################"
)
...
...
@@ -52,9 +52,9 @@ def process(dispatcher):
logger
.
info
(
"#####################################周期更新结束#####################################"
)
#
except Exception as es:
#
logger.error("最外层异常捕获")
#
logger.error(es)
except
Exception
as
es
:
logger
.
error
(
"最外层异常捕获"
)
logger
.
error
(
es
)
def
perform
(
inc
,
dispatcher
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment