Commit d49ee8a4 authored by Andrey Filippov's avatar Andrey Filippov

added multi-sat search;

parent 1328d82c
......@@ -43,6 +43,12 @@ $ARGMAX_OURSIDE_2D = 0.0; // Allow argmax outside of the measured range by thi
// Modem never allows wrong satellite to have signal strength above 29, and tries to maintain 30 for the correct one when the signal falls below.
// So these values can not be used for peaking(maybe only remove 30 if the signal is going down?)
$HUGHES_BAD_STRENGTHS = array(29,30);
$HUGHES_THRESHOLD = 30; // if less - wrong satellite
$GUARD_AZIMUTH = 2.0; // (degrees) do not look for satellites closer than this to alerady found
$GUARD_STEP = 1.0; // (degrees) If will peak on the same satellite, increase guard range on that side
$AZ_TOL = 0.7; // (degrees) If satellites azimuths differ by less than this - they are the same
$MAX_ARC_TILT = 0.2; // maximal local satellite arc tilt near a known satellite
$SAT_AZ_STEP = 0.5; // (degrees) mark found satellites with this resolution
......@@ -117,7 +123,7 @@ $wnd_az = 0;
$wnd_el = 0;
$scan_step = 1.0;
$min_strength = $MODEM_THRESHOLD;
$full_search = 0;
if (isset($_GET["dbg"])) { $dbg=myval($_GET["dbg"]);}
if (isset($_GET["multi"])) { $multi=myval($_GET["multi"]);}
if (isset($_GET["az"])) { $DishAngle[0] = myfval($_GET["az"]);}
......@@ -128,17 +134,59 @@ if (isset($_GET["wnd_az"])) { $wnd_az = myfval($_GET["wnd_az"]);}
if (isset($_GET["wnd_el"])) { $wnd_el = myfval($_GET["wnd_el"]);}
if (isset($_GET["scan_step"])) { $scan_step = myfval($_GET["scan_step"]);}
if (isset($_GET["min_strength"])) { $min_strength = myfval($_GET["min_strength"]);}
if (isset($_GET["full_search"])) { $full_search = 1;}
$scan_mode = ($wnd_az > 0) || ($wnd_el > 0);
if (!$scan_mode){
$full_search = 0;
}
if ($full_search){
$rslt = lockToSatellite($min_strength, $DishAngle, $wnd_az, $wnd_el, $scan_step);
$xml = new SimpleXMLElement("<?xml version='1.0'?><motosat/>");
$State = $xml_state->State+0; // 1 - Ready, 2 - Busy
$busy = ($State & 2) != 0;
$SignalQuality = myfval(explode(",",$xml_state->SignalQuality)[0]);
// print result to XML
// $xml->addChild ('Success',(string) $Success );
$xml->addChild ('SignalQuality',(string) $SignalQuality );
// if (isset($DishAngle1D)){
// $xml->addChild ('DishAngle1D',$DishAngle1D );
// }
// if (isset($DishAngle2D)){
// $xml->addChild ('DishAngle2D',$DishAngle2D );
// }
$xml->addChild ('DishAngle',$xml_state->DishAngle );
$xml->addChild ('DishCount',$xml_state->DishCountt );
$xml->addChild ('busy',(string) $busy );
$xml->addChild ('State',(string) $State );
$rslt=$xml->asXML();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
// allow CORS: needed for multicam controls
header('Access-Control-Allow-Origin: *');
printf($rslt);
exit (0);
}
if ($scan_mode){
$xml_state = scan_window($min_strength, $DishAngle, $wnd_az, $wnd_el, $scan_step);
$Success = $xml_state->Success;
if (intval ($Success)){
$Success = peakAzimuthOrElevation($xml_state, 0, $AZ_PLAY,$AZ_RESCAN, $AZ_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$rslt = peakAzimuthOrElevation($xml_state, 0, $AZ_PLAY,$AZ_RESCAN, $AZ_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$Success = ($rslt === 1)? 1 : 0;
$xml_state = simplexml_load_file($motosat_url);
if (intval ($Success)){
$Success = peakAzimuthOrElevation($xml_state, 1, $EL_PLAY,$EL_RESCAN, $EL_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$rslt = peakAzimuthOrElevation($xml_state, 1, $EL_PLAY,$EL_RESCAN, $EL_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$Success = ($rslt === 1)? 1 : 0;
$xml_state = simplexml_load_file($motosat_url);
$DishAngle1D = $xml_state->DishAngle;
if (intval ($Success) && $ADJUST_2D){
......@@ -193,6 +241,228 @@ header('Access-Control-Allow-Origin: *');
printf($rslt);
exit (0);
function lockToSatellite($min_strength, $DishAngle, $wnd_az, $wnd_el, $scan_step)
{
global $motosat_url, $dbg_file, $SAT_AZ_STEP, $GUARD_AZIMUTH, $GUARD_STEP, $AZ_TOL, $MAX_ARC_TILT;
global $AZ_PLAY, $AZ_RESCAN, $AZ_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE;
global $EL_PLAY,$EL_RESCAN, $EL_RESCAN_STEP, $HUGHES_THRESHOLD, $ADJUST_2D;
global $AZ_2D_RANGE, $EL_2D_RANGE, $AZ_2D_STEP, $EL_2D_STEP, $ARGMAX_OURSIDE_2D;
$xml_state = simplexml_load_file($motosat_url);
$DishAngleCenter = getDishAngles ($xml_state); // will go there if failed
$DishAngleCenter[0] = $DishAngle[0];
$DishAngleCenter[1] = $DishAngle[1];
$empty_az = array(); // array of pairs: ('low'=>min, "high"=>max) for scanned empoty azimuths in degrees
$satellites =array();// array of ('az'=>az, "el"=> el, 'strength'-> strength, 'guard_low', 'guard_high') in degrees for each foubnd satellite
$num_az_steps = (int) ceil ($wnd_az/$SAT_AZ_STEP);
$az_min = $DishAngle[0] - $wnd_az/2;
// $az_max = $az_min + ($num_az_steps)* $SAT_AZ_STEP;
while (true) { // loop until found correct satellite, or failed
$az_array = array_fill(0, $num_az_steps + 1, 0);
// mark already scanned emty ranges
foreach ($empty_az as $range){
$i_min = (int) ceil (($range['low'] - $az_min)/$SAT_AZ_STEP);
$i_max = (int) floor(($range['high'] - $az_min)/$SAT_AZ_STEP);
if ($i_min < 0) $i_min = 0;
if ($i_max > $num_az_steps) $i_max = $num_az_steps;
for ($i = $i_min; $i <= $i_max; $i++){
$az_array[$i] = -1;
}
}
// Exclude each satellite with its guard range
foreach ($satellites as $indx => $azels){
$i_min = (int) round (($azels['az'] - $azels['guard_low'])/$SAT_AZ_STEP);
$i_max = (int) round (($azels['az'] + $azels['guard_high'])/$SAT_AZ_STEP);
if ($i_min < 0) $i_min = 0;
if ($i_max > $num_az_steps) $i_max = $num_az_steps;
for ($i = $i_min; $i <= $i_max; $i++){
$az_array[$i] = $indx +1; // number of satellite, starting from 1
}
}
// Find azimuth range to scan
for ($i_low = 0; ($i_low <= $num_az_steps) && ($az_array[$i_low] == 0); $i_low++ );
if ($i_low > $num_az_steps) { // all searched, no luck
// Here is te exit from thye loop !
return array ('satellite' => null, 'satellites' => $satellites, 'empty' => $empty_az);
}
for ($i_high = $i_low; ($i_high < $num_az_steps) && ($az_array[$i_high+1] == 0); $i_high++);
// setup new scan range
$az_low = $az_min + $i_low * $SAT_AZ_STEP;
$az_high = $az_min + $i_high * $SAT_AZ_STEP;
$low_end_sat = ($i_low > 0)? $az_array[$i_low - 1] : -1;
$high_end_sat = ($i_high < $num_az_steps)? $az_array[$i_high + 1] : -1;
$az_range = $az_high - $az_low;
$az_center = ($az_high + $az_low) / 2;
if ($low_end_sat < 0){
if ($high_end_sat < 0) { // both ends unknown
$el_center = $DishAngleCenter[1];
$el_range = $wnd_el;
} else { // satellite on the right only
$el_center = $satellites[$high_end_sat -1]['el'];
$el_range = $MAX_ARC_TILT * $az_range;
}
} else {
if ($high_end_sat < 0) {// satellite on the left only
$el_center = $satellites[$low_end_sat -1]['el'];
$el_range = $MAX_ARC_TILT * $az_range;
} else { // both ends have satellites
$el_center = ($satellites[$high_end_sat -1]['el'] + $satellites[$low_end_sat -1]['el']) / 2 ;
$el_range = abs($satellites[$high_end_sat -1]['el'] - $satellites[$low_end_sat -1]['el']);
}
}
// $xml_state = simplexml_load_file($motosat_url);
// $DishAnglesNow = getDishAngles ($xml_state); // will go there if failed
// $dir = ($DishAnglesNow[0] < $az_center) ? 1 : 0;
// Do scanning of the range
if ($dbg_file !== null) {
fprintf($dbg_file, "==== Scanning sky window : center (az:%f7.3 el:%f7.3) az_range=%f7.3, el_range = %f7.3 ====\n",
$az_center, $el_center, $az_range, $el_range);
}
$xml_state = simplexml_load_file($motosat_url);
$DishAnglesScan = getDishAngles ($xml_state); // will go there if failed
$DishAnglesScan[0] = $az_center;
$DishAnglesScan[1] = $el_center;
$xml_state = scan_window($min_strength, $DishAnglesScan, $az_range, $el_range, $scan_step);
$success = intval ($xml_state->Success);
if (!$success) {
// $empty_az = array(); // array of pairs: ('low'=>min, "high"=>max) for scanned empoty azimuths in degrees
$empty_az[] = array('low'=> $az_low, 'high' => $az_high);
if ($dbg_file !== null) {
fprintf($dbg_file, ">>>>> Failed to find any satellites in the window : center (az:%f7.3 el:%f7.3) az_range=%f7.3, el_range = %f7.3 >>>>>\n",
$az_center, $el_center, $az_range, $el_range);
}
continue; // to next azimuth range
}
// Did found some satellite - peak azimuth
// peakAzimuthOrElevation - limit range to scan range, do not allow max to be outside of the scan range!
$minmax = array($az_low, $az_high);
$rslt_az = peakAzimuthOrElevation($xml_state, 0, $AZ_PLAY, $AZ_RESCAN, $AZ_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE, $minmax);
$success_az = ($rslt_az ===1) ? 1 : 0;
$xml_state = simplexml_load_file($motosat_url);
$DishAnglesPeakAz = getDishAngles ($xml_state); // after peaking azimuth
$az_sat = $DishAnglesPeakAz[0];
if (!$success_az){ // what could be wrong here? tried to peak on existing satellite but was prohibited to go outside of the range?
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Failed peaking azimuth - assuming that the peak was outside of the scan range, belonging to other satellite\n");
fprintf($dbg_file, "Peaking error: %s\n", $rslt_az);
// fprintf($dbg_file, "For now will only try to recover if the end of scan range was a satellite found before\n");
}
if (($low_end_sat > 0) && (($rslt_az == 'first element') || ($rslt_az == 'too low'))){
$sat = $satellites[$low_end_sat - 1];
if (($az_sat - $sat['az']) < $AZ_TOL + $AZ_RESCAN_STEP){ // accepting larger tolerance
$satellites[$indx]['guard_high'] += $GUARD_STEP; // search range was on the right, increasing high guard range for the satellite
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Increasing high guard range of the satellite :\n".print_r($satellites[$indx]));
}
continue;
}
}
if ((high_end_sat > 0) && (($rslt_az == 'last element') || ($rslt_az == 'too high'))){
$sat = $satellites[$high_end_sat - 1];
if (($sat['az'] - $az_sat) < $AZ_TOL + $AZ_RESCAN_STEP){ // accepting larger tolerance
$satellites[$indx]['guard_low'] += $GUARD_STEP; // search range was on the left, increasing low guard range for the satellite
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Increasing low guard range of the satellite :\n".print_r($satellites[$indx]));
}
continue;
}
}
// other errors - for now discarding that range completely
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Other azimuth peaking errors(%s), discarding last search range %f7.3 < %f7.3\n",
$rslt_az, $az_low, $az_high);
}
$empty_az[] = array($az_low, $az_high);
continue;
}
// compare azimuth to already known satellites
foreach ($satellites as $indx => $sat){
if (abs($az_sat - $sat['az']) < $AZ_TOL){ // it is the same satellite as already found
if ($az_center < $sat['az']) {
$satellites[$indx]['guard_low'] += $GUARD_STEP; // search range was on the left, increasing low guard range for the satellite
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Increasing low guard range of the satellite:\n".print_r($satellites[$indx]));
}
} else {
$satellites[$indx]['guard_high'] += $GUARD_STEP;// search range was on the right, increasing high guard range for the satellite
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Increasing high guard range of the satellite:\n".print_r($satellites[$indx]));
}
}
continue; // recalculate azimuth range, try again
}
}
// got new satellite, peak elevation
$rslt_el = peakAzimuthOrElevation($xml_state, 1, $EL_PLAY,$EL_RESCAN, $EL_RESCAN_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE);
$Success_el = ($rslt_el === 1)? 1 : 0;
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Peak elevation success = %d\n",$Success_el);
if (!$Success_el){
fprintf($dbg_file, "**** Peak elevation error: %s\n",$rslt_el);
}
}
$modem_strength = getModemStrength();
$xml_state = simplexml_load_file($motosat_url);
$DishAngleSat = $xml_state->DishAngle;
$satellite = array(
'az' => $DishAngleSat[0],
"el" => $DishAngleSat[1],
'strength' => $modem_strength,
'guard_low' => $GUARD_AZIMUTH,
'guard_high' => $GUARD_AZIMUTH
);
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Got a satellite\n".print_r($satellite, 1));
}
// See if it is Hughes modem
if ($modem_strength < $HUGHES_THRESHOLD){
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Satellite modem strength is too low (%f < %f) not a target satellite, continuing search\n",$modem_strength, $HUGHES_THRESHOLD);
}
$satellites[] = $satellite;
continue;
}
if ($dbg_file !== null) {
fprintf($dbg_file, "**** Found target satellite, modem strength is %f >= %f\n",$modem_strength, $HUGHES_THRESHOLD);
}
if ($ADJUST_2D){
if ($dbg_file !== null) {
fprintf($dbg_file, "**** 2D peaking requested, performing it\n");
}
$rslt_2d = peak2D($xml_state, $AZ_PLAY, $EL_PLAY, $AZ_2D_RANGE, $EL_2D_RANGE, $AZ_2D_STEP, $EL_2D_STEP, $USABLE_FRACT, $USABLE_POW, $ARGMAX_OURSIDE_2D);
$Success_2d = $rslt_2d;
$xml_state = simplexml_load_file($motosat_url);
if ($dbg_file !== null) {
fprintf($dbg_file, "**** 2D peaking returned: ".$rslt_2d."\n");
}
if ($Success_2d){
$modem_strength = getModemStrength();
$xml_state = simplexml_load_file($motosat_url);
$DishAngleSat = $xml_state->DishAngle;
$satellite = array(
'az' => $DishAngleSat[0],
"el" => $DishAngleSat[1],
'strength' => $modem_strength,
'guard_low' => $GUARD_AZIMUTH,
'guard_high' => $GUARD_AZIMUTH
);
}
$satellites[] = $satellite;
return array ('satellite' => $satellite, 'satellites' => $satellites, 'empty' => $empty_az);
}
}
}
function peak2D($xml_state, $az_play, $el_play, $az_range, $el_range, $az_step, $el_step, $fract, $pow = 1.0, $argmax_outside=0.0){
global $motosat_url, $dbg_file;
if ($xml_state === null){
......@@ -268,61 +538,85 @@ function peak2D($xml_state, $az_play, $el_play, $az_range, $el_range, $az_step,
}
function peakAzimuthOrElevation($xml_state, $el_not_az, $azel_play, $azel_range, $azel_step, $fract, $pow = 1.0, $argmax_outside=0.2){
// return ===1 if OK, else error text string from findMax1D
function peakAzimuthOrElevation($xml_state, $el_not_az, $azel_play, $azel_range, $azel_step, $fract, $pow = 1.0, $argmax_outside = 0.2, $minmax=null)
{
global $motosat_url, $dbg_file;
if ($xml_state === null){
if ($xml_state === null) {
$xml_state = simplexml_load_file($motosat_url);
}
$DishAngle = getDishAngles ($xml_state);
$motor = $el_not_az ? 1: 0;
$DishAngle = getDishAngles($xml_state);
$motor = $el_not_az ? 1 : 0;
$direction = $el_not_az ? "ELEVATION" : "AZIMUTH";
$azel_start_center = $DishAngle[$motor];
//move to sart rescan azimuth minus mechanical play
$DishAngle[$motor] = $azel_start_center - $azel_play - $azel_range/2;
// move to sart rescan azimuth minus mechanical play
$DishAngle[$motor] = $azel_start_center - $azel_play - $azel_range / 2;
moveElAzSk_degrees($DishAngle);
$scan_strengths = Array();
for ($azel = $azel_start_center - $azel_range/2;
$azel < ($azel_start_center + $azel_range/2 + $azel_step);
$azel += $azel_step){
$DishAngle[$motor] = $azel;
moveElAzSk_degrees($DishAngle); // to be on the safe side re-read xml
$modem_strength= getModemStrength();
$scan_strengths[] = $modem_strength;
}
if ($dbg_file !== null) {
fprintf($dbg_file, "==== $direction scan strengths: ====\n");
fprintf($dbg_file, print_r($scan_strengths, 1));
}
$rel_argmax = findMax1d($scan_strengths, $fract, $pow, $argmax_outside);
if ($rel_argmax !== null) {
$azel_argmax = $azel_start_center - $azel_range / 2 + $azel_step * $rel_argmax;
if ($dbg_file !== null) {
fprintf($dbg_file, "reltive argmax = %f\n", $rel_argmax);
fprintf($dbg_file, "$direction argmax = %f (was %f)\n", $azel_argmax, $azel_start_center);
$azel_min = $azel_start_center - $azel_range / 2;
$azel_max = $azel_start_center + $azel_range / 2 + $azel_step;
if ($minmax !== null) {
if ($azel_min < $minmax[0]){
$azel_min = $minmax[0];
}
if ($azel_max < $minmax[1]){
$azel_max = $minmax[1];
}
$DishAngle[$motor] = $azel_argmax - $azel_play;
}
if (($azel_max - $azel_min) < $azel_step){
if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving $direction to compensate motor play to = %f\n", $DishAngle[$motor]);
fprintf($dbg_file, "==== $direction scan range to small min = %f, max = %f: ====\n", $azel_min, $azel_max);
}
moveElAzSk_degrees($DishAngle);
$DishAngle[$motor] = $azel_argmax;
return 'small range';
}
if (($azel_max - $azel_min) < 2.01 * $azel_step){
$azel_step = ($azel_max - $azel_min) / 2.01; // at least 3 samples
if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving $direction to argmax position = %f\n", $DishAngle[$motor]);
fprintf($dbg_file, "==== $direction scan range to small min = %f, max = %f new step = %f: ====\n", $azel_min, $azel_step);
}
moveElAzSk_degrees($DishAngle);
return 1; // success
} else {
// for now - move back
}
for ($azel = $azel_min; $azel < $azel_max; $azel += $azel_step) {
$DishAngle[$motor] = $azel;
moveElAzSk_degrees($DishAngle); // to be on the safe side re-read xml
$modem_strength = getModemStrength();
$scan_strengths[] = $modem_strength;
}
if ($dbg_file !== null) {
fprintf($dbg_file, "==== $direction scan strengths: ====\n");
fprintf($dbg_file, print_r($scan_strengths, 1));
}
// $rel_argmax = findMax1d($scan_strengths, $fract, $pow, $argmax_outside);
$rslt = findMax1d($scan_strengths, $fract, $pow, $argmax_outside);
$rel_argmax = $rslt['argmax'];
if (isset($rslt['err'])){
if ($dbg_file !== null) {
fprintf($dbg_file, "****** Failed to find maximum for $direction, going to known position.\n");
}
$DishAngle[$motor] = $azel_start_center;
moveElAzSk_degrees($DishAngle);
return 0; // failed
}
$azel_argmax = $azel_min + $azel_step * $rel_argmax;
if ($dbg_file !== null) {
fprintf($dbg_file, "reltive argmax = %f\n", $rel_argmax);
fprintf($dbg_file, "$direction argmax = %f (was %f)\n", $azel_argmax, $azel_start_center);
}
$DishAngle[$motor] = $azel_argmax - $azel_play;
if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving $direction to compensate motor play to = %f\n", $DishAngle[$motor]);
}
moveElAzSk_degrees($DishAngle);
$DishAngle[$motor] = $azel_argmax;
if ($dbg_file !== null) {
fprintf($dbg_file, "====== Moving $direction to argmax position = %f\n", $DishAngle[$motor]);
}
moveElAzSk_degrees($DishAngle);
if (isset($rslt['err'])){
return $rslt['err'];
}
return 1; // success
}
function findMax2d($data, $fract, $pow, $frac_outside = 0.2){ // $pow not yet used
......@@ -512,7 +806,17 @@ function findMax1d($data, $fract, $pow, $frac_outside = 0.2){
$argmax = $k;
} else if ($v < $min) $min = $v;
}
$threshold = $min + ($max-$min)*$fract;
if ($argmax == 0){
return array('argmax'=>$argmax,'err'=>'first element');
}
if ($argmax >= (sizeof($data) -1)){
return array('argmax'=>$argmax,'err'=>'last element');
}
$threshold = $min + ($max-$min) * $fract;
$k_min = $argmax;
while (($k_min > 0) && ($data[$k_min - 1] >= $threshold)){
$k_min--;
......@@ -569,7 +873,7 @@ function findMax1d($data, $fract, $pow, $frac_outside = 0.2){
if ($dbg_file) {
fprintf($dbg_file, "Could not find maximum (NaN): coeff = \n".print_r($rslt,1)."\n");
}
return null; // no maximum
return array('argmax'=>$argmax,'err'=>'NaN coefficients');
}
......@@ -577,7 +881,7 @@ function findMax1d($data, $fract, $pow, $frac_outside = 0.2){
if ($dbg_file) {
fprintf($dbg_file, "Could not find maximum coeff = \n".print_r($rslt,1)."\n");
}
return null; // no maximum
return array('argmax'=>$argmax,'err'=>'a2 >= 0');
}
$rel_argmax = $argmax - $rslt[1] / (2 * $rslt[2]);
if ($rel_argmax < -($frac_outside * sizeof($data))){
......@@ -585,15 +889,15 @@ function findMax1d($data, $fract, $pow, $frac_outside = 0.2){
fprintf($dbg_file, "argmax is too low = %f, range=%d\n",$rel_argmax,sizeof($data) );
}
return null; // too low
return array('argmax'=>$rel_argmax,'err'=>'too low');
}
if ($rel_argmax > ((1.0 + $frac_outside) * sizeof($data))){
if ($dbg_file) {
fprintf($dbg_file, "argmax is too high = %f, range=%d\n",$rel_argmax,sizeof($data) );
}
return null; // too low
return array('argmax'=>$rel_argmax,'err'=>'too high');
}
return $rel_argmax; // $rslt;
return array('argmax'=>$rel_argmax,'err'=>null); // $rslt;
}
/**
......@@ -607,12 +911,19 @@ function findMax1d($data, $fract, $pow, $frac_outside = 0.2){
* @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
* @param $dir - 0: start scanning from right to left, 1 : first scan from left to right,
* null - determine direction automatically from the current azimuth
* @return SimpleXMLElement -
*/
function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step){
function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step, $dir = null){
global $motosat_url,$LATE_STOP_AZ,$dbg_file;
if ($dir === null) {
$xml_state = simplexml_load_file($motosat_url);
$DishAnglesNow = getDishAngles($xml_state); // will go there if failed
$dir = ($DishAnglesNow[0] < $DishAngleCenter[0]) ? 1 : 0;
}
$DishAngle = Array($DishAngleCenter[0],$DishAngleCenter[1],$DishAngleCenter[2]);
$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++) {
......@@ -681,7 +992,7 @@ function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step)
return $xml_state;
}
}
$dir = 1-$dir;
$dir = 1 - $dir;
}
moveElAzSk_degrees($DishAngleCenter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment