Skip to content

Commit

Permalink
Move capacity declaration before marking
Browse files Browse the repository at this point in the history
  • Loading branch information
danilovesky committed May 1, 2024
1 parent e634a56 commit 1c56cc0
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ private static List<String> sort(Collection<String> refs) {
private static void writeMarking(PrintWriter out, PetriModel petri, Collection<? extends Place> places,
boolean needInstanceNumbers) {

StringBuilder capacity = new StringBuilder();
for (Place p : places) {
if (p.getCapacity() != 1) {
String placeRef = getReference(petri, p, needInstanceNumbers);
capacity.append(' ').append(placeRef).append('=').append(p.getCapacity());
}
}
if (!capacity.isEmpty()) {
out.write(KEYWORD_CAPACITY + capacity + '\n');
}

ArrayList<String> markingEntries = new ArrayList<>();
for (Place place : places) {
final String reference;
Expand Down Expand Up @@ -249,16 +260,6 @@ private static void writeMarking(PrintWriter out, PetriModel petri, Collection<?
out.write(m);
}
out.write("}\n");
StringBuilder capacity = new StringBuilder();
for (Place p : places) {
if (p.getCapacity() != 1) {
String placeRef = getReference(petri, p, needInstanceNumbers);
capacity.append(' ').append(placeRef).append('=').append(p.getCapacity());
}
}
if (capacity.length() > 0) {
out.write(KEYWORD_CAPACITY + capacity + '\n');
}
}

private static void writePetri(PrintWriter out, PetriModel petri) {
Expand Down

0 comments on commit 1c56cc0

Please sign in to comment.