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

started *3 version

parent 4678d928
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -6,12 +6,16 @@ INSTALL = install
DOCS=       index.html \
			index1.html \
			index2.html \
			index3.html \
            multicam.js \
            multicam2.js \
            multicam3.js \
            multicam.css \
            multicam2.css \
            multicam3.css \
            multicam.php \
            multicam2.php \
            multicam3.php \
            reboot.html

ZIPDOCS= zip/deflate.js \
+205 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <title>Multi cameras control</title>

    <script src="../js/jquery-3.1.1.js"></script>
    <script src="../js/elphel.js"></script>
    <script src="../js/jcanvas.js"></script>
    <script src="../js/UTIF.js"></script>
    <script src="../js/exif.js"></script>
    <script src="../js/jquery-jp4.js"></script>
    <script src="../js/zip/zip.js"></script>

    <link rel="stylesheet" href="../js/bootstrap/css/bootstrap.css">

    <script type='text/javascript' src='multicam3.js'></script>
    <link rel='stylesheet' type='text/css' href='multicam3.css'></link>

  </head>
  <!-- 192.168.0.41/multicam/index3.html?ip=192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45 -->
  <body>
    <div id='display_all'>
      <div id='display_previews'></div>
      <div id='display_controls'>
         <button type="button" class="collapsible">Recording Status</button>
         <div id='display_status'></div>
         <button type="button" class="collapsible">LWIR16 Status</button>
         <div id='lwir16_status'>
           <table><tr><td>
             <table>
               <tr><td><label for="seq_num"    >Seq Num</label></td><td><input type="text" id="idsequence_num" name="seq_num"      size="5" value="?" disabled="disabled"></td></tr>
               <tr><td><label for="request_num">Requests</label></td><td><input type="text" id="idrequest_num" name="request_num"    size="5" value="?" disabled="disabled"></td></tr>
               <tr><td><label for="capture_run">Running</label></td><td><input type="checkbox" id="idcapture_run" name="capture_run" disabled="disabled"></td></tr>
             </table>
           </td><td>
             <table>
               <tr><td><label for="last_ffc"    >Last FFC</label></td><td><input type="text" id="idlast_ffc" name="last_ffc"      size="5" value="?" disabled="disabled">s</td></tr>
               <tr><td><label for="time_to_ffc" >To FFC</label></td><td><input type="text" id="idtime_to_ffc" name="time_to_ffc"   size="5" value="?" disabled="disabled">s</td></tr>
               <tr><td colspan = "2">&nbsp;</td></tr>
           </table>
           </td></tr></table>
         </div>

         <button type="button" class="collapsible">LWIR16 FFC controls</button>
         <div id='lwir16_ffc_controls'>
           <table><tr><td>
             <table>
               <tr><td><label for="gao_gain">GAO Gain</label></td><td><input type="checkbox" id="gao_gain" name="gao_gain" checked="checked"></td></tr>
               <tr><td><label for="gao_sffc">GAO SFFC</label></td><td><input type="checkbox" id="gao_sffc" name="gao_sffc" checked="checked"></td></tr>
               <tr><td><label for="gao_ffc">GAO FFC</label></td><td><input type="checkbox" id="gao_ffc" name="gao_ffc" checked="checked"></td></tr>
               <tr><td><label for="gao_temp">GAO Temp</label></td><td><input type="checkbox" id="gao_temp" name="gao_temp" checked="checked"></td></tr>
               <tr><td><label for="bpr">BPR</label></td><td><input type="checkbox" id="idbpr" name="bpr" checked="checked"></td></tr>
             </table>
           </td><td>
             <table>
               <tr><td><label for="scnr">SCNR</label></td><td><input type="checkbox" id="scnr" name="scnr" checked="checked"></td></tr>
               <tr><td><label for="srnr">SRNR</label></td><td><input type="checkbox" id="srnr" name="srnr" checked="checked"></td></tr>
               <tr><td><label for="spnr">SPNR</label></td><td><input type="checkbox" id="spnr" name="spnr" checked="checked"></td></tr>
               <tr><td><label for="tf">TF</label></td><td><input type="checkbox" id="tf" name="tf" checked="checked" disabled="disabled"></td></tr>
               <tr><td><label for="tf_delta_nf">TF DELTA NF</label></td><td><input type="text" id="tf_delta_nf" name="tf_delta_nf"size="5" value="?">s</td></tr>
           </table>
           </td></tr></table>
         </div>
         
         <button type="button" class="collapsible">LWIR16 Controls</button>
         <div id='lwir16_controls'>

           <table><tr><td>
             <table>
               <tr><td><button id="idStartStop" name = "nStartStop" disabled="disabled">???</button></td>
               <td><button id="idApply" name = "nApply" disabled = "disabled">???</button></td>
               </tr>
               
               <tr><td><label for="idpre_delay"   >Inter-Delay</label></td><td><input type="text" id="idpre_delay" name="pre_delay"      size="5" value="?">s</td></tr>
               <tr><td><label for="duration"      >LWIR frames</label></td><td><input type="text" id="idduration" name="duration"      size="5" value="?"></td></tr>
               <tr><td><label for="duration_eo"   >RGB frames</label></td><td><input type="text" id="idduration_eo" name="duration_eo"      size="5" value="?"></td></tr>
               <tr><td><label for="compressor_run">Compress Init</label></td><td><input type="checkbox" id="idcompressor_run" name="compressor_run"></td></tr>
             </table>
           </td><td>
             <table>
               <tr><td><label for="ffc"    >FFC</label></td><td><input type="checkbox" id="idffc" name="ffc"></td></tr>
               <tr><td><label for="ffc_period"    >FFC period</label></td><td><input type="text" id="idffc_period" name="ffc_period"      size="5" value="?"></td></tr>
               <tr><td><label for="ffc_groups"    >FFC groups</label></td><td><select id="idffc_groups" name="idffc_groups">
														                         <option value="1">1</option>
														        			  	  <option value="2">2</option>
																		          <option value="4" selected="selected">4</option>
																		        </select>
                                                                         </td></tr>
               <tr><td><label for="ffc_frames"    >FFC frames</label></td><td><input type="text" id="idffc_frames" name="ffc_frames"      size="5" value="?"></td></tr>
               <tr><td><label for="debug"    >Debug</label></td><td><input type="text" id="iddebug" name="debug"      size="5" value="?"></td></tr>
           </table>
           </td></tr></table>

         </div>
         
         <button type="button" class="collapsible">Multicam Controls</button>
         <div id='multicam settings'>
		    <table>
			    <tr>
				    <td>
					    <table>
					    <th><td colspan="2">Image Refresh<td> </th>
					    <tr> <td><label>Enable</label></td>
					    <td>
					          <div id="toggle_refresh" class="btn-group btn-toggle">
					            <button class="btn btn-xs btn-success active">ON</button>
					            <button class="btn btn-xs btn-default">OFF</button>
					          </div>
					     </td> </tr>
					    <tr><td><label for="ref_rate">Images</label></td>
							<td><input type="text" id="ref_rate" name="ref_rate" size="4">s</td>
						</tr><tr>
						    <td><label for="sref_rate">Status</label></td>
							<td><input type="text" id="sref_rate" name="sref_rate" size="4">s
					    </td> </tr>
					    </table>
				    </td>
				    <td>
					    <table><th><td colspan="2">SSD Recording<td> </th>
					    <tr><td><label>Record</label></td>
					      <td><div id="toggle_record" class="btn-group btn-toggle">
					            <button class="btn btn-xs btn-success active">ON</button>
					            <button class="btn btn-xs btn-default">OFF</button>
					          </div>
					      </td>
					    </tr><tr> <td><label id = "root_dir" for="ssd_directory">/mnt/sda1/</label></td>
							 <td><input type="text" id="dir_name" name="ssd_directory" size="10"></td>
					    </tr><tr><td colspan="2">&nbsp;</td></tr></table>
				    </td>
			    </tr> 
		    </table>
         </div>
         <button type="button" class="collapsible">Eyesis Controls</button>
		 <div id='settings'>
		    <table>
		      <tr>
		        <td>
		          <div id='rec_button' class='rec_outer' title='start recording'>
		            <div class='rec_inner'></div>
		          </div>
		        </td>
		        <td>
		          <button id='snapshot' title='download snapshot' class="btn btn-sm btn-danger">snapshot</button>
		        </td>
		      </tr>
		      <tr id="toggle_awb" title='Auto White Balance'>
		        <td>Auto WB:</td>
		        <td>
		          <div id="toggle_awb" class="btn-group btn-toggle">
		            <button class="btn btn-xs btn-success active">ON</button>
		            <button class="btn btn-xs btn-default">OFF</button>
		          </div>
		        </td>
		      </tr>
		      <tr id="toggle_aexp" title='Auto Exposure'>
		        <td>Auto Exposure:</td>
		        <td>
		          <div id="toggle_aexp" class="btn-group btn-toggle">
								<button class="btn btn-xs btn-success active">ON</button>
								<button class="btn btn-xs btn-default">OFF</button>
							</div>
						</td>
		      </tr>

		      <tr id="manual_exposure_div" title='Manual Exposure'>
		        <td><label for="exposure_ms">Manual</label></td>
		        <td><input type="text" id="exposure_ms" name="exposure_ms" size="6" value="50">ms</td>
		      </tr>

		      <tr id="image_quality_div" title='Image Quality'>
		        <td><label for="jpeg_quality">Quality</label></td>
		        <td><input type="text" id="jpeg_quality" name="jpeg_quality" size="6" value="97">%</td>
		      </tr>

		      <tr>
		        <td>
		          <button id='system_tests' title='system info' class="btn btn-sm btn-success">tests</button>
		        </td>
		      </tr>
		      <tr>
		        <td hidden>
		          <br/>
		          <div id='edit_addrs_input' hidden>
		            <div id='eai_text_div'>
		              <textarea id='eai_text' rows='4' cols='30'></textarea>
		            </div>
		            <div id='eai_ok_div'>
		              <button id='eai_ok' class="btn btn-sm btn-success">ok</button>
		            </div>
		          </div>
		          <div id='edit_addrs' title='edit ip addresses'>
		            <button id='ea_btn' class="btn btn-sm btn-success">+</button>
		          </div>
		          <div id='addrs'>
		          </div>
		        </td>
		      </tr>
		    </table> <!--  settings table -->
		 </div> <!-- id='settings' -->
		 
	   </div>   <!-- controls -->
    </div>
  </body>
</html>
 No newline at end of file
+166 −0
Original line number Diff line number Diff line
#settings{
  padding:5px;
}

table td {
  padding-right:10px;
}

.btn.active:focus, .btn:focus{
  outline:none;
}

.btn-toggle{
  padding: 1px 0px;
}

#edit_addrs{
  padding: 2px;
}

#ea_btn{
  outline:none;
  font-weight:bold;
}

#addrs{
  padding: 0px 2px 2px 2px;
}

#eai_text{
  resize:none;
  margin:0px;
}

#edit_addrs_input{
  position:absolute;
  top:2px;
  left:2px;
  border:1px solid rgb(169,169,169);
  padding:2px;
  background: white;
  z-index: 100;
}

#eai_text_div{
  line-height:14px;
}

#rec_start{
  outline:none;
  border: 0px solid #00AA66;
}

.rec_outer{
  position:relative;
  width:50px;
  height:50px;
  border-radius:50%;
  border: 1px solid rgba(100,100,100,1);
  background: white;
}

.rec_inner{
  position:relative;
  top:25%;
  left:25%;
  width:50%;
  height:50%;
  border-radius:50%;
  background: rgb(166,14,14);
}

.rec_outer:active{
  border: 1px solid rgb(166,14,14);
}

.rec_outer_active{
  border: 1px solid rgb(166,14,14);
}

.rec_inner_running{
  top:5%;
  left:5%;
  width:90%;
  height:90%;
}

.port_preview{
  width:200px;
}

.hist_preview{
  border:1px solid rgba(200,200,200,0.5);
  width:200px;
}

#display{
  padding:5px;
}

hr{
  margin-top:2px;
  margin-bottom:2px;
}

#display_status th, #s_device{
  text-align:center;
}

#s_space{
  text-align:right;
}

#display_status td, #display_status th{
  border:1px solid rgba(100,100,100,0.8);
  padding:2px 5px;
}

.port_preview canvas,#display{
  padding:0px;
}

#system_tests{
  margin:5px;
}

#display_all {
  display: flex;
}

#display_preview {
  flex: 0 0 65%;
}

#controls {
  flex: 1;
}

.ip_text{
	display: none;
}

.collapsible {
  background-color: #777;
  color: white;
  cursor: pointer;
  padding: 2px;
  width: 100%;
  border: none;
  text-align: center;
  outline: none;
  font-size: 10px;
  font-weight: bold;  
}

.active, .collapsible:hover {
  background-color: #555;
}

.content {
  padding: 0 18px;
  display: none;
  overflow: hidden;
  background-color: #f1f1f1;
}
+1536 −0

File added.

Preview size limit exceeded, changes collapsed.

+301 −0
Original line number Diff line number Diff line
<?php

include "../include/elphel_functions_include.php";
define('CONF_LWIR16',        '/etc/elphel393/lwir16.ini');
define('IPS',                'ips');
define('PORT_MASKS',         'port_masks');
define('NUM_PORTS',          4);
define('IMGSRV_PORT0',       2323);
define('PORTSPATH',          '/sys/devices/soc0/elphel393-detect_sensors@0');
define('MULTICAM_INI',       'multicam_ini');
define('MULTICAM_DIR',       'multicam_dir');
define('MULTICAM_RPERIOD',   'multicam_rperiod');
define('MULTICAM_SPERIOD',   'multicam_speriod');
define('MULTICAM_CONF',      'multicam_conf');

if (isset($_GET['cmd']))
    $cmd = $_GET['cmd'];
else if (isset($argv[1]))
    $cmd = $argv[1];
        
///$ini =    parse_ini_file(CONF_LWIR16);

//$cmd = "donothing";


//$config = "/var/volatile/html/multicam.xml";

// path to sysfs for port scanning
//$portspath = "/sys/devices/soc0/elphel393-detect_sensors@0";
// total number of ports in 10393
//$nports = 4;
//$port0 = 2323;

// extract ip addresses
if ($_SERVER['REQUEST_METHOD']==="POST"){
  $list = file_get_contents("php://input");
}else{
  if (isset($_GET['ip'])){
    $list = $_GET['ip'];
  }else{
    $list = $_SERVER['SERVER_ADDR'];
  }
}
$ips = explode(',',$list);

// allow CORS
header('Access-Control-Allow-Origin: *');

// does not need configs
switch($cmd){
    case "ports":
        xml_header();
        print(getports());
        exit (0);
}

getIni(); // wil exit OK now 

//print ("<!--");
//print_r($lwir16_ini);
//print ("-->");
//exit(0);


switch($cmd){
  case "ips":
      xml_header();
      print(getIps());
      exit (0);
  case "update": 
      foreach($_GET as $key=>$value) {
          if (array_key_exists($key, $GLOBALS[MULTICAM_INI])){
              $GLOBALS[MULTICAM_INI][$key] = $value;
          }
      }
      writeConfig();
      exitXmlOK();
      exit(0); // 
  case "configs": // return xml with all $GLOBALS[MULTICAM_INI]
      xml_header();
      print(getConfigs());
      exit(0);
      
// obsolete old commands
/*
  case "write":
    // write
    // use get and post requests
      write_config($config,$ips);
      print("ok");
      break;
  case "snapshot":
    send_zipped_images($ips);
    break;
  case "read":
      default:
    // will never need read - config is in http://camip/var/multicam.xml
    // read
///      print(file_get_contents($config));
 * */
  default:
      exitXmlOK("Unknown");
}


function getIni() {
    $ini=    parse_ini_file(CONF_LWIR16);
    // define parameter type here
    $GLOBALS[MULTICAM_INI][IPS] =               $ini[IPS];
    $GLOBALS[MULTICAM_INI][PORT_MASKS] =        $ini[PORT_MASKS];
    $GLOBALS[MULTICAM_INI][MULTICAM_DIR] =      $ini[MULTICAM_DIR];
    $GLOBALS[MULTICAM_INI][MULTICAM_RPERIOD] =  $ini[MULTICAM_RPERIOD];
    $GLOBALS[MULTICAM_INI][MULTICAM_SPERIOD] =  $ini[MULTICAM_SPERIOD];
    $GLOBALS[MULTICAM_INI][MULTICAM_CONF] =     $ini[MULTICAM_CONF];
    // copy other default parameters
    // try to read xml if exists
    $multi_xml = 0;
    if (file_exists($ini[MULTICAM_CONF])) {
        $multi_xml = simplexml_load_file($ini[MULTICAM_CONF]);
    }
    if ($multi_xml) { // if file exists
        $multi_ini = array();
        foreach ( $multi_xml->children () as $entry ) {
            $GLOBALS[MULTICAM_INI][$entry->getName ()] = (string) $entry;
        }
    } else {
        writeConfig();
    }
    /*
    print ("<!--");
    var_dump($GLOBALS[MULTICAM_INI]);
    print ("-->");
    exit (0);
    */    
    if (isset($GLOBALS[MULTICAM_INI][IPS])) {
        $GLOBALS[IPS] =        explode(',',$GLOBALS[MULTICAM_INI][IPS]);
        if (isset ($GLOBALS[MULTICAM_INI][PORT_MASKS])){
            $masks = explode(',',$GLOBALS[MULTICAM_INI][PORT_MASKS]);
        }
        // Add port masks incdexed by IPs. Changing IPs resets masks
        $GLOBALS[PORT_MASKS] = array();
        for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
            if (isset($masks) && (count($masks) > $i)){
                $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (int) $masks[$i];
            } else {
                $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (1 << NUM_PORTS) -1;
            }
        }
    }
    /*
    print ("<!--");
    var_dump($GLOBALS[MULTICAM_INI]);
    echo "------------------------";
    var_dump($GLOBALS[IPS]);
    echo "------------------------";
    var_dump($GLOBALS[PORT_MASKS]);
    print ("-->");
    exit (0);
    */
//    exitXmlOK(); // exit for now
}

function writeConfig(){
    $xml="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<multicam>\n";
    foreach($GLOBALS[MULTICAM_INI] as $key=>$value){
        $xml .= "\t<".$key.'>'.$value.'</'.$key.">\n";
    }
    $xml .= "</multicam>\n";
    file_put_contents($GLOBALS[MULTICAM_INI][MULTICAM_CONF],$xml);
    exec('sync');
}

function printToComment($str) {
    echo "<!--".$str."-->";
}

function write_config($config,$ips){

  $list = "";
  foreach($ips as $ip){
    $list .= "\t<camera>$ip</camera>\n";
  }
  $xml  = "<?xml version='1.0' encoding=\"iso-8859-1\" standalone='yes'?>\n";
  $xml .= "<Document>\n";
  $xml .= $list;
  $xml .= "</Document>\n";

  file_put_contents($config,$xml);

  return 0;
}

function getConfigs(){
    $xml .= "<configs>\n";
    // Add more when available. not Using foreach to keep order 
    $xml .= xmlEntry(MULTICAM_DIR,     $GLOBALS[MULTICAM_INI][MULTICAM_DIR],     1);
    $xml .= xmlEntry(MULTICAM_RPERIOD, $GLOBALS[MULTICAM_INI][MULTICAM_RPERIOD], 1);
    $xml .= xmlEntry(MULTICAM_SPERIOD, $GLOBALS[MULTICAM_INI][MULTICAM_SPERIOD], 1);
    $xml .= "</configs>\n";
    return $xml;
}



function getports(){
  $res = "\t<camera ip='".$_SERVER['SERVER_ADDR']."'>\n";
  for($i=0;$i<NUM_PORTS;$i++){
      $sensor = PORTSPATH."/sensor{$i}0";
    // the file is always there actually
    if(is_file($sensor)){
      $c = trim(file_get_contents($sensor));
      $p = IMGSRV_PORT0+$i;
      $res .= "\t\t<port index='$i' port='$p'>$c</port>\n";
    }
  }
  $res .= "\t</camera>\n";
  $xml .= "<Document>\n";
  $xml .= $res;
  $xml .= "</Document>\n";
  return $xml;
}

function getIps(){
    //$GLOBALS[IPS]
    $xml = "<cameras>\n";
    for($i=0;$i< count($GLOBALS[IPS]);$i++){
        $xml .= "\t<ip index='$i'>".$GLOBALS[IPS][$i]."</ip>\n";
    }
    $xml .= "</cameras>\n";
    return $xml;
}

function exitXmlOK($str="ok"){
    xml_header();
    print ('<'.$str.'/>');
    exit(0);
}

function xml_header() {
    header("Content-type: text/xml");
    header("Pragma: no-cache\n");
    // allow CORS: needed for multi cams unified control
    header('Access-Control-Allow-Origin: *');
    echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
}

function xmlEntry($key,$value,$ind=0){
    $res = '';
    for ($i = 0; $i < $ind; $i++) $res.="\t";
    $res .= '<'.$key.'>'.$value.'</'.$key.">\n";
    return $res;
}

function applyConf($arr){
    //port_masks=  "15,15,15,15,15"
    if (isset($arr[IPS])) {
        $GLOBALS[IPS] =        explode(',',$arr[IPS]);
        if (isset ($arr[PORT_MASKS])){
            $masks = explode(',',$arr[PORT_MASKS]);
        }
        // Add port masks incdexed by IPs. Changing IPs resets masks
        $GLOBALS[PORT_MASKS] = array();
        for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
            if (isset($masks) && (count($masks) > $i)){
                $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (int) $masks[$i];
            } else {
                $GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (1 << NUM_PORTS) -1;
            }
        }
    }
    /*
    if (isset($arr[DURATION])){
        $GLOBALS[DURATION] =   (int)       $arr[DURATION];
        $GLOBALS[DURATION_EO] = (int) ($GLOBALS[DURATION]/EO_DECIMATE+1);
    }
    if (isset($arr[DURATION_EO]))     $GLOBALS[DURATION_EO] = (int)      $arr[DURATION_EO];
    if (isset($arr[PRE_DELAY]))       $GLOBALS[PRE_DELAY] =  (double)    $arr[PRE_DELAY];
    if (isset($arr[FFC_PERIOD]))      $GLOBALS[FFC_PERIOD] = (double)    $arr[FFC_PERIOD];
    if (isset($arr[FFC_GROUPS]))      $GLOBALS[FFC_GROUPS] = (int)       $arr[FFC_GROUPS];
    if (isset($arr[FFC_FRAMES]))      $GLOBALS[FFC_FRAMES] = (int)       $arr[FFC_FRAMES];
    if (isset($arr[DAEMON_CMD]))      $GLOBALS[DAEMON_CMD] =             $arr[DAEMON_CMD];
    if (isset($arr[DEBUG]))           $GLOBALS[DEBUG] = (int)            $arr[DEBUG];
    if (isset($arr[COMPRESSOR_RUN]))  $GLOBALS[COMPRESSOR_RUN] = (int)   $arr[COMPRESSOR_RUN]; // only after INIT
    if (isset($arr[FFC]))             $GLOBALS[FFC] =                    $arr[FFC]?1:0;
    if (isset($arr[TIFF_TELEM]))      $GLOBALS[TIFF_TELEM] = (int)       $arr[TIFF_TELEM];
    if (isset($arr[TIFF_MN]))         $GLOBALS[TIFF_MN] = (int)          $arr[TIFF_MN];
    if (isset($arr[TIFF_MX]))         $GLOBALS[TIFF_MX] = (int)          $arr[TIFF_MX];
    if (isset($arr[TIFF_BIN_SHIFT]))  $GLOBALS[TIFF_BIN_SHIFT] = (int)   $arr[TIFF_BIN_SHIFT];
    if (isset($arr[TIFF_AUTO]))       $GLOBALS[TIFF_AUTO] = (int)        $arr[TIFF_AUTO];
    */
}



function send_zipped_images($ips){



}

?>
 No newline at end of file