Example #1
0
  // @ScheduledMethod(start = 1, interval = 1, priority = 0, shuffle = false)
  public void generatePossibleActions() {

    StatefulSession session = getSession();
    session.insert(this, true);

    for (Segment segment : getSegments()) {
      session.insert(segment, true);
    }

    // add configuration variables

    session.startProcess("ACTION_GENERATION_RULEFLOW");
    session.fireAllRules();

    QueryResults results = session.getQueryResults("all floodprotections");

    for (Iterator<?> it = results.iterator(); it.hasNext(); ) {
      QueryResult result = (QueryResult) it.next();
      FloodProtection floodProtection = (FloodProtection) result.get("floodprotection");
      floodProtection.getSegment().addPossibleAction(floodProtection);
      System.out.format("  >>> set possible action %s\n", floodProtection);
    }

    session.dispose();
  }
Example #2
0
  // @ScheduledMethod(start = 1, interval = 1, priority = -1, shuffle = false)
  public void chooseActions() {

    StatefulSession session = getSession();
    session.insert(this, true);

    for (Segment segment : getSegments()) {
      session.insert(segment, true);
    }

    session.startProcess("ACTION_SELECTION_RULEFLOW");
    session.fireAllRules();
    session.dispose();

    for (Segment s : getSegments()) {
      s.setLastBuilt(null);
      if (s.getPossibleActions().size() > 0) {
        FloodProtection construct = s.getPossibleActions().firstElement();
        construct.execute();
        s.setLastBuilt(construct);
        System.out.format("  >>> constructed %s\n", construct);
        s.clearPossibleActions();
      }
    }
  }