예제 #1
0
 /**
  * @param Buzzer $buzzer
  */
 function receiveBuzz(Buzzer $buzzer)
 {
     $this->setPause(true);
     if (is_null($this->gagnant) || $buzzer->getDernierBuzz() + $buzzer->getDecalage() < $this->gagnant->getDernierBuzz() + $this->gagnant->getDecalage()) {
         $this->setGagnant($buzzer);
         $this->notifGagnant();
     }
 }
예제 #2
0
 /**
  * Lance la synchronisation
  */
 public function send()
 {
     $msg = array('idConnection' => $this->buzzer->getConnectionId(), 'msgType' => 'synchro', 'error' => 0, 'errorMsg' => '', 'timeSend' => microtime(true));
     $this->buzzer->send(json_encode($msg));
 }
예제 #3
0
 /**
  * @param Buzzer $buzzer
  * @return string
  */
 public function msgDesinscription(Buzzer $buzzer)
 {
     return json_encode(array('idConnection' => $buzzer->getConnectionId(), 'msgType' => 'desInscriptFromSalon', 'error' => 0, 'errorMsg' => '', 'idSalon' => $this->getId(), 'idBuzzer' => $buzzer->getId()));
 }
<?php

//no close
//ignore_user_abort(true);
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'DB.php';
require 'raspi/Buzzer.php';
require 'raspi/Diode.php';
//scan card
$buzzer = new Buzzer();
$buzzer->buzzStop();
$diode = new Diode();
$diode->off();
while (true) {
    echo "Wait for card...\n";
    do {
        $uid = getNfcUID();
    } while ($uid == NULL);
    echo "Insert {$uid} card\n";
    $newCard = new stdClass();
    $newCard->cardid = $uid;
    addCard($newCard);
    $buzzer->buzzStart();
    $diode->on();
    sleep(1);
    $buzzer->buzzStop();
    echo "Remember take card back...\n";
    while ($uid != NULL && getNfcUID() == $uid) {
    }
 /**
  * @param Buzzer $buzzer
  */
 public function ajout(Buzzer $buzzer)
 {
     $this[$buzzer->getId()] = $buzzer;
 }