public List<Place> getMarkedPlaces() { List<Place> places = new ArrayList<Place>(); for (Place p : net.getPlaces()) { if (getNumTokens(p) > 0) places.add(p); } return places; }
protected boolean hasTokenOnIntermediatePlace() { for (Place place : net.getPlaces()) { if (!place.isFinalPlace() && this.getNumTokens(place) > 0) { return true; } } return false; }
protected boolean hasOneTokenOnFinalPlace() { for (Place place : net.getPlaces()) { if (place.isFinalPlace() && this.getNumTokens(place) == 1) { return true; } } return false; }
public JSONObject toJson() throws JSONException { JSONObject marking = new JSONObject(); for (Place place : net.getPlaces()) { marking.put(place.getResourceId(), this.getNumTokens(place)); } return marking; }
public String toString() { if (markingStr == null) { StringBuilder str = new StringBuilder(); str.append("{"); boolean firstEntry = true; for (Place p : net.getPlaces()) { int numt = getNumTokens(p); if (numt > 0) { if (firstEntry) firstEntry = false; else str.append(","); str.append(p.getId()); if (numt > 1) str.append(":").append(numt); } } str.append("}"); markingStr = str.toString(); } return markingStr; }
public List<Transition> getEnabledTransitions() { return net.getInterpreter().getEnabledTransitions(net, this); }
public Place findUnsafePlace() { for (Place p : net.getPlaces()) { if (getNumTokens(p) > 1) return p; } return null; }