Commit a0cd44c5 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

update system & fpga time from index.php

parent cf152318
...@@ -71,30 +71,25 @@ ...@@ -71,30 +71,25 @@
.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 { table td {
padding-right:10px; padding-right:10px;
} }
.btn.active:focus, .btn:focus{ .btn.active:focus, .btn:focus{
outline:none; outline:none;
} }
.btn-toggle{ .btn-toggle{
padding: 1px 0px; padding: 1px 0px;
} }
</style> </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,7 +130,7 @@ ...@@ -135,7 +130,7 @@
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>
...@@ -177,17 +172,28 @@ ...@@ -177,17 +172,28 @@
<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(){
check_time();
init_awb_toggle(); init_awb_toggle();
init_aexp_toggle(); init_aexp_toggle();
init_jp4_previews(); init_jp4_previews();
}); });
function init_jp4_previews(){ async function check_time(){
$.ajax({
url: "utils.php?cmd=time&ts="+Date.now(),
success: (res)=>{
console.log(res);
}
});
}
function init_jp4_previews(){
$('.port_preview').each(function(){ $('.port_preview').each(function(){
index = parseInt($(this).attr("index")); index = parseInt($(this).attr("index"));
if (jp4_previews_enable) { if (jp4_previews_enable) {
...@@ -197,9 +203,9 @@ function init_jp4_previews(){ ...@@ -197,9 +203,9 @@ function init_jp4_previews(){
$(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"/img' />"); $(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"/img' />");
} }
}); });
} }
function init_awb_toggle(){ function init_awb_toggle(){
$('#toggle_awb').click(function() { $('#toggle_awb').click(function() {
if ($(this).find('.btn.active').html()=="ON"){ if ($(this).find('.btn.active').html()=="ON"){
...@@ -231,7 +237,7 @@ function init_awb_toggle(){ ...@@ -231,7 +237,7 @@ function init_awb_toggle(){
}); });
}); });
} }
function init_aexp_toggle(){ function init_aexp_toggle(){
$('#toggle_aexp').click(function() { $('#toggle_aexp').click(function() {
......
...@@ -23,6 +23,9 @@ switch($cmd){ ...@@ -23,6 +23,9 @@ switch($cmd){
case "sensors": case "sensors":
print(cmd_sensors()); print(cmd_sensors());
break; break;
case "time":
cmd_time();
break;
default: default:
print("OK"); print("OK");
} }
...@@ -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