예제 #1
0
  // フラグを最適化する 2000.10.14 matono
  public boolean exec_optimize_flag(OM_Node node, boolean plus_times) {

    OM_Leaf leaf = node.body;
    boolean flagflag = plus_times;

    //  plus_times = true の時はひとつでも未送信があれば親は未送信のままで、すべて送信済であれば親は必ず送信済
    //  plus_times = false の時はひとつでも送信済があれば親は送信済にし、すべて送信済であれば親は必ず送信済

    while (leaf != null) {

      if (plus_times) flagflag &= leaf.leaf_flag;
      else flagflag |= leaf.leaf_flag;

      if (leaf.ap == null) {
        node = leaf.media_atom.node;
        flagflag = exec_optimize_flag(node, plus_times);
        leaf.leaf_flag = flagflag;
        node = leaf.node;
      }

      if (leaf.nonorder != null) leaf = leaf.nonorder;
      else if (leaf.seq_next != null) leaf = leaf.seq_next;
      else leaf = null;
    }
    return (flagflag);
  }
예제 #2
0
  // フラグを初期化する 2000.10.14 matono
  public void exec_init_flag(OM_Node node) {

    OM_Leaf leaf = node.body;

    while (leaf != null) {
      leaf.leaf_flag = false;

      if (leaf.ap == null) {
        node = leaf.media_atom.node;
        exec_init_flag(node);
        node = leaf.node;
      }

      if (leaf.nonorder != null) leaf = leaf.nonorder;
      else if (leaf.seq_next != null) leaf = leaf.seq_next;
      else leaf = null;
    }
  }
예제 #3
0
  // 重み付けを行い, フラグの初期化を行う 2000.10.24 matono
  public double exec_weight_node(OM_Node node) {
    int objects = 0; // 同階層内のオブジェクト数
    double total = 0; // 同階層内の重みの合計
    double average = 0; // 同階層内の重みの平均

    OM_Leaf leaf = node.body;

    //    System.out.println( "exec_weight_node!!");
    //    System.out.println( );

    while (leaf != null) {

      if (leaf.ap != null) {
        leaf.leaf_flag = false;
        // メディアの場合 type を重みとし利用。
        leaf.weight = (double) (leaf.ap.media.media_type);
        leaf.weight += (double) (leaf.ap.action.action_type) / 10;
        //	System.out.print( leaf.media_atom.name + "["+ leaf.weight + "], ");
        // 同時に合計を計算。
        total += leaf.weight;
      }

      // 子供が存在するか?
      else if (leaf.ap == null) {
        node = leaf.media_atom.node;
        // 再起呼出。averageに下位層の平均が帰ってくる。
        average = exec_weight_node(node);
        node = leaf.node;
        // averageはこのノードの重みになる。
        leaf.leaf_flag = false;
        leaf.weight = average;
        total += average;
        average = 0;
      }

      // 弟に交代。
      if (leaf.nonorder != null) leaf = leaf.nonorder;
      else if (leaf.seq_next != null) leaf = leaf.seq_next;
      else leaf = null;

      // 同階層のオブジェクト数
      objects++;
    }

    // 同階層の平均値を返す。
    return ((double) total / objects);
  }
예제 #4
0
  /* 処理の割り振り */
  public int exec_process_allocation(OM_Atom atom, int flag) {
    int exec_Flag = 0;
    OM_Leaf exec_leaf = null;

    System.out.println("Flag:" + flag);

    switch (flag) {
      case 1: // 終了( stop )
        exec_init_flag(atom.node);
        break;
      case 2: // 一時停止 ( halt )
        break;
      case -1: // 異常( error )
      case 3: // 再開( continue )
        System.out.println("Continue");
        exec_optimize_flag(atom.node, false);
        exec_debag_weight(atom.node);
        exec_leaf = exec_order_decision_error(atom.node);
        if (exec_leaf == null) {
          System.out.println("Continue Error!");
          break;
        } else {
          exec_debug_ap(exec_creat_ap(exec_leaf.ap));
          //	exec_creat_ap( exec_leaf.ap );
          Main.mine.commgr.sendObject(exec_creat_ap(exec_leaf.ap), QuikStatus.OM_ActionPointer);
          break;
        }
      case 0: // 正常( normal )
        exec_optimize_flag(atom.node, true);
        exec_leaf = exec_order_decision_normal(atom.node);
        if (exec_leaf == null) {
          System.out.println("Normal Error!");
          Main.mine.commgr.sendObject(null, -1);
          break;
        } else {
          exec_leaf.leaf_flag = true;
          exec_debug_ap(exec_creat_ap(exec_leaf.ap));
          //	exec_debug_ap( exec_leaf.ap );
          //	exec_creat_ap( exec_leaf.ap );
          Main.mine.commgr.sendObject(exec_creat_ap(exec_leaf.ap), QuikStatus.OM_ActionPointer);
          break;
        }
      case 4: // 開始( start )
        System.out.println("Start");
        exec_weight_node(atom.node);
        exec_leaf = exec_order_decision_normal(atom.node);
        if (exec_leaf == null) {
          System.out.println("Start Error!");
          break;
        } else {
          exec_leaf.leaf_flag = true;
          exec_debug_ap(exec_creat_ap(exec_leaf.ap));
          //	exec_creat_ap( exec_leaf.ap );
          Main.mine.commgr.sendObject(exec_creat_ap(exec_leaf.ap), QuikStatus.OM_ActionPointer);
          break;
        }
      default:
        exec_Flag = -1;
        System.out.println("Error");
        break;
    }

    return (exec_Flag);
  }