diff options
Diffstat (limited to 'Domains/crossingScenario/src')
-rw-r--r-- | Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java | 8 | ||||
-rw-r--r-- | Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java | 135 |
2 files changed, 104 insertions, 39 deletions
diff --git a/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java b/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java index 4442fc7d..c0646edd 100644 --- a/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java +++ b/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java | |||
@@ -1,5 +1,7 @@ | |||
1 | package crossingScenario.run; | 1 | package crossingScenario.run; |
2 | 2 | ||
3 | import java.awt.Desktop; | ||
4 | import java.io.File; | ||
3 | import java.io.IOException; | 5 | import java.io.IOException; |
4 | import java.nio.file.Files; | 6 | import java.nio.file.Files; |
5 | import java.nio.file.Path; | 7 | import java.nio.file.Path; |
@@ -33,6 +35,10 @@ public class CrossingScenarioMain { | |||
33 | System.out.println("postprocessing -> " + t4); | 35 | System.out.println("postprocessing -> " + t4); |
34 | 36 | ||
35 | System.out.println("TOTAL -> " + tot); | 37 | System.out.println("TOTAL -> " + tot); |
36 | 38 | ||
39 | String p1 = "outputs/models/1.xmi"; | ||
40 | String p2 = "outputs/simplePrevLane.tgf"; | ||
41 | QueryDebug.checkPrevLanes(p1, p2); | ||
42 | Desktop.getDesktop().open(new File(p2)); | ||
37 | } | 43 | } |
38 | } | 44 | } |
diff --git a/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java b/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java index 2d866e85..9f9b939b 100644 --- a/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java +++ b/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java | |||
@@ -1,27 +1,82 @@ | |||
1 | package crossingScenario.run; | 1 | package crossingScenario.run; |
2 | 2 | ||
3 | import java.io.FileNotFoundException; | ||
4 | import java.io.PrintWriter; | ||
5 | import java.util.ArrayList; | ||
6 | import java.util.HashMap; | ||
7 | import java.util.List; | ||
8 | import java.util.Map; | ||
9 | import java.util.regex.Matcher; | ||
10 | import java.util.regex.Pattern; | ||
11 | |||
12 | import org.eclipse.emf.common.util.URI; | ||
13 | import org.eclipse.emf.ecore.EPackage; | ||
14 | import org.eclipse.emf.ecore.resource.Resource; | ||
15 | import org.eclipse.emf.ecore.resource.ResourceSet; | ||
16 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; | ||
17 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
18 | |||
19 | import crossingScenario.CrossingScenario; | ||
20 | import crossingScenario.CrossingScenarioPackage; | ||
21 | import crossingScenario.Lane; | ||
22 | |||
3 | public class QueryDebug { | 23 | public class QueryDebug { |
24 | public static void main(String[] args) throws FileNotFoundException { | ||
25 | // checkPrevLanes("outputs/models/1.xmi", "outputs/simplePrevLane.tgf"); | ||
26 | testOnInstance(); | ||
27 | } | ||
28 | |||
29 | public static void checkPrevLanes(String pathSrc, String pathTgt) throws FileNotFoundException { | ||
30 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); | ||
31 | EPackage.Registry.INSTANCE.put(CrossingScenarioPackage.eNS_URI, CrossingScenarioPackage.eINSTANCE); | ||
32 | ResourceSet rs = new ResourceSetImpl(); | ||
33 | Resource res = rs.getResource(URI.createFileURI(pathSrc), true); | ||
34 | |||
35 | PrintWriter printer = new PrintWriter(pathTgt); | ||
36 | |||
37 | CrossingScenario cs = ((CrossingScenario) res.getContents().get(0)); | ||
38 | for (Lane o : cs.getLanes()) { | ||
39 | String prefix = ""; | ||
40 | if (cs.getHorizontal_head().equals(o) || cs.getVertical_head().equals(o)) { | ||
41 | prefix = "HEAD"; | ||
42 | } | ||
43 | String nodeName = prefix + "(" + o.getReferenceCoord() + ")" + | ||
44 | o.eClass().getName().substring(5, 9); | ||
45 | printer.println(o.hashCode() + " " + nodeName); | ||
46 | } | ||
47 | printer.println("#"); | ||
48 | for (Lane o : cs.getLanes()) { | ||
49 | if (o.getPrevLane() != null){ | ||
50 | int curName = o.hashCode(); | ||
51 | int curPrev = o.getPrevLane().hashCode(); | ||
52 | double edgeLabel = o.getPrevLane().getNumWidth(); | ||
53 | printer.println(curName + " " + curPrev + " " + edgeLabel); | ||
54 | } | ||
55 | } | ||
56 | printer.flush(); | ||
57 | printer.close(); | ||
58 | System.out.println("TGF CREATED"); | ||
59 | |||
60 | } | ||
4 | 61 | ||
5 | // public static void main(String[] args) { | 62 | public static void testOnInstance() { |
6 | // Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); | 63 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); |
7 | // EPackage.Registry.INSTANCE.put(CrossingScenarioPackage.eNS_URI, CrossingScenarioPackage.eINSTANCE); | 64 | EPackage.Registry.INSTANCE.put(CrossingScenarioPackage.eNS_URI, CrossingScenarioPackage.eINSTANCE); |
8 | // ResourceSet rs = new ResourceSetImpl(); | 65 | ResourceSet rs = new ResourceSetImpl(); |
9 | // rs.getResource(URI.createFileURI("outputs/models/1.xmi"), true); | 66 | rs.getResource(URI.createFileURI("outputs/models/1.xmi"), true); |
10 | // | 67 | |
11 | // ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); | 68 | // ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); |
12 | // // Access pattern matcher | 69 | // // Access pattern matcher |
13 | // | ||
14 | // | ||
15 | // | ||
16 | // CrossingScenarioQueries.instance().prepare(engine); | 70 | // CrossingScenarioQueries.instance().prepare(engine); |
17 | // Define_numWidth_medium.Matcher matcher = Define_numWidth_medium.Matcher.on(engine); | 71 | // |
72 | // Define_referenceCoord_laneWithPrevHasCorrectRefCoord.Matcher matcher = Define_referenceCoord_laneWithPrevHasCorrectRefCoord.Matcher.on(engine); | ||
18 | // // Get and iterate over all matches | 73 | // // Get and iterate over all matches |
19 | // System.out.println("MATCHES:"); | 74 | // System.out.println("MATCHES:"); |
20 | // for (Define_numWidth_medium.Match match : matcher.getAllMatches()) { | 75 | // for (Define_referenceCoord_laneWithPrevHasCorrectRefCoord.Match match : matcher.getAllMatches()) { |
21 | // // Print all the matches to the standard output | 76 | // // Print all the matches to the standard output |
22 | // System.out.println(match.getL()); | 77 | // System.out.println(match.getL()); |
23 | // } | 78 | // } |
24 | // } | 79 | } |
25 | 80 | ||
26 | 81 | ||
27 | // public static void main(String[] args) { | 82 | // public static void main(String[] args) { |
@@ -84,30 +139,34 @@ public class QueryDebug { | |||
84 | // } | 139 | // } |
85 | 140 | ||
86 | 141 | ||
87 | // public static void main(String[] args) { | 142 | public static void testParsing() { |
88 | // ArrayList<String> out = new ArrayList<String>(); | 143 | ArrayList<String> out = new ArrayList<String>(); |
89 | // out.add("delta-sat with delta = 0.001"); | 144 | out.add("delta-sat with delta = 0.001"); |
90 | // out.add("w1602659765 : [1.797693134862315708e+308, 1.797693134862315708e+308]"); | 145 | out.add("rc1601644608 : [1.797693134862315708e+308, 1.797693134862315708e+308]"); |
91 | // String s = "1.797693134862315708e+308"; | 146 | out.add("nw1149275723 : [12.49949999999999939, 12.50050000000000061]"); |
92 | // | 147 | out.add("nw157857530 : [7.499500000000000277, 7.500499999999999723]"); |
93 | // System.out.println(parseDrealOutput(out)); | 148 | out.add("nw1521058274 : [12.49949999999999939, 12.50050000000000061]"); |
94 | // | 149 | String s = "1.797693134862315708e+308"; |
95 | // } | 150 | |
96 | // | 151 | System.out.println(parseDrealOutput(out)); |
97 | // private static Map<String, String> parseDrealOutput(List<String> output) { | 152 | |
98 | // Map<String, String> res = new HashMap<String, String>(); | 153 | } |
99 | // String re = "(\\w+) : \\[([0-9\\+-.e]+), ([0-9\\+-.e]+)\\]"; | 154 | |
100 | //// String re = "(\\w+) : \\[(.*), (.*)\\]"; | 155 | private static Map<String, String> parseDrealOutput(List<String> output) { |
101 | // Pattern p = Pattern.compile(re); | 156 | Map<String, String> res = new HashMap<String, String>(); |
102 | // for (String varVal : output) { | 157 | String re = "(\\w+) : \\[([0-9\\+-.e]+), ([0-9\\+-.e]+)\\]"; |
103 | // Matcher m = p.matcher(varVal); | 158 | // String re = "(\\w+) : \\[(.*), (.*)\\]"; |
104 | // if (m.matches()) { | 159 | Pattern p = Pattern.compile(re); |
105 | // String name = m.group(1); | 160 | for (String varVal : output) { |
106 | // String lowerB = m.group(2); | 161 | Matcher m = p.matcher(varVal); |
107 | // String upperB = m.group(2); | 162 | if (m.matches()) { |
108 | // res.put(name, lowerB); | 163 | String name = m.group(1); |
109 | // } | 164 | String lowerB = m.group(2); |
110 | // } | 165 | String upperB = m.group(2); |
111 | // return res; | 166 | res.put(name, lowerB); |
112 | // } | 167 | } |
168 | } | ||
169 | return res; | ||
170 | } | ||
171 | |||
113 | } | 172 | } |