Exemple #1
0
  /**
   * Specify the container, adding the entity to the list of entities in the container. If the
   * container already contains an entity with the same name, then throw an exception and do not
   * make any changes. Similarly, if the container is not in the same workspace as this entity,
   * throw an exception. If this entity is a class element and the proposed container does not match
   * the current container, then also throw an exception. If the entity is already contained by the
   * container, do nothing. If this entity already has a container, remove it from that container
   * first. Otherwise, remove it from the directory of the workspace, if it is present. If the
   * argument is null, then unlink the ports of the entity from any relations and remove it from its
   * container. It is not added to the workspace directory, so this could result in this entity
   * being garbage collected. Derived classes may further constrain the container to subclasses of
   * CompositeEntity by overriding the protected method _checkContainer(). This method validates all
   * deeply contained instances of Settable, since they may no longer be valid in the new context.
   * This method is write-synchronized to the workspace and increments its version number.
   *
   * @param container The proposed container.
   * @exception IllegalActionException If the action would result in a recursive containment
   *     structure, or if this entity and container are not in the same workspace, or if the
   *     protected method _checkContainer() throws it, or if a contained Settable becomes invalid
   *     and the error handler throws it.
   * @exception NameDuplicationException If the name of this entity collides with a name already in
   *     the container.
   * @see #getContainer()
   */
  public void setContainer(CompositeEntity container)
      throws IllegalActionException, NameDuplicationException {
    super.setContainer(container);

    if (container != null && directory != null) {
      directory.setBaseDirectory(URIAttribute.getModelURI(container));
    }
  }
 /**
  * Get the tableau to be used by the event that requires a tableau in its actions.
  *
  * @param event The event.
  * @param referredTableau The parameter that contains the name of the TableauParameter to be used,
  *     if not empty.
  * @param defaultTableau The default TableauParameter to be used.
  * @return The tableau.
  * @exception IllegalActionException If the tableau cannot be retrieved.
  * @see #setTableau(Event, StringParameter, TableauParameter, Tableau)
  */
 public static Tableau getTableau(
     Event event, StringParameter referredTableau, TableauParameter defaultTableau)
     throws IllegalActionException {
   TableauParameter parameter = getTableauParameter(event, referredTableau, defaultTableau);
   if (parameter == null) {
     throw new IllegalActionException(
         "referredTableau has not been " + "specified in " + event.getName() + ".");
   }
   Tableau tableau = (Tableau) ((ObjectToken) parameter.getToken()).getValue();
   return tableau;
 }
 /**
  * Invoked when an event is inserted into the event queue.
  *
  * @param position The position at which the event is inserted.
  * @param time The time at which the event is scheduled to fire.
  * @param event The event.
  * @param arguments Arguments to the event, which must be either an ArrayToken or a RecordToken,
  *     or null.
  */
 @Override
 public void insertEvent(int position, Time time, Event event, Token arguments) {
   try {
     boolean isActive = ((BooleanToken) active.getToken()).booleanValue();
     if (isActive) {
       System.out.println(
           "Schedule " + event.getName() + " at " + time + " at position " + position);
     }
   } catch (IllegalActionException e) {
     System.out.println(e.getMessage());
   }
 }