Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. [['distance':3.4938212,'timestamp':'2019-06-21 02:00:00'],['distance':4.4345342,'timestamp':'2019-06-21 02:00:33'],['distance':3.5482918,'timestamp':'2019-06-21 02:02:35']...]
  2.  
  3. $gateway_single = $this->Entrada->find('all', array('conditions' => array('Entrada.id' => $gateway[Constantes::TABLA_RELACIONAL_BEACONS_GATEWAYS]['identrada_secundaria'] ) ) );
  4.  
  5. $distances = $this->Entrada->query('select * from gateway_beacon_distances where beacon_kontakt_id like '' . $beacon_kontakt_id . '' and gateway_kontakt_id = '' . $gateway_single[0]['Entrada']['titulo'] . '' and date(`date`) = '' . $fecha . '' order by date ASC;');
  6.  
  7. $start['running'] = 0;
  8. $start['time_start'] = null;
  9. $start['last_time'] = null;
  10. $times_gone_gateway = 0;
  11. $time_near_gateway = 0;
  12.  
  13. $number_of_points= 0;
  14. foreach ($distances as $distance) {
  15. if ($start['running'] == 0) {
  16. $times_gone_gateway++;
  17. $start['running'] = 1;
  18. $start['time_start'] = $distance['gateway_beacon_distances']['date'];
  19. $start['last_time'] = $distance['gateway_beacon_distances']['date'];
  20. } else {
  21. $date1 = new DateTime($start['last_time']);
  22. $date2 = new DateTime($distance['gateway_beacon_distances']['date']);
  23. $diff_seconds = $date1->diff($date2);
  24. $time_beetween_lectures = ( ($diff_seconds->days * 24 ) * 3600 ) + ($diff_seconds->h * 3600) + ( $diff_seconds->i * 60 ) + $diff_seconds->s;
  25.  
  26. if ($time_beetween_lectures > 15000) {
  27. if($number_of_points > 10){
  28. echo 'Distance: ' . $distance['gateway_beacon_distances']['distance_m'] . ' Time: ' . $time_beetween_lectures. '<br>';
  29. echo 'Start date: ' . $start['time_start'] . ' End date: ' . $start['last_time']. '<br><br><br>';
  30. $times_gone_gateway++;
  31. $date1 = new DateTime($start['time_start']);
  32. $date2 = new DateTime($start['last_time']);
  33. $time_near_gateway += ( ($diff_seconds->days * 24 ) * 3600 ) + ($diff_seconds->h * 3600) + ( $diff_seconds->i * 60 ) + $diff_seconds->s;
  34. }
  35.  
  36. $start['running'] = 1;
  37. $start['time_start'] = $distance['gateway_beacon_distances']['date'];
  38. $start['last_time'] = $distance['gateway_beacon_distances']['date'];
  39. $number_of_points = 0;
  40. }
  41. }
  42. $number_of_points++;
  43. }
  44.  
  45. if ($start['running'] == 0) {
  46. $date1 = new DateTime($start['time_start']);
  47. $date2 = new DateTime($start['last_time']);
  48.  
  49. $time_near_gateway += ( ($diff_seconds->days * 24 ) * 3600 ) + ($diff_seconds->h * 3600) + ( $diff_seconds->i * 60 ) + $diff_seconds->s;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement