Package org.woped.qualanalysis.soundness.datamodel

Examples of org.woped.qualanalysis.soundness.datamodel.LowLevelPetriNet


     */
    protected void createLowLevelPetriNet() {
        Iterator<AbstractPetriNetElementModel> iterTransition = sa.getTransitions().iterator();
        Iterator<AbstractPetriNetElementModel> iterPlace = sa.getPlaces().iterator();

        LowLevelPetriNet lNet = new LowLevelPetriNet();
        Set<AbstractPetriNetElementModel> successors;
        Set<AbstractPetriNetElementModel> predecessors;
        TransitionModel tm;
        PlaceModel pm;

        // loop over all places
        while (iterPlace.hasNext()) {
            pm = (PlaceModel) iterPlace.next();
            lNet.getPlaceNode(new PlaceNode(pm.getTokenCount(), pm.getVirtualTokenCount(), pm.getId(), pm
                    .getNameValue(), makeOriginId(pm.getId())));
        }

        // loops over all transitions and set predecessors and successors
        while (iterTransition.hasNext()) {
          AbstractPetriNetElementModel trans = iterTransition.next();
          AbstractPetriNetElementModel opTrans = null;
          tm = (TransitionModel) trans;
            successors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeOUTBOUND);
            predecessors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeINBOUND);
            ModelElementContainer mec;
            AbstractPetriNetElementModel elem = null;
            Iterator<ModelElementContainer> ownerIterator = trans.getOwningContainersIterator();
            while (ownerIterator.hasNext()) {
              mec = ownerIterator.next();
              elem = mec.getOwningElement();
              if (elem != null && elem.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
                opTrans = (TransitionModel)elem;
                break;
              }
            }
        
            // add current transition node
            TransitionNode tNode;
            if (opTrans != null && opTrans.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
              tNode = lNet.getTransitionNode(new TransitionNode(tm.getId(), tm.getNameValue(),
                    makeOriginId(tm.getId()), ((OperatorTransitionModel)opTrans).getOperatorType()));
            }
            else {
              tNode = lNet.getTransitionNode(new TransitionNode(tm.getId(), tm.getNameValue(),
                    makeOriginId(tm.getId()), OperatorTransitionModel.TRANS_SIMPLE_TYPE));
            }

            // add predecessor of current transition node
            for (AbstractPetriNetElementModel predecessor : predecessors) {
                lNet.getPlaceNode(
                        new PlaceNode(((PlaceModel) predecessor).getTokenCount(), ((PlaceModel) predecessor)
                                .getVirtualTokenCount(), predecessor.getId(), predecessor.getNameValue(),
                                makeOriginId(predecessor.getId()))).addPostNode(tNode);
            }

            // add successor of current transition node
            for (AbstractPetriNetElementModel successor : successors) {
                tNode.addPostNode(lNet.getPlaceNode(new PlaceNode(((PlaceModel) successor).getTokenCount(),
                        ((PlaceModel) successor).getVirtualTokenCount(), successor.getId(), successor.getNameValue(),
                        makeOriginId(successor.getId()))));
            }

        }
        // if editor is subprocess-editor, add a token to source-places
        if (isSubprocess) {
            Iterator<AbstractPetriNetElementModel> sourcePlacesIterator = sa.getSourcePlaces().iterator();
            String sourcePlaceId;
            while (sourcePlacesIterator.hasNext()) {
                sourcePlaceId = sourcePlacesIterator.next().getId();
                for (PlaceNode lNetPlace : lNet.getPlaces()) {
                    if (lNetPlace.getOriginId().equals(sourcePlaceId) && lNetPlace.getTokenCount() == 0) {
                        lNetPlace.setTokenCount(1);
                        break;
                    }
                }
View Full Code Here


            System.out.println(marking);
        }
    }

    public LowLevelNetTest() {
        LowLevelPetriNet lolNet;
        IMarkingNet markingNet;

        lolNet = createNewLowLevelPetriNet();

        markingNet = new MarkingNet(lolNet);
View Full Code Here

        putOut(markingNet);
    }

    public LowLevelPetriNet createNewLowLevelPetriNet() {
        LowLevelPetriNet lowlevelNet = new LowLevelPetriNet();

        PlaceNode p1 = lowlevelNet.getPlaceNode(new PlaceNode(2, 2, "p1", null, null));
        PlaceNode p2 = lowlevelNet.getPlaceNode(new PlaceNode(0, 0, "p2", null, null));
        PlaceNode p3 = lowlevelNet.getPlaceNode(new PlaceNode(0, 0, "p3", null, null));
        PlaceNode p4 = lowlevelNet.getPlaceNode(new PlaceNode(0, 0, "p4", null, null));
        PlaceNode p5 = lowlevelNet.getPlaceNode(new PlaceNode(0, 0, "p5", null, null));

        TransitionNode t1 = lowlevelNet.getTransitionNode(new TransitionNode("t1", null, null,0));
        TransitionNode t2 = lowlevelNet.getTransitionNode(new TransitionNode("t2", null, null,0));
        TransitionNode t3 = lowlevelNet.getTransitionNode(new TransitionNode("t3", null, null,0));

        p1.addPostNode(t1);
        t1.addPostNode(p2);
        t1.addPostNode(p3);
        p2.addPostNode(t2);
View Full Code Here

TOP

Related Classes of org.woped.qualanalysis.soundness.datamodel.LowLevelPetriNet

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.