Package model.devscore.couplings

Examples of model.devscore.couplings.Coupling


   *          the port2
   */
  private void addCoupling(ICouplingSet couplings, IBasicDEVSModel model1,
      IPort port1, IBasicDEVSModel model2, IPort port2) {

    Coupling coupling = new Coupling(model1, port1, model2, port2);

    // only allow addition if models and ports are existent!
    if ((!subModels.contains(model1) && (this != model1))
        || (!subModels.contains(model2) && (this != model2))
        || !model1.hasPort(port1) || !model2.hasPort(port2)) {
View Full Code Here


          // System.out.println("The model "+src.getFullName()+" has outputs on
          // port "+coups.get(0).getPort1().getName());
          // copy the port's values according to the couplings, thus for each
          // coupling do
          for (int i = 0; i < coups.size(); i++) {
            Coupling c = (Coupling) coups.get(i);
            c.getPort2().writeAll(c.getPort1().readAll());
            influencedAM.put(
                (IBasicAtomicModel<? extends AbstractState>) c.getModel2(),
                null);
          }
        }
      }
    }
View Full Code Here

            // destination

            List<BasicCoupling> nc = null;

            if (bc instanceof Coupling) {
              Coupling c = (Coupling) bc;

              // get the replacements for the coupling c
              nc = getCouplings(c, allCouplings);

              // add the direct replacements to the list of direct couplings
View Full Code Here

    List<BasicCoupling> result = new ArrayList<>();

    if (!(endModel instanceof IBasicCoupledModel)) {
      // create new direct coupling if the endModel is an atomic one
      Coupling c = new Coupling(startModel, startPort, endModel, endPort);
      // System.out.println("got new direct coupling "+c);
      result.add(c);
    } else {
      // recursively call this method if the current end model is still a
      // coupled one
      Map<IPort, List<BasicCoupling>> portCouplingMap =
          allCouplings.get(endModel);
      if (portCouplingMap != null) {
        List<BasicCoupling> coups = portCouplingMap.get(endPort);

        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

      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);
View Full Code Here

TOP

Related Classes of model.devscore.couplings.Coupling

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.