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

more debugging

parent edaa3147
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -17,8 +17,7 @@ PHP_SCRIPTS_EXE=lwir16.php \
            test_int.php \
            test_wpipe.php \
            test_ps.php
CONFIGS = lwir16.ini \
          multicamconf.xml
CONFIGS = lwir16.ini
            
all:
	@echo "make all in src"
+4 −3
Original line number Diff line number Diff line
@@ -5,10 +5,11 @@ multicam_speriod = 2.0
#save current settings to overwrite those in this file
multicam_conf = "/etc/elphel393/multicamconf.xml"

ips =        "192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45"
port_masks=  "15,15,15,15,15"
ips =        "192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45,192.168.0.46"
port_masks=  "15,15,15,15,15,0"
#1 - run/stop, 2 - continuous, 0 do not use
run_modes =  "1,1,1,1,2"
#OR-ed: 49 - master LWIR RAW, 33 - slave LWIR RAW, 42 - continuously-run slave EO RAW, 4 - slave IMS logger, file system  
run_modes =  "49,33,33,33,42,4"
lwir_fps =      59.98
eo_decimate_m1 = 5
duration =     500
+176 −85
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@
   define('REG_FFC_RUN',        'SENSOR_REGS26');    // Register to trigger FFC
   define('SCRIPT_RESET',       'reset_frames.php'); // Reset frame numbers
   define('SCRIPT_WAIT',        'wait_frame.php');   // wait frame
   define('DEFAULT_IPS',        '192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45');
//   define('DEFAULT_IPS',        '192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45,192.168.0.45');
//   define('DEFAULT_PORTS',      '15,15,15,15,15,0');
//   define('DEFAULT_MODES',      '1,1,1,1,2,0'); // maybe make a special mode for the logger
   define('PIPE_CMD',           '/tmp/pipe_cmd');
   define('PIPE_RESPONSE',      '/tmp/pipe_response');
   define('PIPE_MODE',          0600);
@@ -41,6 +43,21 @@
   define('IPS',                'ips');
   define('PORT_MASKS',         'port_masks');
   define('RUN_MODES',          'run_modes');
   // OR-ed: 49 - master LWIR RAW, 33 - slave LWIR RAW, 42 - continuously-run slave EO RAW, 4 - slave IMS logger, file system  
   define('RUN_MODE_LWIR',      1);
   define('RUN_MODE_EO',        2);
   define('RUN_MODE_IMS',       4);
   define('RUN_MODE_CONT',      8); // continuously run from start to stop
   define('RUN_MODE_MASTER',   16);
   define('RUN_MODE_RAWREC',   32); // raw recording, 0 - use file system
   // calculated and set to globals
   define('IP_LWIR',            'ip_lwir');
   define('IP_EO',              'ip_eo');
   define('IP_CAMERAS',         'ip_cameras');
   define('IP_MASTER',          'ip_master');
   define('IP_IMS',             'ip_ims');
   
   
   
   define('ALL_PORTS',          15);
   define('IMGSRV_PORT0',       2323);
@@ -146,6 +163,7 @@
       if (($key == 'ip') || ($key == 'ips')){ //  multicamera operation
           $GLOBALS[IPS] = explode(',',$value);
           unset ($GLOBALS[PORT_MASKS]); // invalidate
           unset ($GLOBALS[RUN_MODES]); // invalidate
       } else if ($key == PORT_MASKS){ //
           $masks = explode(',',$value);
           unset ($GLOBALS[PORT_MASKS]); // invalidate
@@ -180,25 +198,30 @@
       else if ($key == TIFF_AUTO)      $GLOBALS[TIFF_AUTO] =      (int) $value;
       else if ($key == OUTPUT_LOG)     $GLOBALS[OUTPUT_LOG] =           $value;
   }
   $need_setIPs=!isset($GLOBALS[PORT_MASKS]) || !isset($GLOBALS[RUN_MODES]);
   if (!isset($GLOBALS[PORT_MASKS])){
       $GLOBALS[PORT_MASKS] = array();
       for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
//           print ('<pre>'.$i."\n</pre>");
           if (isset($masks) && (count($masks) > $i)){
               $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (int) ($masks[$i]);
               $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = intval ($masks[$i]);
           } else {
               $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = ALL_PORTS;
//               print ('<pre>'.$i."->".$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]."\n</pre>");
           }
       }
   }
   if (!isset($GLOBALS[RUN_MODES])){
       $GLOBALS[RUN_MODES] = array();
       for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
           if (isset($run_modes) && (count($run_modes) > $i)){
               $GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] = (int) ($run_modes[$i]);
               $GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] = intval ($run_modes[$i]);
           } else {
               $GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] = 0;
               //               print ('<pre>'.$i."->".$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]."\n</pre>");
           }
           
       }
   }
   if ($need_setIPs) {
       setIPs(); // normally not used - all that data is provided by config file, not the URL
   }
   //   print_r($lswir16cmds);
//   exit(0);
    /*
@@ -246,10 +269,10 @@
//       print("1");
//       print("2");
//       exit(0);
       
       $lwir_ips= array($GLOBALS[IPS][0],$GLOBALS[IPS][1],$GLOBALS[IPS][2],$GLOBALS[IPS][3]);
           //$GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] = 0;
//       $ip_lwir= array($GLOBALS[IPS][0],$GLOBALS[IPS][1],$GLOBALS[IPS][2],$GLOBALS[IPS][3]);
//       $twoIPs= array($GLOBALS[IPS][0],$GLOBALS[IPS][4]);
       $twoIPs= $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
//       $twoIPs= $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
//       print_r($lswir16cmds);
 
       for ($ncmd = 0; $ncmd < count($lswir16cmds); $ncmd++){
@@ -422,27 +445,71 @@ EOT;
        $FFC_FRAMES = 8;
        $REG_FFC_FRAMES = 'SENSOR_REGS4'; // Register for the number of FFC frames to integrate
        $REG_FFC_RUN = 'SENSOR_REGS26'; // Register to trigger FFC
        $lwir_ips = array(
            $GLOBALS[IPS][0],
            $GLOBALS[IPS][1],
            $GLOBALS[IPS][2],
            $GLOBALS[IPS][3]
        );
        $twoIPs = $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
//        $lwir_ips = array(
//            $GLOBALS[IPS][0],
//            $GLOBALS[IPS][1],
//            $GLOBALS[IPS][2],
//            $GLOBALS[IPS][3]
//        );
//        $twoIPs = $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
        if ($debug) {
            printf("--- twoIPs:\n");
            print_r($twoIPs);
            printf("--- GLOBALS[IP_CAMERAS]:\n");
            print_r($GLOBALS[IP_CAMERAS]);
        }
        
        $results0 = skipFrames($twoIPs, 2, $debug);
        
        
        $results0 = skipFrames($GLOBALS[IP_CAMERAS], 2, $debug);
        // print_r($results0);
        $results1 = resetIPs($GLOBALS[IPS],$debug); // sync channels in each subcamera
        $results1 = resetIPs($GLOBALS[IP_CAMERAS],$debug); // sync channels in each subcamera
        // print_r($results1);
        $results2 = skipFrames($twoIPs, 16,$debug); // was 1
        $results2 = skipFrames($GLOBALS[IP_CAMERAS], 16,$debug); // was 1
        // print_r($results2); print("<br/>");
        $trig_period = 100000000/$GLOBALS[LWIR_FPS];
        $urls = array(); // eo - individual
                     // For LWIR - only port 0, for EO - every port
//        echo "<pre>\n";
//        var_dump($GLOBALS[IP_LWIR]);
//        var_dump($GLOBALS);
//        echo "</pre>\n";
//        exit(0);
        foreach ($GLOBALS[IP_LWIR] as $ip) {
            $url = 'http://' . $ip . '/parsedit.php?immediate&sensor_port=0' .
                    '&TRIG_OUT=0x66555' . '&TRIG_CONDITION=0x95555' . '&TRIG_BITLENGTH=31' . '&EXTERN_TIMESTAMP=1' .
                    '&XMIT_TIMESTAMP=1' . '&TRIG_DELAY=' . $lwir_trig_dly . '&*TRIG_DELAY=15' . // apply to all ports
                    '&TRIG_PERIOD=' . $trig_period . '&*TRIG_PERIOD=15' . '&BITS=16&*BITS=15' . '&COLOR=' . $COLOR_RAW . '&*COLOR=15' .
                    '&WOI_HEIGHT=' . ($LWIR_HEIGHT + ($LWIR_TELEMETRY ? $LWIR_TELEMETRY_LINES : 0)) . '&*WOI_HEIGHT=15' .
                    '&' . $REG_FFC_FRAMES . '=' . $FFC_FRAMES . '&*' . $REG_FFC_FRAMES . '=15' . // apply to all channels
                    '&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15';
            $urls[] = $url;
        }
        foreach ($GLOBALS[IP_EO] as $ip) {
            for ($port = 0; $port < 4; $port ++) {
                if ($GLOBALS[PORT_MASKS][$ip] & (1 << $port)) {
                    $url = 'http://' . $ip . '/parsedit.php?immediate&sensor_port=' . $port .
                    '&TRIG_OUT=0x66555' . '&TRIG_CONDITION=0x95555' . '&TRIG_BITLENGTH=31' . '&EXTERN_TIMESTAMP=1' . '&XMIT_TIMESTAMP=1' .
                    "&COLOR=" . $COLOR_JP4 .
                    "&QUALITY=" . $eo_quality .
                    "&EXPOS=" . $exposure .
                    "&AUTOEXP_EXP_MAX=" . $autoExposureMax .
                    "&AUTOEXP_ON=" . $autoExp .
                    "&GAING=" . $gain .
                    "&RSCALE=" . $rScale . // "*0".
                    "&BSCALE=" . $bScale . // "*0".
                    "&GSCALE=" . $gScale . // "*0". // GB/G ratio
                    "&WB_EN=" . $autoWB . // "*0".
                    "&DAEMON_EN_TEMPERATURE=1"; // "*0";
                    "&DAEMON_EN_TEMPERATURE=1"; // "*0";
                    if (lrp . eo_full_window) {
                        $url .= "&WOI_LEFT=0" . "&WOI_TOP=0" . "&WOI_WIDTH=2592" . "&WOI_HEIGHT=1936";
                    }
                    if ($chn == 0) {
                        $url .= '&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15';
                        $url .= '&TRIG_DECIMATE='.$GLOBALS[EO_DECIMATE_M1] .'&*TRIG_DECIMATE=15';
                    }
                    $urls[] = $url;
                }
            }
        }
        /*
        for ($i = 0; $i < (count($GLOBALS[IPS]) + 3); $i ++) {
            $nip = $i;
            if ($nip >= count($GLOBALS[IPS])) {
@@ -451,19 +518,22 @@ EOT;
            $urls[$i] = 'http://' . $GLOBALS[IPS][$nip] . '/parsedit.php?immediate&sensor_port=' . ($i - $nip);
            $urls[$i] .= '&TRIG_OUT=0x66555' . '&TRIG_CONDITION=0x95555' . '&TRIG_BITLENGTH=31' . '&EXTERN_TIMESTAMP=1' . '&XMIT_TIMESTAMP=1';
        }
        */
        // print_r($urls); print("<br/>");
        // exit(0);
        $trig_period = 100000000/$GLOBALS[LWIR_FPS];
/*        
        for ($i = 0; $i < count($lwir_ips); $i ++) {
            $urls[$i] .= '&TRIG_DELAY=' . $lwir_trig_dly . '&*TRIG_DELAY=15' . // apply to all ports
                '&TRIG_PERIOD=' . $trig_period . '&*TRIG_PERIOD=15' .
                '&BITS=16&*BITS=15' . '&COLOR=' . $COLOR_RAW . '&*COLOR=15' . '&WOI_HEIGHT=' . ($LWIR_HEIGHT + ($LWIR_TELEMETRY ? $LWIR_TELEMETRY_LINES : 0)) . '&*WOI_HEIGHT=15' . '&' . $REG_FFC_FRAMES . '=' . $FFC_FRAMES . '&*' . $REG_FFC_FRAMES . '=15'; // apply to all channels
            $urls[$i] .= '&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15';
        }
        
        if ($debug) {
            print_r($GLOBALS[IPS]);
            print_r($urls);
        }

        for ($chn = 0; $chn < 4; $chn ++) { // last IP
            $urls[count($GLOBALS[IPS]) - 1 + $chn] .=
            "&COLOR=" . $COLOR_JP4 .
@@ -485,6 +555,7 @@ EOT;
                $urls[count($GLOBALS[IPS]) - 1] .= '&TRIG_DECIMATE='.$GLOBALS[EO_DECIMATE_M1] .'&*TRIG_DECIMATE=15';
            }
        }
        */
        if ($debug) {
            printf("--- setting camera parameters, urls:\n");
            print_r($urls);
@@ -499,16 +570,24 @@ EOT;
            print_r($results3);
        }
        
        
        
        $results4 = skipFrames($twoIPs, 16,$debug);
        $results4 = skipFrames($GLOBALS[IP_CAMERAS], 16,$debug);
        // set external trigger mode for all LWIR and EO cameras
        $urls = array();
        /*
        for ($i = 0; $i < count($GLOBALS[IPS]); $i ++) {
            $urls[] = 'http://' . $GLOBALS[IPS][$i] .
            '/parsedit.php?immediate&sensor_port=0&TRIG=4&*TRIG=15' .
            '&COMPRESSOR_RUN=' . $GLOBALS[COMPRESSOR_RUN] . '*5&*COMPRESSOR_RUN=15'; // delay turning off COMPRESSOR_RUN
        }
        */
        foreach ($GLOBALS[IP_CAMERAS] as $ip) {
            $url = 'http://' . $ip .
            '/parsedit.php?immediate&sensor_port=0&TRIG=4&*TRIG=15' .
            '&COMPRESSOR_RUN=' . $GLOBALS[COMPRESSOR_RUN] . '*5&*COMPRESSOR_RUN=15'; // delay turning off COMPRESSOR_RUN
            $urls[] = $url;
        }
        
        
        if ($debug) {
            printf("--- finally setting camera parameters (see COMPRESSOR_RUN), urls:\n");
            print_r($urls);
@@ -522,13 +601,13 @@ EOT;
            print_r($results5);
        }
        
        $results6 = skipFrames($twoIPs, 16,$debug); // make sure all previous parameters are applied // waits for both LWIR and EO
        $results6 = skipFrames ($GLOBALS[IP_CAMERAS], 16,$debug); // make sure all previous parameters are applied // waits for both LWIR and EO
                                             // second reset after cameras running synchronously
        $results7 = resetIPs($GLOBALS[IPS]); // sync channels in each subcamera
        $results8 = skipFrames($twoIPs, 16,$debug); // was 2
        $results7 = resetIPs   ($GLOBALS[IP_CAMERAS]); // sync channels in each subcamera
        $results8 = skipFrames ($GLOBALS[IP_CAMERAS], 16,$debug); // was 2
    
        $results9 = resetIPs($GLOBALS[IPS]); // sync channels in each subcamera
        $results10 = skipFrames($twoIPs, 16,$debug); // was 2
        $results9 = resetIPs   ($GLOBALS[IP_CAMERAS]); // sync channels in each subcamera
        $results10 = skipFrames($GLOBALS[IP_CAMERAS], 16,$debug); // was 2
        $results = $results10;
        return $results;
   }
@@ -558,21 +637,23 @@ EOT;
       $FFC_FRAMES = 8;
       $REG_FFC_FRAMES = 'SENSOR_REGS4'; // Register for the number of FFC frames to integrate
       $REG_FFC_RUN = 'SENSOR_REGS26'; // Register to trigger FFC
       /*
       $lwir_ips = array(
           $GLOBALS[IPS][0],
           $GLOBALS[IPS][1],
           $GLOBALS[IPS][2],
           $GLOBALS[IPS][3]
       );
       $twoIPs = $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
       */
//       $twoIPs = $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
       $sensor_port = 0;
       if ($debug) {
           printf("--- runCapture: run_ffc=%d, wait=%d\n",$run_ffc,$wait);
           print_r($lwir_ips);
           print_r($GLOBALS[IP_LWIR]);
       }
       
       if ($run_ffc){ // may move after measuring time, but need to make sure it will be not too late
           runFFC($lwir_ips, $ffc_wait_frames, $debug);
           runFFC($GLOBALS[IP_LWIR], $ffc_wait_frames, $debug);
       }
       if ($GLOBALS[I_AM_MASTER]) {
           $this_frame = elphel_get_frame($sensor_port);
@@ -581,37 +662,27 @@ EOT;
       }
//       $timestamp = $this_timestamp + $GLOBALS[PRE_DELAY]; // this will be a delay between capture sequences (default - 3s)
       $urls = array();
       for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] > 0){ // 0 - do not use this camera at all
//       for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] > 0){ // 0 - do not use this camera at all
       foreach ($GLOBALS[IP_CAMERAS] as $ip) { // already filtered
           // $_SERVER[SCRIPT_NAME] STARTS WITH '/'
           $url = 'http://'.$GLOBALS[IPS][$i].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
//           $url = 'http://'.$GLOBALS[IPS][$i].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
           $url = 'http://'.$ip.'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
           if ($GLOBALS[I_AM_MASTER]) {
               $url .= '&ts='.$timestamp;        // &timestamp" -> ×tamp
           } else {
               $url .= '&a='.$GLOBALS[PRE_DELAY]; // &timestamp" -> ×tamp
           }
//           $url .= '&port_mask=15'; // .$port_mask[$i];
           $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]; //indexed by IPs
           $dur = ($i < 4) ? $GLOBALS[DURATION] : $GLOBALS[DURATION_EO];  // maybe turn on EO forever
           if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] == 2) {// continuous run mode
           /*
               if ($first_run)  {
                   $dur = -1; // start only, no stop
               } else {
                   continue; // nothing to do for this camera, it is supposed to already be running. Or just enable compressor anyway?
               }
               */
//           $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]; //indexed by IPs
           $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$ip]; //indexed by IPs
//           $dur = ($i < 4) ? $GLOBALS[DURATION] : $GLOBALS[DURATION_EO];  // maybe turn on EO forever
           $dur = ($GLOBALS[RUN_MODES][$ip] & RUN_MODE_LWIR) ? $GLOBALS[DURATION] : $GLOBALS[DURATION_EO];
//           if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] == 2) {// continuous run mode
           // TODO: Make conditional?
           if ($GLOBALS[RUN_MODES][$ip] & RUN_MODE_CONT) {// continuous run mode
               $dur = -1; // start only, no stop
           }
           $url .= '&duration='. $dur;
           //                   $url .= '&maxahead='. $maxahead;
           //                   $url .= '&minahead='. $minahead;
           $url .= '&extra='.    CR_EXTRA; // $extra;
           // 
           /* disabling $wait
           if ($wait && ($i == (count($GLOBALS[IPS]) - 1))){ // addd to the last ip in a list maybe to the first?
               $url .= '&wait';
           }
           */
           $urls[] = $url;
       }
       if ($debug) {
@@ -699,7 +770,6 @@ EOT;
   function skipFrames($ips, $skip, $debug=0) {
       $urls = array();
       for ($i = 0; $i<count($ips); $i++){
//           $url = 'http://'.$ips[$i].$_SERVER[SCRIPT_NAME].'?frame='.$frame; //
           $url = 'http://'.$ips[$i].'/'.SCRIPT_WAIT.'?frame='.(-$skip); //
           $urls[] = $url;
       }
@@ -722,7 +792,7 @@ EOT;
       if(file_exists(PIPE_CMD)){
           unlink(PIPE_CMD); //delete pipe if it was already there - waiting prevents signal handling!
       }
       $url_wait_capture;
       $url_wait_capture; // ???
       $GLOBALS[DAEMON_RUN] =   1;
       $GLOBALS[CAPTURE_RUN] =  0; // until command
       $GLOBALS[CAPTURE_WAIT] = 0;
@@ -834,12 +904,6 @@ EOT;
               if ($GLOBALS[DEBUG]){
                   printf("--- got from pipe: ---\n");
               }
               /*
               $f = fopen(PIPE_CMD,"r");
               if ($GLOBALS[DEBUG]) echo "(r) opened cmd\n";
               $cmd_lines = fgets($f);
               fclose ($f);
               */
               $cmd_lines = file_get_contents(PIPE_CMD);
               if ($GLOBALS[DEBUG]) echo $cmd_lines."\n";
               if ($GLOBALS[DEBUG]) echo "(r) closed cmd\n";
@@ -849,8 +913,6 @@ EOT;
                   print_r($ini);
               }
               unset ($GLOBALS[DAEMON_CMD]);
               
               
               applyConf ($ini); // update $GLOBALS
               $from_pipe = true;
               if ($GLOBALS[DEBUG] > 1){
@@ -867,7 +929,8 @@ EOT;
               // or maybe monitor one of the cameras until done?
//               $skip = 1; // OK if more
//               $rslt = skipFrames($ips0,$skip);
               $url = 'http://'.$GLOBALS[IPS][0].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port=0&state&frame='.$GLOBALS[FRAMES_WAIT]; //
//               $url = 'http://'.$GLOBALS[IPS][0].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port=0&state&frame='.$GLOBALS[FRAMES_WAIT]; //
               $url = 'http://'.$GLOBALS[IP_LWIR][0].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port=0&state&frame='.$GLOBALS[FRAMES_WAIT]; // or use IP_MASTER?
               $resp = file_get_contents($url);
               $spos = strpos($resp, '<left>')+strlen('<left>');
               $epos = strpos($resp, '</left>', $spos);
@@ -884,10 +947,11 @@ EOT;
                   $sensor_port = 0;
                   $urls = array();
                   // stop all started cameras, including started-only, but not inactive. TODO - add inactive to skip initialization?
                   for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] > 0){ // 0 - do not use this camera at all
//                   for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] > 0){ // 0 - do not use this camera at all
                   foreach ($GLOBALS[IP_CAMERAS] as $ip) { // already filtered
                           // $_SERVER[SCRIPT_NAME] STARTS WITH '/'
                       $url = 'http://'.$GLOBALS[IPS][$i].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
                       $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]; //indexed by IPs
                       $url = 'http://'.$ip.'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
                       $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$ip]; //indexed by IPs
                       $url .= '&frame=0&duration=0'; // immediately stop compressors, do not use daemon
                       $urls[] = $url;
                   }
@@ -907,7 +971,7 @@ EOT;
///               if (($left_frames > 0) && !$abort_sequence){
               if ($left_frames > 0) {
                       // skip some frames as there is nothing to do
                   $rslt = skipFrames(array($GLOBALS[IPS][0]),$GLOBALS[FRAMES_IDLE]);// just master camera IP
                       $rslt = skipFrames(array($GLOBALS[IP_LWIR][0]),$GLOBALS[FRAMES_IDLE]);// just master camera IP
               }
               $abort_sequence  = 0;
               
@@ -919,7 +983,6 @@ EOT;
                   $run_ffc = true;
                   $GLOBALS[LAST_FFC] = $now;
               }
//               $result =  runCapture($run_ffc, false, $GLOBALS[$GLOBALS[DEBUG]]);
               $result =  runCapture($run_ffc, false, $need_service, $GLOBALS[DEBUG]);
               $need_service = 0;
               $GLOBALS[SEQUENCE_NUM]++;
@@ -932,17 +995,19 @@ EOT;
               if ($GLOBALS[DEBUG] > 0){
                   printf("--- idle: need_service=$need_service: ---\n");
               }
               if ($need_service) { // need to stop those that were continuously running. FIXME: now will not wor if all are continuously running
               if ($need_service) { // need to stop those that were continuously running. FIXME: now will not work if all are continuously running
                   $sensor_port = 0;
                   $urls = array();
                   // stop all continuously run cameras, but not inactive. TODO - add inactive to skip initialization?
                   for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] ==2) { // only continuously running
                       // $_SERVER[SCRIPT_NAME] STARTS WITH '/'
                   //for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] ==2) { // only continuously running
                   foreach ($GLOBALS[IP_CAMERAS] as $ip) {
                       if ($GLOBALS[RUN_MODES][$ip] & RUN_MODE_CONT) {
                           $url = 'http://'.$GLOBALS[IPS][$i].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
                           $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]; //indexed by IPs
                           $url .= '&frame=0&duration=0'; // immediately stop compressors, do not use daemon
                           $urls[] = $url;
                       }
                   }
                   if ($GLOBALS[DEBUG] > 0){
                       printf("--- stopping continuously running cameras: URLs:\n");
                       print_r($urls);
@@ -963,7 +1028,7 @@ EOT;
                   $need_service = 0;
               }
               // skip some frames as there is nothing to do
               $rslt = skipFrames(array($GLOBALS[IPS][0]),$GLOBALS[FRAMES_IDLE]);// just master camera IP
               $rslt = skipFrames(array($GLOBALS[IP_LWIR][0]),$GLOBALS[FRAMES_IDLE]);// just master camera IP
           }
       }
       if ($GLOBALS[DEBUG]){
@@ -1016,6 +1081,7 @@ EOT;
                   $GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] = 0;
               }
           }
           setIPs(); // set ip arrays ($GLOBALS[IP_LWIR], ...) that depend on RUN_MODES
       }
       if (isset($arr[DURATION])){
           $GLOBALS[DURATION] =   (int)       $arr[DURATION];
@@ -1278,4 +1344,29 @@ EOT;
        return $camera_state['state'];
    }
    
    function setIPs(){
        $GLOBALS[IP_LWIR]=     array();
        $GLOBALS[IP_EO]=       array();
        $GLOBALS[IP_CAMERAS]=  array();
        $GLOBALS[IP_MASTER]=   array(); // normally just one, use [0]
        $GLOBALS[IP_IMS]=      array(); // normally just one, use [0]
        foreach ($GLOBALS[RUN_MODES] as $ip => $smode){
            $mode = intval($smode); // just in case, should already be integer
            if ($mode & RUN_MODE_MASTER) {
                $GLOBALS[IP_MASTER][] =  $ip; // use [0]
            }
            if ($mode & RUN_MODE_LWIR) {
                $GLOBALS[IP_LWIR][] =    $ip;
                $GLOBALS[IP_CAMERAS][] = $ip;
            }
            if ($mode & RUN_MODE_EO) {
                $GLOBALS[IP_EO][] =      $ip;
                $GLOBALS[IP_CAMERAS][] = $ip;
            }
            if ($mode & RUN_MODE_IMS) {
                $GLOBALS[IP_IMS] =       $ip;
            }
        }
    }
   
?>

src/lwir16/multicamconf.xml

deleted100644 → 0
+0 −9
Original line number Diff line number Diff line
<?xml version="1.0" encoding="iso-8859-1"?>
<multicam>
	<ips>192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45</ips>
	<port_masks>15,15,15,15,15</port_masks>
	<multicam_dir>office_04</multicam_dir>
	<multicam_rperiod>5</multicam_rperiod>
	<multicam_speriod>10</multicam_speriod>
	<multicam_conf>/etc/elphel393/multicamconf.xml</multicam_conf>
</multicam>
Loading