Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public synchronized int[][] getInformationOfTLsDetectors(String id) {
- int indexOfCrossing = 0;
- for (; indexOfCrossing < listOfCrossingsWithTLsIds.length; indexOfCrossing++) {
- if (listOfCrossingsWithTLsIds[indexOfCrossing].equals(id)) {
- break;
- }
- }
- if (indexOfCrossing == listOfCrossingsWithTLsIds.length) {
- System.err.println("--> getInformationOfTLsDetectors() : Não tem o id desse cruzamento");
- System.exit(-1);
- }
- SumoTransaction newTransaction = new SumoTransaction();
- int[][] carsOnDetectorByLane = new int[][]{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
- Vector<String> lanesOfCrossingVector = new Vector<String>();
- for (String junctionEdge : crossingLanes.get(listOfCrossingsWithTLsIds[indexOfCrossing]).keySet())
- lanesOfCrossingVector.addAll(crossingLanes.get(listOfCrossingsWithTLsIds[indexOfCrossing]).get(junctionEdge));
- String[] lanesOfCrossing = new String[16];
- for (int k = 0; k < lanesOfCrossingVector.size(); k++)
- lanesOfCrossing[k] = lanesOfCrossingVector.get(k);
- for (int k = 0; k < 4; k++) {
- for (int g = 0; g < 4; g++) {
- if (lanesOfCrossing[k * 4 + g] == null) {
- continue;
- }
- newTransaction.clear();
- newTransaction.addCommand(Command.SIM_GetInformationE3(lanesOfCrossing[k * 4 + g], LAST_STEP_VEHICLE_NUMBER));
- newTransaction.finish();
- socket.execute(newTransaction);
- newTransaction.clear();
- newTransaction = socket.receive();
- carsOnDetectorByLane[k][g] = Command.processSIM_GetNumberOfCarsInformationE3(newTransaction.getCommands().get(1));
- }
- }
- /*for(int k = 0; k < 4; k++)
- for(int g = 0; g < 4; g++)
- System.out.println("--> " + k + " " + g + " --> " + carsOnDetectorByLane[k][g]);*/
- return carsOnDetectorByLane;
- }
Add Comment
Please, Sign In to add comment