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
62c4edc6
Commit
62c4edc6
authored
Mar 23, 2023
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化穿越装载区调度,优化二次调度触发机制
parent
97c4b861
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
70 additions
and
45 deletions
+70
-45
app.py
app.py
+0
-0
config.json
config.json
+8
-6
group.py
core/group.py
+0
-0
util.py
core/util.py
+9
-3
truck.py
equipment/truck.py
+35
-24
realtime_dispatch_test.py
realtime_dispatch_test.py
+1
-1
settings.py
settings.py
+4
-4
start.sh
start.sh
+3
-2
tables.py
tables.py
+2
-2
area_analysis.py
util/area_analysis.py
+0
-0
core_exception.py
util/core_exception.py
+8
-3
调度系统部署说明4.2.docx
调度系统部署说明4.2.docx
+0
-0
No files found.
app.py
View file @
62c4edc6
This diff is collapsed.
Click to expand it.
config.json
View file @
62c4edc6
...
...
@@ -6,25 +6,26 @@
"dump_target_mass"
:
5000
,
"excavator_target_mass"
:
5000
},
"mysql"
:
{
"host"
:
"172.16.0.
103
"
,
"host"
:
"172.16.0.
51
"
,
"port"
:
"3306"
,
"user"
:
"root"
,
"password"
:
"Huituo@123"
,
"database"
:
"ht_zhunneng"
},
"postgresql"
:
{
"host"
:
"172.16.0.
103
"
,
"host"
:
"172.16.0.
51
"
,
"port"
:
"5432"
,
"user"
:
"postgres"
,
"password"
:
"Huituo@123"
,
"database"
:
"gis_zhunneng"
},
"redis"
:
{
"host"
:
"172.16.0.
103
"
,
"host"
:
"172.16.0.
51
"
,
"password"
:
"Huituo@123"
},
"gothrough"
:
{
"closer_area_name"
:
"哈1010平盘"
,
"further_area_name"
:
"哈1026平盘"
}
}
\ No newline at end of file
core/group.py
View file @
62c4edc6
This diff is collapsed.
Click to expand it.
core/util.py
View file @
62c4edc6
...
...
@@ -8,7 +8,7 @@
import
requests
from
tables
import
*
with
open
(
json_file
)
as
f
:
with
open
(
json_file
,
encoding
=
'UTF-8'
)
as
f
:
mysql_config
=
json
.
load
(
f
)[
"mysql"
]
...
...
@@ -50,13 +50,19 @@ with open(json_file) as f:
def
get_cross_next_lanes
(
truck_locate
):
"""
获取当前车辆所在路段(交叉口),的子孙(后续两个)节点
:param truck_locate:
:return: lane_id list
"""
next_lane_list
=
[]
startNodeId
=
session_postgre
.
query
(
Lane
)
.
filter_by
(
Id
=
truck_locate
)
.
first
()
.
EndNodeId
for
item
in
session_postgre
.
query
(
Lane
)
.
filter_by
(
StartNodeId
=
startNodeId
)
.
all
():
next_lane_list
.
append
(
str
(
item
.
Id
))
next_lane_end_node
=
item
.
EndNodeId
for
next_item
in
session_postgre
.
query
(
Lane
)
.
filter_by
(
StartNodeId
=
next_lane_end_node
)
.
all
():
next_lane_list
.
append
(
str
(
next_item
.
Id
))
if
item
.
Length
<
100
:
for
next_item
in
session_postgre
.
query
(
Lane
)
.
filter_by
(
StartNodeId
=
next_lane_end_node
)
.
all
():
next_lane_list
.
append
(
str
(
next_item
.
Id
))
print
(
"next_lane_list"
)
print
(
next_lane_list
)
return
next_lane_list
...
...
equipment/truck.py
View file @
62c4edc6
...
...
@@ -8,6 +8,7 @@
from
data.para_config
import
*
from
typing
import
List
from
util.core_exception
import
CoreException
# 矿卡设备类
...
...
@@ -136,6 +137,7 @@ class TruckInfo(WalkManage):
################################################ short term update ################################################
# TODO: 应该一次读取形成一个对象,然后分配各属性
# 更新矿卡当前任务
def
update_truck_current_task
(
self
):
self
.
truck_current_task
=
{}
...
...
@@ -145,27 +147,30 @@ class TruckInfo(WalkManage):
truck_name_to_uuid_dict
=
get_value
(
"truck_name_to_uuid_dict"
)
for
item
in
device_name_set
:
# try:
item
=
item
.
decode
(
encoding
=
"utf-8"
)
key_value_dict
=
redis2
.
hgetall
(
item
)
# reids str可以自动转为bytes
if
str_to_byte
(
"type"
)
in
key_value_dict
:
device_type
=
int
(
key_value_dict
[
str_to_byte
(
"type"
)])
else
:
continue
if
device_type
==
1
:
if
truck_name_to_uuid_dict
[
item
]
in
self
.
dynamic_truck_set
:
# currentTask = int(key_value_dict[str_to_byte("currentTask")])
currentTask
=
int
(
byte_to_str
(
key_value_dict
[
str_to_byte
(
"currentTask"
)]))
self
.
truck_current_task
[
truck_name_to_uuid_dict
[
item
]
]
=
currentTask
currentState
=
int
(
float
(
byte_to_str
(
key_value_dict
[
str_to_byte
(
"state"
)])))
self
.
truck_current_state
[
truck_name_to_uuid_dict
[
item
]
]
=
currentState
# except Exception as es:
# self.logger.error("读取矿卡任务异常-reids读取异常")
# self.logger.error(es)
try
:
item
=
item
.
decode
(
encoding
=
"utf-8"
)
key_value_dict
=
redis2
.
hgetall
(
item
)
# reids str可以自动转为bytes
if
str_to_byte
(
"type"
)
in
key_value_dict
:
device_type
=
int
(
key_value_dict
[
str_to_byte
(
"type"
)])
else
:
continue
if
device_type
==
1
:
if
item
not
in
truck_name_to_uuid_dict
:
raise
CoreException
(
107
,
f
'车辆{item}不存在于truck_name_to_uuid_dict'
)
if
truck_name_to_uuid_dict
[
item
]
in
self
.
dynamic_truck_set
:
# currentTask = int(key_value_dict[str_to_byte("currentTask")])
currentTask
=
int
(
byte_to_str
(
key_value_dict
[
str_to_byte
(
"currentTask"
)]))
self
.
truck_current_task
[
truck_name_to_uuid_dict
[
item
]
]
=
currentTask
currentState
=
int
(
float
(
byte_to_str
(
key_value_dict
[
str_to_byte
(
"state"
)])))
self
.
truck_current_state
[
truck_name_to_uuid_dict
[
item
]
]
=
currentState
except
Exception
as
es
:
self
.
logger
.
warning
(
"读取矿卡任务异常-reids读取异常"
)
self
.
logger
.
warning
(
es
)
self
.
logger
.
info
(
"矿卡当前任务:"
)
self
.
logger
.
info
(
self
.
truck_current_task
)
...
...
@@ -208,10 +213,16 @@ class TruckInfo(WalkManage):
if
item
not
in
truck_name_to_uuid_dict
:
continue
key_value_dict
=
byte_to_str
(
redis5
.
get
(
truck_name_to_uuid_dict
[
item
]))
# reids str可以自动转为bytes
if
item
not
in
truck_name_to_uuid_dict
:
raise
CoreException
(
107
,
f
'车辆{item}不存在于truck_name_to_uuid_dict'
)
key_value_dict
=
redis5
.
get
(
truck_name_to_uuid_dict
[
item
])
# reids str可以自动转为bytes
if
key_value_dict
is
None
:
raise
CoreException
(
108
,
f
'车辆{item}不存在于redis5'
)
key_value_dict
=
json
.
loads
(
byte_to_str
(
key_value_dict
))
print
(
key_value_dict
)
key_value_dict
=
json
.
loads
(
key_value_dict
)
if
truck_name_to_uuid_dict
[
item
]
in
self
.
dynamic_truck_set
:
try
:
isTemp
=
key_value_dict
[
"isTemp"
]
...
...
realtime_dispatch_test.py
View file @
62c4edc6
...
...
@@ -188,4 +188,4 @@ if __name__ == "__main__":
logger
.
info
(
" "
)
logger
.
info
(
"调度系统启动"
)
main
(
3
0
,
dispatcher
)
main
(
2
0
,
dispatcher
)
settings.py
View file @
62c4edc6
...
...
@@ -23,16 +23,16 @@ global redispatch_active
json_file
=
"config.json"
with
open
(
json_file
)
as
f
:
with
open
(
json_file
,
encoding
=
'UTF-8'
)
as
f
:
para_config
=
json
.
load
(
f
)[
"para"
]
with
open
(
json_file
)
as
f
:
with
open
(
json_file
,
encoding
=
'UTF-8'
)
as
f
:
mysql_config
=
json
.
load
(
f
)[
"mysql"
]
with
open
(
json_file
)
as
f
:
with
open
(
json_file
,
encoding
=
'UTF-8'
)
as
f
:
postgre_config
=
json
.
load
(
f
)[
"postgresql"
]
with
open
(
json_file
)
as
f
:
with
open
(
json_file
,
encoding
=
'UTF-8'
)
as
f
:
redis_config
=
json
.
load
(
f
)[
"redis"
]
# 全局参数
...
...
start.sh
View file @
62c4edc6
...
...
@@ -2,4 +2,5 @@
ps
-ef
|grep realtime_dispatch.py|grep
-v
grep
|awk
{
'print $2'
}
kill
-9
ps
python3 topo_update_server.py
nohup
python3 realtime_dispatch.py
--active
>
/dev/null 2>&1 &
\ No newline at end of file
nohup
python3 realtime_dispatch.py
--active
>
/dev/null 2>&1 &
nohup
flask run
--host
=
0.0.0.0
>
/dev/null 2>&1 &
\ No newline at end of file
tables.py
View file @
62c4edc6
...
...
@@ -21,8 +21,8 @@ relative_path = os.path.dirname(os.path.abspath(__file__)) # 获取当前文件
json_file
=
os
.
path
.
join
(
relative_path
,
"config.json"
)
# json_file = "config.json"
with
open
(
json_file
)
as
f
:
load_vale
=
json
.
load
(
f
)
with
open
(
json_file
,
encoding
=
'UTF-8'
)
as
f
:
load_vale
=
json
.
load
(
f
,
encoding
=
'UTF-8'
)
postgre_config
=
load_vale
[
"postgresql"
]
...
...
util/area_analysis.py
0 → 100644
View file @
62c4edc6
This diff is collapsed.
Click to expand it.
util/core_exception.py
View file @
62c4edc6
...
...
@@ -13,20 +13,25 @@ code_msg = {101: "调度失败",
103
:
"数组越界异常"
,
104
:
"数组维度不一致"
,
105
:
"数组越界"
,
106
:
"挖机不存在或信息缺失"
}
106
:
"挖机不存在或信息缺失"
,
107
:
"redis2设备信息与数据库不一致"
,
108
:
"redis5调度信息为空"
,
109
:
"配置信息不完整"
,
110
:
"车辆行程信息异常"
,
111
:
"挖机不存在或信息确实"
}
class
CoreException
(
Exception
):
""" class for my exception."""
def
__init__
(
self
,
Code
:
int
=
None
,
ErrorInfo
:
str
=
None
):
def
__init__
(
self
,
Code
:
int
=
101
,
ErrorInfo
:
str
=
None
):
super
()
.
__init__
(
self
,
ErrorInfo
)
self
.
__error_info
=
ErrorInfo
self
.
code
=
Code
self
.
__traceback
=
""
def
__str__
(
self
)
->
str
:
return
'{0:}-{1:}
\n
{2:}'
.
format
(
code_msg
[
self
.
code
],
self
.
__error_info
,
self
.
__traceback
)
return
'{0:}-{1:} {2:}'
.
format
(
code_msg
[
self
.
code
],
self
.
__error_info
,
self
.
__traceback
)
# def with_traceback(self, tb) -> BaseException:
# self.__traceback = tb
...
...
调度系统部署说明4.2.docx
View file @
62c4edc6
No preview for this file type
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