Example #1
0
 /**
  * On est calé sur $tInterMin en pente montante
  * On calcul l'ensemble du temps de la restriction avec restriction Max et restriction Min
  */
 static function calculTimeRestrictionFromTInterMin($tInterMin, $periode, $timeToAdd, $timeInter2tInterMax, $tEnd, $timeRestriction, $timeTab)
 {
     $t = $tInterMin;
     if ($t < $tEnd) {
         if ($t + $timeToAdd <= $tEnd) {
             // cas normal on ajoute $timeToAdd
             $timeRestriction += $timeToAdd;
             $timeTab[] = array("begin" => date("H:i:s", $t), "end" => date("H:i:s", $t + $timeToAdd));
             $t = $t + $timeToAdd;
             // $t = $tInterMax
             // On va jusqu'à l'autre $tInterMax (pente descendante)
             $t = $t + $timeInter2tInterMax;
             if ($t + $timeToAdd <= $tEnd) {
                 // On peut ajouter $timeToAdd
                 $timeRestriction += $timeToAdd;
                 $timeTab[] = array("begin" => date("H:i:s", $t), "end" => date("H:i:s", $t + $timeToAdd));
                 $t = $t + $timeToAdd;
                 //$t est sur $tInterMin pente descendente
                 $t = $tInterMin + $periode;
                 // $t est sur $tinterMin pente montante
                 return MareeTools::calculTimeRestrictionFromTInterMin($t, $periode, $timeToAdd, $timeInter2tInterMax, $tEnd, $timeRestriction, $timeTab);
             } else {
                 //$t+$timeToAdd>$tEnd
                 if ($t < $tEnd) {
                     // $tEnd est entre $tInterMax et $tInterMin, cad entre $t et $t+$timeToAdd (pente descendante)
                     $timeRestriction += $tEnd - $t;
                     $timeTab[] = array("begin" => date("H:i:s", $t), "end" => date("H:i:s", $tEnd));
                 }
                 return array($timeRestriction, $timeTab);
             }
         } else {
             // $tEnd est entre $tInterMin et $tInterMax, cad entre $t et $t+$timeToAdd (pente montante)
             $timeRestriction += $tEnd - $t;
             $timeTab[] = array("begin" => date("H:i:s", $t), "end" => date("H:i:s", $tEnd));
             return array($timeRestriction, $timeTab);
         }
     } else {
         return array($timeRestriction, $timeTab);
     }
 }