Пример #1
0
 /** Custom initialization method, called by the enclosing actor, during its initialization. */
 public synchronized void initialize() {
   operationalSourcePorts = new HashSet<IOPort>();
   operationalSourcePorts.addAll(this.sourcePortList());
   if (isInput() && getContainer() instanceof MessageBuffer) {
     MessageBuffer _msgBfr = (MessageBuffer) getContainer();
     if (_msgBfr.acceptInputPort(this)) {
       Receiver[][] receivers = getReceivers();
       for (int i = 0; i < receivers.length; i++) {
         Receiver[] receivers2 = receivers[i];
         for (int j = 0; j < receivers2.length; j++) {
           Receiver receiver = receivers2[j];
           if (receiver instanceof MessageProvider) {
             ((MessageProvider) receiver).setMessageBuffer(_msgBfr);
           }
         }
       }
     } else {
       setMessageBuffer(null);
     }
   }
   //     first need to find a way to register the port statistics
   //     as children of the actor statistics
   statistics.reset();
   StatisticsServiceFactory.getService().registerStatistics(statistics);
 }
Пример #2
0
 /**
  * Input ports can finish because all their connected msg source ports are exhausted, or because
  * their containing actor forces them to finish. The first case is typical for process-domains,
  * and happens through invocations of notifySourcePortFinished(). The second case is when a model
  * is forcefully stopped by a user or by a central control/dispatch like in an event-based domain.
  */
 public void requestFinish() {
   logger.trace("{} - requestFinish() - entry", this.getFullName());
   operationalSourcePorts.clear();
   Receiver[][] myLocalReceivers = getReceivers();
   for (Receiver[] receivers : myLocalReceivers) {
     for (Receiver receiver : receivers) {
       if (receiver instanceof ProcessReceiver) {
         ((ProcessReceiver) receiver).requestFinish();
       } else if (receiver instanceof MessageProvider) {
         ((MessageProvider) receiver).requestFinish();
       }
     }
   }
   logger.trace("{} - requestFinish() - exit", this.getFullName());
 }