List of commits:
Subject Hash Author Date (UTC)
hallo aae977040cd511a72ee3558ac95249edf820f6c9 XCBouke 2018-01-10 12:47:49
Work done during lecture. 7a0518a31a21e7ee0be11bc0966647acae129a94 Jan Allersma 2018-01-10 12:40:34
Traffic queues now implemented on all traffic. bcf0ece12b63e87894a2f9d1138145353054fbab Jan Allersma 2018-01-08 21:37:25
Pedestrian don't think they're cars anymore! Also small code cleanup. 7c6e2978497442330d56fd334cf8b33e73c7525a Jan Allersma 2018-01-08 20:53:51
Cars send signal once they're waiting, not before they're waiting. 49fda0804f0e056fe6a060ff13bd1c10408f696e Jan Allersma 2018-01-08 15:57:41
Assessment 8ad5b23b821e160483b919f0f375313ec6dc79be Jan Allersma 2017-12-20 11:37:13
TrafficLights working..? 7f12d9c9d44a2fa556d15e075723ec9c11c8b468 Jan Allersma 2017-12-19 15:22:32
Add lights and fully working train. ee0e851a1b482f162918f8723fc0c62d257aff83 Jan Allersma 2017-12-18 16:59:33
Commit after fixing issues during lecture 93b7f5e88a7a4427867054ebabe0505963b14da0 Jan Allersma 2017-12-13 12:49:55
Some more fixes :D 09f121a8de8ef6f49abbf0a52b0e9d9c033ade58 Jan Allersma 2017-12-09 15:09:38
Also added additional waypoints for 106. 1567c42fbaa689848d2ca2620e37bb83bb30eaf4 Jan Allersma 2017-12-07 13:40:56
Fixed some bugs (See TestResultsSimulator.txt for more info). 7c4466770f8b4da0af1156856a40b32cd11b6d37 Jan Allersma 2017-12-07 13:31:04
Werk van Simulator na testen 05/12/17. 80af7ffb5438b855a2e73fb185ba66c1cd50efe3 Jan Allersma 2017-12-05 09:45:11
Nieuwe plattegrond toegevoegd. b520f51bdd4a4d25e5d1a54cd094cf3b4632a369 Jan Allersma 2017-12-02 14:19:52
More Waypoints! 465108ac6a127bbda26b40989fd6a68cd3e00aad Jan Allersma 2017-11-30 12:52:22
Added voetganger. dad12c3d2eb2a7160838c3495e4a7a2d382e493f Jan Allersma 2017-11-30 12:32:35
Added all waiting waypoints for 1xx. bbba002738e0a26b085673400c76329d3055d8ba Jan Allersma 2017-11-29 12:00:37
Simulation now working correctly for ID's 101, 102 and 103. 1bc2fb65bb75b3a1f63cf7690472152fe1f32564 Jan Allersma 2017-11-28 16:22:53
Autos kunnen gespawned worden en rijden dan de goede richting op. b36ef1cafeda20d5753b72c6f8e6ac8423c42d95 Jan Allersma 2017-11-26 21:44:39
Last changes before test case 5. 258ba4735dfd2078f8e4f034fffed2bbbb086f2a Jan Allersma 2017-11-22 14:08:37
Commit aae977040cd511a72ee3558ac95249edf820f6c9 - hallo
Author: XCBouke
Author date (UTC): 2018-01-10 12:47
Committer name: XCBouke
Committer date (UTC): 2018-01-10 12:47
Parent(s): 7a0518a31a21e7ee0be11bc0966647acae129a94
Signing key:
Tree: a5801e14dcafd408069bbba36781f69518eff31c
File Lines added Lines deleted
Controller/RabbitMq2/src/rabbitmq2/Checker.java 120 11
Controller/RabbitMq2/src/rabbitmq2/Connectie.java 47 36
Controller/RabbitMq2/src/rabbitmq2/CountAdder.java 42 0
Controller/RabbitMq2/src/rabbitmq2/CreateJsonObj.java 127 50
Controller/RabbitMq2/src/rabbitmq2/CreateJsonObj2.java 74 29
Controller/RabbitMq2/src/rabbitmq2/ExclusiveTrain.java 16 0
Controller/RabbitMq2/src/rabbitmq2/RandomUselessSend.java 4 4
Controller/RabbitMq2/src/rabbitmq2/UpdateStatus.java 140 6
File Controller/RabbitMq2/src/rabbitmq2/Checker.java changed (mode: 100644) (index e223f29..aabd77b)
5 5 */ */
6 6 package rabbitmq2; package rabbitmq2;
7 7
8 import java.util.*;
9 import org.json.JSONArray;
10 import org.json.JSONException;
8 11 import org.json.JSONObject; import org.json.JSONObject;
9 12
10 13 /** /**
 
... ... import org.json.JSONObject;
12 15 * @author bouke * @author bouke
13 16 */ */
14 17 public class Checker { public class Checker {
18 HashMap<Integer, List<Integer>> exclusive = new HashMap<Integer, List<Integer>>();
15 19
16 boolean Check = false;
20 boolean Check = true;
17 21
18 public void Check(Integer Id, JSONObject obj){
19 //ugly ugly code yeah
20 /*
21 if(Id == 104)
22
23 public void exclusive(){
24 exclusive.put(101, new ArrayList<Integer>());
25 exclusive.get(101).addAll(Arrays.asList(105,107,201,301,302,303,305,401,402,407,412));
26 exclusive.put(102, new ArrayList<Integer>());
27 exclusive.get(102).addAll(Arrays.asList(105,107,108,109,110,201,302,303,402,407, 501,502,601));
28 exclusive.put(103, new ArrayList<Integer>());
29 exclusive.get(103).addAll(Arrays.asList(105,106,109,110,201,302,303,304,402,405,407,410));
30 exclusive.put(104, new ArrayList<Integer>());
31 exclusive.get(104).addAll(Arrays.asList(106,110,302,303,304,403,404,408,409,201));
32 exclusive.put(105, new ArrayList<Integer>());
33 exclusive.get(105).addAll(Arrays.asList(101,102,103,106,107,110,201,301,304,305,401,404,409,412));
34 exclusive.put(106, new ArrayList<Integer>());
35 exclusive.get(106).addAll(Arrays.asList(103, 104, 105, 109, 110, 302, 303, 403, 408, 201,501,502,601));
36 exclusive.put(107, new ArrayList<Integer>());
37 exclusive.get(107).addAll(Arrays.asList(101, 102, 105, 109, 110, 201, 301, 305, 401, 412,501,502,601));
38 exclusive.put(108, new ArrayList<Integer>());
39 exclusive.get(108).addAll(Arrays.asList(102, 301, 305, 406, 411,501,502,601));
40 exclusive.put(109, new ArrayList<Integer>());
41 exclusive.get(109).addAll(Arrays.asList(102, 103, 106, 107, 301, 304, 305, 405, 406, 410, 411));
42 exclusive.put(110, new ArrayList<Integer>());
43 exclusive.get(110).addAll(Arrays.asList(102, 103, 104, 105, 106, 107, 201, 301, 302, 303, 305, 401, 403, 408, 412));
44 exclusive.put(201, new ArrayList<Integer>());
45 exclusive.get(201).addAll(Arrays.asList(101, 102, 103, 104, 105, 106, 107, 110, 301, 302, 303, 304, 305, 401, 403, 404, 408, 409, 412));
46 exclusive.put(301, new ArrayList<Integer>());
47 exclusive.get(301).addAll(Arrays.asList(101, 105, 107, 108, 109, 110, 201));
48 exclusive.put(302, new ArrayList<Integer>());
49 exclusive.get(302).addAll(Arrays.asList(101, 102, 103, 104, 106, 110, 201));
50 exclusive.put(303, new ArrayList<Integer>());
51 exclusive.get(303).addAll(Arrays.asList(101, 102, 103, 104, 106, 110, 201));
52 exclusive.put(304, new ArrayList<Integer>());
53 exclusive.get(304).addAll(Arrays.asList(104, 105, 103, 109, 201));
54 exclusive.put(305, new ArrayList<Integer>());
55 exclusive.get(305).addAll(Arrays.asList(101, 105, 107, 108, 109, 110, 201));
56 exclusive.put(401, new ArrayList<Integer>());
57 exclusive.get(401).addAll(Arrays.asList(101, 105, 107, 201));
58 exclusive.put(402, new ArrayList<Integer>());
59 exclusive.get(402).addAll(Arrays.asList(101, 102, 103));
60 exclusive.put(403, new ArrayList<Integer>());
61 exclusive.get(403).addAll(Arrays.asList(104, 106, 110, 201));
62 exclusive.put(404, new ArrayList<Integer>());
63 exclusive.get(404).addAll(Arrays.asList(104, 105, 201));
64 exclusive.put(405, new ArrayList<Integer>());
65 exclusive.get(405).addAll(Arrays.asList(103, 109));
66 exclusive.put(406, new ArrayList<Integer>());
67 exclusive.get(406).addAll(Arrays.asList(108, 109, 110));
68 exclusive.put(407, new ArrayList<Integer>());
69 exclusive.get(407).addAll(Arrays.asList(101,102,103));
70 exclusive.put(408, new ArrayList<Integer>());
71 exclusive.get(408).addAll(Arrays.asList(104,106,110,201));
72 exclusive.put(409, new ArrayList<Integer>());
73 exclusive.get(409).addAll(Arrays.asList(104,105,201));
74 exclusive.put(410, new ArrayList<Integer>());
75 exclusive.get(410).addAll(Arrays.asList(103,109));
76 exclusive.put(411, new ArrayList<Integer>());
77 exclusive.get(411).addAll(Arrays.asList(108,109,110));
78 exclusive.put(412, new ArrayList<Integer>());
79 exclusive.get(412).addAll(Arrays.asList(101,105,107,201));
80 exclusive.put(501, new ArrayList<Integer>());
81 exclusive.get(501).addAll(Arrays.asList(102,106,107,108,502));
82 exclusive.put(601, new ArrayList<Integer>());
83 exclusive.get(601).addAll(Arrays.asList(102,106,107,108));
84
85 }
86
87 public void Check(Integer Id, JSONObject obj) throws JSONException {
88 Check = true;
89 JSONArray first = obj.getJSONArray("Lights");
90 exclusive();
91 //System.out.println(Id);
92 //System.out.println(obj);
93 //System.out.println(exclusive);
94 if(Id.equals(501) || Id.equals(502))
22 95 { {
23 96 Check = true; Check = true;
24 97 } }
25 else
26 Check = false;
27 */
28 Check = true;
98
99 else{
100 //check welke stoplichten op groen mogen
101 for (int LightId : exclusive.get(Id)) {
102 for (int i = 0; i < first.length(); i++) {
103 JSONObject itemArr = first.getJSONObject(i);
104
105
106 if(itemArr.get("Id").equals(601) && LightId == 601 && itemArr.get("Status").equals(1) || itemArr.get("Status").equals(0))
107 {
108 Check = false;
109 }
110
111 else if (itemArr.get("Id").equals(LightId) && itemArr.get("Status").equals(1) || itemArr.get("Status").equals(2)) {
112 //System.out.println("waarom kom ik hier");
113 Check = false;
114 //System.out.println("false");
115
116 }
117
118 //if(!itemArr.get("Count").equals(0) || !itemArr.get("Count").equals(1) || !itemArr.get("Count").equals(2) || !itemArr.get("Count").equals(3) && itemArr.get("Id").equals(201))
119 //{
120 // Check = false;
121
122 else {
123 Check = true;
124
125 //System.out.println("true");
126
127 }
128
129 }
130 }
131
29 132 } }
30
31 public boolean getCheck(){
133 }
134 public boolean getCheck(Integer Id) throws InterruptedException{
135 if(Check == true && Id != 501 || Id != 502)
136 {
137 Thread.sleep(3000);
138
139 Check = true;
140 }
32 141 return Check; return Check;
33 142 } }
34 143 } }
File Controller/RabbitMq2/src/rabbitmq2/Connectie.java changed (mode: 100644) (index a4c8070..d9ea37e)
... ... public class Connectie {
28 28 private static Channel channel; private static Channel channel;
29 29 private static Connectie p; private static Connectie p;
30 30 private static Checker C = new Checker(); private static Checker C = new Checker();
31 private final static String host = "localhost";//"141.252.237.90";
31 private final static String host = "141.252.237.84";
32 32 private final static String vhost = "/8"; private final static String vhost = "/8";
33 33 private final CreateJsonObj CJO = new CreateJsonObj(); private final CreateJsonObj CJO = new CreateJsonObj();
34 34 private final CreateJsonObj2 CJO2 = new CreateJsonObj2(); private final CreateJsonObj2 CJO2 = new CreateJsonObj2();
35 35 private UpdateStatus U = new UpdateStatus(); private UpdateStatus U = new UpdateStatus();
36 36 private TrafficParse T = new TrafficParse(); private TrafficParse T = new TrafficParse();
37 private CountAdder CA = new CountAdder();
38 private ExclusiveTrain ET = new ExclusiveTrain();
37 39 private int Count = 0; private int Count = 0;
38 40 private final RandomUselessSend RUS = new RandomUselessSend(); private final RandomUselessSend RUS = new RandomUselessSend();
39 41 private final List<Integer> Ids = new ArrayList<>(); private final List<Integer> Ids = new ArrayList<>();
42 private final List<Integer>Counts = new ArrayList<>();
40 43
41 44 public static Connectie instance() { public static Connectie instance() {
42 45 return p; return p;
 
... ... public class Connectie {
47 50
48 51 Map<String, Object> args = new HashMap<String, Object>(); Map<String, Object> args = new HashMap<String, Object>();
49 52 args.put("x-message-ttl", 10000); args.put("x-message-ttl", 10000);
50 channel.queueDeclare(QUEUE_NAME, false, false, false, args);
51 channel.basicQos(1);
53 channel.queueDeclare(QUEUE_NAME, false, false, true, args);
54
52 55
53 56 Consumer consumer; Consumer consumer;
54 57
 
... ... public class Connectie {
72 75 if (Count == 0) { if (Count == 0) {
73 76 //update de JSONObject met de binnen gekomen message //update de JSONObject met de binnen gekomen message
74 77 check = true; check = true;
75 U.UpdateStatus(CJO.getJSONobj(), T.getLightId(), T.getCount(), T.getDirectionRequests(), check, CJO2.getJSONobj());
78 System.out.println("ik kom hier");
79
80 CA.CountAdder(T.getLightId(), T.getCount(), CJO.getJSONobj());
81
82 /*C.Check(T.getLightId(), CA.getObj());
83 System.out.println(C.getCheck());
84 C.Check(108, CA.getObj());
85 System.out.println(C.getCheck());*/
86 U.UpdateStatus(CA.getObj(), T.getLightId(), T.getCount(), T.getDirectionRequests(), check, CJO2.getJSONobj());
87
76 88 Count++; Count++;
77 89 } else { } else {
78 90 //update de JSONObject met ouwe waardes met de nieuwe //update de JSONObject met ouwe waardes met de nieuwe
79 91 check = true; check = true;
80 Update();
92 CA.CountAdder(T.getLightId(), T.getCount(), U.getFinal());
93 C.Check(T.getLightId(), CA.getObj());
94 System.out.println(C.getCheck(T.getLightId()));
95 if (C.getCheck(T.getLightId()) == true) {
96 U.UpdateStatus(CA.getObj(), T.getLightId(), T.getCount(), T.getDirectionRequests(), true, U.getSecond());
97 }
98 else {
99 Ids.add(T.getLightId());
100 }
101
102
81 103
82 104 } }
83 105 } }
84 106 } catch (JSONException ex) { } catch (JSONException ex) {
85 107 Logger.getLogger(Connectie.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Connectie.class.getName()).log(Level.SEVERE, null, ex);
108 } catch (InterruptedException ex) {
109 Logger.getLogger(Connectie.class.getName()).log(Level.SEVERE, null, ex);
86 110 } }
87 111
88 112 } }
 
... ... public class Connectie {
91 115
92 116 } }
93 117
94 public void Update() throws JSONException {
95
96 C.Check(T.getLightId(),U.getFinal());
97
98 if (C.getCheck() == true) {
99 U.UpdateStatus(U.getFinal(), T.getLightId(), T.getCount(), T.getDirectionRequests(), true, U.getSecond());
100
101 } else {
102 Ids.add(T.getLightId());
103 }
104
105 }
118
106 119
107 public void CheckLoop() throws JSONException{
108 if(!Ids.isEmpty());
120 public void CheckLoop() throws JSONException, InterruptedException{
121 while(!Ids.isEmpty());
109 122 { {
110 123 for (int i = 0; i < Ids.size(); i++) { for (int i = 0; i < Ids.size(); i++) {
111 124
112 125
113 126 Integer Id = Ids.get(i); Integer Id = Ids.get(i);
114 127 C.Check(Id, U.getFinal()); C.Check(Id, U.getFinal());
115 if (C.getCheck() == true) {
128 if (C.getCheck(T.getLightId()) == true) {
116 129 U.UpdateStatus(U.getFinal(), Id, T.getCount(), T.getDirectionRequests(), true, U.getSecond()); U.UpdateStatus(U.getFinal(), Id, T.getCount(), T.getDirectionRequests(), true, U.getSecond());
117 130 Ids.remove(i); Ids.remove(i);
118 131 } }
 
... ... public class Connectie {
128 141
129 142 Map<String, Object> hallo = new HashMap<String, Object>(); Map<String, Object> hallo = new HashMap<String, Object>();
130 143 hallo.put("x-message-ttl", 10000); hallo.put("x-message-ttl", 10000);
131 channel.queueDeclare(QUEUE_NAME, false,false,false,hallo);
144 channel.queueDeclare("simulator", false,false,true,hallo);
132 145
133 146
134 147 //stuurt steeds per seconde de momentele Status naar simulator //stuurt steeds per seconde de momentele Status naar simulator
135 148 while (true) { while (true) {
136 149 if (U.getFinal() == null) { if (U.getFinal() == null) {
137 testChannel.basicPublish("", QUEUE_NAME, null, obj2.toString().getBytes("UTF-8"));
138 System.out.println(" [x] Sent1 '" + obj.toString() + "'");
150 testChannel.basicPublish("", "simulator", null, obj.toString().getBytes("UTF-8"));
151 //System.out.println(" [x] Sent1 '" + obj.toString() + "'");
139 152 //testChannel.queueDelete(QUEUE_NAME); //testChannel.queueDelete(QUEUE_NAME);
140 153
141 154 } else { } else {
142 155
143 testChannel.basicPublish("", QUEUE_NAME, null, U.getSecond().toString().getBytes("UTF-8"));
144 System.out.println(" [x] Sent2 '" + U.getSecond().toString() + "'");
156
157
158
159 testChannel.basicPublish("", "simulator", null, U.getSecond().toString().getBytes("UTF-8"));
160 //System.out.println(" [x] Sent2 '" + U.getFinal().toString() + "'");
145 161 //testChannel.queueDelete(QUEUE_NAME); //testChannel.queueDelete(QUEUE_NAME);
146 162 U.UpdateStatus(U.getFinal(), T.getLightId(), T.getCount(), T.getDirectionRequests(), U.check, U.getSecond()); U.UpdateStatus(U.getFinal(), T.getLightId(), T.getCount(), T.getDirectionRequests(), U.check, U.getSecond());
147 CheckLoop();
148 //System.out.println(U.getFinal());
163
149 164 } }
150 165 Thread.sleep(1000); Thread.sleep(1000);
151 166
 
... ... public class Connectie {
158 173 public static void main(String[] args) throws IOException, TimeoutException, JSONException, InterruptedException { public static void main(String[] args) throws IOException, TimeoutException, JSONException, InterruptedException {
159 174 //host connectie info //host connectie info
160 175 factory.setHost(host); factory.setHost(host);
161 /*
176
162 177 factory.setVirtualHost(vhost); factory.setVirtualHost(vhost);
163 178 factory.setUsername("softdev"); factory.setUsername("softdev");
164 179 factory.setPassword("softdev"); factory.setPassword("softdev");
165 */
180
166 181 try { try {
167 182 //roept reciever class en loop class aan //roept reciever class en loop class aan
168 183 connection = factory.newConnection(); connection = factory.newConnection();
169 184 p = new Connectie(); p = new Connectie();
185 instance().Loop();
186 //instance().CheckLoop();
170 187
171 188 } catch (Exception ex) { } catch (Exception ex) {
172 189 ex.printStackTrace(); ex.printStackTrace();
173 190 System.exit(1); System.exit(1);
174 191 } }
175 try{
176 instance().Loop();
177 }
178 catch (Exception ex) {
179 ex.printStackTrace();
180 System.exit(1);
181 }
192
182 193
183 194 } }
184 195 } }
File Controller/RabbitMq2/src/rabbitmq2/CountAdder.java added (mode: 100644) (index 0000000..6ba2ac1)
1 /*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6 package rabbitmq2;
7
8 import org.json.JSONArray;
9 import org.json.JSONException;
10 import org.json.JSONObject;
11
12 /**
13 *
14 * @author bouke
15 */
16 public class CountAdder {
17 private JSONObject obj123;
18 public void CountAdder(Integer Id,Integer Count, JSONObject obj) throws JSONException{
19 JSONArray first = obj.getJSONArray("Lights");
20
21 for (int i = 0; i < first.length(); i++) {
22 JSONObject itemArr = first.getJSONObject(i);
23
24 if(itemArr.get("Id").equals(601) && Id == 502)
25 {
26
27 itemArr.put("Count", Count);
28 }
29 if(itemArr.get("Id").equals(Id))
30 {
31 itemArr.put("Count", Count);
32 }
33 }
34 obj123 = new JSONObject();
35 this.obj123.put("Lights", first);
36 }
37
38
39 public JSONObject getObj(){
40 return obj123;
41 }
42 }
File Controller/RabbitMq2/src/rabbitmq2/CreateJsonObj.java changed (mode: 100644) (index 29857c8..359dbe4)
5 5 */ */
6 6 package rabbitmq2; package rabbitmq2;
7 7
8 import java.util.HashMap;
8
9 import java.util.LinkedHashMap;
9 10 import org.json.JSONArray; import org.json.JSONArray;
10 11 import org.json.JSONException; import org.json.JSONException;
11 12 import org.json.JSONObject; import org.json.JSONObject;
 
... ... import org.json.JSONObject;
17 18 public class CreateJsonObj { public class CreateJsonObj {
18 19 private JSONArray obj = new JSONArray(); private JSONArray obj = new JSONArray();
19 20 private JSONObject JSONobj = new JSONObject(); private JSONObject JSONobj = new JSONObject();
20 private HashMap rows = new HashMap();
21 private LinkedHashMap rows = new LinkedHashMap();
21 22
22 23 public CreateJsonObj() throws JSONException{ public CreateJsonObj() throws JSONException{
23 24 rows.put("Id",101); rows.put("Id",101);
24 25 rows.put("Status", 0); rows.put("Status", 0);
25 rows.put("Time", -1 );
26 rows.put("Time", 20 );
27 rows.put("Count", 0);
26 28 obj.put(rows); obj.put(rows);
27 29 JSONobj.put("Lights",obj); JSONobj.put("Lights",obj);
28 30
29 rows = new HashMap();
31 rows = new LinkedHashMap();
30 32 rows.put("Id",102); rows.put("Id",102);
31 33 rows.put("Status", 0); rows.put("Status", 0);
32 rows.put("Time", -1);
34 rows.put("Time", 20);
35 rows.put("Count", 0);
33 36 obj.put(rows); obj.put(rows);
34 37 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
35 38
36 rows = new HashMap();
39 rows = new LinkedHashMap();
37 40 rows.put("Id",103); rows.put("Id",103);
38 41 rows.put("Status", 0); rows.put("Status", 0);
39 rows.put("Time", -1);
42 rows.put("Time", 20);
43 rows.put("Count", 0);
40 44 obj.put(rows); obj.put(rows);
41 45 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
42 46
43 rows = new HashMap();
47 rows = new LinkedHashMap();
44 48 rows.put("Id",104); rows.put("Id",104);
45 49 rows.put("Status", 0); rows.put("Status", 0);
46 rows.put("Time", -1);
50 rows.put("Time", 20);
51 rows.put("Count", 0);
47 52 obj.put(rows); obj.put(rows);
48 53 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
49 54
50 rows = new HashMap();
55 rows = new LinkedHashMap();
51 56 rows.put("Id",105); rows.put("Id",105);
52 57 rows.put("Status", 0); rows.put("Status", 0);
53 rows.put("Time", -1);
58 rows.put("Time", 20);
59 rows.put("Count", 0);
54 60 obj.put(rows); obj.put(rows);
55 61 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
56 62
57 rows = new HashMap();
63 rows = new LinkedHashMap();
58 64 rows.put("Id",106); rows.put("Id",106);
59 65 rows.put("Status", 0); rows.put("Status", 0);
60 rows.put("Time", -1);
66 rows.put("Time", 20);
67 rows.put("Count", 0);
61 68 obj.put(rows); obj.put(rows);
62 69 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
63 70
64 rows = new HashMap();
71 rows = new LinkedHashMap();
65 72 rows.put("Id",107); rows.put("Id",107);
66 73 rows.put("Status", 0); rows.put("Status", 0);
67 rows.put("Time", -1);
74 rows.put("Time", 20);
75 rows.put("Count", 0);
68 76 obj.put(rows); obj.put(rows);
69 77 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
70 78
71 rows = new HashMap();
79 rows = new LinkedHashMap();
72 80 rows.put("Id",108); rows.put("Id",108);
73 81 rows.put("Status", 0); rows.put("Status", 0);
74 rows.put("Time", -1);
82 rows.put("Time", 20);
83 rows.put("Count", 0);
75 84 obj.put(rows); obj.put(rows);
76 85 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
77 86
78 rows = new HashMap();
87 rows = new LinkedHashMap();
79 88 rows.put("Id",109); rows.put("Id",109);
80 89 rows.put("Status", 0); rows.put("Status", 0);
81 rows.put("Time", -1);
90 rows.put("Time", 20);
91 rows.put("Count", 0);
82 92 obj.put(rows); obj.put(rows);
83 93 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
84 94
85 rows = new HashMap();
95 rows = new LinkedHashMap();
86 96 rows.put("Id",110); rows.put("Id",110);
87 97 rows.put("Status", 0); rows.put("Status", 0);
88 rows.put("Time", -1);
98 rows.put("Time", 20);
99 rows.put("Count", 0);
89 100 obj.put(rows); obj.put(rows);
90 101 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
91 102
92 rows = new HashMap();
103 rows = new LinkedHashMap();
93 104 rows.put("Id",201); rows.put("Id",201);
94 105 rows.put("Status", 0); rows.put("Status", 0);
95 rows.put("Time", -1);
106 rows.put("Time", 20);
107 rows.put("Count", 0);
96 108 obj.put(rows); obj.put(rows);
97 109 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
98 110
99 rows = new HashMap();
111 rows = new LinkedHashMap();
100 112 rows.put("Id",301); rows.put("Id",301);
101 113 rows.put("Status", 0); rows.put("Status", 0);
102 rows.put("Time", -1);
114 rows.put("Time", 20);
115 rows.put("Count", 0);
103 116 obj.put(rows); obj.put(rows);
104 117 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
105 118
106 rows = new HashMap();
119 rows = new LinkedHashMap();
107 120 rows.put("Id",302); rows.put("Id",302);
108 121 rows.put("Status", 0); rows.put("Status", 0);
109 rows.put("Time", -1);
122 rows.put("Time", 20);
123 rows.put("Count", 0);
110 124 obj.put(rows); obj.put(rows);
111 125 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
112 126
113 rows = new HashMap();
127 rows = new LinkedHashMap();
114 128 rows.put("Id",303); rows.put("Id",303);
115 129 rows.put("Status", 0); rows.put("Status", 0);
116 rows.put("Time", -1);
130 rows.put("Time", 20);
131 rows.put("Count", 0);
117 132 obj.put(rows); obj.put(rows);
118 133 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
119 134
120 rows = new HashMap();
135 rows = new LinkedHashMap();
121 136 rows.put("Id",304); rows.put("Id",304);
122 137 rows.put("Status", 0); rows.put("Status", 0);
123 rows.put("Time", -1);
138 rows.put("Time", 20);
139 rows.put("Count", 0);
124 140 obj.put(rows); obj.put(rows);
125 141 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
126 142
127 rows = new HashMap();
143 rows = new LinkedHashMap();
128 144 rows.put("Id",305); rows.put("Id",305);
129 145 rows.put("Status", 0); rows.put("Status", 0);
130 rows.put("Time", -1);
146 rows.put("Time", 20);
147 rows.put("Count", 0);
131 148 obj.put(rows); obj.put(rows);
132 149 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
133 150
134 rows = new HashMap();
151 rows = new LinkedHashMap();
135 152 rows.put("Id",401); rows.put("Id",401);
136 153 rows.put("Status", 0); rows.put("Status", 0);
137 rows.put("Time", -1);
154 rows.put("Time", 20);
155 rows.put("Count", 0);
138 156 obj.put(rows); obj.put(rows);
139 157 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
140 158
141 rows = new HashMap();
159 rows = new LinkedHashMap();
142 160 rows.put("Id",402); rows.put("Id",402);
143 161 rows.put("Status", 0); rows.put("Status", 0);
144 rows.put("Time", -1);
162 rows.put("Time", 20);
163 rows.put("Count", 0);
145 164 obj.put(rows); obj.put(rows);
146 165 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
147 166
148 rows = new HashMap();
167 rows = new LinkedHashMap();
149 168 rows.put("Id",403); rows.put("Id",403);
150 169 rows.put("Status", 0); rows.put("Status", 0);
151 rows.put("Time", -1);
170 rows.put("Time", 20);
171 rows.put("Count", 0);
152 172 obj.put(rows); obj.put(rows);
153 173 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
154 174
155 rows = new HashMap();
175 rows = new LinkedHashMap();
156 176 rows.put("Id",404); rows.put("Id",404);
157 177 rows.put("Status", 0); rows.put("Status", 0);
158 rows.put("Time", -1);
178 rows.put("Time", 20);
179 rows.put("Count", 0);
159 180 obj.put(rows); obj.put(rows);
160 181 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
161 182
162 rows = new HashMap();
183 rows = new LinkedHashMap();
163 184 rows.put("Id",405); rows.put("Id",405);
164 185 rows.put("Status", 0); rows.put("Status", 0);
165 rows.put("Time", -1);
186 rows.put("Time", 20);
187 rows.put("Count", 0);
166 188 obj.put(rows); obj.put(rows);
167 189 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
168 190
169 rows = new HashMap();
191 rows = new LinkedHashMap();
170 192 rows.put("Id",406); rows.put("Id",406);
171 193 rows.put("Status", 0); rows.put("Status", 0);
172 rows.put("Time", -1);
194 rows.put("Time", 20);
195 rows.put("Count", 0);
196 obj.put(rows);
197 JSONobj.put("Lights", obj);
198
199 rows = new LinkedHashMap();
200 rows.put("Id",407);
201 rows.put("Status", 0);
202 rows.put("Time", 20);
203 rows.put("Count", 0);
204 obj.put(rows);
205 JSONobj.put("Lights", obj);
206
207 rows = new LinkedHashMap();
208 rows.put("Id",408);
209 rows.put("Status", 0);
210 rows.put("Time", 20);
211 rows.put("Count", 0);
212 obj.put(rows);
213 JSONobj.put("Lights", obj);
214
215 rows = new LinkedHashMap();
216 rows.put("Id",409);
217 rows.put("Status", 0);
218 rows.put("Time", 20);
219 rows.put("Count", 0);
220 obj.put(rows);
221 JSONobj.put("Lights", obj);
222
223 rows = new LinkedHashMap();
224 rows.put("Id",410);
225 rows.put("Status", 0);
226 rows.put("Time", 20);
227 rows.put("Count", 0);
228 obj.put(rows);
229 JSONobj.put("Lights", obj);
230
231 rows = new LinkedHashMap();
232 rows.put("Id",411);
233 rows.put("Status", 0);
234 rows.put("Time", 20);
235 rows.put("Count", 0);
173 236 obj.put(rows); obj.put(rows);
174 237 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
175 238
176 rows = new HashMap();
239 rows = new LinkedHashMap();
240 rows.put("Id",412);
241 rows.put("Status", 0);
242 rows.put("Time", 20);
243 rows.put("Count", 0);
244 obj.put(rows);
245 JSONobj.put("Lights", obj);
246
247 rows = new LinkedHashMap();
177 248 rows.put("Id",501); rows.put("Id",501);
178 249 rows.put("Status", 0); rows.put("Status", 0);
179 rows.put("Time", -1);
250 rows.put("Time", 20);
251 rows.put("Count", 0);
180 252 obj.put(rows); obj.put(rows);
181 253 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
182 254
183 rows = new HashMap();
255
256
257
258 rows = new LinkedHashMap();
184 259 rows.put("Id",601); rows.put("Id",601);
185 rows.put("Status", 0);
186 rows.put("Time", -1);
260 rows.put("Status", 2);
261 rows.put("Time",1000);
262 rows.put("Count", 0);
187 263 obj.put(rows); obj.put(rows);
188 264 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
189 265
190 266
191 267
192 268 } }
269
193 270 public JSONObject getJSONobj(){ public JSONObject getJSONobj(){
194 271 return JSONobj; return JSONobj;
195 272 } }
File Controller/RabbitMq2/src/rabbitmq2/CreateJsonObj2.java changed (mode: 100644) (index e9c6707..1786e3d)
5 5 */ */
6 6 package rabbitmq2; package rabbitmq2;
7 7
8 import java.util.HashMap;
8 import java.util.LinkedHashMap;
9 9 import org.json.JSONArray; import org.json.JSONArray;
10 10 import org.json.JSONException; import org.json.JSONException;
11 11 import org.json.JSONObject; import org.json.JSONObject;
 
... ... import org.json.JSONObject;
15 15 * @author bouke * @author bouke
16 16 */ */
17 17 public class CreateJsonObj2 { public class CreateJsonObj2 {
18 private JSONArray obj = new JSONArray();
19 private JSONObject JSONobj = new JSONObject();
20 private HashMap rows = new HashMap();
18 private final JSONArray obj = new JSONArray();
19 private final JSONObject JSONobj = new JSONObject();
20 private LinkedHashMap rows = new LinkedHashMap();
21 21
22 22 public CreateJsonObj2() throws JSONException{ public CreateJsonObj2() throws JSONException{
23 23 rows.put("Id",101); rows.put("Id",101);
 
... ... public class CreateJsonObj2 {
26 26 obj.put(rows); obj.put(rows);
27 27 JSONobj.put("Lights",obj); JSONobj.put("Lights",obj);
28 28
29 rows = new HashMap();
29 rows = new LinkedHashMap();
30 30 rows.put("Id",102); rows.put("Id",102);
31 31 rows.put("Status", 0); rows.put("Status", 0);
32 32 rows.put("Time", -1); rows.put("Time", -1);
33 33 obj.put(rows); obj.put(rows);
34 34 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
35 35
36 rows = new HashMap();
36 rows = new LinkedHashMap();
37 37 rows.put("Id",103); rows.put("Id",103);
38 38 rows.put("Status", 0); rows.put("Status", 0);
39 39 rows.put("Time", -1); rows.put("Time", -1);
40 40 obj.put(rows); obj.put(rows);
41 41 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
42 42
43 rows = new HashMap();
43 rows = new LinkedHashMap();
44 44 rows.put("Id",104); rows.put("Id",104);
45 45 rows.put("Status", 0); rows.put("Status", 0);
46 46 rows.put("Time", -1); rows.put("Time", -1);
47 47 obj.put(rows); obj.put(rows);
48 48 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
49 49
50 rows = new HashMap();
50 rows = new LinkedHashMap();
51 51 rows.put("Id",105); rows.put("Id",105);
52 52 rows.put("Status", 0); rows.put("Status", 0);
53 53 rows.put("Time", -1); rows.put("Time", -1);
54 54 obj.put(rows); obj.put(rows);
55 55 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
56 56
57 rows = new HashMap();
57 rows = new LinkedHashMap();
58 58 rows.put("Id",106); rows.put("Id",106);
59 59 rows.put("Status", 0); rows.put("Status", 0);
60 60 rows.put("Time", -1); rows.put("Time", -1);
61 61 obj.put(rows); obj.put(rows);
62 62 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
63 63
64 rows = new HashMap();
64 rows = new LinkedHashMap();
65 65 rows.put("Id",107); rows.put("Id",107);
66 66 rows.put("Status", 0); rows.put("Status", 0);
67 67 rows.put("Time", -1); rows.put("Time", -1);
68 68 obj.put(rows); obj.put(rows);
69 69 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
70 70
71 rows = new HashMap();
71 rows = new LinkedHashMap();
72 72 rows.put("Id",108); rows.put("Id",108);
73 73 rows.put("Status", 0); rows.put("Status", 0);
74 74 rows.put("Time", -1); rows.put("Time", -1);
75 75 obj.put(rows); obj.put(rows);
76 76 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
77 77
78 rows = new HashMap();
78 rows = new LinkedHashMap();
79 79 rows.put("Id",109); rows.put("Id",109);
80 80 rows.put("Status", 0); rows.put("Status", 0);
81 81 rows.put("Time", -1); rows.put("Time", -1);
82 82 obj.put(rows); obj.put(rows);
83 83 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
84 84
85 rows = new HashMap();
85 rows = new LinkedHashMap();
86 86 rows.put("Id",110); rows.put("Id",110);
87 87 rows.put("Status", 0); rows.put("Status", 0);
88 88 rows.put("Time", -1); rows.put("Time", -1);
89 89 obj.put(rows); obj.put(rows);
90 90 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
91 91
92 rows = new HashMap();
92 rows = new LinkedHashMap();
93 93 rows.put("Id",201); rows.put("Id",201);
94 94 rows.put("Status", 0); rows.put("Status", 0);
95 95 rows.put("Time", -1); rows.put("Time", -1);
96 96 obj.put(rows); obj.put(rows);
97 97 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
98 98
99 rows = new HashMap();
99 rows = new LinkedHashMap();
100 100 rows.put("Id",301); rows.put("Id",301);
101 101 rows.put("Status", 0); rows.put("Status", 0);
102 102 rows.put("Time", -1); rows.put("Time", -1);
103 103 obj.put(rows); obj.put(rows);
104 104 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
105 105
106 rows = new HashMap();
106 rows = new LinkedHashMap();
107 107 rows.put("Id",302); rows.put("Id",302);
108 108 rows.put("Status", 0); rows.put("Status", 0);
109 109 rows.put("Time", -1); rows.put("Time", -1);
110 110 obj.put(rows); obj.put(rows);
111 111 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
112 112
113 rows = new HashMap();
113 rows = new LinkedHashMap();
114 114 rows.put("Id",303); rows.put("Id",303);
115 115 rows.put("Status", 0); rows.put("Status", 0);
116 116 rows.put("Time", -1); rows.put("Time", -1);
117 117 obj.put(rows); obj.put(rows);
118 118 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
119 119
120 rows = new HashMap();
120 rows = new LinkedHashMap();
121 121 rows.put("Id",304); rows.put("Id",304);
122 122 rows.put("Status", 0); rows.put("Status", 0);
123 123 rows.put("Time", -1); rows.put("Time", -1);
124 124 obj.put(rows); obj.put(rows);
125 125 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
126 126
127 rows = new HashMap();
127 rows = new LinkedHashMap();
128 128 rows.put("Id",305); rows.put("Id",305);
129 129 rows.put("Status", 0); rows.put("Status", 0);
130 130 rows.put("Time", -1); rows.put("Time", -1);
131 131 obj.put(rows); obj.put(rows);
132 132 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
133 133
134 rows = new HashMap();
134 rows = new LinkedHashMap();
135 135 rows.put("Id",401); rows.put("Id",401);
136 136 rows.put("Status", 0); rows.put("Status", 0);
137 137 rows.put("Time", -1); rows.put("Time", -1);
138 138 obj.put(rows); obj.put(rows);
139 139 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
140 140
141 rows = new HashMap();
141 rows = new LinkedHashMap();
142 142 rows.put("Id",402); rows.put("Id",402);
143 143 rows.put("Status", 0); rows.put("Status", 0);
144 144 rows.put("Time", -1); rows.put("Time", -1);
145 145 obj.put(rows); obj.put(rows);
146 146 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
147 147
148 rows = new HashMap();
148 rows = new LinkedHashMap();
149 149 rows.put("Id",403); rows.put("Id",403);
150 150 rows.put("Status", 0); rows.put("Status", 0);
151 151 rows.put("Time", -1); rows.put("Time", -1);
152 152 obj.put(rows); obj.put(rows);
153 153 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
154 154
155 rows = new HashMap();
155 rows = new LinkedHashMap();
156 156 rows.put("Id",404); rows.put("Id",404);
157 157 rows.put("Status", 0); rows.put("Status", 0);
158 158 rows.put("Time", -1); rows.put("Time", -1);
159 159 obj.put(rows); obj.put(rows);
160 160 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
161 161
162 rows = new HashMap();
162 rows = new LinkedHashMap();
163 163 rows.put("Id",405); rows.put("Id",405);
164 164 rows.put("Status", 0); rows.put("Status", 0);
165 165 rows.put("Time", -1); rows.put("Time", -1);
166 166 obj.put(rows); obj.put(rows);
167 167 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
168 168
169 rows = new HashMap();
169 rows = new LinkedHashMap();
170 170 rows.put("Id",406); rows.put("Id",406);
171 171 rows.put("Status", 0); rows.put("Status", 0);
172 172 rows.put("Time", -1); rows.put("Time", -1);
173 173 obj.put(rows); obj.put(rows);
174 174 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
175 175
176 rows = new HashMap();
177 rows.put("Id",501);
176 rows = new LinkedHashMap();
177 rows.put("Id",407);
178 178 rows.put("Status", 0); rows.put("Status", 0);
179 179 rows.put("Time", -1); rows.put("Time", -1);
180 180 obj.put(rows); obj.put(rows);
181 181 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
182 182
183 rows = new HashMap();
184 rows.put("Id",601);
183 rows = new LinkedHashMap();
184 rows.put("Id",408);
185 rows.put("Status", 0);
186 rows.put("Time", -1);
187 obj.put(rows);
188 JSONobj.put("Lights", obj);
189
190 rows = new LinkedHashMap();
191 rows.put("Id",409);
192 rows.put("Status", 0);
193 rows.put("Time", -1);
194 obj.put(rows);
195 JSONobj.put("Lights", obj);
196
197 rows = new LinkedHashMap();
198 rows.put("Id",410);
199 rows.put("Status", 0);
200 rows.put("Time", -1);
201 obj.put(rows);
202 JSONobj.put("Lights", obj);
203
204 rows = new LinkedHashMap();
205 rows.put("Id",411);
185 206 rows.put("Status", 0); rows.put("Status", 0);
186 207 rows.put("Time", -1); rows.put("Time", -1);
187 208 obj.put(rows); obj.put(rows);
188 209 JSONobj.put("Lights", obj); JSONobj.put("Lights", obj);
189 210
211 rows = new LinkedHashMap();
212 rows.put("Id",412);
213 rows.put("Status", 0);
214 rows.put("Time", -1);
215 obj.put(rows);
216 JSONobj.put("Lights", obj);
217
218 rows = new LinkedHashMap();
219 rows.put("Id",501);
220 rows.put("Status", 0);
221 rows.put("Time", -1);
222 obj.put(rows);
223 JSONobj.put("Lights", obj);
224
225
226
227 rows = new LinkedHashMap();
228 rows.put("Id",601);
229 rows.put("Status", 2);
230 rows.put("Time", -1);
231 obj.put(rows);
232 JSONobj.put("Lights", obj);
233
234 System.out.println(JSONobj);
190 235
191 236
192 237 } }
File Controller/RabbitMq2/src/rabbitmq2/ExclusiveTrain.java added (mode: 100644) (index 0000000..6f04897)
1 /*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6 package rabbitmq2;
7
8 /**
9 *
10 * @author bouke
11 */
12 public class ExclusiveTrain {
13 public void ExclusiveTrain(Integer Id){
14
15 }
16 }
File Controller/RabbitMq2/src/rabbitmq2/RandomUselessSend.java changed (mode: 100644) (index dd96367..139dd80)
... ... public class RandomUselessSend {
22 22 JSONObject test3 = new JSONObject(); JSONObject test3 = new JSONObject();
23 23
24 24
25 test1.put("LightId",104);
26 test1.put("Count", 3);
27 int[] hoi = {2};
28 test1.put("DirectionRequests", test3.NULL); //test3.NULL);
25 test1.put("LightId",502);
26 test1.put("Count", 2);
27 int[] hoi = {4,2,4};
28 test1.put("DirectionRequests",test3.NULL); //test3.NULL);
29 29 test2.put("TrafficUpdate", test1); test2.put("TrafficUpdate", test1);
30 30
31 31
File Controller/RabbitMq2/src/rabbitmq2/UpdateStatus.java changed (mode: 100644) (index 95c9440..673adc9)
... ... public class UpdateStatus {
17 17
18 18 private JSONObject Final; private JSONObject Final;
19 19 private JSONObject Second; private JSONObject Second;
20 private boolean Train;
20 21 public boolean check; public boolean check;
21
22 public void UpdateStatus(JSONObject obj, Integer LightId, Integer Count, Object DirectionRequests, Boolean check, JSONObject obj2) throws JSONException {
22 boolean vijf01 = false;
23 boolean vijf02 = false;
24 public void UpdateStatus(JSONObject obj, Integer LightId, Integer Count, JSONArray DirectionRequests, Boolean check, JSONObject obj2) throws JSONException {
23 25 JSONArray first = obj.getJSONArray("Lights"); JSONArray first = obj.getJSONArray("Lights");
24 26 JSONArray second = obj2.getJSONArray("Lights"); JSONArray second = obj2.getJSONArray("Lights");
25 27 //JSONArray second = obj2.getJSONArray("Lights"); //JSONArray second = obj2.getJSONArray("Lights");
26 28 //System.out.println(Count2); //System.out.println(Count2);
27 29 //Count2+=1; //Count2+=1;
28
30
29 31 for (int i = 0; i < first.length(); i++) { for (int i = 0; i < first.length(); i++) {
30 32 JSONObject itemArr = first.getJSONObject(i); JSONObject itemArr = first.getJSONObject(i);
31 33 JSONObject itemArr2 = second.getJSONObject(i); JSONObject itemArr2 = second.getJSONObject(i);
32 34 Integer Time = first.getJSONObject(i).getInt("Time"); Integer Time = first.getJSONObject(i).getInt("Time");
35 Integer Count1 = first.getJSONObject(i).getInt("Count");
33 36 Time = Time + 1; Time = Time + 1;
34 37 itemArr.put("Time", Time); itemArr.put("Time", Time);
35 if (itemArr.get("Id").equals(LightId) && itemArr.get("Status").equals(0) && check == true) {
38
39 //wanneer je een trein binnen krijgt zet tijd op 998 en begint met tellen
40 if(itemArr.get("Id").equals(601) && (LightId == 502 || LightId == 501) && check == true && Count!= 0)
41 {
42 if(LightId == 501)
43 {
44 if (vijf02 == false)
45 {
46 System.out.println("TREIN");
47 itemArr.put("Time", 998);
48 itemArr.put("Status", 1);
49 }
50 vijf01 = true;
51 }
52 if(LightId == 502)
53 {
54 if(vijf01 == false)
55 {
56 System.out.println("TREIN");
57 itemArr.put("Time", 998);
58 itemArr.put("Status", 1);
59 }
60 //Count1+=1;
61
62 System.out.println(Count1);
63 vijf02 = true;
64
65 }
66 Train = true;
67 check = false;
68
69 }
70 //zorgt ervoor dat de tijd bij 501 ook begint te tellen als er een trein 501 is
71 else if(itemArr.get("Id").equals(501) && LightId == 501 && check == true && Count!= 0)
72 {
73 itemArr.put("Time", 998);
74 }
75 //voor system om te weten dat die moet beginnen met stoppen van bepaalde stoplichten
76 /*else if(Train == true && itemArr.get("Id").equals(601) && itemArr.get("Time").equals(1000))
77 {
78
79 }*/
80 //Systeem begint met het door geven van dalen van treinpalen
81 else if(Train == true && itemArr.get("Id").equals(601) && itemArr.get("Time").equals(1008))
82 {
83 itemArr.put("Status", 0);
84 itemArr2.put("Status", 0);
85
86 }
87 //als er geen 502 trein aankomt laat trein 501 rijden
88 else if(Train == true && itemArr.get("Id").equals(501) && itemArr.get("Time").equals(1020) && vijf02 == false)
89 {
90 itemArr.put("Status", 2);
91 itemArr2.put("Status", 2);
92 itemArr.put("Count", 0);
93 vijf01 = false;
94
95 }
96 else if(Train == true && itemArr.get("Id").equals(601) && itemArr.get("Time").equals(1020) && vijf02 == true)
97 {
98 System.out.print(Count1);
99 if(Count1 == 0)
100 {
101 vijf02 = false;
102
103 }
104 else{
105 //Count1 = Count1 - 1;
106
107 itemArr.put("Time", 1019);
108 itemArr2.put("Time", 1019);
109 }
110
111 }
112 else if(Train == true && itemArr.get("Id").equals(501) && itemArr.get("Time").equals(1020) && vijf02 == true)
113 {
114 System.out.print(Count1);
115 if(Count1 == 0)
116 {
117 vijf02 = false;
118
119 }
120 else{
121
122 itemArr.put("Time", 10019);
123 itemArr2.put("Time", 10019);
124 }
125 }
126 else if(Train == true && itemArr.get("Id").equals(501) && vijf01 == false && itemArr.get("Time").equals(1022))
127 {
128 itemArr.put("Status", 0);
129 itemArr2.put("Status", 0);
130 }
131
132 else if(Train == true && itemArr.get("Id").equals(601) && itemArr.get("Time").equals(1040) && vijf02 == false && vijf01 == false)
133 {
134 itemArr.put("Status", 1);
135 itemArr2.put("Status", 2);
136 }
137 else if(Train == true && itemArr.get("Id").equals(601) && itemArr.get("Time").equals(1052) && itemArr.get("Status").equals(1))
138 {
139 itemArr.put("Status", 2);
140 Train = false;
141 }
142
143 //als er een 502 is dan pruts pruts pruts
144 //1017 status van vijf01 op groen als er geen 502 is
145 //check of trein aankomt
146
147
148 else if(itemArr.get("Id").equals(201) && itemArr.get("Id").equals(LightId) && check == true && (Time > 19) && !itemArr.get("Count").equals(0))
149 {
150 itemArr.put("Status", DirectionRequests.get(0));
151 itemArr2.put("Status", DirectionRequests.get(0));
152 DirectionRequests.remove(0);
153 System.out.println(DirectionRequests);
154 itemArr.put("Time", 0);
155 itemArr.put("Count", 0);
156 check = false;
157
158 }
159 else if (itemArr.get("Id").equals(LightId) && (Time > 19) && itemArr.get("Status").equals(0) && check == true && (!itemArr.get("Count").equals(0))) {
36 160
161
162 System.out.println("ik kom hier");
37 163 itemArr.put("Status", 2); itemArr.put("Status", 2);
38 164 itemArr2.put("Status", 2); itemArr2.put("Status", 2);
39 165 itemArr.put("Time", 0); itemArr.put("Time", 0);
166 itemArr.put("Count", 0);
40 167 check = false; check = false;
41 168
42 } else if (itemArr.get("Time").equals(10) && itemArr.get("Status").equals(2)) {
169 }
170
171 else if (itemArr.get("Time").equals(8) && (itemArr.get("Status").equals(2) || itemArr.get("Status").equals(4)) && !itemArr.get("Id").equals(601)) {
43 172 itemArr.put("Status", 1); itemArr.put("Status", 1);
44 173 itemArr2.put("Status", 1); itemArr2.put("Status", 1);
45 } else if (itemArr.get("Time").equals(15) && itemArr.get("Status").equals(1)) {
174 } else if (itemArr.get("Time").equals(11) && itemArr.get("Status").equals(1) && !itemArr.get("Id").equals(601)) {
46 175 itemArr.put("Status", 0); itemArr.put("Status", 0);
47 176 itemArr2.put("Status", 0); itemArr2.put("Status", 0);
48 177 } }
 
... ... public class UpdateStatus {
56 185 this.check = check; this.check = check;
57 186
58 187 } }
188
189
59 190
60 191 public JSONObject getFinal() { public JSONObject getFinal() {
61 192
 
... ... public class UpdateStatus {
66 197 public JSONObject getSecond() { public JSONObject getSecond() {
67 198 return Second; return Second;
68 199 } }
200 public boolean getTrain(){
201 return Train;
202 }
69 203 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-SoftDev

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main