1
package dk.aau.cs.model.NTA;
2
3
/* Copyright (c) 2009, Kenneth Yrke Jørgensen <kyrke@cs.aau.dk>
5
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
* Neither the name of the TAPAAL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
* Neither the name of the TAPAAL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
14
public class Edge {
15
16
private String guard = "";
16
17
private String sync = "";
17
18
private String update = "";
19
20
private Location source;
20
21
private Location dest;
23
public Edge(Location source, Location dest, String guard, String sync, String update)
23
public Edge(Location source, Location dest, String guard, String sync,
25
25
this.source = source;
27
27
this.guard = guard;
29
29
this.update = update;
32
public Location getSource()
32
public Location getSource() {
37
public void setSource(Location source)
36
public void setSource(Location source) {
39
37
this.source = source;
42
public Location getDestination()
40
public Location getDestination() {
47
public void setDestination(Location dest)
44
public void setDestination(Location dest) {
52
public String getGuard()
48
public String getGuard() {
57
public void setGuard(String guard)
52
public void setGuard(String guard) {
59
53
// TODO: check guard conforms to what is allowed
60
54
this.guard = guard;
63
public String getSync()
57
public String getSync() {
68
public void setSync(String sync)
61
public void setSync(String sync) {
70
62
// TODO: check sync conforms to what is allowed in uppaal
74
public String getUpdate()
66
public String getUpdate() {
79
public void setUpdate(String update)
81
//TODO: check update conforms to what is allowed in uppaal
70
public void setUpdate(String update) {
71
// TODO: check update conforms to what is allowed in uppaal
82
72
this.update = update;
85
public StringBuffer toXML()
75
public StringBuffer toXML() {
87
76
StringBuffer res = new StringBuffer();
89
78
res.append("<transition>\n");
90
79
res.append("<source ref=\"a" + source.getID() + "\" />\n");
91
80
res.append("<target ref=\"a" + dest.getID() + "\" />\n");
93
// replace "<" and ">" in guard with "<" and ">" respectively and replace "&&" with "&&"
82
// replace "<" and ">" in guard with "<" and ">" respectively and
83
// replace "&&" with "&&"
94
84
String tmp = guard.replace("<", "<").replace(">", ">");
95
85
tmp = tmp.replace("&&", "&&");
97
87
res.append("<label kind=\"guard\">" + tmp + "</label>\n");
98
88
res.append("<label kind=\"synchronisation\">" + sync + "</label>\n");
99
89
res.append("<label kind=\"assignment\">" + update + "</label>\n");
101
91
res.append("</transition>\n");
106
public String toString(){
107
return "Edge from " + source.getID() + " to " + dest.getID() + ". Guard: " + guard + ", Sync: " + sync + ", Update: " + update;
96
public String toString() {
97
return "Edge from " + source.getName() + " to " + dest.getName()
98
+ ". Guard: " + guard + ", Sync: " + sync + ", Update: "