Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
PNML Flattener
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DiNeROS
DiNeROS 1
PNML Flattener
Commits
fccee9c4
Commit
fccee9c4
authored
2 years ago
by
Sebastian Ebert
Browse files
Options
Downloads
Patches
Plain Diff
work on stateful node flattening
parent
5e46f24d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tudresden/inf/st/pnml/flatter/transform/ChannelFlatter.java
+61
-2
61 additions, 2 deletions
...dresden/inf/st/pnml/flatter/transform/ChannelFlatter.java
with
61 additions
and
2 deletions
src/main/java/de/tudresden/inf/st/pnml/flatter/transform/ChannelFlatter.java
+
61
−
2
View file @
fccee9c4
...
...
@@ -363,8 +363,13 @@ public class ChannelFlatter extends Flatter {
Set
<
OutputSignalPlace
>
topicInputPlaces
=
new
HashSet
<>();
System
.
out
.
println
(
"[FLATTER] Copying server net: "
+
serverSubnet
);
// TODO: get the directly connected elements
List
<
Tuple2
<
Node
,
Node
>>
externalElementsToReconnect
=
new
ArrayList
<>();
// true -> element is source
getDirectlyConnectedElements
(
petriNet
,
serverSubnet
,
externalElementsToReconnect
);
Pair
<
OutputSignalPlace
,
OutputSignalPlace
>
ioPlacePair
=
copyServerNet
(
petriNet
,
serverPlaces
,
serverTransitions
,
topicInputPlaces
,
serverInstanceCount
+
"-"
+
clientCount
,
serverSubnet
,
copiedObjects
);
serverInstanceCount
+
"-"
+
clientCount
,
serverSubnet
,
copiedObjects
,
externalElementsToReconnect
);
// new needed publisher nets (reason: publishers are potentially also cloned)
int
topicInputPlaceCount
=
0
;
...
...
@@ -561,9 +566,50 @@ public class ChannelFlatter extends Flatter {
return
petriNet
;
}
private
static
void
getDirectlyConnectedElements
(
PetriNet
petriNet
,
String
serverSubnet
,
List
<
Tuple2
<
Node
,
Node
>>
externalElementsToReconnect
)
{
for
(
Place
p
:
petriNet
.
allPlaces
()){
for
(
Arc
a
:
p
.
getInArcList
()){
if
(
a
.
getSource
().
asTransitionNode
().
asTransition
().
asInputSignalTransition
().
getStaticTransitionInformation
().
getSubNet
()
.
equals
(
serverSubnet
)
&&
!
p
.
asOutputSignalPlace
().
getStaticPlaceInformation
().
getSubNet
().
equals
(
serverSubnet
)){
externalElementsToReconnect
.
add
(
new
Tuple2
<>(
a
.
getSource
(),
p
));
break
;
}
}
for
(
Arc
a
:
p
.
getOutArcList
()){
if
(
a
.
getTarget
().
asTransitionNode
().
asTransition
().
asInputSignalTransition
().
getStaticTransitionInformation
().
getSubNet
()
.
equals
(
serverSubnet
)
&&
!
p
.
asOutputSignalPlace
().
getStaticPlaceInformation
().
getSubNet
().
equals
(
serverSubnet
)){
externalElementsToReconnect
.
add
(
new
Tuple2
<>(
p
,
a
.
getTarget
()));
break
;
}
}
}
for
(
Transition
t
:
petriNet
.
allTransitions
()){
for
(
Arc
a
:
t
.
getInArcList
()){
if
(
a
.
getSource
().
asPlaceNode
().
asPlace
().
asOutputSignalPlace
().
getStaticPlaceInformation
().
getSubNet
()
.
equals
(
serverSubnet
)
&&
!
t
.
asInputSignalTransition
().
getStaticTransitionInformation
().
getSubNet
().
equals
(
serverSubnet
)){
externalElementsToReconnect
.
add
(
new
Tuple2
<>(
a
.
getSource
(),
t
));
break
;
}
}
for
(
Arc
a
:
t
.
getOutArcList
()){
if
(
a
.
getTarget
().
asPlaceNode
().
asPlace
().
asOutputSignalPlace
().
getStaticPlaceInformation
().
getSubNet
()
.
equals
(
serverSubnet
)
&&
!
t
.
asInputSignalTransition
().
getStaticTransitionInformation
().
getSubNet
().
equals
(
serverSubnet
)){
externalElementsToReconnect
.
add
(
new
Tuple2
<>(
a
.
getSource
(),
t
));
break
;
}
}
}
}
private
static
Pair
<
OutputSignalPlace
,
OutputSignalPlace
>
copyServerNet
(
PetriNet
petriNet
,
Set
<
Place
>
serverPlaces
,
Set
<
Transition
>
serverTransitions
,
Set
<
OutputSignalPlace
>
topicInputPlaces
,
String
suffix
,
String
serverSubnet
,
Set
<
PnObject
>
copiedObjects
)
{
String
suffix
,
String
serverSubnet
,
Set
<
PnObject
>
copiedObjects
,
List
<
Tuple2
<
Node
,
Node
>>
externalElementsToReconnect
)
{
final
String
instanceId
=
"server-instance-"
+
UUID
.
randomUUID
().
toString
();
...
...
@@ -603,6 +649,19 @@ public class ChannelFlatter extends Flatter {
topPage
.
addObject
(
copy
);
addedPnObjects
.
add
(
copy
);
for
(
Tuple2
<
Node
,
Node
>
t
:
externalElementsToReconnect
){
if
(
p
.
getId
().
equals
(
t
.
get_1
().
getId
())){
createAndIncludeArc
(
topPage
,
"ext-"
+
t
.
get_1
().
getId
()
+
"-to-"
+
t
.
get_2
().
getId
(),
t
.
get_1
(),
p
);
}
if
(
p
.
getId
().
equals
(
t
.
get_2
().
getId
())){
createAndIncludeArc
(
topPage
,
"ext-"
+
t
.
get_2
().
getId
()
+
"-to-"
+
t
.
get_1
().
getId
(),
p
,
t
.
get_1
());
}
}
// todo: remove old arcs connecting external elements
for
(
Arc
a
:
p
.
getOutArcList
())
{
if
(!
a
.
getTarget
().
getSubnet
().
equals
(
serverSubnet
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment