Examples of IPort


Examples of model.devscore.ports.IPort

  @Override
  public void deltaExternal(double elapsedTime) {
    theExtCounter++;
    // checking the port allocations
    Iterator<IPort> inPortIt = getInPortIterator();
    IPort port;
    // FireParcel obj;

    // System.out.println("I'm on this host "+getFullName());

    // System.out.print(getFullName()+" -- Number of incoming messages ");

    // let's remove all those models from the list of models we have to spread
    // the fire to from which we already received a message
    while (inPortIt.hasNext()) {
      port = inPortIt.next();
      while (port.hasValue()) {
        // we are not interest in what, but from where ;-)
        port.read();

        // System.out.println(getName()+" .. "+port.getName());

        if (port.getName() == InNorth) {
          getState().spreadFireTo -= FireState.North;
        }
        if (port.getName() == InSouth) {
          getState().spreadFireTo -= FireState.South;
        }
        if (port.getName() == InEast) {
          getState().spreadFireTo -= FireState.East;
        }
        if (port.getName() == InWest) {
          getState().spreadFireTo -= FireState.West;
        }

      }
    }
View Full Code Here

Examples of model.devscore.ports.IPort

    }

    // System.out.println("delta ext of the map");

    Iterator<IPort> inPortIt = getInPortIterator();
    IPort port;
    FireParcel obj;

    while (inPortIt.hasNext()) {
      port = inPortIt.next();
      List<Object> values = port.readAll();
      for (int i = 0; i < values.size(); i++) {

        obj = (FireParcel) values.get(i);

        int y = obj.sender.getSecondValue();
View Full Code Here

Examples of model.devscore.ports.IPort

   *
   * @return the model in port
   */
  public IPort getModelInPort(String model, String port) {

    IPort iport = getModel(model).getInPort(port);
    if (iport == null) {
      throw new InvalidPortException("A port with the given name " + port
          + " does not exist in " + model + "!");
    }
    return iport;
View Full Code Here

Examples of model.devscore.ports.IPort

   *
   * @return the model out port
   */
  public IPort getModelOutPort(String model, String port) {

    IPort iport = getModel(model).getOutPort(port);
    if (iport == null) {
      throw new InvalidPortException("A port with the given name " + port
          + " does not exist in " + model + "!");
    }
    return iport;
View Full Code Here

Examples of model.devscore.ports.IPort

  public void modifyModel(M model) {

    try {

      IBasicDEVSModel fromModel = getModel1();
      IPort fromPort = getPort1();
      IBasicDEVSModel toModel = getModel2();
      IPort toPort = getPort2();

      // Lookup models if needed

      Pair<IBasicDEVSModel, IPort> src =
          getModelAndOutPort(model, fromModel, fromModelString, fromPort,
View Full Code Here

Examples of model.devscore.ports.IPort

   */
  private List<BasicCoupling> getCouplings(Coupling coupling,
      Map<IBasicDEVSModel, Map<IPort, List<BasicCoupling>>> allCouplings) {

    IBasicDEVSModel startModel = coupling.getModel1();
    IPort startPort = coupling.getPort1();

    // this is okay because we only allow couplings of type Coupling here
    IBasicDEVSModel endModel = coupling.getModel2();
    IPort endPort = coupling.getPort2();

    // find the targets of the given coupling, these are the models finally
    // receiving events transferred by this coupling
    List<BasicCoupling> result =
        searchEndModelsAndPorts(startModel, startPort, endModel, endPort,
View Full Code Here

Examples of model.devscore.ports.IPort

      // if the model m is an atomic one we have found a potential source of
      // external events
      if (!(m instanceof IBasicCoupledModel)) {
        // get all couplings (per port) of this event source
        for (Map.Entry<IPort, List<BasicCoupling>> iPortListEntry : allCouplings.get(m).entrySet()) {
          IPort p = iPortListEntry.getKey();

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

          // for all couplings search for direct coupling replacements
          for (int i = 0; i < allCouplingsOfPort.size(); i++) {
View Full Code Here

Examples of model.devscore.ports.IPort

    IBasicDEVSModel model = getModel();

    Map<String, List<Object>> result = new HashMap<>();

    Iterator<IPort> itp = model.getOutPortIterator();
    IPort p;

    // while there are ports
    while (itp.hasNext()) {

      List<Object> list;

      // fetch a port
      p = itp.next();
      // if this port has at least one value
      if (p.hasValue()) {

        list = p.readAll();
        p.clear();
        p.changed();

        // add a new PortParcel (that's a port reference as well as the list
        // of objects
        result.put(p.getName(), list);
      }
    }
    // return a list of PortParcels
    return result;
  }
View Full Code Here

Examples of model.devscore.ports.IPort

    IBasicDEVSModel model = getModel();

    ArrayList<PortParcel> result = new ArrayList<>();

    Iterator<IPort> itp = model.getOutPortIterator();
    IPort p;

    // while there are ports
    while (itp.hasNext()) {

      List<Object> list;

      // fetch a port
      p = itp.next();

      // if this port has at least one value
      if (p.hasValue()) {

        list = p.readAll();
        p.clear();
        p.changed();

        // System.out.println("all values added");
        // add a new PortParcel (that's a port reference as well as the list
        // of objects
        result.add(new PortParcel(p, list));
View Full Code Here

Examples of model.devscore.ports.IPort

      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
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.