Exemplo n.º 1
0
 public function isEqual(StationState $stationState)
 {
     if ($stationState->availableBikes != $this->availableBikes) {
         return false;
     }
     if ($stationState->freeSlots != $this->freeSlots) {
         return false;
     }
     if ($stationState->statusCode != $this->statusCode) {
         return false;
     }
     if ($stationState->station->getId() != $this->station->getId()) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 public function addStation(Station $station)
 {
     if (!array_key_exists($station->getId(), $this->stations)) {
         $this->stations[$station->getId()] = $station;
     } else {
         throw new ObjectAlreadyStoredException($station);
     }
 }
Exemplo n.º 3
0
 /**
  * @access protected
  * @param  Station $station
  * @param  Array $data
  * @return void
  */
 protected function _debug(Station $station, $data)
 {
     require APPPATH . "models/Sources/Measurements.php";
     $measurements = new Measurements();
     $columns = $measurements->_default_columns;
     $final = [];
     $data['station'] = $station->getId();
     $data['multiple'] = false;
     $data['download'] = false;
     foreach ($columns as $column => $value) {
         $data['measurement'] = $value['name'];
         $source = new Source($data);
         $res = $source->get();
         if (isset($res[0]['data'])) {
             $result[$value["name"]] = count($res[0]['data']);
         } else {
             $result[$value["name"]] = 0;
         }
     }
     $region = (new Region())->findById($station->getRegionId());
     $final['rows'] = json_encode($result);
     $final['station'] = $station->getName();
     $final['region'] = $region->getName();
     $final['created'] = (new DateTime())->format("Y-m-d H:i:s");
     $this->_addContent($station->getId(), $final);
 }