db = new MySQL(DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME); } //Check if there are permissions for the charging station to connect to our server public function SelectConected($idTag, $data=null) { return true; // if ($this->returnAuthorizeData($idTag, $data=null)) { // return true; // } // return false; } public function returnAuthorizeData($idTag, $data=null) { $list = array( '23F532C35', 'TESTCP1', 'TESTCP2', 'STL01', '20230222104823-1002' ); if (in_array($idTag, $list)) { return $this->returnResponse([ 3, $data[1], [ "idTagInfo" => [ "status" => "Accepted" ] ] ]); } } public function returnBootNotification($idTag, $data = null) { return $this->returnResponse([ 3, $data[1], [ "currentTime" => $this->current_time, "interval" => 60, "status" => "Accepted" ] ]); } public function returnStartTransaction($idTag, $data = null) { $obj = new stdClass; $obj->transactionId = rand(1, 1000000000000); return $this->returnResponse([ 3, $data[1], [ "idTagInfo" => [ "parentIdTag" => "", "status" => "Accepted" ], $obj ] ]); } public function returnRemoteStartTransaction($idTag, $data = null) { return $this->returnResponse([ 3, $data[1], [ "status" => "Accepted" ] ]); } public function returnRemoteStopTransaction($idTag, $data = null) { return $this->returnResponse([ 3, $data[1], [ "status" => "Accepted" ] ]); } public function returnMeterValues($idTag, $data=null) { return $this->returnResponse([ 3, $data[1], [] ]); } public function returnStatusNotification($idTag, $data=null) { return $this->returnResponse([ 3, $data[1], [] ]); } public function returnDiagnosticsStatusNotification($idTag, $data=null) { } //Ping the my_set_command database and if there is a command, send the command to the charging station, then delete the command and the database public function SetCommand($idTag, $data=null) { } //Ping the my_set_command database and if there is a command, send the command to the charging station, then delete the command and the database //We write to the temporary base which connector was launched public function UpConnectorCommand($idTag, $connector_id = 0) { } //Write to the temporary base who launched the command public function UpUserCommand($idTag, $user_id = 0) { } //Get the user id who last ran the command on the current station public function UserID($idTag, $data=null) { } //Get the connector id who last ran the command on the current station public function ConnectorSID($idTag, $data=null) { } //Write to the database, the history of commands sent manually public function up_command($data, $idTag) { } //Get the heart beat public function returnHeartBeat($idTag, $data=null) { return $this->returnResponse([ 3, $data[1], [ "currentTime" => $this->current_time ] ]); } //Reset command public function returnReset($idTag, $data=null) { return $this->returnResponse([ 3, $data[1], [ "status" => "Accepted" ] ]); } //We receive some data from the station and process it through the switch - we answer public function Status($data, $idTag = '') { $command = ''; if (!empty($data)) { $command = $data[2]; } $t = explode(" ", microtime()); $this->current_time = date("Y-m-d\TH:i:s", time()) . substr((string)$t[0], 1, 4) . 'Z'; // return $command; switch ($command) { case "Authorize": return $this->returnAuthorizeData($idTag, $data); break; case "BootNotification": return $this->returnBootNotification($idTag, $data); break; case "DiagnosticsStatusNotification": return $this->returnDiagnosticsStatusNotification($idTag, $data); break; case "MeterValues": return $this->returnMeterValues($idTag, $data); break; case "DataTransfer": // break; case "StartTransaction": return $this->returnStartTransaction($idTag, $data); break; case "RemoteStartTransaction": return $this->returnRemoteStartTransaction($idTag, $data); break; case "RemoteStopTransaction": return $this->returnRemoteStopTransaction($idTag, $data); break; case "StatusNotification": return $this->returnStatusNotification($idTag, $data); break; case "FirmwareStatusNotification": // break; case "Heartbeat": return $this->returnHeartBeat($idTag, $data); break; case "Reset": return $this->returnReset($idTag, $data); break; case "StatusNotification": // break; default: echo "No Command Detected"; } // $this->saveData($idTag,$data); } public function StartTransactionStatus($idTag, $data) { } public function AuthorizeStatus($idTag, $data) { } //Write the firmware version public function SetBootNotification($data) { } //Write the status of the stations in the StatusNotification method public function SetStatus($data) { } //Write the status of the stations in the StatusNotification method //Write a fake 0, MeterValues public function SetFalseMeterValues($idTag, $user_id, $rand) { } ///Updating connector information public function connectorId($data) { } //Updating connector information //Get the user id who started the transaction public function UserTransactionId($transaction = 0) { } //Get the user id who started the transaction //Determinations through which algorithm to write off money public function MeterStartZero($idTag, $transactionId) { } //Determinations through which algorithm to write off money //Write data from counters public function MeterValues($idTag, $data) { } //Write data from counters public function NotStandardAlgorithm($data, $idTag, $zero) { } public function StandardAlgorithm($data, $idTag) { } //Ticketing public function SetMoney($parent_id) { } // Special price for some users public function SpecialMoney($idTag, $connectorId, $user_id) { } // Special price for some users //What type is this number public function SetType($type) { } //What type is this number //Search for the Energy.Active.Import.Register value in the array public function searchForId($id, $array) { } public function sendData($idTag, $data, $url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $response = curl_exec($ch); curl_close($ch); } public function saveData($idTag, $data = null) { $json = json_encode($data); $this->db->query("INSERT INTO ws_log (`idTag`,`request`) VALUES ('{$idTag}', '{$json}')"); } public function returnResponse($data) { return json_encode($data); } }