Esempio n. 1
0
 public List<Place> getMarkedPlaces() {
   List<Place> places = new ArrayList<Place>();
   for (Place p : net.getPlaces()) {
     if (getNumTokens(p) > 0) places.add(p);
   }
   return places;
 }
Esempio n. 2
0
 protected boolean hasTokenOnIntermediatePlace() {
   for (Place place : net.getPlaces()) {
     if (!place.isFinalPlace() && this.getNumTokens(place) > 0) {
       return true;
     }
   }
   return false;
 }
Esempio n. 3
0
  protected boolean hasOneTokenOnFinalPlace() {
    for (Place place : net.getPlaces()) {
      if (place.isFinalPlace() && this.getNumTokens(place) == 1) {
        return true;
      }
    }

    return false;
  }
Esempio n. 4
0
  public JSONObject toJson() throws JSONException {
    JSONObject marking = new JSONObject();

    for (Place place : net.getPlaces()) {
      marking.put(place.getResourceId(), this.getNumTokens(place));
    }

    return marking;
  }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 public Place findUnsafePlace() {
   for (Place p : net.getPlaces()) {
     if (getNumTokens(p) > 1) return p;
   }
   return null;
 }