示例#1
0
  /** Create the embedded actor and add ports to it. */
  public void preinitialize() throws IllegalActionException {
    try {
      setEmbeddedActor();

      int i = 0;
      for (TypedIOPort port : (List<TypedIOPort>) portList()) {
        TypedIOPort newPort = (TypedIOPort) port.clone(workspace());
        newPort.setContainer(_embeddedActor);
        for (int channel = 0; channel < port.getWidth(); channel++) {
          TypedIORelation relation = new TypedIORelation(this, "relation" + i++);
          relation.setPersistent(false);
          port.link(relation);
          newPort.link(relation);
        }
      }
    } catch (NameDuplicationException ex) {
      throw new IllegalActionException(this, ex, "Name duplication.");
    } catch (CloneNotSupportedException ex) {
      throw new IllegalActionException(this, ex, "Clone not supported.");
    }
    super.preinitialize();
  }