Commit 28b392c6 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

Merge branch 'framepars' of https://github.com/Elphel/elphel-web-393 into framepars

parents ab0526c0 d5ba77fb
...@@ -418,13 +418,17 @@ CAPTION; ...@@ -418,13 +418,17 @@ CAPTION;
// $xml->addChild ( 'compressor_irqon_result', fseek ( $circbuf_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts // $xml->addChild ( 'compressor_irqon_result', fseek ( $circbuf_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
// fclose ( $circbuf_file ); // fclose ( $circbuf_file );
// Init turn on cmdseq interrupts, but not compressor ones // Init turn on cmdseq interrupts, but not compressor ones
$xml->addChild ( 'frame_before' . strval ( $sensor_port ), elphel_get_frame($sensor_port));
$xml->addChild ('DEBUG_01_'. strval ( $sensor_port ), $GLOBALS ['framepars_paths'] [$sensor_port]); $xml->addChild ('DEBUG_01_'. strval ( $sensor_port ), $GLOBALS ['framepars_paths'] [$sensor_port]);
$xml->addChild ( 'LSEEK_FRAMEPARS_INIT' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_FRAMEPARS_INIT, SEEK_END ) ); $xml->addChild ( 'LSEEK_FRAMEPARS_INIT' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_FRAMEPARS_INIT, SEEK_END ) );
$xml->addChild ( 'elphel_set_P_value' . strval ( $sensor_port ), elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ) ); // / will start detection $xml->addChild ( 'elphel_set_P_value' . strval ( $sensor_port ), elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ) ); // / will start detection
// Seems that next LSEEK_SENSORPROC is not needed as 0->ELPHEL_SENSOR will trigger it anyway // Seems that next LSEEK_SENSORPROC is not needed as 0->ELPHEL_SENSOR will trigger it anyway
// Still try it to make sure new lock handles it // Still try it to make sure new lock handles it
// $xml->addChild ( 'LSEEK_SENSORPROC' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_SENSORPROC, SEEK_END ) ); // $xml->addChild ( 'LSEEK_SENSORPROC' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_SENSORPROC, SEEK_END ) );
$frame = 0; //$frame = 0 (in NC353)
$frame = elphel_get_frame($sensor_port);
$xml->addChild ( 'frame' . strval ( $sensor_port ), $frame);
//elphel_get_frame
// gets half-frame // gets half-frame
elphel_set_P_value ( $sensor_port, ELPHEL_MAXAHEAD, 2, 0, 8 ); // / When servicing interrupts, try programming up to 2 frames ahead of due time) elphel_set_P_value ( $sensor_port, ELPHEL_MAXAHEAD, 2, 0, 8 ); // / When servicing interrupts, try programming up to 2 frames ahead of due time)
...@@ -436,13 +440,22 @@ CAPTION; ...@@ -436,13 +440,22 @@ CAPTION;
elphel_set_P_value ( $sensor_port, ELPHEL_BITS, 8, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_BITS, 8, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_QUALITY, 80, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_QUALITY, 80, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR, 1, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_COLOR, ELPHEL_CONST_COLORMODE_COLOR, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_BLUE, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_BLUE, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_RED, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_RED, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_BAYER, 0, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_BAYER, 0, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAING, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAINGB, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAINR, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAINB, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_VIGNET_C, 0x8000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_VIGNET_SHL, 1, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COMPRESSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / run compressor elphel_set_P_value ( $sensor_port, ELPHEL_COMPRESSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / run compressor
$xml->addChild ( 'frame_after' . strval ( $sensor_port ), elphel_get_frame($sensor_port));
fclose ( $framepars_file ); fclose ( $framepars_file );
$gamma = 57; $gamma = 57;
$black = 10; $black = 10;
...@@ -461,6 +474,7 @@ CAPTION; ...@@ -461,6 +474,7 @@ CAPTION;
); );
$frame = elphel_get_frame ( $sensor_port ); // 0 $frame = elphel_get_frame ( $sensor_port ); // 0
elphel_set_P_arr ( $sensor_port, $gamma_pars, $frame + 3, 0 ); elphel_set_P_arr ( $sensor_port, $gamma_pars, $frame + 3, 0 );
$xml->addChild ( 'frame_final' . strval ( $sensor_port ), elphel_get_frame($sensor_port));
} else if ($value == "initgamma") { } else if ($value == "initgamma") {
$gammas_file = fopen ( "/dev/gamma_cache", "w+" ); $gammas_file = fopen ( "/dev/gamma_cache", "w+" );
$xml->addChild ( 'LSEEK_GAMMA_INIT' . strval ( $sensor_port ), fseek ( $gammas_file, ELPHEL_LSEEK_GAMMA_INIT, SEEK_END ) ); $xml->addChild ( 'LSEEK_GAMMA_INIT' . strval ( $sensor_port ), fseek ( $gammas_file, ELPHEL_LSEEK_GAMMA_INIT, SEEK_END ) );
......
...@@ -124,8 +124,8 @@ ...@@ -124,8 +124,8 @@
$sensor_port=0; /// TODO: NC393 - add sensor port control, initially will use $sensor_port=0 for all php functions that require it $sensor_port=0; /// TODO: NC393 - add sensor port control, initially will use $sensor_port=0 for all php functions that require it
$autocampars='/www/pages/autocampars.php'; $autocampars='/www/pages/autocampars.php';
$descriptions=getParDescriptions($autocampars); $descriptions=getParDescriptions($autocampars);
$default_ahead=3; $default_ahead=5; // 3;
$maxahead=6; /// maximal ahead of the current frame that tasks can currently be set to driver; $maxahead=6; /// maximal ahead of the current frame that tasks can currently be set to driver; //NC393 - is it the same?
$minahead=4; /// skip to frame $minahead from the soonest next task before programming $minahead=4; /// skip to frame $minahead from the soonest next task before programming
$brief=true; $brief=true;
$ahead_separator='*'; $ahead_separator='*';
...@@ -135,12 +135,15 @@ ...@@ -135,12 +135,15 @@
$testBefore=2;/// Start compressor $testBefore frames before first task $testBefore=2;/// Start compressor $testBefore frames before first task
$testAfter=2; /// Stop compressor $testAfter frames after the last task $testAfter=2; /// Stop compressor $testAfter frames after the last task
$framesBeforeStart=2; ///In test mode - compressor will be started theis frames after "now" $framesBeforeStart=2; ///In test mode - compressor will be started theis frames after "now"
$imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081"; // $imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081";
/// $imglink="img"; /// use this for faster output (and safer in simultaneous accesses from multiple hosts $imgsrv_base="http://".$_SERVER['SERVER_ADDR'].":";
$imgsrv_ports= array ("2323","2324","2325","2326");
/// $imglink="img"; /// use this for faster output (and safer in simultaneous accesses from multiple hosts
$imglink="bimg"; ///It was "img" - faster, but image may get corrupted if buffer is overrun before it is trasferred (network congestion) $imglink="bimg"; ///It was "img" - faster, but image may get corrupted if buffer is overrun before it is trasferred (network congestion)
$defaultImgScale=0.2; /// 20% image size $defaultImgScale=0.2; /// 20% image size
$defaultImagesPerRow=3; $defaultImagesPerRow=3;
$defaultImagesNumber=9; $defaultImagesNumber= 9; // 12
$isPost=$_SERVER["REQUEST_METHOD"]=="POST"; $isPost=$_SERVER["REQUEST_METHOD"]=="POST";
$ignoreVals=$isPost; $ignoreVals=$isPost;
$imagesNumber=$defaultImagesNumber; $imagesNumber=$defaultImagesNumber;
...@@ -164,6 +167,8 @@ ...@@ -164,6 +167,8 @@
if (array_key_exists ( 'sensor_port', $_GET )) { if (array_key_exists ( 'sensor_port', $_GET )) {
$GLOBALS [sensor_port] = (myval($_GET ['sensor_port'])) & 3; $GLOBALS [sensor_port] = (myval($_GET ['sensor_port'])) & 3;
} }
$imgsrv = $imgsrv_base.$imgsrv_ports[$GLOBALS [sensor_port]];
$elp_const=get_defined_constants(true); $elp_const=get_defined_constants(true);
$elp_const=$elp_const["elphel"]; $elp_const=$elp_const["elphel"];
$immediateMode=parseGetNames(); $immediateMode=parseGetNames();
...@@ -495,7 +500,7 @@ USAGE; ...@@ -495,7 +500,7 @@ USAGE;
/// show table with last acquired images and meta data /// show table with last acquired images and meta data
/// TODO: show chnaged parameters for those frames? *** /// TODO: show changed parameters for those frames? ***
function showImgData($meta,$skipped,$prev,$imgScale,$done) { function showImgData($meta,$skipped,$prev,$imgScale,$done) {
global $imgsrv,$imglink; global $imgsrv,$imglink;
$width= $meta['meta']['width']; $width= $meta['meta']['width'];
...@@ -571,95 +576,106 @@ echo "</pre>"; ...@@ -571,95 +576,106 @@ echo "</pre>";
///TODO:if $todo is provided in $_GET - try to find the correct images even if they are not the latest ///TODO:if $todo is provided in $_GET - try to find the correct images even if they are not the latest
function showLastImages($numImg,$imagesPerRow,$imgScale) { function showLastImages($numImg, $imagesPerRow, $imgScale) {
$done= decodeTodo ($_GET['done']); // elphel_update_exif(); // just for testing
// $this_exif=elphel_get_exif_elphel(0); $done = decodeTodo ( $_GET ['done'] );
$circbuf_pointers=elphel_get_circbuf_pointers($GLOBALS [sensor_port],1); // $this_exif=elphel_get_exif_elphel(0);
$framesAgo=0; $circbuf_pointers = elphel_get_circbuf_pointers ( $GLOBALS [sensor_port], 1 );
//echo "<pre>\n"; echo "<!--";
end($circbuf_pointers); var_dump($circbuf_pointers);
var_dump($done);
var_dump($numImg);
echo "-->";
$framesAgo = 0;
// echo "<pre>\n";
end ( $circbuf_pointers );
if ($done) { if ($done) {
end($done); end ( $done );
$lastFrameNumber=key($done); $lastFrameNumber = key ( $done );
$cur_ptr=current($circbuf_pointers); // $lastFrameNumber = key ( $done ) + 9; // NC393 debugging
while($cur_ptr['frame'] > $lastFrameNumber) { $cur_ptr = current ( $circbuf_pointers );
if (!prev($circbuf_pointers)) { /// failed to find the right frame in circbuf - probably overwritten while ( $cur_ptr ['frame'] > $lastFrameNumber ) {
end($circbuf_pointers); if (! prev ( $circbuf_pointers )) { // / failed to find the right frame in circbuf - probably overwritten
end ( $circbuf_pointers );
break; break;
} }
$cur_ptr=current($circbuf_pointers); $cur_ptr = current ( $circbuf_pointers );
$framesAgo++; $framesAgo ++;
} }
} }
///TODO: If all changes were later than the images shown - disregard $todo // /TODO: If all changes were later than the images shown - disregard $todo
//print_r($circbuf_pointers); // print_r($circbuf_pointers);
//print_r($done); // print_r($done);
//echo "</pre>\n"; // echo "</pre>\n";
$meta=array(); $meta = array ();
// end($circbuf_pointers); // end($circbuf_pointers);
$lastFrameIndex=key($circbuf_pointers); $lastFrameIndex = key ( $circbuf_pointers );
for ($i=0; $i<=min(($numImg-1),$lastFrameIndex);$i++) { for($i = 0; $i <= min ( ($numImg - 1), $lastFrameIndex ); $i ++) {
$meta[$i]=array('circbuf_pointer'=>$circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['circbuf_pointer'], $meta [$i] = array (
'meta'=>elphel_get_interframe_meta($GLOBALS [sensor_port],$circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['circbuf_pointer']), 'circbuf_pointer' => $circbuf_pointers [$lastFrameIndex - ($numImg - 1) + $i] ['circbuf_pointer'],
'Exif'=>elphel_get_exif_elphel ($GLOBALS [sensor_port],$circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['exif_pointer'])); 'meta' => elphel_get_interframe_meta (
$lastFrameNumber=$circbuf_pointers[$lastFrameIndex-($numImg-1)+$i]['frame']; $GLOBALS [sensor_port],
} $circbuf_pointers [$lastFrameIndex - ($numImg - 1) + $i] ['circbuf_pointer'] ),
$running=(elphel_get_P_value($GLOBALS [sensor_port], ELPHEL_COMPRESSOR_RUN)==ELPHEL_CONST_COMPRESSOR_RUN_CONT) && 'Exif' => elphel_get_exif_elphel (
(elphel_get_P_value($GLOBALS [sensor_port], ELPHEL_SENSOR_RUN)==ELPHEL_CONST_SENSOR_RUN_CONT); $GLOBALS [sensor_port],
$page_title=sprintf("%s %d images acquired to the circular buffer (circbuf). Acquisition is %s. Last frame is %d" $circbuf_pointers [$lastFrameIndex - ($numImg - 1) + $i] ['exif_pointer'] )
,$framesAgo?"$framesAgo frames (stored) ago":"Latest"
,$numImg
,$running?"on - these frames are/will be overwritten in the camera memory":"off"
,$lastFrameNumber);
/*
$page_title=sprintf("%d: %s %d images acquired to the circular buffer (circbuf). Acquisition is %s"
,$lastFrameNumber
,$framesAgo?"$framesAgo frames ago":"Latest"
,$numImg
,$running?"on - these frames are/will be overwritten in the camera memory":"off"
); );
*/ $lastFrameNumber = $circbuf_pointers [$lastFrameIndex - ($numImg - 1) + $i] ['frame'];
startPage($page_title, ""); }
printf("<h4>%s</h4>\n",$page_title); echo "<!--";
printf ("<table>\n"); var_dump($meta);
$rowOpen=$false; echo "-->";
$lastFrame=0;
$done_left=count($done); $running = (elphel_get_P_value ( $GLOBALS [sensor_port], ELPHEL_COMPRESSOR_RUN ) == ELPHEL_CONST_COMPRESSOR_RUN_CONT) && (elphel_get_P_value ( $GLOBALS [sensor_port], ELPHEL_SENSOR_RUN ) == ELPHEL_CONST_SENSOR_RUN_CONT);
reset($done); $page_title = sprintf ( "%s %d images acquired to the circular buffer (circbuf). Acquisition is %s. Last frame is %d", $framesAgo ? "$framesAgo frames (stored) ago" : "Latest", $numImg, $running ? "on - these frames are/will be overwritten in the camera memory" : "off", $lastFrameNumber );
$slice_start=0; /*
$slice_count=0; * $page_title=sprintf("%d: %s %d images acquired to the circular buffer (circbuf). Acquisition is %s"
for ($i=0;$i<$numImg;$i++) { * ,$lastFrameNumber
$slice_start+=$slice_count; * ,$framesAgo?"$framesAgo frames ago":"Latest"
$slice_count=0; * ,$numImg
$frame=$meta[$i]['Exif']['FrameNumber']; * ,$running?"on - these frames are/will be overwritten in the camera memory":"off"
while($done_left && (key($done) <= $frame)) { * );
$slice_count++; */
$done_left--; startPage ( $page_title, "" );
next($done); printf ( "<h4>%s</h4>\n", $page_title );
} printf ( "<table>\n" );
///$done per image $rowOpen = $false;
$this_done=array_slice($done,$slice_start,$slice_count,true); $lastFrame = 0;
if (!($i % $imagesPerRow)) { $done_left = count ( $done );
reset ( $done );
$slice_start = 0;
$slice_count = 0;
for($i = 0; $i < $numImg; $i ++) {
$slice_start += $slice_count;
$slice_count = 0;
$frame = $meta [$i] ['Exif'] ['FrameNumber'];
while ( $done_left && (key ( $done ) <= $frame) ) {
$slice_count ++;
$done_left --;
next ( $done );
}
// /$done per image
$this_done = array_slice ( $done, $slice_start, $slice_count, true );
if (! ($i % $imagesPerRow)) {
if ($rowOpen) { if ($rowOpen) {
printf ("</tr>\n"); printf ( "</tr>\n" );
} }
printf ("<tr>\n"); printf ( "<tr>\n" );
$rowOpen=true; $rowOpen = true;
} }
printf("<td style='vertical-align: top;'>"); printf ( "<td style='vertical-align: top;'>" );
$skipped=($i>0)?($frame-$lastFrame-1):0; $skipped = ($i > 0) ? ($frame - $lastFrame - 1) : 0;
$lastFrame=$frame; $lastFrame = $frame;
showImgData($meta[$i],$skipped,$numImg-$i-1,$imgScale,$this_done); showImgData ( $meta [$i], $skipped, $numImg - $i - 1, $imgScale, $this_done );
printf("</td>\n"); printf ( "</td>\n" );
} }
while ($i++ % $imagesPerRow) { while ( $i ++ % $imagesPerRow ) {
printf ("<td>&nbsp;</td>\n"); printf ( "<td>&nbsp;</td>\n" );
} }
printf ("</tr>\n"); printf ( "</tr>\n" );
printf ("</table>\n"); printf ( "</table>\n" );
endPage(); endPage ();
} }
/** /**
...@@ -734,7 +750,7 @@ function showSequence($todo,$frame_zero) { ...@@ -734,7 +750,7 @@ function showSequence($todo,$frame_zero) {
printf ("</table>\n"); printf ("</table>\n");
} }
function applyPost($todo,$noFinalWait=false) { function applyPost_debug($todo,$noFinalWait=false) {
global $maxahead,$minahead,$frame_zero,$showSeqMode; global $maxahead,$minahead,$frame_zero,$showSeqMode;
if ($showSeqMode>0) { if ($showSeqMode>0) {
printf("<h4>Running sequence...</h4>\n"); printf("<h4>Running sequence...</h4>\n");
...@@ -747,10 +763,12 @@ function applyPost($todo,$noFinalWait=false) { ...@@ -747,10 +763,12 @@ function applyPost($todo,$noFinalWait=false) {
/// Skip to the next frame (so more deterministic phase - maximal time till next frame) /// Skip to the next frame (so more deterministic phase - maximal time till next frame)
$waitingEnabled=true; $waitingEnabled=true;
/*
foreach ($todo as $pars) if (array_key_exists('SENSOR', $pars)) { foreach ($todo as $pars) if (array_key_exists('SENSOR', $pars)) {
$waitingEnabled=false; $waitingEnabled=false;
break; break;
} }
*/
if (elphel_get_frame($GLOBALS [sensor_port])< 8) $waitingEnabled=false; /// or is "==0" enough? if (elphel_get_frame($GLOBALS [sensor_port])< 8) $waitingEnabled=false; /// or is "==0" enough?
if ($waitingEnabled && !$noFinalWait) elphel_skip_frames($GLOBALS [sensor_port],1); // in GET mode, do not skip any frames if ($waitingEnabled && !$noFinalWait) elphel_skip_frames($GLOBALS [sensor_port],1); // in GET mode, do not skip any frames
/// store the current frame number as reference for all actions delays /// store the current frame number as reference for all actions delays
...@@ -763,16 +781,104 @@ function applyPost($todo,$noFinalWait=false) { ...@@ -763,16 +781,104 @@ function applyPost($todo,$noFinalWait=false) {
$frame_since=$since-$minahead; $frame_since=$since-$minahead;
$frame_now=$frame_since+$frame_zero; $frame_now=$frame_since+$frame_zero;
if ($waitingEnabled) { if ($waitingEnabled) {
if ($showSeqMode > 0) {
printf ( "waiting frame %d (0x%x) ...s=%d, fs=%d noFinalWait=",
$frame_now, $frame_now, $since, $frame_since, $noFinalWait);
ob_flush ();
flush ();
}
elphel_wait_frame_abs ( $GLOBALS [sensor_port], $frame_now );
if ($showSeqMode > 0) {
printf ( "done\n" );
ob_flush ();
flush ();
}
}
}
elphel_set_P_arr ($GLOBALS [sensor_port], $pgmpars, $frame_zero+$since,ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); /// Are these flags needed?
// if ($showSeqMode > 0) {
// printf ( "frame_zero=%d, since=%d",$frame_zero,$since);
// printf ( "elphel_set_P_arr ($GLOBALS [sensor_port], $pgmpars, $frame_zero+$since,ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC)");
// ob_flush ();
// flush ();
// }
}
if (!$noFinalWait) {
$frame_now=$since+$frame_zero+1; /// wait just 1 frame longer that the target of the last command in $todo
// $frame_now+=256;
// if ($showSeqMode > 0) {
// printf ( "frame_zero=%d, since=%d",$frame_zero,$since);
// printf ( "elphel_set_P_arr ($GLOBALS [sensor_port], $pgmpars, $frame_zero+$since,ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC)");
// ob_flush ();
// flush ();
// }
// echo "since=$since\n"; ob_flush(); flush();
if ($showSeqMode>0) {printf ("(final) waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();}
if ($waitingEnabled) {
$rslt = elphel_wait_frame_abs($GLOBALS [sensor_port], $frame_now);
} else {
$timeout_step= 100000; /// 0.1 sec
$timeout= 3000000; /// 3.0sec
for ($i=0 ; $i < $timeout; $i+=$timeout_step) {
if (elphel_get_frame($GLOBALS [sensor_port])>=$frame_now) break;
usleep($timeout_step);
}
}
}
// $rslt2 = elphel_wait_frame_abs($GLOBALS [sensor_port], 100);
// $rslt3 = elphel_wait_frame_abs($GLOBALS [sensor_port], $frame_now);
// $rslt4 = elphel_skip_frames($GLOBALS [sensor_port],4);
if ($showSeqMode>0) {printf ("done, frame is %d, rslt=%d, frame_now was %d, waitingEnabled=%d\n",
elphel_get_frame($GLOBALS [sensor_port]), $rslt, $frame_now, $waitingEnabled);
ob_flush(); flush();
}
if ($showSeqMode>0) echo "</pre>";
// exit (0);
}
function applyPost($todo,$noFinalWait=false) {
global $maxahead,$minahead,$frame_zero,$showSeqMode;
if ($showSeqMode>0) {
printf("<h4>Running sequence...</h4>\n");
echo "<pre>";
}
// print_r($_POST);
// print_r($posted_params);
// var_dump($todo);
// print_r($todo);
/// Skip to the next frame (so more deterministic phase - maximal time till next frame)
$waitingEnabled=true;
foreach ($todo as $pars) if (array_key_exists('SENSOR', $pars)) {
$waitingEnabled=false;
break;
}
if (elphel_get_frame($GLOBALS [sensor_port])< 8) $waitingEnabled=false; /// or is "==0" enough?
if ($waitingEnabled && !$noFinalWait) elphel_skip_frames($GLOBALS [sensor_port],1); // in GET mode, do not skip any frames
/// store the current frame number as reference for all actions delays
$frame_zero=elphel_get_frame($GLOBALS [sensor_port]);
$frame_since=0;
$frame_now=$frame_zero;
///Iterate through $todo array, programming the parameter changes
foreach ($todo as $since=>$pgmpars) {
if (($since-$maxahead) >$frame_since ) { /// too early to program, need to wait
$frame_since=$since-$minahead;
$frame_now=$frame_since+$frame_zero;
// $frame_now=$frame_since+$frame_zero+2; // NC393: adding 2 extra
if ($waitingEnabled) {
// $frame_now=$frame_since+$frame_zero;
if ($showSeqMode>0) {printf ("waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();} if ($showSeqMode>0) {printf ("waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();}
elphel_wait_frame_abs($GLOBALS [sensor_port], $frame_now); elphel_wait_frame_abs($GLOBALS [sensor_port], $frame_now);
if ($showSeqMode>0) {printf ("done\n"); ob_flush(); flush();} if ($showSeqMode>0) {printf ("done (%d)\n", elphel_get_frame($GLOBALS [sensor_port])); ob_flush(); flush();}
} }
} }
elphel_set_P_arr ($GLOBALS [sensor_port], $pgmpars, $frame_zero+$since,ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); /// Are these flags needed? elphel_set_P_arr ($GLOBALS [sensor_port], $pgmpars, $frame_zero+$since,ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC); /// Are these flags needed?
} }
if (!$noFinalWait) { if (!$noFinalWait) {
$frame_now=$since+$frame_zero+1; /// wait just 1 frame longer that the target of the last command in $todo $frame_now=$since+$frame_zero+1; /// wait just 1 frame longer that the target of the last command in $todo
// echo "since=$since\n"; ob_flush(); flush(); // $frame_now=$since+$frame_zero+4; /// wait just 1 frame longer that the target of the last command in $todo
// echo "since=$since\n"; ob_flush(); flush();
if ($showSeqMode>0) {printf ("waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();} if ($showSeqMode>0) {printf ("waiting frame %d (0x%x) ... ",$frame_now,$frame_now); ob_flush(); flush();}
if ($waitingEnabled) { if ($waitingEnabled) {
elphel_wait_frame_abs($GLOBALS [sensor_port], $frame_now); elphel_wait_frame_abs($GLOBALS [sensor_port], $frame_now);
...@@ -784,12 +890,15 @@ function applyPost($todo,$noFinalWait=false) { ...@@ -784,12 +890,15 @@ function applyPost($todo,$noFinalWait=false) {
usleep($timeout_step); usleep($timeout_step);
} }
} }
// } else { // just debugging - still waiting
// elphel_skip_frames($GLOBALS [sensor_port],8); // skip 8 frames - debugging NC393 - no differnce!
} }
if ($showSeqMode>0) {printf ("done\n"); ob_flush(); flush();} if ($showSeqMode>0) {printf ("done (%d, 0x%x)\n", elphel_get_frame($GLOBALS [sensor_port]), elphel_get_frame($GLOBALS [sensor_port])); ob_flush(); flush();}
if ($showSeqMode>0) echo "</pre>"; if ($showSeqMode>0) echo "</pre>";
// exit (0); // exit (0);
} }
function parsePost() { function parsePost() {
global $_POST,$testMode,$showSeqMode,$posted_params; global $_POST,$testMode,$showSeqMode,$posted_params;
$posted_params=array(); $posted_params=array();
...@@ -1204,11 +1313,11 @@ function printPage($encoded_todo) { ...@@ -1204,11 +1313,11 @@ function printPage($encoded_todo) {
printf ("<table border='1' style='font-family: Courier, monospace;'>\n"); printf ("<table border='1' style='font-family: Courier, monospace;'>\n");
if ($embedImageScale) { if ($embedImageScale) {
$fd_circ=fopen("/dev/circbuf","r"); $fd_circ=fopen("/dev/circbuf".strval($GLOBALS['sensor_port']),"r");
fseek($fd_circ, ELPHEL_LSEEK_CIRC_LAST,SEEK_END); fseek($fd_circ, ELPHEL_LSEEK_CIRC_LAST,SEEK_END);
$circbuf_pointer=ftell($fd_circ); $circbuf_pointer=ftell($fd_circ);
fclose($fd_circ); fclose($fd_circ);
// echo "circbuf_pointer=$circbuf_pointer";
if ($circbuf_pointer>=0) { if ($circbuf_pointer>=0) {
$meta=elphel_get_interframe_meta($GLOBALS [sensor_port], $circbuf_pointer); $meta=elphel_get_interframe_meta($GLOBALS [sensor_port], $circbuf_pointer);
$width= floor($meta['width']*$embedImageScale); $width= floor($meta['width']*$embedImageScale);
......
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