示例#1
0
 @SuppressWarnings("unused")
 private PlaceToTransition lookupArc(CustomedPlace place, CustomedTransition transition) {
   if (null == pTNetMem) return null;
   else
     return pTNetMem.pttList.get(
         String.valueOf(place.getId()) + "," + String.valueOf(transition.getId()));
 }
示例#2
0
 @SuppressWarnings("unused")
 private void addArc(CustomedTransition t, CustomedPlace p) {
   TransitionToPlace arc = new TransitionToPlace();
   arc.p = p;
   arc.t = t;
   this.ttpList.put(String.valueOf(t.getId()) + "," + String.valueOf(p.getId()), arc);
 }
示例#3
0
 @SuppressWarnings("unused")
 private void addArc(CustomedPlace p, CustomedTransition t) {
   PlaceToTransition arc = new PlaceToTransition();
   arc.p = p;
   arc.t = t;
   this.pttList.put(String.valueOf(p.getId()) + "," + String.valueOf(t.getId()), arc);
 }
示例#4
0
 private void addArc(CustomedTransition t, CustomedPlace p, CustomedCondition c) {
   TransitionToPlace arc = new TransitionToPlace();
   arc.con = c;
   arc.p = p;
   arc.t = t;
   p.addInArc(arc);
   this.ttpList.put(String.valueOf(t.getId()) + "," + String.valueOf(p.getId()), arc);
 }
示例#5
0
 private void addArc(CustomedPlace p, CustomedTransition t, CustomedCondition c) {
   PlaceToTransition arc = new PlaceToTransition();
   arc.p = p;
   arc.t = t;
   arc.con = c;
   this.pttList.put(String.valueOf(p.getId()) + "," + String.valueOf(t.getId()), arc);
   p.addOutArc(arc);
 }
示例#6
0
    private boolean scan() {
      boolean has = false;
      Set<Integer> tSet = this.ftList.keySet();
      for (Iterator<Integer> it = tSet.iterator(); it.hasNext(); ) {
        Integer id = (Integer) it.next();
        CustomedTransition ct = ftList.get(id);
        if (ct.isVisited() || ct.isInvalid()) continue;
        if (ct.getDeadLine() > 0) {
          Timestamp current = new Timestamp(System.currentTimeMillis());
          Log.getLogger(Config.FLOW).debug(ct.getDeadLine() + ":" + ct.getId());
          long howlong = (current.getTime() - parentProcess.startTime.getTime()) / 1000 / 60;
          Log.getLogger(Config.FLOW).debug("流程运行时间:" + howlong);
          if (howlong >= ct.getDeadLine()) {

            parentProcess.scheduler.addAction(Action.timeoutAction(null, ct));
            String info = "[Transition" + ct.getId() + "(" + ct.getInfo() + ")]发生超时异常";
            String pid = "" + parentProcess.id;
            ExceptionModel.insertNewException(pid, info);
            has = true;
            try {
              Thread.sleep(10000);
            } catch (InterruptedException e) {
              Log.getLogger("system").fatal("thread sleep error", e);
            }
            CustomedPlace p = ct.getBackPlace();
            ct.setInvalid(true);
            ct.setVisited(true);
            if (p != null) {
              parentProcess.tokenArrivePlace(
                  p.getId(), new ForwardToken(p.getId(), ForwardToken.EXCEPTION));
            }
          }
        }
      }
      return has;
    }
示例#7
0
    private TCG toTCG() {
      TCG graph = new TCG();
      // 找当前活跃节点,应该是place
      CustomedPlace p = this.lastActivePlace;
      if (null == p) return null;
      TCGNode tnode = new TCGNode(String.valueOf(p.getId()));
      this.startTCGNode = tnode;
      graph.addNode(tnode);
      // 给lastActivePlace的直接后继加弧,别的都由普通库所加弧
      LinkedList<PlaceToTransition> oArc = lastActivePlace.getOutArc();
      for (PlaceToTransition ptt : oArc) {
        CustomedTransition cto = ptt.t;
        TCGNode newnode =
            new TCGNode(
                String.valueOf(cto.getId()),
                new TimeDesc(0, cto.getInnerTime()[0]),
                new TimeDesc(0, cto.getInnerTime()[1]));
        graph.addNode(newnode);
        TimeConstraint tc =
            new TimeConstraint(
                tnode, newnode, new TimeDesc(0, 0), TimeDesc.MAXTIME(), TimeConstraint.DIRECT);
        graph.addConstraint(tc);
      }
      /*Set<String> pSet = pttList.keySet();
      for(Iterator it=pSet.iterator();it.hasNext();){
      	String id = (String)it.next();
      	String idArray[] = id.split(",");
      	if(null != idArray && idArray.length > 1
      			&& null != idArray[0] &&
      			idArray[0].equals(String.valueOf(p.getId()))
      			&& null != idArray[1]){
      		PlaceToTransition pttt = (PlaceToTransition)pttList.get(idArray[1]);
      		if(pttt!=null){
      			CustomedTransition ct = pttt.t;
      			TCGNode newnode = new TCGNode(idArray[1],new TimeDesc(0,ct.getInnerTime()[0]),new TimeDesc(0,ct.getInnerTime()[1]));
      			graph.addNode(newnode);
      			TimeConstraint tc = new TimeConstraint(tnode,newnode,new TimeDesc(0,0),TimeDesc.MAXTIME(),TimeConstraint.DIRECT);
      		    graph.addConstraint(tc);
      		}
      	}
      }*/
      // 遍历所有库所,加弧和变迁,加的是前置后置,绝对时间约束
      Set<Integer> pSet = this.fpList.keySet();
      for (Iterator<Integer> it = pSet.iterator(); it.hasNext(); ) {
        Integer id = (Integer) it.next();
        CustomedPlace cp = fpList.get(id);
        if (cp.isVisited() || cp.isInvalid() || cp == this.lastActivePlace) ;
        LinkedList<TransitionToPlace> inArc = cp.getInArc();
        LinkedList<PlaceToTransition> outArc = cp.getOutArc();
        if (inArc != null && outArc != null) {
          for (TransitionToPlace ttp : inArc) {
            CustomedTransition cti = ttp.t;
            for (PlaceToTransition ptt : outArc) {
              CustomedTransition cto = ptt.t;
              if (cti != null && cto != null) {
                TCGNode t1 =
                    new TCGNode(
                        String.valueOf(cti.getId()),
                        new TimeDesc(0, cti.getInnerTime()[0]),
                        new TimeDesc(0, cti.getInnerTime()[1]));
                TCGNode t2 =
                    new TCGNode(
                        String.valueOf(cto.getId()),
                        new TimeDesc(0, cto.getInnerTime()[0]),
                        new TimeDesc(0, cto.getInnerTime()[1]));
                graph.addNode(t1);
                graph.addNode(t2);
                TimeConstraint tc =
                    new TimeConstraint(
                        t1, t2, new TimeDesc(0, 0), TimeDesc.MAXTIME(), TimeConstraint.DIRECT);
                graph.addConstraint(tc);
              }
            }
          }
        }
      }
      // 遍历所有变迁,加截止时间约束
      Timestamp startTime = this.parentProcess.startTime;
      //	Timestamp lastUpdateTime = this.lastActivePlace.getAvailableTime();
      Timestamp lastUpdateTime = new Timestamp(System.currentTimeMillis());
      Set<Integer> tSet = this.ftList.keySet();
      for (Iterator<Integer> it = tSet.iterator(); it.hasNext(); ) {
        Integer id = (Integer) it.next();
        CustomedTransition ct = ftList.get(id);
        if (ct.isVisited() || ct.isInvalid()) ;

        TCGNode has = graph.getNode(String.valueOf(ct.getId()));
        if (null == has) {
          has =
              new TCGNode(
                  String.valueOf(ct.getId()),
                  new TimeDesc(0, ct.getInnerTime()[0]),
                  new TimeDesc(0, ct.getInnerTime()[1]));
          graph.addNode(has);
        }
        if (ct.getDeadLine() != 0) {
          @SuppressWarnings("deprecation")
          int gap = lastUpdateTime.getMinutes() - startTime.getMinutes();
          int relative = ct.getDeadLine() - gap;
          @SuppressWarnings("unused")
          TimeConstraint tc1 =
              new TimeConstraint(
                  this.startTCGNode,
                  has,
                  new TimeDesc(0, 0),
                  new TimeDesc(0, relative),
                  TimeConstraint.ASSIGNED);
        }
      }
      return graph;
    }
示例#8
0
 private void addTransition(CustomedTransition ft) {
   if (null == ftList) ftList = new HashMap<Integer, CustomedTransition>();
   ftList.put(ft.getId(), ft);
 }