Commit a52dba03 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

+snapshot (sub save_single)

parent ebae18e2
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/php_top src/python_tests src/debugfs-webgui src/jp4-canvas src/update src/eyesis4pi src/index src/pointers src/save_single # src1
SUBDIRS := src/php_top src/python_tests src/debugfs-webgui src/jp4-canvas src/update src/eyesis4pi src/index src/pointers src/snapshot # src1
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS = $(SUBDIRS:%=clean-%)
......
DOCUMENTROOT=$(DESTDIR)/www/pages/snapshot
OWN = -o root -g root
INSTDOCS = 0644
INSTALL = install
DOCS= snapshot.js
PHP_SCRIPTS= index.php
all:
@echo "make all in src"
install:
@echo "make install in src"
$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHP_SCRIPTS) $(DOCUMENTROOT)
clean:
@echo "make clean in src"
<?php
/**
* @file snapshot.php
* @brief snapshot
* @copyright Copyright (C) 2017 Elphel Inc.
* @author Oleg Dzhimiev <oleg@elphel.com>
*
* @par <b>License</b>:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<?php
$port0 = 2323;
$path = "/sys/devices/soc0/elphel393-detect_sensors@0";
$available_ports = Array();
$trig_master = -1;
$trig_master_port = -1;
for($i=0;$i<4;$i++){
$sensor = $path."/sensor{$i}0";
if (is_file($sensor)){
$c = trim(file_get_contents($sensor));
if ($c!="none"){
array_push($available_ports,$port0+$i);
}
}
}
// get TRIG_MASTER from lowest port
if(!empty($available_ports)){
$trig_master = intval(elphel_get_P_value($available_ports[0]-$port0,ELPHEL_TRIG_MASTER));
$trig_master_port = $trig_master + $port0;
}
if ($trig_master>0){
if (isset($_GET['trig'])){
// just in case one wants to override master
if (isset($_GET['port'])){
$trig_master_port = $_GET['port'];
}
$f = fopen("http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers", 'r');
fclose($f);
die();
}
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Snapshot</title>
<script type='text/javascript' src='snapshot.js'></script>
<script type='text/javascript' src='../js/jquery-3.1.1.js'></script>
<style>
body {
font-family: "Helvetica Neue", Helvetica;
}
#snapshot{
background-color: #CF4040; /* not Green */
border: none;
color: white;
padding: 32px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
font-weight: bold;
border-radius:3px;
outline:none;
}
#snapshot:hover{
background-color: #BF4040; /* not Green */
}
#snapshot:active{
background-color: #9F4040; /* not Green */
}
#snapshot:disabled{
background-color: #A0A0A0; /* not Green */
}
</style>
<script>
var ip = location.origin;
var ports = [<?php echo implode(",",$available_ports);?>];
var trig_master = <?php echo $trig_master;?>;
var trig_master_port = <?php echo $trig_master_port;?>;
</script>
</head>
<body>
<button title='Download images (synced) from all channels over network' id='snapshot' onclick='take_snapshot()'>Snapshot</button>
</body>
</html>
\ No newline at end of file
var tp_old = 0;
function take_snapshot(){
$("#snapshot").attr("disabled",true);
if(ports.length!=0){
read_trig_master();
}else{
console.log("No ports detected");
}
}
function read_trig_master(){
var param = "TRIG_MASTER";
$.ajax({
url: ip+"/parsedit.php?immediate&"+param,
success:function(data){
trig_master = parseInt($(data).find(param));
read_tp();
}
});
}
function read_tp(){
var param = "TRIG_PERIOD";
$.ajax({
url: ip+"/parsedit.php?immediate&"+param,
success:function(data){
tp_old = parseInt($(data).find(param));
trigger();
}
});
}
// channel independent or lowest?
function read_par(param,callback){
$.ajax({
url: ip+"/parsedit.php?immediate&"+param,
success:function(data){
tp_old = parseInt($(data).find("TRIG_MASTER"));
trigger();
}
});
}
function trigger(){
$.ajax({
url:ip+"/snapshot.php?trig",
success:function(){
setTimeout(download_all,200);
}
});
}
function download_all(){
ports.forEach(function(c,i){
download_single(ip+":"+c+"/bimg");
});
$.ajax({
url: ip+"/parsedit.php?immediate&TRIG_PERIOD="+(tp_old+1)+"*-2&sensor_port="+trig_master,
success: function(){
$.ajax({
url: ip+"/parsedit.php?immediate&TRIG_PERIOD="+(tp_old)+"*-2&sensor_port="+trig_master,
success: function(){
console.log("Done!");
$("#snapshot").attr("disabled",false);
}
});
}
});
}
function download_single(addr){
var link = document.createElement('a');
link.setAttribute('download', null);
link.style.display = 'none';
document.body.appendChild(link);
link.setAttribute('href', addr+"/img");
link.click();
document.body.removeChild(link);
}
\ No newline at end of file
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