Package model.devscore.couplings

Examples of model.devscore.couplings.BasicCoupling


   */
  protected void addCouplings(Iterator<BasicCoupling> it,
      Map<IBasicDEVSModel, Map<IPort, List<BasicCoupling>>> cl) {
    // get one coupling after the other
    while (it.hasNext()) {
      BasicCoupling bc = it.next();
      // fetch the sub map for the model
      Map<IPort, List<BasicCoupling>> sl = cl.get(bc.getModel1());
      // check wether we already have such a sub map, if not create
      if (sl == null) {
        sl = new HashMap<>();
        cl.put(bc.getModel1(), sl);
      }
      // now we have a sub map, and we can try to fetch the list for the source
      // port
      List<BasicCoupling> basicCouplings = sl.get(bc.getPort1());
      // if there is no such list, create
      if (basicCouplings == null) {
        basicCouplings = new ArrayList<>();
        sl.put(bc.getPort1(), basicCouplings);
      }

      // add the current coupling the the list of coupling of the model + port
      basicCouplings.add(bc);

View Full Code Here


          List<BasicCoupling> allCouplingsOfPort = allCouplings.get(m).get(p);

          // for all couplings search for direct coupling replacements
          for (int i = 0; i < allCouplingsOfPort.size(); i++) {
            BasicCoupling bc = allCouplingsOfPort.get(i);

            // this coupling is our starting point, let's find it final
            // destination

            List<BasicCoupling> nc = null;
View Full Code Here

        if (coups != null) {

          Iterator<BasicCoupling> basicCouplingIterator = coups.iterator();
          if (basicCouplingIterator != null) {
            while (basicCouplingIterator.hasNext()) {
              BasicCoupling bc = basicCouplingIterator.next();
              Coupling c;
              if (bc instanceof Coupling) {
                c = (Coupling) bc;
                result.addAll(searchEndModelsAndPorts(startModel, startPort,
                    c.getModel2(), c.getPort2(), allCouplings));
View Full Code Here

   *          the involved cm
   */
  public final void copyValues(Iterator<BasicCoupling> couplingIterator,
      IBasicCoupledModel model, AM influencees, CM involvedCM) {
    while (couplingIterator.hasNext()) {
      BasicCoupling coupling = couplingIterator.next();
      if (coupling instanceof Coupling) {
        // get the next coupling
        Coupling currentCoupling = (Coupling) coupling;
        // this is an out coupling of the current childModel
        // backup a reference to the port
        IPort a = currentCoupling.getPort1();

        // System.out.println("Copying in "+model.getFullName());

        // get the number of elements stored at this out port
        int numberOfElements = a.getValuesCount();
        // if there are any elements
        if (numberOfElements > 0) {
          // we want handle only real messages and not empty (null) messages
          // backup the target port

          // System.out.println("copy to
          // "+currentCoupling.getModel2().getFullName());

          IPort b = currentCoupling.getPort2();

          // copy all elements to the target port, but do not remove them
          // from the source port (they may have to copied more than once!!)
          copyPortValues(a, b, numberOfElements);

          addToInfluenceeSet(model, influencees, involvedCM,
              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);

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

            addToInfluenceeSet(model, influencees, involvedCM, targetModel);
          }
        }
      } // if multicoupling
      else {
        throw new InvalidModelException(
            "This coupling class is not yet supported!! ("
                + coupling.getClass().getName() + ")");
      }
    } // end of while(coupIter.hasNext())
  }
View Full Code Here

TOP

Related Classes of model.devscore.couplings.BasicCoupling

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.