Commit bd363b03 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

cherry-picked sys & fpga time updating from warrior branch

parent 92ec9d48
...@@ -23,78 +23,73 @@ ...@@ -23,78 +23,73 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<title>Elphel 393</title> <title>Elphel 393</title>
<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
* redistribute it and/or modify it under the terms of the GNU * redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software * General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) * Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY; * any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS * without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
* *
* As additional permission under GNU GPL version 3 section 7, you * As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of * may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by * that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL * section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source. * through which recipients can access the Corresponding Source.
* *
* @licend The above is the entire license notice * @licend The above is the entire license notice
* for the JavaScript code in this page. * for the JavaScript code in this page.
*/ */
</script> </script>
<script type='text/javascript' src='js/jquery-3.1.1.js'></script> <script type='text/javascript' src='js/jquery-3.1.1.js'></script>
<!--<script type='text/javascript' src='../js/bootstrap/js/bootstrap.js'></script>--> <!--<script type='text/javascript' src='../js/bootstrap/js/bootstrap.js'></script>-->
<script src="js/elphel.js"></script> <script src="js/elphel.js"></script>
<script src="js/jcanvas.js"></script> <script src="js/jcanvas.js"></script>
<script src="js/UTIF.js"></script> <script src="js/UTIF.js"></script>
<script src="js/exif.js"></script> <script src="js/exif.js"></script>
<script src="js/jquery-jp4.js"></script> <script src="js/jquery-jp4.js"></script>
<link rel="stylesheet" href="js/bootstrap/css/bootstrap.css"> <link rel="stylesheet" href="js/bootstrap/css/bootstrap.css">
<style> <style>
.port_window{ .port_window{
padding: 5px; padding: 5px;
background: rgba(240,240,240,0.5); background: rgba(240,240,240,0.5);
border-radius: 2px; border-radius: 2px;
} }
.img_window{ .img_window{
border: 1px solid rgba(210,210,210,1); border: 1px solid rgba(210,210,210,1);
} }
.port_preview{
.port_preview{ width:300px;
width:300px; min-height:224px;
min-height:224px; overflow: auto;
overflow: auto; }
} table td {
padding-right:10px;
table td { }
padding-right:10px; .btn.active:focus, .btn:focus{
} outline:none;
}
.btn.active:focus, .btn:focus{ .btn-toggle{
outline:none; padding: 1px 0px;
} }
</style>
.btn-toggle{
padding: 1px 0px;
}
</style>
</head> </head>
<body> <body>
<div style='padding:10px'> <div style='padding:10px'>
<?php <?php
include "include/elphel_functions_include.php"; include "include/elphel_functions_include.php";
...@@ -135,135 +130,147 @@ ...@@ -135,135 +130,147 @@
echo "Camera Control Interface<ul>$port_links</ul>\n"; echo "Camera Control Interface<ul>$port_links</ul>\n";
?> ?>
<table> <table>
<tr id="toggle_awb" title='Auto White Balance'> <tr id="toggle_awb" title='Auto White Balance'>
<td> <td>
Auto WB: Auto WB:
</td> </td>
<td> <td>
<div id="toggle_awb" class="btn-group btn-toggle"> <div id="toggle_awb" class="btn-group btn-toggle">
<button class="btn btn-xs <?php echo ($awb_on)?"btn-success active":"btn-default";?>">ON</button> <button class="btn btn-xs <?php echo ($awb_on)?"btn-success active":"btn-default";?>">ON</button>
<button class="btn btn-xs <?php echo (!$awb_on)?"btn-danger active":"btn-default";?>">OFF</button> <button class="btn btn-xs <?php echo (!$awb_on)?"btn-danger active":"btn-default";?>">OFF</button>
</div> </div>
</td> </td>
</tr> </tr>
<tr id="toggle_aexp" title='Auto Exposure'> <tr id="toggle_aexp" title='Auto Exposure'>
<td> <td>
Auto Exposure: Auto Exposure:
</td> </td>
<td> <td>
<div id="toggle_aexp" class="btn-group btn-toggle"> <div id="toggle_aexp" class="btn-group btn-toggle">
<button class="btn btn-xs <?php echo ($aexp_on)?"btn-success active":"btn-default";?>">ON</button> <button class="btn btn-xs <?php echo ($aexp_on)?"btn-success active":"btn-default";?>">ON</button>
<button class="btn btn-xs <?php echo (!$aexp_on)?"btn-danger active":"btn-default";?>">OFF</button> <button class="btn btn-xs <?php echo (!$aexp_on)?"btn-danger active":"btn-default";?>">OFF</button>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
<a href="autocampars.php" title="autocampars.php">Parameter Editor</a><br /> <a href="autocampars.php" title="autocampars.php">Parameter Editor</a><br />
<br /> <br />
<a href="camogmgui.php" title="Store video/images to the camera's storage">Recorder</a><br /> <a href="camogmgui.php" title="Store video/images to the camera's storage">Recorder</a><br />
<a href="snapshot/" title="Take a snapshot and download from the camera">Snapshot</a><br /> <a href="snapshot/" title="Take a snapshot and download from the camera">Snapshot</a><br />
<a href="raw.php" title="Take a snapshot and download raw pixel data from the camera">Snapshot (raw image data)</a><br /> <a href="raw.php" title="Take a snapshot and download raw pixel data from the camera">Snapshot (raw image data)</a><br />
<a href="photofinish/" title="Scanline mode demo">Photo finish demo</a><br /> <a href="photofinish/" title="Scanline mode demo">Photo finish demo</a><br />
<br /> <br />
<a href="hwmon.html" title="hwmon.html">Temperature monitor</a><br /> <a href="hwmon.html" title="hwmon.html">Temperature monitor</a><br />
<a href="update_software.html" title="Update NAND flash">Update firmware</a><br /> <a href="update_software.html" title="Update NAND flash">Update firmware</a><br />
<br /> <br />
<a title="docs" href="http://wiki.elphel.com/index.php?title=Tmp_manual">User manual</a><br /> <a title="docs" href="http://wiki.elphel.com/index.php?title=Tmp_manual">User manual</a><br />
<a href="jp4-viewer/?width=1200&quality=1" title="Preview jp4 images (drag and drop from PC)">JP4 Viewer</a><br /> <a href="jp4-viewer/?width=1200&quality=1" title="Preview jp4 images (drag and drop from PC)">JP4 Viewer</a><br />
<a href="/diagnostics/index.html" title="Inspect camera system info">System info</a><br /> <a href="/diagnostics/index.html" title="Inspect camera system info">System info</a><br />
<a href="/test_sensors.php" title="Switch to test pattern and check md5sums">Test sensors</a><br /> <a href="/test_sensors.php" title="Switch to test pattern and check md5sums">Test sensors</a><br />
<a href="/debugfs.html" title="Linux Kernel Dynamic Debug helper interface (debug device drivers)">DebugFS</a><br /> <a href="/debugfs.html" title="Linux Kernel Dynamic Debug helper interface (debug device drivers)">DebugFS</a><br />
</div> </div>
<script> <script>
var jp4_previews_enable = true; var jp4_previews_enable = true;
$(function(){ $(function(){
init_awb_toggle(); check_time();
init_aexp_toggle(); init_awb_toggle();
init_jp4_previews(); init_aexp_toggle();
}); init_jp4_previews();
});
function init_jp4_previews(){
$('.port_preview').each(function(){ async function check_time(){
index = parseInt($(this).attr("index")); $.ajax({
if (jp4_previews_enable) { url: "utils.php?cmd=time&ts="+Date.now(),
$(this).jp4({ip:location.host,port:2323+index,width:300,fast:true,lowres:4}); success: (res)=>{
}else{ console.log(res);
$(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"/img' />"); }
});
} }
});
}
function init_awb_toggle(){ function init_jp4_previews(){
$('#toggle_awb').click(function() { $('.port_preview').each(function(){
index = parseInt($(this).attr("index"));
if (jp4_previews_enable) {
$(this).jp4({ip:location.host,port:2323+index,width:300,fast:true,lowres:4});
//$(this).jp4({src:"http://"+location.host+":"+(2323+index)+"/img",width:300,fast:true,lowres:4});
}else{
$(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"/img' />");
}
});
}
if ($(this).find('.btn.active').html()=="ON"){ function init_awb_toggle(){
$(this).find('.btn.active').toggleClass('btn-success'); $('#toggle_awb').click(function() {
}else{
$(this).find('.btn.active').toggleClass('btn-danger');
}
// toggle active if ($(this).find('.btn.active').html()=="ON"){
$(this).find('.btn').toggleClass('active'); $(this).find('.btn.active').toggleClass('btn-success');
}else{
$(this).find('.btn.active').toggleClass('btn-danger');
}
if ($(this).find('.btn.active').html()=="ON"){ // toggle active
wb_en = 1; $(this).find('.btn').toggleClass('active');
$(this).find('.btn.active').toggleClass('btn-success');
}else{
wb_en = 0;
$(this).find('.btn.active').toggleClass('btn-danger');
}
$(this).find('.btn').toggleClass('btn-default'); if ($(this).find('.btn.active').html()=="ON"){
wb_en = 1;
$(this).find('.btn.active').toggleClass('btn-success');
}else{
wb_en = 0;
$(this).find('.btn.active').toggleClass('btn-danger');
}
url = "parsedit.php?immediate&sensor_port=<?php echo $master_port;?>&WB_EN="+wb_en+"&*WB_EN=0xf"; $(this).find('.btn').toggleClass('btn-default');
$.ajax({ url = "parsedit.php?immediate&sensor_port=<?php echo $master_port;?>&WB_EN="+wb_en+"&*WB_EN=0xf";
url: url,
success: function(){
console.log("awb "+(wb_en?"on":"off"));
}
});
}); $.ajax({
} url: url,
success: function(){
console.log("awb "+(wb_en?"on":"off"));
}
});
});
}
function init_aexp_toggle(){ function init_aexp_toggle(){
$('#toggle_aexp').click(function() { $('#toggle_aexp').click(function() {
if ($(this).find('.btn.active').html()=="ON"){ if ($(this).find('.btn.active').html()=="ON"){
$(this).find('.btn.active').toggleClass('btn-success'); $(this).find('.btn.active').toggleClass('btn-success');
}else{ }else{
$(this).find('.btn.active').toggleClass('btn-danger'); $(this).find('.btn.active').toggleClass('btn-danger');
} }
// toggle active // toggle active
$(this).find('.btn').toggleClass('active'); $(this).find('.btn').toggleClass('active');
if ($(this).find('.btn.active').html()=="ON"){ if ($(this).find('.btn.active').html()=="ON"){
aexp_en = 1; aexp_en = 1;
$(this).find('.btn.active').toggleClass('btn-success'); $(this).find('.btn.active').toggleClass('btn-success');
}else{ }else{
aexp_en = 0; aexp_en = 0;
$(this).find('.btn.active').toggleClass('btn-danger'); $(this).find('.btn.active').toggleClass('btn-danger');
} }
$(this).find('.btn').toggleClass('btn-default'); $(this).find('.btn').toggleClass('btn-default');
url = "parsedit.php?immediate&sensor_port=<?php echo $master_port;?>&AUTOEXP_ON="+aexp_en+"&*AUTOEXP_ON=0xf"; url = "parsedit.php?immediate&sensor_port=<?php echo $master_port;?>&AUTOEXP_ON="+aexp_en+"&*AUTOEXP_ON=0xf";
$.ajax({ $.ajax({
url: url, url: url,
success: function(){ success: function(){
console.log("aexp "+(aexp_en?"on":"off")); console.log("aexp "+(aexp_en?"on":"off"));
} }
}); });
}); });
} }
</script> </script>
......
...@@ -12,19 +12,22 @@ include "include/elphel_functions_include.php"; ...@@ -12,19 +12,22 @@ include "include/elphel_functions_include.php";
$cmd = "donothing"; $cmd = "donothing";
if (isset($_GET['cmd'])) if (isset($_GET['cmd']))
$cmd = $_GET['cmd']; $cmd = $_GET['cmd'];
else if (isset($argv[1])) else if (isset($argv[1]))
$cmd = $argv[1]; $cmd = $argv[1];
// allow CORS // allow CORS
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
switch($cmd){ switch($cmd){
case "sensors": case "sensors":
print(cmd_sensors()); print(cmd_sensors());
break; break;
default: case "time":
print("OK"); cmd_time();
break;
default:
print("OK");
} }
function cmd_sensors(){ function cmd_sensors(){
...@@ -37,12 +40,40 @@ function cmd_sensors(){ ...@@ -37,12 +40,40 @@ function cmd_sensors(){
$res .= "\t\t<port index='$i' port='$p'>$sensor</port>\n"; $res .= "\t\t<port index='$i' port='$p'>$sensor</port>\n";
} }
$res .= "\t</camera>\n"; $res .= "\t</camera>\n";
return wrap_into_xml($res);
}
function cmd_time(){
date_default_timezone_set('UTC');
$t = elphel_get_fpga_time();
if (!isset($_GET['ts'])){
//date +%s will report system time
//print(exec("date +%s"));
print("Camera time: $t");
}else{
// ts is in ms
$ts_s = substr($_GET['ts'],0,10);
$ts_ms = substr($_GET['ts'],-3);
//$ts = $_GET['ts']/1000;
$ts_formatted = date("Y-m-d H:i:s.$ts_ms",$ts_s);
print("Your time: $ts_s.$ts_ms ($ts_formatted)\nCamera time: $t\n");
if (abs($ts_s-$t)>24*3600){
elphel_set_fpga_time($_GET['ts']/1000);
exec("date -s $ts_formatted");
exec("hwclock --systohc");
print("Timestamps differ by more than 24h. Camera and fpga time updated.\n");
}
}
}
function wrap_into_xml($s){
$xml = "<?xml version='1.0' standalone='yes'?>\n"; $xml = "<?xml version='1.0' standalone='yes'?>\n";
$xml .= "<Document>\n"; $xml .= "<Document>\n";
$xml .= $res; $xml .= $s;
$xml .= "</Document>\n"; $xml .= "</Document>\n";
return $xml; return $xml;
} }
......
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