public boolean isPredecessor(int id) {
   for (LinkedList<SeqCond> linkedList : sequenceCondition) {
     for (SeqCond sc : linkedList) {
       if (sc.isOperationCheck() && sc.id == id && sc.state == 2) return true;
     }
   }
   return false;
 }
  public Set<Integer> getPreCondOperations() {
    HashSet<Integer> ids = new HashSet<Integer>();

    for (LinkedList<SeqCond> preCond : this.sequenceCondition) {
      for (SeqCond s : preCond) {
        if (s.isOperationCheck()) ids.add(s.id);
      }
    }
    return ids;
  }
 /**
  * Checks if this operation is relating to the the state (init=0, exe=1, fin=2) of the operation
  * with id == id.
  *
  * @param id The id of the other operation
  * @return True if this operation is relating to the execute state of the other op.
  */
 public boolean isRelatingToState(int id, int state) {
   for (LinkedList<SeqCond> linkedList : sequenceCondition) {
     for (SeqCond sc : linkedList) {
       if (sc.isOperationCheck() && sc.id == id && sc.state == state) return true;
     }
   }
   for (LinkedList<SeqCond> linkedList : pSequenceCondition) {
     for (SeqCond sc : linkedList) {
       if (sc.isOperationCheck() && sc.id == id && sc.state == state) return true;
     }
   }
   return false;
 }
  protected LinkedList<LinkedList<SeqCond>> cloneSequenceConditions(
      LinkedList<LinkedList<SeqCond>> seq) {
    LinkedList<LinkedList<SeqCond>> tempSeq = new LinkedList<LinkedList<SeqCond>>();
    for (LinkedList<SeqCond> linkedList : seq) {
      LinkedList<SeqCond> l = new LinkedList<SeqCond>();
      for (SeqCond seqCond : linkedList) {
        l.add((SeqCond) seqCond.clone());
      }
      tempSeq.add(l);
    }

    return tempSeq;
  }
 public LinkedList<LinkedList<Integer>> getPredecessors() {
   LinkedList<LinkedList<Integer>> result = new LinkedList<LinkedList<Integer>>();
   for (LinkedList<SeqCond> linkedList : sequenceCondition) {
     LinkedList<Integer> orPred = new LinkedList<Integer>();
     for (SeqCond sc : linkedList) {
       if (sc.isOperationCheck() && sc.state == 2) {
         orPred.add(sc.id);
       }
     }
     if (!orPred.isEmpty()) result.add(orPred);
   }
   return result;
 }
 public boolean isPredecessorsOR(int id, int id2) {
   for (LinkedList<SeqCond> linkedList : sequenceCondition) {
     boolean foundID = false, foundID2 = false;
     for (SeqCond sc : linkedList) {
       foundID = (sc.isOperationCheck() && sc.id == id && sc.state == 2) ? true : foundID;
       foundID2 = (sc.isOperationCheck() && sc.id == id2 && sc.state == 2) ? true : foundID2;
     }
     if (foundID && foundID2) {
       return true;
     }
   }
   return false;
 }
    @Override
    public boolean equals(Object obj) {
      if (obj instanceof SeqCond) {
        SeqCond t = (SeqCond) obj;

        if (t.id == id && t.state == state) {

          if ((isVariableCheck() && t.isVariableCheck() && value == t.value)
              || (isOperationCheck() && t.isOperationCheck())) {
            return true;
          }
        }
      }
      return false;
    }
  /** Returns a Set of id of the variables used as guards in the postcondition */
  public Set<Integer> getPostCondVariableGuards() {
    HashSet<Integer> ids = new HashSet<Integer>();

    for (LinkedList<SeqCond> preCond : this.pSequenceCondition) {
      for (SeqCond s : preCond) {
        if (s.isVariableCheck()) ids.add(s.id);
      }
    }

    for (Integer[] id : this.pResourceBooking) {
      ids.add(id[0]);
    }

    return ids;
  }
  /** Returns a Set of id of the variables used as guards in the precondition */
  public Set<Integer> getPreCondVariableGuards() {
    HashSet<Integer> ids = new HashSet<Integer>();

    for (LinkedList<SeqCond> preCond : this.sequenceCondition) {
      for (SeqCond s : preCond) {
        if (s.isVariableCheck()) ids.add(s.id);
      }
    }

    // The Integer[] stores the resource booking in the form
    // id[0] stores id, id[1] = 1 booking resource, id[1]=0 unbooking
    // Observe that these variables are both guards and actions!
    for (Integer[] id : this.resourceBooking) {
      ids.add(id[0]);
    }

    return ids;
  }
示例#10
0
 public boolean isPredecessorsAND(int id, int id2) {
   boolean foundID = false, foundID2 = false;
   for (LinkedList<SeqCond> linkedList : sequenceCondition) {
     for (SeqCond sc : linkedList) {
       if (sc.isOperationCheck() && sc.id == id && sc.state == 2) {
         foundID = true;
         break;
       } else if (sc.isOperationCheck() && sc.id == id2 && sc.state == 2) {
         foundID2 = true;
         break;
       }
     }
   }
   if (foundID && foundID2) {
     return true;
   } else {
     return false;
   }
 }
示例#11
0
  public String getRawOr(LinkedList<SeqCond> s) {
    String out = "";

    if (s.size() == 1) {
      SeqCond seqCond = s.getFirst();

      if (seqCond.isOperationCheck()) {
        out += Integer.toString(seqCond.id) + Model.getOperationEnding(seqCond.state);
      } else if (seqCond.isVariableCheck()) {
        out +=
            Integer.toString(seqCond.id)
                + Model.getVariabelCheck(seqCond.state)
                + Integer.toString(seqCond.value);
      }

    } else if (s.size() > 1) {
      out += "(";
      for (Iterator<SeqCond> it = s.iterator(); it.hasNext(); ) {
        SeqCond seqCond = it.next();

        if (seqCond.isOperationCheck()) {
          out += Integer.toString(seqCond.id) + Model.getOperationEnding(seqCond.state);
        } else if (seqCond.isVariableCheck()) {
          out +=
              Integer.toString(seqCond.id)
                  + Model.getVariabelCheck(seqCond.state)
                  + Integer.toString(seqCond.value);
        }

        out = it.hasNext() ? out + EFAVariables.SP_OR : out;
      }
      out += ")";
    }

    return out;
  }