Commit eca9882b authored by Andrey Filippov's avatar Andrey Filippov
Browse files

spiral search

parent e7c0ea42
Loading
Loading
Loading
Loading
+31 −33
Original line number Diff line number Diff line
@@ -272,35 +272,41 @@ printf($rslt);
exit (0);




/*
 Start rotation
$AZ_CMAX =  4790;
$EL_CMAX = 10979;
$SK_CMAX =   931;
 
/**
 * Scan rectangular AZ/EL window arownd expected satellite position, alternating 
 * azimuth directions and increasing elevation offset.
 * Start with expected elevation and low az margin, scan azimuth to high margin,
 * then alternatively increase/decrease elevation
 * @param  $threshold - minimal modem signal strength
 * @param  $DishAngleCenter - array of (elevation, azimuth, skew) in degrees,
 *                            corresponding to the center of the scan window
 * @param  $wnd_az - full range of azimuth scan in degrees
 * @param  $wnd_el - full range of elevation scan in degrees
 * @param  $scan_step - elevation scan step
 * @return SimpleXMLElement - 
 */

function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step){
    global $motosat_url,$LATE_STOP_AZ,$dbg_file;
    $DishAngle = Array($DishAngleCenter[0],$DishAngleCenter[1],$DishAngleCenter[2]);
    $pass = 0;
    for ($DishAngle[1] = $DishAngleCenter[1] - $wnd_el/2;
         $DishAngle[1] <= ($DishAngleCenter[1] + $wnd_el/2);
         $DishAngle[1]+=  $scan_step) {
             
             if ($pass & 1) {
    $dir = 0;
    for ($delta_el = 0.0; $delta_el < $wnd_el/2; $delta_el += $scan_step) {
        $passes = ($delta_el > 0.0)? 2 : 1;
        for ($pass = 0; $pass < $passes; $pass++) {
//        for ($dir = 0; $dir < 2; $dir++) {
            if ($dir > 0){
                $DishAngle[1] = $DishAngleCenter[1] + $delta_el;
                $az_start =     $DishAngleCenter[0] + $wnd_az/2;
                $az_end =       $DishAngleCenter[0] - $wnd_az/2;
            } else {
                $DishAngle[1] = $DishAngleCenter[1] - $delta_el;
                $az_start =     $DishAngleCenter[0] - $wnd_az/2;
                $az_end =       $DishAngleCenter[0] + $wnd_az/2;
            }
            
             $DishAngle[0] = $az_start;
             
             if ($dbg_file) {
                 fprintf($dbg_file, "\npass=%d:\n",$pass);
                 fprintf($dbg_file, "\ndir=%d:\n",$dir);
                 fprintf($dbg_file, "wnd_az=%f:\n",$wnd_az);
                 fprintf($dbg_file, "wnd_el=%f:\n",$wnd_el);
                 fprintf($dbg_file, "threshold=%f:\n",$threshold);
@@ -311,11 +317,6 @@ function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step)
                 fprintf($dbg_file, print_r($DishAngleCenter,1));
             }
             
             
//             while (true) {
//                 $counts = moveElAzSk_degrees($DishAngle);
//                 if (!isset($counts)) break;
//             }
             while (null !==moveElAzSk_degrees($DishAngle));
             $DishAngle[0] = $az_end;
             
@@ -346,7 +347,7 @@ function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step)
                 foreach ($DishCount as $key => $value){
                     $DishCount[$key] = $value + 0;
                 }
                 if ($pass & 1){
                 if ($dir > 0){
                     $DishCount[0] += $LATE_STOP_AZ;
                 } else {
                     $DishCount[0] -= $LATE_STOP_AZ;
@@ -367,13 +368,10 @@ function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step)
                 
                 return $xml_state;
             }
             $pass ++;
        }
        $dir = 1-$dir;
    }
    moveElAzSk_degrees($DishAngleCenter);
//    while (true) {
//        $counts = moveElAzSk_degrees($DishAngleCenter);
//        if (!isset($counts)) break;
//    }
    
    while (null !==moveElAzSk_degrees($DishAngleCenter));
    $xml_state = simplexml_load_file($motosat_url);