All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.uni.freiburg.iig.telematik.sepia.petrinet.timedNet.TimedNet Maven / Gradle / Ivy

Go to download

SEPIA provides implementations for various types of Petri nets. Along Place/Transition-nets, it supports Petri nets with distinguishable token colors and defines coloured workflow nets, where coloured tokens are interpreted as data elements used during process execution. To support information flow analysis of processes, SEPIA defines so-called IF-Nets, tailored for security-oriented workflow modeling which enable users to assign security-levels (HIGH, LOW) to transitions, data elements and persons/agents participating in the process execution.

The newest version!
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package de.uni.freiburg.iig.telematik.sepia.petrinet.timedNet;

import de.uni.freiburg.iig.telematik.sepia.event.TransitionEvent;
import de.uni.freiburg.iig.telematik.sepia.exception.PNException;
import de.uni.freiburg.iig.telematik.sepia.mg.pt.PTMarkingGraph;
import de.uni.freiburg.iig.telematik.sepia.petrinet.NetType;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPetriNet;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractTransition;
import de.uni.freiburg.iig.telematik.sepia.petrinet.ifnet.IFNet;
import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTFlowRelation;
import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking;
import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTPlace;
import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTTransition;
import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.abstr.AbstractPTNet;
import de.uni.freiburg.iig.telematik.sepia.petrinet.timedNet.abstr.AbstractTimedNet;
import de.uni.freiburg.iig.telematik.sewol.context.process.ProcessContext;

import java.security.AccessControlContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author richard
 */
public class TimedNet extends AbstractTimedNet {

	private static final long serialVersionUID = -2596591166620976262L;
	

	//private Map> pendingActions = new HashMap>();


	public TimedNet() {
		super();
		clock = 0.0;
		setAccessControl(new ProcessContext());
	}

	public static void main(String args[]) throws PNException {
		TimedNet test = new TimedNet();
	}


	@Override
	public Class getMarkingGraphClass() {
		return PTMarkingGraph.class;
	}

	@Override
	protected TimedTransition createNewTransition(String name, String label, boolean isSilent) {
		return new TimedTransition(name, label, isSilent);
	}

	@Override
	protected TimedNetPlace createNewPlace(String name, String label) {
		return new TimedNetPlace(name, label);
	}

	@Override
	protected TimedFlowRelation createNewFlowRelation(TimedNetPlace place, TimedTransition transition, Integer constraint) {
		return new TimedFlowRelation(place, transition, constraint);
	}

	@Override
	protected TimedFlowRelation createNewFlowRelation(TimedTransition transition, TimedNetPlace place, Integer constraint) {
		return new TimedFlowRelation(transition, place, constraint);
	}

	@Override
	protected TimedFlowRelation createNewFlowRelation(TimedNetPlace place, TimedTransition transition) {
		return new TimedFlowRelation(place, transition);
	}

	@Override
	protected TimedFlowRelation createNewFlowRelation(TimedTransition transition, TimedNetPlace place) {
		return new TimedFlowRelation(transition, place);
	}

	@Override
	public TimedMarking createNewMarking() {
		return new TimedMarking();
	}

	@Override
	public TimedMarking fireCheck(String transitionName) throws PNException {
		TimedMarking newMarking = cloneMarking();
		TimedTransition transition = getTransition(transitionName);
		for (TimedFlowRelation relation : transition.getIncomingRelations()) {
			String inputPlaceName = relation.getPlace().getName();
			newMarking.set(inputPlaceName, newMarking.get(inputPlaceName) - relation.getWeight());
		}
		for (TimedFlowRelation relation : transition.getOutgoingRelations()) {
			String outputPlaceName = relation.getPlace().getName();
			Integer oldState = (newMarking.get(outputPlaceName) == null ? 0 : newMarking.get(outputPlaceName));
			newMarking.set(outputPlaceName, oldState + relation.getWeight());
		}
		return newMarking;
	}

	@Override
	public TimedNet newInstance() {
		return new TimedNet();
	}

//	private boolean checkPendingActions() {
//		List actionTimepoints = new ArrayList();
//		for (double pendingActionTime : pendingActions.keySet()) {
//			if (pendingActionTime <= clock) {
//				actionTimepoints.add(pendingActionTime);
//			}
//		}
//		if (actionTimepoints.isEmpty())
//			return false;
//
//		Collections.sort(actionTimepoints);
//		for (Double actionTimepoint : actionTimepoints) {
//			for (TokenConstraint constraint : pendingActions.get(actionTimepoint)) {
//				getPlace(constraint.placeName).addTokens(constraint.tokens);
//			}
//			pendingActions.remove(actionTimepoint);
//		}
//		return true;
//	}

    @Override
    public NetType getNetType() {
        return NetType.RTPTnet;
    }

//    @Override
//    public void transitionFired(TransitionEvent> e) {
//        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
//    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy