1
/* PeTe - Petri Engine exTremE
2
* Copyright (C) 2011 Jonas Finnemann Jensen <jopsen@gmail.com>,
3
* Thomas Søndersø Nielsen <primogens@gmail.com>,
4
* Lars Kærlund Østergaard <larsko@gmail.com>,
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#ifndef DTAPNTRANSLATOR_H
20
#define DTAPNTRANSLATOR_H
26
#include "../AbstractPetriNetBuilder.h"
27
#include "AbstractDTAPNBuilder.h"
29
namespace PetriEngine{
32
/** Translator from DTAPN to PNDV */
33
class DTAPNTranslator : public AbstractDTAPNBuilder
35
/** Encapsulates a place */
42
typedef std::list<Place> PlaceList;
43
typedef std::list<Place>::iterator PlaceIter;
44
/** Encapsulates a transition */
48
typedef std::list<Transition> TransitionList;
49
typedef std::list<Transition>::iterator TransitionIter;
57
typedef std::list<InArc> InArcList;
58
typedef std::list<InArc>::iterator InArcIter;
64
typedef std::list<OutArc> OutArcList;
65
typedef std::list<OutArc>::iterator OutArcIter;
67
DTAPNTranslator(int bound){ this->bound = bound; }
68
void addPlace(const std::string& name, int tokens, int maxInvariantAge, double x = 0, double y = 0);
69
void addTransition(const std::string& name, double x = 0, double y = 0);
70
void addInputArc(const std::string& place, const std::string& transition, int startInterval, int endInterval);
71
void addOutputArc(const std::string& transition, const std::string& place);
72
void makePNDV(AbstractPetriNetBuilder* builder);
73
static std::string translateQuery(const std::string& query);
75
/** Maximum number of tokens at a place */
77
/** List of DTAPN places */
79
/** List of DTAPN transitions */
80
TransitionList transitions;
81
/** List of DTAPN input arcs */
83
/** List of DTAPN output arcs */
85
/** Returns a DTAPN place with the provided name */
86
Place& findPlace(const std::string& name);
87
/** Make sure it can't collide with stuff we have */
88
std::string escapeIdentifier(std::string identifier);
89
/** Gets a list of input arcs for a transition */
90
InArcList preset(const std::string& transition);
91
/** Gets a list of output arcs for a transition */
92
OutArcList postset(const std::string& transition);
93
/** True, if place is the target of any output arcs */
94
bool isEndPlace(const std::string& place);
95
/** Lock state, when in idle */
97
/** Lock state, when in ageing */
99
/** Lock state for a transition */
100
std::string lockState(const std::string& transition);
101
/** Pre place to a transition */
102
std::string prePlace(const std::string& transition, int inArcNr);
103
/** Transition from place to pre-place */
104
std::string prePlaceTransition(const std::string& transition, int inArcNr, int tokenIndex);
105
/** Post-place from a transition, only one per place */
106
std::string postPlace(const std::string& place);
107
/** Transition from post-place to place */
108
std::string postPlaceTransition(const std::string& place, int tokenIndex);
109
/** Variable representing the age of a specific token at a place */
110
std::string tokenAgeVariable(const std::string& place, int tokenIndex);
111
/** Max transition between two intermediate ageing places */
112
std::string maxTransition(const std::string& place, int tokenIndex);
113
/** Age transition between two intermediate ageing places */
114
std::string ageTransition(const std::string& place, int tokenIndex);
115
/** An intermediate ageing place*/
116
std::string intermediateAgeingPlace(const std::string& place, int tokenIndex);
117
/** to ensure unique names */
118
bool hasIdentifier(const std::string& id);
124
#endif // DTAPNTRANSLATOR_H