Commit e7c0ea42 authored by Andrey Filippov's avatar Andrey Filippov

debugging scan

parent 5bccccf6
...@@ -15,6 +15,8 @@ $AZ_CMAX = 4790; ...@@ -15,6 +15,8 @@ $AZ_CMAX = 4790;
$EL_CMAX = 10979; $EL_CMAX = 10979;
$SK_CMAX = 931; $SK_CMAX = 931;
$MODEM_THRESHOLD = 17.0; // consider something if modem strength is above $MODEM_THRESHOLD = 17.0; // consider something if modem strength is above
$OVERSHOOT = 1; // final steps absolute error
$LATE_STOP_AZ = 30; // steps
/* /*
http://192.168.1.250/motor.xml?Action=ElUp&Distance=0.5&Units=1 0.5 degree up http://192.168.1.250/motor.xml?Action=ElUp&Distance=0.5&Units=1 0.5 degree up
...@@ -177,17 +179,17 @@ string(61) "http://192.168.1.250/motor.xml?Action=ElDn&Distance=1&Units=0" ...@@ -177,17 +179,17 @@ string(61) "http://192.168.1.250/motor.xml?Action=ElDn&Distance=1&Units=0"
$dbg_file = fopen("/home/eyesis/git/motosat/attic/logs/modem.log","w"); $dbg_file = fopen("/home/eyesis/git/motosat/attic/logs/modem.log","w");
fprintf($dbg_file,"test log\n"); fprintf($dbg_file,"test log\n");
if (false) {
print("<p>".date('l jS \of F Y h:i:s A')."</p>"); print("<p>".date('l jS \of F Y h:i:s A')."</p>");
$modem_strength= getModemStrength(); $modem_strength= getModemStrength();
for ($i=0;$i<10;$i++){ for ($i=0;$i<10;$i++){
//$modem_strength= getModemStrength(); //$modem_strength= getModemStrength();
$xml_state = simplexml_load_file($motosat_url); // 0.29 sec $xml_state = simplexml_load_file($motosat_url); // 0.29 sec
}
print("<p>modem_strength=".$modem_strength." file=".$modem_strengt_url."</p>");
print("<p>".date('l jS \of F Y h:i:s A')."</p>");
exit (0);
} }
print("<p>modem_strength=".$modem_strength." file=".$modem_strengt_url."</p>");
print("<p>".date('l jS \of F Y h:i:s A')."</p>");
exit (0);
$xml_state = simplexml_load_file($motosat_url); $xml_state = simplexml_load_file($motosat_url);
...@@ -224,7 +226,7 @@ if ($scan_mode){ ...@@ -224,7 +226,7 @@ if ($scan_mode){
$xml = new SimpleXMLElement("<?xml version='1.0'?><motosat/>"); $xml = new SimpleXMLElement("<?xml version='1.0'?><motosat/>");
$State = $xml_state->State+0; // 1 - Ready, 2 - Busy $State = $xml_state->State+0; // 1 - Ready, 2 - Busy
$busy = ($State & 2) != 0; $busy = ($State & 2) != 0;
$SignalQuality = (explode(",",myfval($xml_state->SignalQuality)[0])); $SignalQuality = myfval(explode(",",$xml_state->SignalQuality)[0]);
$DishCount = $xml_state->DishCount; $DishCount = $xml_state->DishCount;
$DishAngle = $xml_state->DishAngle; $DishAngle = $xml_state->DishAngle;
$Success = $xml_state->Success; $Success = $xml_state->Success;
...@@ -281,31 +283,99 @@ $SK_CMAX = 931; ...@@ -281,31 +283,99 @@ $SK_CMAX = 931;
*/ */
function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step){ function scan_window($threshold, $DishAngleCenter, $wnd_az, $wnd_el, $scan_step){
global $motosat_url; global $motosat_url,$LATE_STOP_AZ,$dbg_file;
$DishAngle = Array($DishAngleCenter[0],$DishAngleCenter[1],$DishAngleCenter[2]); $DishAngle = Array($DishAngleCenter[0],$DishAngleCenter[1],$DishAngleCenter[2]);
$pass = 0; $pass = 0;
for ($DishAngle[1] = $DishAngleCenter[1] - $wnd_el/2; for ($DishAngle[1] = $DishAngleCenter[1] - $wnd_el/2;
$DishAngle[1] <= ($DishAngleCenter[1] + $wnd_el/2); $DishAngle[1] <= ($DishAngleCenter[1] + $wnd_el/2);
$DishAngle[1]+= $scan_step) { $DishAngle[1]+= $scan_step) {
if ($pass & 1) { if ($pass & 1) {
$az_start = $DishAngleCenter[1] + $wnd_el/2; $az_start = $DishAngleCenter[0] + $wnd_az/2;
$az_end = $DishAngleCenter[1] - $wnd_el/2; $az_end = $DishAngleCenter[0] - $wnd_az/2;
} else { } else {
$az_start = $DishAngleCenter[1] - $wnd_el/2; $az_start = $DishAngleCenter[0] - $wnd_az/2;
$az_end = $DishAngleCenter[1] + $wnd_el/2; $az_end = $DishAngleCenter[0] + $wnd_az/2;
} }
$DishAngle[0] = $az_start; $DishAngle[0] = $az_start;
moveElAzSk_degrees($DishAngle);
if ($dbg_file) {
fprintf($dbg_file, "\npass=%d:\n",$pass);
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);
fprintf($dbg_file, "scan_step=%f:\n",$scan_step);
fprintf($dbg_file, "DishAngle - start:\n");
fprintf($dbg_file, print_r($DishAngle,1));
fprintf($dbg_file, "DishAngleCenter - start:\n");
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; $DishAngle[0] = $az_end;
if ($dbg_file) {
fprintf($dbg_file, "\nDishAngle - end:\n");
fprintf($dbg_file, print_r($DishAngle,1));
}
moveElAzSk_start_degrees($DishAngle); moveElAzSk_start_degrees($DishAngle);
$scan_rslt = waitMotorsReady($threshold); $scan_rslt = waitMotorsReady($threshold);
if ($dbg_file) {
fprintf($dbg_file, "-----scan_rslt=%d:\n",$scan_rslt);
}
if ($scan_rslt < 0) { if ($scan_rslt < 0) {
$xml_state = simplexml_load_file($motosat_url); $xml_state = simplexml_load_file($motosat_url);
if ($dbg_file) {
$DishAngle = explode(",",$xml_state->DishAngle);
foreach ($DishAngle as $key => $value){
$DishAngle[$key] = floatval($value);
}
fprintf($dbg_file, "\nDishAngle - after hitting/stopped:\n");
fprintf($dbg_file, print_r($DishAngle,1));
}
//,$LATE_STOP_AZ
//move az back to compensate for late stop
$DishCount = explode(",",$xml_state->DishCount);
foreach ($DishCount as $key => $value){
$DishCount[$key] = $value + 0;
}
if ($pass & 1){
$DishCount[0] += $LATE_STOP_AZ;
} else {
$DishCount[0] -= $LATE_STOP_AZ;
}
moveElAzSk_counts($DishCount);
if ($dbg_file) {
$xml_state = simplexml_load_file($motosat_url);
$DishAngle = explode(",",$xml_state->DishAngle);
foreach ($DishAngle as $key => $value){
$DishAngle[$key] = floatval($value);
}
fprintf($dbg_file, "\nDishAngle - after backing:\n");
fprintf($dbg_file, print_r($DishAngle,1));
}
$xml_state->addChild ('Success',(string) true ); $xml_state->addChild ('Success',(string) true );
return $xml_state; return $xml_state;
} }
$pass ++;
} }
moveElAzSk_degrees($DishAngleCenter); 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); $xml_state = simplexml_load_file($motosat_url);
$xml_state->addChild ('Success',(string) false ); $xml_state->addChild ('Success',(string) false );
return $xml_state; return $xml_state;
...@@ -320,7 +390,7 @@ function getModemStrength(){ //0.2sec ...@@ -320,7 +390,7 @@ function getModemStrength(){ //0.2sec
} }
function moveElAzSk_start_counts($new_azelsk_count) { function moveElAzSk_start_counts($new_azelsk_count) {
global $motosat_url, $AZ_CMAX, $EL_CMAX, $SK_CMAX,$dbg,$dbg_file; global $motosat_url, $AZ_CMAX, $EL_CMAX, $SK_CMAX,$OVERSHOOT,$dbg,$dbg_file;
$xml_state = simplexml_load_file($motosat_url); $xml_state = simplexml_load_file($motosat_url);
$DishCount = explode(",",$xml_state->DishCount); $DishCount = explode(",",$xml_state->DishCount);
foreach ($DishCount as $key => $value){ foreach ($DishCount as $key => $value){
...@@ -337,6 +407,9 @@ function moveElAzSk_start_counts($new_azelsk_count) { ...@@ -337,6 +407,9 @@ function moveElAzSk_start_counts($new_azelsk_count) {
$dist_el = $new_azelsk_count[1] - $DishCount[1]; $dist_el = $new_azelsk_count[1] - $DishCount[1];
$dist_sk = $new_azelsk_count[2] - $DishCount[2]; $dist_sk = $new_azelsk_count[2] - $DishCount[2];
$dist_az = $new_azelsk_count[0] - $DishCount[0]; $dist_az = $new_azelsk_count[0] - $DishCount[0];
if (abs ($dist_el) <= $OVERSHOOT) $dist_el = 0;
if (abs ($dist_sk) <= $OVERSHOOT) $dist_sk = 0;
if (abs ($dist_az) <= $OVERSHOOT) $dist_az = 0;
$dir = "Up"; $dir = "Up";
$dist = 0; $dist = 0;
...@@ -430,10 +503,10 @@ function moveElAzSk_start_degrees($new_azelsk_degree) { ...@@ -430,10 +503,10 @@ function moveElAzSk_start_degrees($new_azelsk_degree) {
* Wait motors stopped and optionally modem strength > threshold * Wait motors stopped and optionally modem strength > threshold
* Can be improved slightly by curl-multi: reading modem - 0.2s, controller - 0.29s * Can be improved slightly by curl-multi: reading modem - 0.2s, controller - 0.29s
* @param $modem_threshold - if >0, stop on modem strength above threshold * @param $modem_threshold - if >0, stop on modem strength above threshold
* @return: 0: no ovement needed, >0 - number of status requests, <0 - -SignalQuality * @return: 0: no movement needed, >0 - number of status requests, <0 - -SignalQuality
*/ */
function waitMotorsReady($modem_threshold = 0.0){ // function waitMotorsReady($modem_threshold = 0.0){ //
global $motosat_url; global $motosat_url,$dbg_file;
$busy = true; $busy = true;
$try = 0; $try = 0;
while ($busy) { while ($busy) {
...@@ -441,12 +514,43 @@ function waitMotorsReady($modem_threshold = 0.0){ // ...@@ -441,12 +514,43 @@ function waitMotorsReady($modem_threshold = 0.0){ //
$State = $xml_state->State+0; // 1 - Ready, 2 - Busy $State = $xml_state->State+0; // 1 - Ready, 2 - Busy
$busy = ($State & 2) != 0; $busy = ($State & 2) != 0;
if ($modem_threshold > 0){ if ($modem_threshold > 0){
$SignalQuality = (explode(",",myfval($xml_state->SignalQuality)[0])); $SignalQuality = myfval(explode(",",$xml_state->SignalQuality)[0]);
$url = $motosat_url."?Action=Stop&Distance=0&Units=0"; if ($SignalQuality > $modem_threshold) {
$xml_state = simplexml_load_file($url); $url = $motosat_url."?Action=Stop&Distance=0&Units=0";
return -$SignalQuality; $xml_state1 = simplexml_load_file($url);
if ($dbg_file) {
fprintf($dbg_file, "SignalQuality= %f:\n",$SignalQuality);
}
while ($busy) {
$xml_state1 = simplexml_load_file($motosat_url);
$State = $xml_state1->State+0; // 1 - Ready, 2 - Busy
$busy = ($State & 2) != 0;
if ($dbg_file) {
fprintf($dbg_file,$busy);
fprintf($dbg_file, " %03d State= %d:\n",$try,$State);
}
}
// Now move back to where good signal strength was detected
$DishCountGood = explode(",",$xml_state->DishCount);
foreach ($DishCountGood as $key => $value){
$DishCountGood[$key] = $value + 0;
}
moveElAzSk_counts($DishCountGood);
if ($dbg_file) {
fprintf($dbg_file, "SignalQuality= %f:\n",$SignalQuality);
}
return -$SignalQuality;
}
} }
$try++; $try++;
if ($dbg_file) {
fprintf($dbg_file, "%03d State= %d:\n",$try,$State);
}
//?Action=Stop&Distance=0&Units=0 //?Action=Stop&Distance=0&Units=0
} }
return $try; return $try;
...@@ -482,17 +586,4 @@ function myfval ($s) { ...@@ -482,17 +586,4 @@ function myfval ($s) {
} }
/*
$AZ_CPD = 12.74445;
$EL_CPD = 75.778567;
$SK_CPD = 8.34;
$AZ_0 = 0.0; // degrees
$EL_0 = 0.0; // degrees
$SK_0 = 55.7554; // degrees
$AZ_CMAX = 4790;
$EL_CMAX = 10979;
$SK_CMAX = 931;
*/
?> ?>
\ No newline at end of file
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