Package model.devscore.couplings

Examples of model.devscore.couplings.ClassCoupling


   */
  private void addCoupling(ICouplingSet couplings, IBasicDEVSModel model1,
      IPort port1, Class<IBasicDEVSModel> model2, String port2,
      ISelector<IBasicDEVSModel> selector) {

    ClassCoupling coupling =
        new ClassCoupling(model1, port1, model2, port2, selector);
    // only allow addition if models and ports are existent!
    if ((!subModels.contains(model1) && (this != model1))
        || !model1.hasPort(port1)) {
      throw new InvalidCouplingException(
          "Add coupling: Not existing model or port! " + model1.getName() + ":"
View Full Code Here


   * @param port2
   *          the port2
   */
  public void removeCoupling(IBasicDEVSModel model1, IPort port1,
      Class<IBasicDEVSModel> model2, String port2) {
    ClassCoupling c = new ClassCoupling(model1, port1, model2, port2, null);
    removeCoupling(c);
  }
View Full Code Here

              currentCoupling.getModel2());
        }
      } // if coupling
      else if (coupling instanceof ClassCoupling) {
        // get the next coupling
        ClassCoupling currentCoupling = (ClassCoupling) coupling;
        // this is an out coupling of the current childModel
        // backup a reference to the port
        IPort a = currentCoupling.getPort1();
        // get the number of elements stored at this out port
        int numberOfElements = a.getValuesCount();
        // if there are any elements
        if (numberOfElements > 0) {
          // retrieve list containing the selected targets of this classcoupling
          List<IBasicDEVSModel> targets =
              currentCoupling.getSelector().executeSelection(
                  model.getSubmodelsByClass(currentCoupling.getModel2()));
          // create iterator for retrieved elements
          for (int j = 0; j < targets.size(); j++) {

            // retrieve current targetmodel
            BasicDEVSModel targetModel = (BasicDEVSModel) targets.get(j);
            // retrieve inputport for the given model
            IPort b = targetModel.getInPort(currentCoupling.getPort2());

            copyPortValues(a, b, numberOfElements);

            // the the target model is an atomic model remember that it got
            // an external message

            addToInfluenceeSet(model, influencees, involvedCM, targetModel);
          }
        }
      } // if classcoupling
      else if (coupling instanceof MultiCoupling) {
        // get the next coupling
        MultiCoupling currentCoupling = (MultiCoupling) coupling;
        // this is an out coupling of the current childModel
        // backup a reference to the port
        IPort a = currentCoupling.getPort1();
        // get the number of elements stored at this out port
        int numberOfElements = a.getValuesCount();
        // if there are any elements
        if (numberOfElements > 0) {
          // retrieve vector containing the selected targets of this
          // classcoupling
          List<IBasicDEVSModel> targets =
              currentCoupling.getSelector().executeSelection(
                  currentCoupling.getTargetsAsArrayList());
          // create iterator for retrieved elements
          // Iterator targetIterator = targets.iterator();
          // System.out.println(currentCoupling.getTargetsAsArrayList().size());
          for (int j = 0; j < targets.size(); j++) {
            // retrieve current targetmodel
            IBasicDEVSModel targetModel = targets.get(j);
            // retrieve inputport for the given model
            String portname =
                (currentCoupling.getTargets().getTarget(targetModel))
                    .getPortName();
            IPort b = targetModel.getInPort(portname);

            copyPortValues(a, b, numberOfElements);
View Full Code Here

TOP

Related Classes of model.devscore.couplings.ClassCoupling

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.