Commit 5a1a4d6f authored by Andrey Filippov's avatar Andrey Filippov
Browse files

removed excessive killall polluting log and more debugging multicam3.js

parent 9389820e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ tiff_bin_shift = 1
tiff_auto =      0
frames_idle =   10
frames_wait =   20
debug =          1
debug =          0
output_log = /var/log/lwir16.log
 # no spaces around commas!
CMD =        INIT,START
 No newline at end of file
+74 −19
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ var Camera = function(options){
    camogm: false,
    recording: false,
    mounted: false,
    restarts: 0,
    ports: []
  };

@@ -213,7 +214,6 @@ function get_ports(){
}

function check_camogm(cam_i){

  // run_status does not interact with camogm, quickest response
  $.ajax({
    url: "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=run_status",
@@ -226,11 +226,12 @@ function check_camogm(cam_i){
        console.log(cams[this.cam_i].ip+": camogm is off");
        // launch it
        camogm_launch(this.cam_i);
        cams[this.cam_i].restarts++;
      }
      if (state=='on'){
        console.log(cams[this.cam_i].ip+": camogm is on");
//        check_camogm_status(this.cam_i);
        setDirSingle(this.cam_i); // wiil end with check_camogm_status(this.cam_i)
        check_camogm_status(this.cam_i);
//        setDirSingle(this.cam_i); // wiil end with check_camogm_status(this.cam_i)
      }
    }
  });
@@ -285,6 +286,7 @@ function check_camogm_status(cam_i){ // full check, slow
	    url: "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=status",
	    cam_i: cam_i,
	    success: function(res){
		let full_buf=0x4000000-4000000; // subtracted MIN_USED_SIZE from camogm.h
	      var cam = cams[this.cam_i];
	//      console.log("check_camogm_status for "+cam_i+" success");
	      if ($(res).find('state').length!=0){
@@ -305,8 +307,33 @@ function check_camogm_status(cam_i){ // full check, slow
	        var lba_current = parseInt($(res).find('lba_current').text());
	
	        var free_space = (lba_end - lba_current)/2/1024/1024;
		    var sdd_found = free_space > 0;
		    cam.mounted = sdd_found;
	        
	        free_space = Math.round(100*free_space)/100;
	        se.find("#s_space").html(free_space+" GB");
            var bgcol = sdd_found ? "rgb(200, 255, 200)":"rgb(255, 100,100)"; // add yellow for low space
            se.find("#s_space").attr("style","background-color:"+bgcol+";");
            
   	        se.find("#s_restarts").html(cam.restarts);
            var bgcol_restarts = cam.camogm ? "rgb(200, 255, 200)":"rgb(255, 100,100)";
            se.find("#s_restarts").attr("style","background-color:"+bgcol_restarts+";");
// find free buffer size - minimum of all ports 
            var buf_free_coll = $(res).find('buffer_free');
//            console.log(buf_free_coll);
            var min_free=full_buf;
            var this_free;
            for (var i = 0; i< buf_free_coll.length; i++){
				this_free=parseInt(buf_free_coll[i].innerHTML);
				if (this_free < min_free) min_free = this_free;
//				console.log(buf_free_coll[i]);
//				console.log(i+":"+buf_free_coll[i].innerHTML);
            }
            var free_buf =  Math.round(100 *min_free / full_buf);
            console.log(free_buf+"%  - min free="+min_free+" ("+full_buf+"), ");
   	        se.find("#s_buf").html(free_buf+'%');
            var bgcol_buf = (free_buf > 25) ? "rgb(200, 255, 200)":"rgb(255, 100,100)";
            se.find("#s_buf").attr("style","background-color:"+bgcol_buf+";");
	      }
	    }
	  }).fail(function(data,status){
@@ -339,7 +366,7 @@ function check_camogm_free_space(cam_i){ // file system, no raw
       se.find("#s_space").html(free_space+" GB");
       var bgcol = sdd_found ? "rgb(200, 255, 200)":"rgb(255, 100,100)"; // add yellow for low space
       se.find("#s_space").attr("style","background-color:"+bgcol+";");
       
       console.log("hdd: "+cam.ip+", mounted="+cam.mounted);
      }
    }
  }).fail(function(data,status){
@@ -358,7 +385,6 @@ function rec_button_update_state(){
  var all_ready = true;
  var any_running = false;
  var any_stopped = false;

  for(var i=0;i<cams.length;i++){
    if (cams[i].init){
      if ((cams[i].camogm=='on')&&(!cams[i].recording)){
@@ -378,6 +404,9 @@ function rec_button_update_state(){

    if (any_running && any_stopped){
      console.log("WARNING: some camogms are running, some are stopped"); // false
  		for(var i=0;i<cams.length;i++){
	       console.log(i+": "+cams[i].recording);
		}
    }

    if (all_ready_init_run){
@@ -588,7 +617,9 @@ function init3(index){
    '<td id=\'s_ip\'>'+cam.ip+'</td>',
    '<td id=\'s_device\'></td>',
    '<td id=\'s_space\'></td>',
    '<td id=\'s_errors\'></td>'
    '<td id=\'s_errors\'></td>',
    '<td id=\'s_restarts\'></td>',
    '<td id=\'s_buf\'></td>'
  ].join('\n');

  $("#display_status").find("tr[ip=\'"+cam.ip+"\']").html($(status_str));
@@ -704,7 +735,13 @@ function init_rec_button(){
        recording = 1;
        rec_button_switch(recording);
		// mkdir for recording
	    if (use_file_system ){
			url = "camogm_interface.php?cmd=dir_prefix&name=" + multicam_dir;
       		console.log("Setting camogm directory/prefix, url="+url); 
		} else {
			url = "camogm_interface.php?cmd=set_prefix_raw&prefix=" + multicam_dir;
       		console.log("Setting camogm raw prefix, url="+url); 
		}
	    multi_ajax(url,function(){
       		console.log("starting recording in the camera "+ this.ip+" to " + multicam_dir); 
       		// launch recording 
@@ -767,6 +804,8 @@ function addrs_create_tables(){
    '  <th>device</th>',
    '  <th>free space</th>',
    '  <th>errors</th>',
    '  <th>r</th>',
    '  <th>buf</th>',
    '</tr>',
    '</table>'
  ].join('\n'));
@@ -1398,16 +1437,21 @@ function updateConfifs(){ // write modified settings to the master camera persis

function setDirMulti(){
//    url = "camogm_interface.php?cmd=dir_prefix&name=" + multicam_dir;
    url = "camogm_interface.php?cmd=set_prefix_raw&name=" + multicam_dir; // can not mkdir before mounted
	if (use_file_system ){
		url = "camogm_interface.php?cmd=set_prefix&prefix=" + multicam_dir; // can not mkdir before mounted
	} else {
    	url = "camogm_interface.php?cmd=set_prefix_raw&prefix=" + multicam_dir; // can not mkdir before mounted
    }
    console.log("setDirMulti(), url="+url);
    multi_ajax(url,function(){
    	console.log(this.ip+": dir_prefix " + multicam_dir);
    	console.log(this.ip+": prefix " + multicam_dir+", url="+url);
    });
}

var appply_pending = 0;
function setDirSingle(cam_i){ // set recording directory for one camera (after starting camogm), request status 
  console.log("csetDirSingle("+cam_i+")");
  console.log("setDirSingle("+cam_i+"):"+multicam_dir+"use_file_system="+use_file_system);
  if (use_file_system ){
	  $.ajax({
	//    url: "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=dir_prefix&name=" + multicam_dir, // should never be done before partition is mounted!
	    url: "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=SET_prefix&name=" + multicam_dir, // can not mkdir before mounted
@@ -1417,6 +1461,17 @@ function setDirSingle(cam_i){ // set recording directory for one camera (after s
	        check_camogm_status(this.cam_i);
	    }
	  });
  } else { // still need to create directory?
      console.log("set directory to, url=" + "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=set_prefix_raw&prefix=" + multicam_dir);
	  $.ajax({
	    url: "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=set_prefix_raw&prefix=" + multicam_dir, // can not mkdir before mounted
	    cam_i: cam_i,
	    success: function(){
	        console.log(cams[this.cam_i].ip+": set directory to " + multicam_dir);
	        check_camogm_status(this.cam_i);
	    }
	  });
  }
}

// LWIR16
+15 −10
Original line number Diff line number Diff line
@@ -66,13 +66,13 @@
           file_get_contents($notify);
       }
//       fclose ( $f );
       // can still get stuck for a long time, but testing file exists is faster that find a process
       if (file_exists(CAPTURE_RANGE_STATE)) {
           unlink(CAPTURE_RANGE_STATE);
       }
       exit(0);
   }
//   $output=null;
   $retval=-1; // not used
   // kill CLI mode if it was running (e.g. waiting for 100 years)
//   exec("killall capture_range.php", $output, $retval);
//   exec("/www/pages/capture_range.php 1 2 3 4 > /dev/null 2>&1 &");
   
   if (count($_GET) < 1) {
       print ("CGI mode");
@@ -287,8 +287,12 @@ USAGE;
            if (! isset($duration)) {
                $duration = 0;
            }
            // kill CLI mode if it was running (e.g. waiting for 100 years)
            exec("killall capture_range.php", $output, $retval);
            // kill CLI mode if it was running (e.g. waiting for 100 years) first check file exists (faster)
//            if (file_exists(CAPTURE_RANGE_STATE) || getPIDByName('capture_range.php', 'php', $active_only = false)) {
            if (file_exists(CAPTURE_RANGE_STATE)) { // getPIDByName('capture_range.php', 'php', $active_only = false) is slower
               exec("killall capture_range.php", $output, $retval); // grows lighttpd_stderr.log, need to check before kill
               unlink(CAPTURE_RANGE_STATE);
            }
            // spawn CLI program in background duration <0 - start only, ==0 - stop only, >0 - start+stop
            // $f = fopen ( "/var/log/capture_range.log", 'a' );
            // fwrite($f,"exec(/www/pages/capture_range.php $sensor_port $port_mask $frame $duration > /dev/null 2>&1 &\n");
@@ -300,15 +304,16 @@ USAGE;
                if (isset($ahead_now) && ($ahead_now == 0)){
                    $frame = 0; // ASAP
                }
                $end_frame = $frame;
                if ($duration > 0) {
                    $end_frame += $duration; // xml will contain end frame
                }
                file_put_contents(CAPTURE_RANGE_STATE, "end_frame = $end_frame\n");
                exec("/www/pages/capture_range.php $sensor_port $port_mask $frame $duration '$notify_url'> /dev/null 2>&1 &");
                // }
                // $f = fopen ( "/var/log/capture_range.log", 'a' );
                // fwrite($f,"DONE exec\n");
                // fclose ( $f );
                if ($duration > 0) {
                    $frame += $duration; // xml will contain end frame
                }
                file_put_contents(CAPTURE_RANGE_STATE, "end_frame = $frame\n");
                if ($wait) {
                    elphel_wait_frame_abs($sensor_port, $frame + 1);
                }