Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-WIC-Opencpc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-WIC-Opencpc
Commits
9ffbf7e1
Commit
9ffbf7e1
authored
Apr 15, 2018
by
joliu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更名
parent
07d40328
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
99 deletions
+0
-99
hfv/process.py
hfv/process.py
+0
-99
No files found.
hfv/process.py
deleted
100644 → 0
View file @
07d40328
'''
*************************************************
* 任务流解析程序 *
* 程序说明: *
* 1. 输入任务流矩阵 *
* 1. 解析任务工作流 *
* *
* author: joliu<joliu@s-an.org> *
* date: 2018-4-13 *
*************************************************
'''
import
numpy
as
np
def
resolveMatrix
(
inputTask
,
inputTypeList
,
outputNode
,
inputDeviceData
):
'''
根据矩阵构建输入输出关系
inputTask: 输入矩阵;inputTypeList: 节点类型列表,指明各个节点的具体功能;outputNode: 输出节点;
inputDeviceData: 输入设备节点状态值
'''
nodeType
=
inputTypeList
[
outputNode
]
lastNode
=
np
.
where
((
inputTask
.
T
[
outputNode
]
==
1
))[
0
]
if
nodeType
==
0
:
output
=
resolveMatrix
(
inputTask
,
inputTypeList
,
lastNode
[
0
],
inputDeviceData
)
elif
nodeType
==
1
:
a
=
resolveMatrix
(
inputTask
,
inputTypeList
,
lastNode
[
0
],
inputDeviceData
)
b
=
resolveMatrix
(
inputTask
,
inputTypeList
,
lastNode
[
1
],
inputDeviceData
)
output
=
a
&
b
elif
nodeType
==
2
:
a
=
resolveMatrix
(
inputTask
,
inputTypeList
,
lastNode
[
0
],
inputDeviceData
)
b
=
resolveMatrix
(
inputTask
,
inputTypeList
,
lastNode
[
1
],
inputDeviceData
)
output
=
a
|
b
elif
nodeType
==
3
:
a
=
resolveMatrix
(
inputTask
,
inputTypeList
,
lastNode
[
0
],
inputDeviceData
)
output
=
not
a
elif
nodeType
==
4
:
output
=
inputDeviceData
[
outputNode
]
return
output
def
checkMatrix
(
inputTask
,
inputTypeList
):
# 测试矩阵是否符合要求
length
=
inputTask
.
shape
[
0
]
zeroList
=
np
.
zeros
(
length
)
outputNode
=
np
.
where
((
inputTask
==
zeroList
).
all
(
1
))[
0
]
if
outputNode
.
shape
[
0
]
!=
1
:
print
(
"输出节点不符合单输出要求"
)
exit
(
1
)
# 验证inputTypeList与inputTask矩阵是否匹配,主要验证输入与类型是否一致
for
i
in
range
(
length
):
countInput
=
np
.
sum
(
inputTask
.
T
[
i
]
==
1
)
if
inputTypeList
[
i
]
in
[
0
,
3
]:
if
countInput
==
1
:
continue
else
:
print
(
"请检查%d行"
%
i
)
return
False
elif
inputTypeList
[
i
]
in
[
1
,
2
]:
if
countInput
==
2
:
continue
else
:
print
(
"请检查%d行"
%
i
)
return
False
elif
inputTypeList
[
i
]
in
[
4
]:
if
countInput
==
0
:
continue
else
:
print
(
"请检查%d行"
%
i
)
return
False
return
True
if
__name__
==
"__main__"
:
# 测试程序
inputTask
=
np
.
array
([[
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
],
\
[
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
],
\
[
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
],
\
[
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
],
\
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
\
[
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
\
[
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
\
[
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
]])
inputTypeList
=
np
.
array
([
1
,
3
,
2
,
3
,
0
,
4
,
4
,
4
])
inputDeviceData
=
np
.
array
([
0
,
0
,
0
,
0
,
0
,
1
,
1
,
0
])
if
not
checkMatrix
(
inputTask
,
inputTypeList
):
exit
(
1
)
# 获取矩阵宽度
length
=
inputTask
.
shape
[
0
]
# 创建零向量
zeroList
=
np
.
zeros
(
length
)
# 获取输出节点,即行为零向量
outputNode
=
np
.
where
((
inputTask
==
zeroList
).
all
(
1
))[
0
]
# 获取输入节点,即列为零向量
inputNodes
=
np
.
where
((
inputTask
.
T
==
zeroList
).
all
(
1
))[
0
]
print
(
resolveMatrix
(
inputTask
,
inputTypeList
,
outputNode
[
0
],
inputDeviceData
))
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