Guest User

Untitled

a guest
Jul 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. public synchronized int[][] getInformationOfTLsDetectors(String id) {
  2. int indexOfCrossing = 0;
  3. for (; indexOfCrossing < listOfCrossingsWithTLsIds.length; indexOfCrossing++) {
  4. if (listOfCrossingsWithTLsIds[indexOfCrossing].equals(id)) {
  5. break;
  6. }
  7. }
  8.  
  9. if (indexOfCrossing == listOfCrossingsWithTLsIds.length) {
  10. System.err.println("--> getInformationOfTLsDetectors() : Não tem o id desse cruzamento");
  11. System.exit(-1);
  12. }
  13.  
  14. SumoTransaction newTransaction = new SumoTransaction();
  15.  
  16. int[][] carsOnDetectorByLane = new int[][]{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
  17.  
  18. Vector<String> lanesOfCrossingVector = new Vector<String>();
  19. for (String junctionEdge : crossingLanes.get(listOfCrossingsWithTLsIds[indexOfCrossing]).keySet())
  20. lanesOfCrossingVector.addAll(crossingLanes.get(listOfCrossingsWithTLsIds[indexOfCrossing]).get(junctionEdge));
  21.  
  22. String[] lanesOfCrossing = new String[16];
  23. for (int k = 0; k < lanesOfCrossingVector.size(); k++)
  24. lanesOfCrossing[k] = lanesOfCrossingVector.get(k);
  25.  
  26.  
  27. for (int k = 0; k < 4; k++) {
  28. for (int g = 0; g < 4; g++) {
  29. if (lanesOfCrossing[k * 4 + g] == null) {
  30. continue;
  31. }
  32.  
  33. newTransaction.clear();
  34. newTransaction.addCommand(Command.SIM_GetInformationE3(lanesOfCrossing[k * 4 + g], LAST_STEP_VEHICLE_NUMBER));
  35. newTransaction.finish();
  36. socket.execute(newTransaction);
  37. newTransaction.clear();
  38. newTransaction = socket.receive();
  39.  
  40. carsOnDetectorByLane[k][g] = Command.processSIM_GetNumberOfCarsInformationE3(newTransaction.getCommands().get(1));
  41. }
  42. }
  43. /*for(int k = 0; k < 4; k++)
  44. for(int g = 0; g < 4; g++)
  45. System.out.println("--> " + k + " " + g + " --> " + carsOnDetectorByLane[k][g]);*/
  46. return carsOnDetectorByLane;
  47. }
Add Comment
Please, Sign In to add comment