예제 #1
0
 /** Remove inside relations. */
 public void wrapup() throws IllegalActionException {
   try {
     for (TypedIOPort port : (List<TypedIOPort>) portList()) {
       for (TypedIORelation relation : (List<TypedIORelation>) port.insideRelationList()) {
         relation.setContainer(null);
       }
     }
     // If an exception occurred earlier, then
     // _embeddedActor may be null, and we don't want
     // the null pointer exception masking the real
     // one.
     if (_embeddedActor != null) {
       _embeddedActor.setContainer(null);
     }
   } catch (NameDuplicationException ex) {
     // should not happen.
     throw new IllegalActionException(this, "name duplication.");
   }
   super.wrapup();
 }
예제 #2
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();
  }