Package org.woped.core.model.petrinet

Examples of org.woped.core.model.petrinet.SimulationModel


    /**
     * Will create a Simulation-Object that can be added to the Simulations-Vector
     */
    public void createSaveableHistory() {
        if (HistoryVector != null) {
            SaveableSimulation = new SimulationModel(PetriNet
                    .getNewElementId(AbstractPetriNetElementModel.SIMULATION_TYPE), "Default",
                    (Vector<TransitionModel>) HistoryVector.clone(), PetriNet.getLogicalFingerprint(), new Date());
            newHistory = true;
        }
    }
View Full Code Here


   *            the moment
   */
  private boolean importSimulations(SimulationType[] simulations,
      PetriNetModelProcessor currentPetrinet) throws Exception {
    boolean savedFlag = true;
    SimulationModel currSimulation;
    TransitionModel currTransition;
    String currSimulationID;
    int greatestSimulationIDnumber = 0;
    for (int k = 0; k < simulations.length; k++) {
      // collect the information about the current simulation in local
      // variables
      currSimulationID = simulations[k].getId();
      simulations[k].getSimulationdate();
      OccuredtransitionType[] occuredTransitions = simulations[k]
          .getTransitionsequence().getOccuredtransitionArray();
      Vector<TransitionModel> currentTransitions = new Vector<TransitionModel>();
      String currTransitionID = null;
      String currTransitionName = null;
      String arcSource, arcTarget;
      for (int l = 0; l < occuredTransitions.length; l++) {
        currTransition = null;
        currTransitionID = occuredTransitions[l].getTransitionID();
        if (currTransitionID.charAt(0) == 'a') {
          // for XOR-transitions the simulation has to fire arcs
          // instead of simpletransitions
          // because of the inner representation of van der
          // Aalst-operators.
          // Therefore a virtual helper-transition with the arcs' ID
          // and a special name is created.

          arcSource = currentPetrinet.getElementContainer()
              .getArcById(currTransitionID).getSourceId();
          arcTarget = currentPetrinet.getElementContainer()
              .getArcById(currTransitionID).getTargetId();
          if (arcSource.charAt(0) == 't') {
            currTransitionName = arcSource + " -> (" + arcTarget
                + ")";
          } else {
            currTransitionName = "(" + arcSource + ") -> "
                + arcTarget;
          }
          CreationMap map = CreationMap.createMap();
          map.setId(currTransitionID);
          currTransition = new TransitionModel(map);
          currTransition.setNameValue(currTransitionName);
          LoggerManager.debug(Constants.FILE_LOGGER,
              " ... Simulation: HelperTransition for arc ("
                  + currTransitionID + ") created");
        } else {
          currTransition = (TransitionModel) currentPetrinet
              .getElementContainer().getElementById(
                  currTransitionID);
        }
        currentTransitions.add(currTransition);
      }
      currSimulation = new SimulationModel(currSimulationID,
          simulations[k].getSimulationname(), currentTransitions,
          simulations[k].getNetFingerprint(), simulations[k]
              .getSimulationdate().getTime());
      // check if current fingerprint of the net equals the imported one
      // if not ask the user if he want's to keep the simulation
View Full Code Here

            SimulationType iSimulation;
            TransitionsequenceType iTransitionsequence;
            OccuredtransitionType iOccuredTransition;
            for (Iterator<SimulationModel> iter = petrinetModel.getSimulations().iterator();iter.hasNext();)
            {
              SimulationModel currSimulation = iter.next();
             
              // check if current fingerprint of the net equals the imported one
            // if not ask the user if he want's to keep the simulation
            //
            // this check is performed as well on:
            // - fileixport
            // - loading a simulation
            // when you change it here please do at those locations as well
              int answer = 0;
              Date simulationCreationDate = currSimulation.getSavedDate();
              if(!petrinetModel.isLogicalFingerprintEqual(currSimulation.getFingerprint()))
              {
                Object[] options = {Messages.getString("Tokengame.ChangedNetDialog.ButtonKeep"),Messages.getString("Tokengame.ChangedNetDialog.ButtonDelete")};
                // get the localized message text
                String message = Messages.getString("Tokengame.ChangedNetDialog.Export.Message");
              // fill the message text dynamically with the simulationname and simulationdate
                message = message.replaceAll("##SIMULATIONNAME##", currSimulation.getName());
                message = message.replaceAll("##SIMULATIONDATE##", DateFormat.getDateInstance().format(currSimulation.getSavedDate()));
              answer = JOptionPane.showOptionDialog(null, message, Messages.getString("Tokengame.ChangedNetDialog.Title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
              // if the user didn't choose one of the buttons but closed the OptionDialog don't drop the simulation
              if(answer == -1)
              {
                answer = 0;
              }
              }
              if(answer == 0)
              {
                  iSimulation = iNetSimulations.addNewSimulation();
                  iSimulation.setId(currSimulation.getId());
                  iSimulation.setSimulationname(currSimulation.getName());
                  Calendar cal = Calendar.getInstance();
                  cal.setTime(simulationCreationDate);
                  iSimulation.setSimulationdate(cal);
                  iTransitionsequence = iSimulation.addNewTransitionsequence();
                  for(Iterator<TransitionModel> iterator = currSimulation.getOccuredTransitions().iterator();iterator.hasNext();)
                  {
                    iOccuredTransition = iTransitionsequence.addNewOccuredtransition();
                    iOccuredTransition.setTransitionID((iterator.next()).getId());
                  }
                  iSimulation.setNetFingerprint(currSimulation.getFingerprint());
                  LoggerManager.debug(Constants.FILE_LOGGER, "   ... Simulation (ID:" + currSimulation.getId() + ") set");
              }
              else
              {
                LoggerManager.debug(Constants.FILE_LOGGER, "   ... Simulation (ID:" + currSimulation.getId() + ") dropped by user");
              }
            }
           
            // toolspecific
            for (short i = 0; i < petrinetModel.getUnknownToolSpecs().size(); i++)
View Full Code Here

TOP

Related Classes of org.woped.core.model.petrinet.SimulationModel

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.