Commit 49717aca authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

+download as zip

parent 89621f29
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<script> <script>
// for LibreJS: // for LibreJS:
/** /**
* @file index.php * @file index.php
* @copyright Copyright (C) 2017 Elphel Inc. * @copyright Copyright (C) 2017 Elphel Inc.
* @author - * @author -
* *
* @licstart The following is the entire license notice for the * @licstart The following is the entire license notice for the
* JavaScript code in this page. * JavaScript code in this page.
* *
* The JavaScript code in this page is free software: you can * The JavaScript code in this page is free software: you can
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
} }
.img_window{ .img_window{
border: 1px solid rgba(210,210,210,1); border: 1px solid rgba(210,210,210,1);
} }
table td { table td {
padding-right:10px; padding-right:10px;
} }
...@@ -72,13 +72,13 @@ ...@@ -72,13 +72,13 @@
<body> <body>
<div style='padding:10px'> <div style='padding:10px'>
<?php <?php
$port0 = 2323; $port0 = 2323;
$path = "/sys/devices/soc0/elphel393-detect_sensors@0"; $path = "/sys/devices/soc0/elphel393-detect_sensors@0";
$table_contents = ""; $table_contents = "";
$port_links = ""; $port_links = "";
for($i=0;$i<4;$i++){ for($i=0;$i<4;$i++){
$sensor = $path."/sensor{$i}0"; $sensor = $path."/sensor{$i}0";
if (is_file($sensor)){ if (is_file($sensor)){
...@@ -87,31 +87,31 @@ ...@@ -87,31 +87,31 @@
$sandp = "http://{$_SERVER["SERVER_ADDR"]}:".($port0+$i); $sandp = "http://{$_SERVER["SERVER_ADDR"]}:".($port0+$i);
$href1 = "$sandp/bimg"; $href1 = "$sandp/bimg";
$href2 = "$sandp/mimg"; $href2 = "$sandp/mimg";
$table_contents .= "<td>"; $table_contents .= "<td>";
$table_contents .= "<div class='port_window img_window'>"; $table_contents .= "<div class='port_window img_window'>";
$table_contents .= "<div><a href=\"$href1\"><img class='img_window' src='$href1' style='width:300px'/></a></div>"; $table_contents .= "<div><a href=\"$href1\"><img class='img_window' src='$href1' style='width:300px'/></a></div>";
$table_contents .= "<div style='text-align:center;'>port $i: <a title='single image' href='$href1'>bimg</a>, <a title='multi-part image stream (M-JPEG)' href='$href2'>mimg</a></div>"; $table_contents .= "<div style='text-align:center;'>port $i: <a title='single image' href='$href1'>bimg</a>, <a title='multi-part image stream (M-JPEG)' href='$href2'>mimg</a></div>";
$table_contents .= "</div>"; $table_contents .= "</div>";
$table_contents .= "</td>"; $table_contents .= "</td>";
$port_links .= "<li><a href=\"#\" onclick=\"window.open('camvc.html?sensor_port=$i&reload=0', 'port 0','menubar=0, width=800, height=600, toolbar=0, location=0, personalbar=0, status=0, scrollbars=1')\">port $i</a></li>\n"; $port_links .= "<li><a href=\"#\" onclick=\"window.open('camvc.html?sensor_port=$i&reload=0', 'port 0','menubar=0, width=800, height=600, toolbar=0, location=0, personalbar=0, status=0, scrollbars=1')\">port $i</a></li>\n";
} }
} }
} }
echo "<table><tr>$table_contents</tr></table>\n"; echo "<table><tr>$table_contents</tr></table>\n";
echo "<br/>"; echo "<br/>";
echo "Camera Control Interface<ul>$port_links</ul>\n"; echo "Camera Control Interface<ul>$port_links</ul>\n";
?> ?>
<br /> <br />
<a title="autocampars.php" href="autocampars.php">Parameter Editor</a><br /> <a title="autocampars.php" href="autocampars.php">Parameter Editor</a><br />
<a title="camogmgui.php" href="camogmgui.php">Recorder</a><br /> <a title="camogmgui.php" href="camogmgui.php">Recorder</a><br />
<a title="save snapshots" href="snapshot/">Take snapshot</a><br /> <a title="save snapshots" href="snapshot/">Snapshot</a><br />
<a title="preview jp4 images (drag and drop from PC)" href="jp4-viewer/?width=1200&quality=1">JP4 Viewer</a><br /> <a title="preview jp4 images (drag and drop from PC)" href="jp4-viewer/?width=1200&quality=1">JP4 Viewer</a><br />
<a title="hwmon.html" href="hwmon.html">Temperature monitor</a><br /> <a title="hwmon.html" href="hwmon.html">Temperature monitor</a><br />
<a title="update NAND flash" href="update_software.html">Update firmware</a><br /> <a title="update NAND flash" href="update_software.html">Update firmware</a><br />
......
...@@ -43,9 +43,11 @@ ...@@ -43,9 +43,11 @@
} }
$lowest_port = $available_ports[0]-$port0;
// get TRIG_MASTER from lowest port // get TRIG_MASTER from lowest port
if(!empty($available_ports)){ if(!empty($available_ports)){
$trig_master = intval(elphel_get_P_value($available_ports[0]-$port0,ELPHEL_TRIG_MASTER)); $trig_master = intval(elphel_get_P_value($lowest_port,ELPHEL_TRIG_MASTER));
$trig_master_port = $trig_master + $port0; $trig_master_port = $trig_master + $port0;
} }
...@@ -74,7 +76,7 @@ ...@@ -74,7 +76,7 @@
if (isset($_GET['sensor_port'])){ if (isset($_GET['sensor_port'])){
$port = $_GET['sensor_port']; $port = $_GET['sensor_port'];
}else{ }else{
$port = $available_ports[0]-$port0; $port = $lowest_port;
} }
$circbuf_pointers = elphel_get_circbuf_pointers($port,1); $circbuf_pointers = elphel_get_circbuf_pointers($port,1);
...@@ -95,6 +97,55 @@ ...@@ -95,6 +97,55 @@
} }
if (isset($_GET['zip'])){
$tmpdir = "/tmp/snapshot";
// create tmp dir
if (!is_dir($tmpdir)){
mkdir($tmpdir);
}
foreach($available_ports as $port){
exec("wget --content-disposition -P $tmpdir http://{$_SERVER['SERVER_ADDR']}:$port/timestamp_name/bimg");
}
$fstring = "";
$zipfile = "bimg.zip";
$files = scandir($tmpdir);
//remove . & ..
array_splice($files,0,2);
$prefixed_files = preg_filter('/^/', "$tmpdir/", $files);
$fstring = implode(" ",$prefixed_files);
// pick name for the zip archive
foreach($files as $file){
$tmp = explode(".",$file);
if ($tmp[1]=="jp4"||$tmp[1]=="jpeg"){
$tmp = explode("_",$tmp[0]);
if ($tmp[2]=="0"){
$zipfile = $tmp[0]."_".$tmp[1].".zip";
break;
}
}
}
$zipped_data = `zip -qj - $fstring `;
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zipfile.'"');
echo $zipped_data;
// clean up
foreach($prefixed_files as $file){
unlink($file);
}
die();
}
} }
?> ?>
...@@ -142,7 +193,7 @@ ...@@ -142,7 +193,7 @@
background-color: #A0A0A0; /* not Green */ background-color: #A0A0A0; /* not Green */
} }
#synced{ #synced, #aszip{
width:25px; width:25px;
height:25px; height:25px;
} }
...@@ -183,6 +234,11 @@ ...@@ -183,6 +234,11 @@
<br/> <br/>
<div> <div>
<table> <table>
<tr>
<td valign='middle'><span style='font-size:20px;line-height:25px;' title='checked = single zip
unchecked = multiple files'>zip</span></td>
<td valign='middle'><input type='checkbox' id='aszip' checked/></td>
</tr>
<tr> <tr>
<td valign='middle'><span style='font-size:20px;line-height:25px;'>sync</span></td> <td valign='middle'><span style='font-size:20px;line-height:25px;'>sync</span></td>
<td valign='middle'><input type='checkbox' id='synced' checked/></td> <td valign='middle'><input type='checkbox' id='synced' checked/></td>
......
...@@ -46,11 +46,34 @@ function trigger(){ ...@@ -46,11 +46,34 @@ function trigger(){
function download_all(rtp){ function download_all(rtp){
DLC = 0; if ($("#aszip").prop("checked")){
ports.forEach(function(c,i){
//download_single(ip+":"+c+"/timestamp_name/img"); // get ze blob
download_single(ip+":"+c+"/timestamp_name/bimg"); var http = new XMLHttpRequest();
}); http.open("GET", "?zip", true);
http.responseType = "blob";
http.onload = function(e){
if (this.status === 200) {
var filename = this.getResponseHeader("Content-Disposition");
pass_to_file_reader(filename,http.response);
if ($("#synced").prop("checked")) {
read_tp();
}
}
};
http.send();
}else{
DLC = 0;
ports.forEach(function(c,i){
//download_single(ip+":"+c+"/timestamp_name/img");
download_single(ip+":"+c+"/timestamp_name/bimg");
});
}
} }
......
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