Esempio n. 1
0
  private void make(double proc_time, int size) {

    addInport("in");
    addOutport("out");

    multiServerCoord co = new multiServerCoord("MultiSco");
    add(co);

    for (int i = 1; i <= size; i++) {
      proc p = new procName("processor_" + i, proc_time);
      add(p);
      co.add_procs(p);
      p.setPreferredLocation(new Point(187, 22 + 80 * (i - 1)));
    }

    Iterator i = getComponents().iterator();
    while (i.hasNext()) {
      entity ent = (entity) i.next();
      devs comp = (devs) ent;
      if (!ent.equals(co)) {
        addCoupling(co, "y", comp, "inName"); // use name for routing
        addCoupling(comp, "outName", co, "x");
      }
    }
    addCoupling(this, "in", co, "in");
    addCoupling(co, "out", this, "out");

    initialize();

    preferredSize = new Dimension(508, 32 + 80 * size);
    co.setPreferredLocation(new Point(-7, 20));
  }
Esempio n. 2
0
  /**
   * Resolves the component name in each of the couplings in the given set to its devs component,
   * and returns a new list of resolved such couplings.
   *
   * @param couplings The set of couplings, each containing an unresolved component name.
   * @param modelToSimMap A mapping of (names of) components to their simulators.
   * @param rootSim The root simulator (or coordinator) of the simulator making this call (if any).
   * @return A new list of couplings, corresponding to the given one, except each coupling contains
   *     the actual destination component, rather than just that component's name.
   */
  protected static List resolveCouplings(
      Set couplings, Function modelToSimMap, atomicSimulator rootSim) {
    // for each of the couplings to the source port
    List resolvedCouplings = new ArrayList();
    Iterator i = couplings.iterator();
    while (i.hasNext()) {
      Pair coupling = (Pair) i.next();

      // resolve the destination component name to its actual component
      EntityInterface component =
          getComponentWithName((String) coupling.getKey(), modelToSimMap, rootSim);

      // package the destination component with the destination
      // port-name, and add the result to our list of resolved
      // couplings
      resolvedCouplings.add(new Pair(component, coupling.getValue()));
    }

    return resolvedCouplings;
  }