Commit f3f0316d authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

still working

parent 3533e55e
<?php
include 'functions_cams.php';
$cmd = "do_nothing";
if (isset($_GET['cmd'])) $cmd = $_GET['cmd'];
if (isset($_GET['interval'])) $interval = $_GET['interval'];
//skip mask isnot needed
//skip mask is not needed
if (isset($_GET['mask'])) $mask = $_GET['mask'];
$mask = "0x1ff";
// keys assign
//example: rq=192.168.0.161:2323:0:0,192.168.0.162:2324:1:1
$cams = array();
$master = array();
if (isset($_GET['rq'])){
$pars = explode(",",$_GET['rq']);
foreach($pars as $val){
$ip = strtok($val,":");
$port = strtok(":");
$channel = strtok(":");
$master = strtok(":");
array_push($cams,array('ip'=>$ip,'port'=>$port,'channel'=>$channel,'master'=>$master));
if ($master=="1"){
$master_ip = $ip;
$master_port = $port;
$master_channel = $channel;
}
}
$cams = get_cams($_GET['rq']);
$master = get_master($cams);
}
if ($cmd=="launch") {
......@@ -37,7 +30,6 @@ if ($cmd=="launch") {
function launch(){
$status = system("./eyesis_daemon.php > /data/footage/daemon_log.txt &");
echo "Daemon started";
// if (!$status) {
......@@ -61,15 +53,7 @@ function launch(){
function get_camstr(){
global $cams;
$msg = "";
for($i=0;$i<count($cams);$i++){
$msg .= "<cam>\n";
$msg .= " <ip>{$cams[$i]['ip']}</ip>";
$msg .= " <port>{$cams[$i]['port']}</port>";
$msg .= " <channel>{$cams[$i]['channel']}</channel>";
$msg .= " <master>{$cams[$i]['master']}</master>";
$msg .= "</cam>\n";
}
$msg = "<cams>".cams_to_str($cams)."</cams>";
return $msg;
}
......
This diff is collapsed.
......@@ -29,6 +29,10 @@
// Check location - should be launched on the PC websrver
$elp_const=get_defined_constants(true);
ini_set('display_errors', 1);
include 'functions_cams.php';
include 'parallel_requests_inc.php';
if (isset($elp_const["elphel"])) {
$fp = fopen($_SERVER['SCRIPT_FILENAME'], 'rb');
......@@ -108,26 +112,14 @@ foreach($_GET as $key=>$value) {
}
}
$master_ip = "";
$master_port = "";
$master_channel = "";
// keys assign
$cams = array();
$master = array();
$unique_cams = array();
if (isset($_GET['rq'])){
$pars = explode(",",$_GET['rq']);
foreach($pars as $val){
$ip = strtok($val,":");
$port = strtok(":");
$channel = strtok(":");
$master = strtok(":");
array_push($cams,array('ip'=>$ip,'port'=>$port,'channel'=>$channel,'master'=>$master));
if ($master=="1"){
$master_ip = $ip;
$master_port = $port;
$master_channel = $channel;
}
}
$cams = get_cams($_GET['rq']);
$master = get_master($cams);
$unique_cams = get_unique_cams($cams);
}
//overrides
......@@ -140,72 +132,66 @@ if ($test) {
}
if ($set_parameter) {
for ($i=0;$i<count($cams);$i++){
if ($pname=="SET_SKIP")
$fp = fopen("http://{$cams[$i]['ip']}/camogm_interface.php?sensor_port={$cams[$i]['channel']}&cmd=set_skip&skip_mask=".dechex($pvalue), 'r');
else
$fp = fopen("http://{$cams[$i]['ip']}/camogm_interface.php?sensor_port={$cams[$i]['channel']}&cmd=set_parameter&pname=$pname&pvalue=$pvalue", 'r');
if ($fp) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
}
$message_IP[$i] = $content;
}else{
$message_IP[$i] = "no connection";
}
$res_xml .= $message_IP[$i];
}
header("Content-Type: text/xml");
header("Content-Length: ".strlen($res_xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $res_xml);
flush();
$rqs = array();
foreach($cams as $cam){
$rqstr = "http://{$cam['ip']}/parsedit.php?immediate&sensor_port={$cam['channel']}&$pname=$pvalue";
array_push($rqs,$rqstr);
}
$res_xmls = curl_multi_finish(curl_multi_start($rqs),false);
$res_xml = implode("",$res_xmls);
header("Content-Type: text/xml");
header("Content-Length: ".strlen($res_xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $res_xml);
flush();
}
if ($get_parameter) {
for ($i=0;$i<count($cams);$i++) {
$content = file_get_contents("http://{$cams[$i]['ip']}/camogm_interface.php?sensor_port={$cams[$i]['channel']}&cmd=get_parameter&pname=$pname");
$message_IP[$i] = $content;
$res_xml .= $message_IP[$i];
}
header("Content-Type: text/xml");
header("Content-Length: ".strlen($res_xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $res_xml);
flush();
$rqs = array();
foreach($cams as $cam){
$rqstr = "http://{$cam['ip']}/parsedit.php?immediate&sensor_port={$cam['channel']}&$pname";
array_push($rqs,$rqstr);
}
$res_xmls = curl_multi_finish(curl_multi_start($rqs),false);
$res_xml = implode("",$res_xmls);
header("Content-Type: text/xml");
header("Content-Length: ".strlen($res_xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $res_xml);
flush();
}
//CAMOGM
if ($run_camogm) {
for ($i=0;$i<count($cams);$i++) {
for ($i=0;$i<count($unique_cams);$i++) {
// start camogm
//if (!$debug) fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=run_camogm", 'r');
//else fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=run_camogm&debug=$debug&debuglev=$debuglev", 'r');
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=run_camogm", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=run_camogm", 'r');
// set debug level
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=set_debuglev&debuglev=$debuglev", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=set_debuglev&debuglev=$debuglev", 'r');
// set "/var/0" prefix
//fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=set_prefix&prefix=/var/html/CF/", 'r');
// default path
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=setrawdevpath&path=/dev/sda2", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=setrawdevpath&path=/dev/sda2", 'r');
//mount
//fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=mount&partition=/dev/hda1&mountpoint=/var/html/CF", 'r');
// set .mov format
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=setjpeg", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=setjpeg", 'r');
// set frames_per_chunk in exif to 1
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=set_frames_per_chunk&frames_per_chunk=1", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=set_frames_per_chunk&frames_per_chunk=1", 'r');
// set default split parameters
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=set_duration&duration=1000", 'r');
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=set_size&size=1800000000", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=set_duration&duration=1000", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=set_size&size=1800000000", 'r');
//debugging
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=set_max_frames&max_frames=1000", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=set_max_frames&max_frames=1000", 'r');
/*
// start camogm
......@@ -246,13 +232,13 @@ if ($run_camogm) {
}
if ($exit) {
for ($i=0;$i<count($cams);$i++) fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=exit", 'r');
for ($i=0;$i<count($unique_cams);$i++) fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=exit", 'r');
}
if ($start) {
if ($rec_delay<>0) {
// get time from master camera
if ($fp = fopen("http://$master_ip/camogm_interface.php?sensor_port=$master_channel&cmd=gettime", 'r')) {
if ($fp = fopen("http://{$master['ip']}/camogm_interface.php?sensor_port={$master['channel']}&cmd=gettime", 'r')) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
......@@ -271,21 +257,21 @@ if ($start) {
//for ($i=0;$i<$n;$i++) fopen("http://".$cam_ip[$i]."/camogm_interface.php?cmd=set_start_after_timestamp&start_after_timestamp=$start_timestamp", 'r');
}
for ($i=0;$i<count($cams);$i++) {
for ($i=0;$i<count($unique_cams);$i++) {
//delayed start?
//file_get_contents("http://$master_ip:$master_port/bimg");
//file_get_contents("http://".$cam_ip[0].":8081/bimg");
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=start", 'r');
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=start", 'r');
}
}
if ($stop) {
for ($i=0;$i<count($cams);$i++) fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=stop", 'r');
for ($i=0;$i<count($unique_cams);$i++) fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=stop", 'r');
}
if ($mount) {
for ($i=0;$i<count($cams);$i++) {
fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=mount&partition=/dev/sda1&mountpoint=/mnt/sda1", 'r');
for ($i=0;$i<count($unique_cams);$i++) {
fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=mount&partition=/dev/sda1&mountpoint=/mnt/sda1", 'r');
}
}
......@@ -297,9 +283,9 @@ if ($unmount) {
}
if ($get_hdd_space) {
for ($i=0;$i<count($cams);$i++) {
for ($i=0;$i<count($unique_cams);$i++) {
//$content = file_get_contents()
if ($fp = fopen("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=get_hdd_space&mountpoint=$mount_point", 'r')) {
if ($fp = fopen("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=get_hdd_space&mountpoint=$mount_point", 'r')) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
......@@ -315,7 +301,7 @@ if ($get_hdd_space) {
}
$res_xml = "<?xml version='1.0' standalone='yes'?>\n<camogm_multiple>\n";
for ($i=0;$i<count($cams);$i++) {
for ($i=0;$i<count($unique_cams);$i++) {
$res_xml .= "<cam>\n";
$res_xml .= "<hdd_free_space>\n";
$res_xml .= $message_IP[$i];
......@@ -333,8 +319,8 @@ if ($get_hdd_space) {
}
if ($status) {
for ($i=0;$i<count($cams);$i++) {
$content = file_get_contents("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=status");
for ($i=0;$i<count($unique_cams);$i++) {
$content = file_get_contents("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=status");
$content = substr($content,22);
$message_IP[$i] = $content;
}
......@@ -343,7 +329,7 @@ if ($status) {
$res_xml = "<?xml version='1.0' standalone='yes'?>\n<camogm_multiple>\n";
for ($i=0;$i<count($cams);$i++) {
for ($i=0;$i<count($unique_cams);$i++) {
$res_xml .= "<cam>\n";
$res_xml .= $message_IP[$i];
$res_xml .= "</cam>\n";
......@@ -359,8 +345,8 @@ if ($status) {
}
if ($run_status) {
for ($i=0;$i<count($cams);$i++) {
$content = file_get_contents("http://{$cams[$i]['ip']}/camogm_interface.php?cmd=run_status");
for ($i=0;$i<count($unique_cams);$i++) {
$content = file_get_contents("http://{$unique_cams[$i]['ip']}/camogm_interface.php?cmd=run_status");
$content = new SimpleXMLElement($content);
$message_IP[$i] = "\t<camogm_state>".($content->state)."</camogm_state>\n";
......@@ -368,7 +354,7 @@ if ($run_status) {
$res_xml = "<?xml version='1.0' standalone='yes'?>\n<camogm_multiple>\n";
}
for ($i=0;$i<count($cams);$i++) {
for ($i=0;$i<count($unique_cams);$i++) {
$res_xml .= "<cam>\n";
$res_xml .= $message_IP[$i];
$res_xml .= "</cam>\n";
......
#!/usr/bin/php -q
<?php
// For PC
include 'filesystem.php';
include 'functions_cams.php';
// Allow the script to hang around waiting for connections.
set_time_limit(0);
......@@ -21,9 +24,8 @@ $socket = stream_socket_server("tcp://$address:$port", $errno, $errstr);
$status = "idle";
$master_ip = "";
$master_port = "";
$master_channel = "";
$cams = array();
$master = array();
$interval = 1000;
......@@ -48,14 +50,9 @@ if (!$socket) {
$interval = $xml->interval;
$cams = array();
foreach($xml->cam as $item){
array_push($cams,array('ip'=>($item->ip),'port'=>($item->port),'channel'=>($item->channel),'master'=>($item->master)));
if ($item->master=="1"){
$master_ip = $item->ip;
$master_port = $item->port;
$master_channel = $item->channel;
}
}
$master = array();
$cams = get_cams($xml->cams);
$master = get_master($cams);
//$ip = $xml->ip;
//$n = $xml->n;
......@@ -84,8 +81,8 @@ if (!$socket) {
system("killall -9 recorder.php");
$ci = $interval*100000;
$fp = fopen("http://$master_ip/camogmgui/camogm_interface.php?sensor_port=$master_channel&cmd=set_parameter&pname=TRIG_PERIOD&pvalue=".($ci+1), 'r');
$fp = fopen("http://$master_ip/camogmgui/camogm_interface.php?sensor_port=$master_channel&cmd=set_parameter&pname=TRIG_PERIOD&pvalue=".($ci), 'r');
$fp = fopen("http://{$master['ip']}/camogmgui/camogm_interface.php?sensor_port=$master_channel&cmd=set_parameter&pname=TRIG_PERIOD&pvalue=".($ci+1), 'r');
$fp = fopen("http://{$master['ip']}/camogmgui/camogm_interface.php?sensor_port=$master_channel&cmd=set_parameter&pname=TRIG_PERIOD&pvalue=".($ci), 'r');
$status = "idle";
}
......@@ -122,7 +119,7 @@ if (!$socket) {
$footage_index = update_subsubdir("$footage_root_path/$footage_subfolder",$footage_index,$footage_file_limit,$index_max=1);
if ($footage_index>=0) {
passthru("./recorder.php '".get_rq_str($cams)."' $interval $mask $footage_root_path $footage_subfolder $footage_file_limit $footage_index > /dev/null 2>&1 &");
passthru("./recorder.php '".cams_to_str($cams)."' $interval $mask $footage_root_path $footage_subfolder $footage_file_limit $footage_index > /dev/null 2>&1 &");
}
}
......@@ -133,13 +130,4 @@ if (!$socket) {
fclose($socket);
}
function get_rq_str($a){
$rq_str = "";
for($i=0;$i<count($a);$i++){
if ($i!=0) $rq_str .= ",";
$rq_str .= "{$a[$i]['ip']}:{$a[$i]['port']}:{$a[$i]['channel']}:{$a[$i]['master']}";
}
return $rq_str;
}
?>
\ No newline at end of file
<?php
function get_cams($str){
$cams = array();
$pars = explode(",",$_GET['rq']);
foreach($pars as $val){
$ip = strtok($val,":");
$port = strtok(":");
$channel = strtok(":");
$master = strtok(":");
$logger = strtok(":");
array_push($cams,array('ip'=>$ip,'port'=>$port,'channel'=>$channel,'master'=>$master,'logger'=>$logger));
}
return $cams;
}
function get_master($cams){
foreach($cams as $cam){
if ($cam['master']=="1") return $cam;
}
return array();
}
function get_logger($cams){
foreach($cams as $cam){
if ($cam['logger']=="1") return $cam;
}
return array();
}
function get_unique_cams($cams){
$ress = array();
foreach($cams as $cam){
$found = false;
foreach($ress as $res){
if ($cam['ip']==$res['ip']) $found = true;
}
if (!$found) array_push($ress,$cam);
}
return $ress;
}
function cams_to_str($cams){
$str = "";
foreach($cams as $cam){
$str = implode(":",$cam).",";
}
return trim($str,",");
}
?>
......@@ -197,7 +197,7 @@ input{
padding: 2px;
}
#close_settings, #close_previews, #close_notice{
#close_settings, #close_previews {
width: 18px;
height: 18px;
text-align: center;
......
......@@ -7,7 +7,11 @@
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.18.custom/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.18.custom/css/ui-lightness/jquery-ui-1.8.18.custom.css" />
<!--
<script src="js/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.12.1.custom/jquery-ui.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="js/jquery-ui-1.12.1.custom/jquery-ui.theme.min.css" />
-->
<script src="temperatures.js" type="text/javascript"></script>
<script src="settings.js" type="text/javascript"></script>
<script src="tabs.js" type="text/javascript"></script>
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -34,10 +34,10 @@
//default parameters
$cmd = "start";
$file = "/var/html/CF/imu_log.log";
$file = "/mnt/sda1/imu_log.log";
$index = 1;
$n = 5000000;
$mount_point = "/var/html/CF";
$mount_point = "/mnt/sda1";
$force_dev = false;
......@@ -60,15 +60,10 @@ if ($cmd=="start") {
if (!is_dir($mount_point)) mkdir($mount_point);
//detect devices
//$dev = "/dev/hda1";
if (!$force_dev) {
$hda1 = exec("cat /proc/diskstats | grep 'hda1'");
$hdb1 = exec("cat /proc/diskstats | grep 'hdb1'");
$sda1 = exec("cat /proc/diskstats | grep 'sda1'");
if (strlen($hda1)>0) $dev = "/dev/hda1";
else if (strlen($hdb1)>0) $dev = "/dev/hdb1";
if (strlen($sda1)>0) $dev = "/dev/sda1";
else {
$xml .= "\t<error>CF cards not found</error>\n";
send_response($xml);
......
<?php
/*
*!***************************************************************************
*! FILE NAME : logger_manager.php
*! DESCRIPTION: command interface for event logger
*! Copyright (C) 2016 Elphel, Inc.
*! --------------------------------------------------------------------------
*! 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/>.
*! --------------------------------------------------------------------------
*/
$cmd = "donothing";
if (isset($_GET['cmd'])) $cmd = $_GET['cmd'];
else die("-1");
if (isset($_GET['ip'])) $ip = $_GET['ip'];
else die("-2");
if ($cmd=="start") {
switch($cmd){
case "start":
if (isset($_GET['file'])) $file = $_GET['file'];
else die("-3");
......@@ -19,64 +40,76 @@ if ($cmd=="start") {
if ($fp = fopen("http://$ip/logger_launcher.php?cmd=start&file=$file&index=$index&n=$n", 'r'))
die("started");
else
die("no connection");
}
if ($cmd=="stop") {
die("no connection");
break;
case "stop":
if ($fp = fopen("http://$ip/logger_launcher.php?cmd=stop", 'r'))
die("stopped");
else
die("no connection");
}
if ($cmd=="mount"){
if (isset($_GET['device'])) $device = $_GET['device'];
else $device = "/dev/hda1";
$fp = fopen("http://$ip/phpshell.php?command=mkdir%20/var/html/CF",'r');
if ($fp = fopen("http://$ip/phpshell.php?command=mount%20$device%20/var/html/CF", 'r'))
die("mounted");
else
die("no connection");
}
if ($cmd=="umount") {
//if ($fp = fopen("http://$ip/phpshell.php?command=umount%20/var/html/CF", 'r'))
if ($fp = fopen("http://$ip/phpshell.php?command=sync", 'r'))
break;
case "mount":
// TODO: rename later to symlink
$fp = fopen("http://$ip/eyesis4pi_interface.php?cmd=symlink",'r');
die("already mounted");
break;
case "umount":
// TODO: remove later or rename to sync
if ($fp = fopen("http://$ip/autocampars.py?cmd=shell&include=sync", 'r'))
die("unmounted");
else
die("no connection");
}
if ($cmd=="free_space") {
if (isset($_GET['mountpoint']))
$mountpoint = $_GET['mountpoint'];
else
$mountpoint = '/var/html/CF';
if ($fp = file_get_contents("http://$ip/camogmgui/camogm_interface.php?cmd=get_hdd_space&mountpoint=$mountpoint")) {
break;
case "free_space":
$mountpoint = '/mnt/sda1';
if (isset($_GET['mountpoint'])) $mountpoint = $_GET['mountpoint'];
if ($fp = file_get_contents("http://$ip/eyesis4pi_interface.php?cmd=free_space&mountpoint=$mountpoint")){
die($fp);
}else{
die("no connection");
}
break;
case "":
break;
default:
die("bad command");
}
if ($cmd=="free_space") {
if (isset($_GET['mountpoint']))
$mountpoint = $_GET['mountpoint'];
else
$mountpoint = '/mnt/sda1';
if ($fp = file_get_contents("http://$ip/camogm_interface.php?cmd=get_hdd_space&mountpoint=$mountpoint")) {
die($fp);
}else{
die("no connection");
}
}
if ($cmd=="clean") {
if (isset($_GET['mountpoint']))
$mountpoint = $_GET['mountpoint'];
else
$mountpoint = '/var/html/CF';
if (isset($_GET['mountpoint']))
$mountpoint = $_GET['mountpoint'];
else
$mountpoint = '/mnt/sda1';
$fp = fopen("http://$ip/phpshell.php?command=rm%20-r%20/var/html/CF/*",'r');
//$fp = fopen("http://$ip/phpshell.php?command=rm%20-rf%20/mnt/sda1/*",'r');
$fp = fopen("http://$ip/autocampars.py?cmd=shell&include=rm%20-rf%20/mnt/sda1/*",'r');
}
if ($cmd=="download") {
$path = "/var/html/CF";
$fc = file_get_contents("http://$ip/camogmgui/camogm_interface.php?cmd=list&path=$path");
$path = "/mnt/sda1";
$fc = file_get_contents("http://$ip/camogm_interface.php?cmd=list&path=$path");
$xml = new SimpleXMLElement($fc);
//echo "<pre>";
$test_arr = $xml->list->f;
......@@ -102,9 +135,9 @@ if ($cmd=="scandir") {
if (isset($_GET['mountpoint']))
$mountpoint = $_GET['mountpoint'];
else
$mountpoint = '/var/html/CF';
$mountpoint = '/mnt/sda1';
$fc = file_get_contents("http://$ip/camogmgui/camogm_interface.php?cmd=list&path=$mountpoint");
$fc = file_get_contents("http://$ip/camogm_interface.php?cmd=list&path=$mountpoint");
PrintXML($fc);
}
......
<?php
/*!***************************************************************************
*! FILE NAME : parallel_requests.php
*! DESCRIPTION: send out parallel url requests and collect responses
*! Copyright (C) 2016 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! 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/>.
*! -----------------------------------------------------------------------------**
*/
// Using parallel requests, PHP has to be configured '--with-curl=' (and libcurl should be installed)
function curl_multi_start($urls) {
// numprime is needed to actually send the request and remote starts executing it
// Not really clear - what it should be
$numprime = 4; // magic number, see http://lampe2e.blogspot.com/2015/03/making-stuff-faster-with-curlmultiexec.html
$curl_mh = curl_multi_init ();
$aCurlHandles = array ();
foreach ($urls as $url) {
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
$aCurlHandles[] = $ch;
curl_multi_add_handle ($curl_mh, $ch);
}
$curl_active = count ($urls);
for($x = 0; $x < $numprime && $curl_active; $x++) {
curl_multi_exec ($curl_mh, $curl_active);
// we wait for a bit to allow stuff TCP handshakes to complete and so forth...
usleep (10000);
// echo ".";
}
return array ("mh" => $curl_mh,"handles" => $aCurlHandles);
}
function curl_multi_finish($data, $use_xml=true, $ntry=0, $echo = false) {
$curl_active = 1;
$curl_mrc = CURLM_OK;
$nrep = 0;
$curl_mh = $data['mh'];
while ($curl_active && $curl_mrc == CURLM_OK ) {
if (curl_multi_select ($curl_mh) != -1) {
do {
$curl_mrc = curl_multi_exec ($curl_mh, $curl_active);
} while ($curl_mrc == CURLM_CALL_MULTI_PERFORM );
}
//if ($echo) echo colorize("$curl_active ",'YELLOW',1);
$nrep++;
if ($ntry && ($nrep > $ntry)) {
break;
}
}
$results = array ();
if ($use_xml) {
foreach ($data['handles'] as $i => $ch) {
$xml = simplexml_load_string (curl_multi_getcontent ($ch));
curl_multi_remove_handle ($curl_mh, $ch);
$results[$i] = array ();
foreach ($xml as $tag => $value) {
$svalue = (string) $value;
if (strlen ($svalue) > 0) {
if ($svalue[0] == '"') $results[$i][$tag] = trim ($svalue, '"');
else $results[$i][$tag] = (int) $svalue;
}
}
}
} else {
foreach ($data['handles'] as $i => $ch) {
$r = curl_multi_getcontent ($ch);
curl_multi_remove_handle ($curl_mh, $ch);
$results[] = $r;
}
}
curl_multi_close ($curl_mh);
return $results;
}
?>
......@@ -2,8 +2,9 @@
<?php
include 'filesystem.php';
include 'functions_cams.php';
$ip = $argv[1];
$cams_str = $argv[1];
$n = $argv[2];
$interval = $argv[3]*1000;
$mask = $argv[4];
......@@ -12,10 +13,17 @@ $subfolder = $argv[6];
$file_limit = $argv[7];
$index = $argv[8];
$cams = array();
$master = array();
$cams = get_cams($cams_str);
$master = get_master($cams);
/*
if ($mask=="0x1ff") $skip = false;
else $skip = true;
$odd = true;
*/
$skip = false;
$odd = false;
while(true) {
......@@ -28,13 +36,16 @@ while(true) {
//$odd = !$odd;
}
fopen("http://192.168.0.$ip:8081/trig/pointers");
fopen("http://{$master['ip']}:{$master['port']}/trig/pointers");
//usleep(1000);
if ($odd) {
$index = update_subsubdir("$root_path/$subfolder",$index,$file_limit,$index_max=100000);
$path = "$root_path/$subfolder/$index";
system("./images.sh $ip $n $path &");
//system("./images.sh $ip $n $path &");
for($i=0;$i<count($cams);$i++){
exec("./get_image.sh \"{$cams[$i]['ip']}:{$cams[$i]['port']}/bimg\" \"${path}\" \"${i}.jp4\" \"${i}.log\" \"${i}\"> /dev/null 2>&1 &");
}
}
$time2 = microtime(true);
......
<?php
include 'filesystem.php';
include 'functions_cams.php';
$root_path = $_GET['root_path'];
$subfolder = $_GET['subfolder'];
$period = $_GET['period']+0;
$index=0;
$file_limit = 3000;
$master_ip = "";
$master_port = "";
$master_channel = "";
// keys assign
$cams = array();
$master = array();
if (isset($_GET['rq'])){
$pars = explode(",",$_GET['rq']);
foreach($pars as $val){
$ip = strtok($val,":");
$port = strtok(":");
$channel = strtok(":");
$master = strtok(":");
array_push($cams,array('ip'=>$ip,'port'=>$port,'channel'=>$channel,'master'=>$master));
if ($master=="1"){
$master_ip = $ip;
$master_port = $port;
$master_channel = $channel;
}
}
$cams = get_cams($_GET['rq']);
$master = get_master($cams);
}
$path = $root_path."/".$subfolder;
......@@ -48,15 +37,15 @@ if (!is_dir($path)) {
umask($old);
}
if ($fp = simplexml_load_file("http://$master_ip:$master_port/trig/pointers")) {
if ($fp = simplexml_load_file("http://{$master['ip']}:{$master['port']}/trig/pointers")) {
//$system_status = system("./images.sh $ip $n $path");
for($i=0;$i<count($cams);$i++){
exec("./get_image.sh \"{$cams[$i]['ip']}:{$cams[$i]['port']}/bimg\" \"${path}\" \"${i}.jp4\" > /dev/null 2>&1 &");
exec("./get_image.sh \"{$cams[$i]['ip']}:{$cams[$i]['port']}/bimg\" \"${path}\" \"${i}.jp4\" \"${i}.log\" \"${i}\"> /dev/null 2>&1 &");
}
//why fopen?
$fp = fopen("http://$master_ip/camogmgui/camogm_interface.php?cmd=set_parameter&pname=TRIG_PERIOD&pvalue=192000001&sensor_port=$master_channel", 'r');
$fp = fopen("http://$master_ip/camogmgui/camogm_interface.php?cmd=set_parameter&pname=TRIG_PERIOD&pvalue=192000000&sensor_port=$master_channel", 'r');
$add_str = "http://{$master['ip']}/camogmgui/camogm_interface.php?cmd=set_parameter&pname=TRIG_PERIOD&pvalue=";
$fp = fopen($addr_str.($period+1)."&sensor_port={$master['channel']}", 'r');
$fp = fopen($addr_str.($period+1)."&sensor_port={$master['channel']}", 'r');
//$fp = fopen("http://192.168.0.221:8081/trig/pointers",'r');
//$fp = fopen("http://192.168.0.221:8081/trig/pointers",'r');
//$fp = fopen("http://192.168.0.221:8081/trig/pointers",'r');
......
......@@ -5,13 +5,13 @@
<footage_path>/data/footage</footage_path>
<footage_subfolder>test</footage_subfolder>
<footage_limit>3000</footage_limit>
<gpsimu_device_name>/dev/hda1</gpsimu_device_name>
<gpsimu_device_name>/dev/sda1</gpsimu_device_name>
<box_force_jp4>checked</box_force_jp4>
<input_quality>98</input_quality>
<input_trigger_period>1000</input_trigger_period>
<input_hdrvexpos>0x36000</input_hdrvexpos>
<input_autoexp_max>40</input_autoexp_max>
<input_autoexp_lvl>220</input_autoexp_lvl>
<input_autoexp_fracpix>90</input_autoexp_fracpix>
<input_autoexp_max>10</input_autoexp_max>
<input_autoexp_lvl>200</input_autoexp_lvl>
<input_autoexp_fracpix>99.9</input_autoexp_fracpix>
<input_autoexp_frames_ahead>1</input_autoexp_frames_ahead>
</Document>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<master_ip>221</master_ip>
<master_ip>161</master_ip>
<rec_mode>camogm</rec_mode>
<footage_path>/data/footage</footage_path>
<footage_subfolder>test</footage_subfolder>
<footage_limit>3000</footage_limit>
<gpsimu_device_name>/dev/hda1</gpsimu_device_name>
<gpsimu_log_filename>/var/html/CF/test.log</gpsimu_log_filename>
<gpsimu_device_name>/dev/sda1</gpsimu_device_name>
<gpsimu_log_filename>/mnt/sda1/test.log</gpsimu_log_filename>
<gpsimu_records_per_file>10000000</gpsimu_records_per_file>
<box_force_jp4>checked</box_force_jp4>
<input_quality>97</input_quality>
<input_quality>98</input_quality>
<input_trigger_period>1000</input_trigger_period>
<input_skip_frames>0x1ff</input_skip_frames>
<input_hdrvexpos>0x36000</input_hdrvexpos>
<input_autoexp_max>1</input_autoexp_max>
<input_autoexp_max>10</input_autoexp_max>
<input_autoexp_lvl>200</input_autoexp_lvl>
<input_autoexp_fracpix>90.0</input_autoexp_fracpix>
<input_autoexp_frames_ahead>1</input_autoexp_frames_ahead>
......
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<master_ip>161</master_ip>
<master_ip>163</master_ip>
<rec_mode>pc</rec_mode>
<footage_path>/data/footage</footage_path>
<footage_subfolder>test_phg21</footage_subfolder>
<footage_limit>3000</footage_limit>
<gpsimu_log_filename>/var/html/CF/test_phg21.log</gpsimu_log_filename>
<gpsimu_device_name>/dev/hda1</gpsimu_device_name>
<gpsimu_log_filename>/mnt/sda1/test_phg21.log</gpsimu_log_filename>
<gpsimu_device_name>/dev/sda1</gpsimu_device_name>
<gpsimu_records_per_file>10000000</gpsimu_records_per_file>
<box_force_jp4>checked</box_force_jp4>
<input_quality>97</input_quality>
<input_quality>98</input_quality>
<input_trigger_period>2000</input_trigger_period>
<input_skip_frames>0x1ff</input_skip_frames>
<input_hdrvexpos>0x36000</input_hdrvexpos>
......
......@@ -10,35 +10,36 @@
<link rel="stylesheet" type="text/css" href="index.css" />
<style>
#save_button{
width: 100px;
height: 100px;
line-height:50px;
font-weight: bold;
font-size: 1.5em;
}
#dest_path{
border: 1px solid black;
font-size: 1em;
}
#dest_path_div, #button_div{
padding: 10px;
}
#save_button {
background: rgba(220,30,30,1);
}
#save_button:hover{
background: -webkit-gradient(linear, left top, left bottom, from(rgba(256,70,70,1)), to(rgba(255,100,100,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(256,70,70,1), rgba(230,100,100,1)); /* for firefox 3.6+ */
}
#save_button:active, #save_button:disabled {
background: -webkit-gradient(linear, left top, left bottom, from(rgba(150,150,150,1)), to(rgba(200,200,200,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(150,150,150,1), rgba(200,200,200,1)); /* for firefox 3.6+ */
color: rgba(100,100,100,1);
}
#save_button{
width: 100px;
height: 100px;
line-height:50px;
font-weight: bold;
font-size: 1.5em;
}
#dest_path{
border: 1px solid black;
font-size: 1em;
}
#dest_path_div, #button_div{
padding: 10px;
}
#save_button {
background: rgba(220,30,30,1);
}
#save_button:hover{
background: -webkit-gradient(linear, left top, left bottom, from(rgba(256,70,70,1)), to(rgba(255,100,100,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(256,70,70,1), rgba(230,100,100,1)); /* for firefox 3.6+ */
}
#save_button:active, #save_button:disabled {
background: -webkit-gradient(linear, left top, left bottom, from(rgba(150,150,150,1)), to(rgba(200,200,200,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(150,150,150,1), rgba(200,200,200,1)); /* for firefox 3.6+ */
color: rgba(100,100,100,1);
}
</style>
......@@ -51,69 +52,68 @@
</div>
<div id="button_div">
<button id="save_button" onclick="save()">Save</button>
<button id="save_button" onclick="save()" disabled>Save</button>
</div>
<div id="status"></div>
<script>
var ip = "221";
var n = 9;
var color = 5;
var period = 100000000/2; //defult 1/fps when not taking image
var rq = "";
var color = 5;
var period = 100000000/2; //defult 1/fps when not taking image
parseURL();
set_parameter(rq,"COLOR",color,enable_save_button());
//set_parameter(rq,"TRIG_PERIOD",period,enable_save_button())
function save(){
$("#status").html("Saving...");
$.ajax({
url: "recorder_single.php?rq="+rq+"&root_path=/data/footage&subfolder="+$("#dest_path").val()+"&period="+period,
async: true,
success: function(response){
save_response(response);
},
contentType: "text/xml; charset=\"utf-8\""
});
}
function save_response(text){
var data = $(text).find("Document");
var status = data.find("status").text();
parseURL();
set_parameter(ip,"COLOR",color);
set_parameter(ip,"TRIG_PERIOD",period);
$("#status").html(status);
}
function save(){
$("#status").html("Saving...");
$.ajax({
url: "recorder_single.php?ip="+ip+"&n="+n+"&root_path=/data/footage&subfolder="+$("#dest_path").val()+"&",
async: true,
success: function(response){
save_response(response);
},
contentType: "text/xml; charset=\"utf-8\""
});
}
function save_response(text){
var data = $(text).find("Document");
var status = data.find("status").text();
$("#status").html(status);
}
function parseURL() {
var parameters=location.href.replace(/\?/ig,"&").split("&");
for (var i=0;i<parameters.length;i++) parameters[i]=parameters[i].split("=");
for (var i=1;i<parameters.length;i++) {
switch (parameters[i][0]) {
case "n": n = parseInt(parameters[i][1]);break;
case "ip": ip = parseInt(parameters[i][1]);break;
case "mode": color = parseInt(parameters[i][1]);break;
case "period": period = parseInt(parameters[i][1]);break;
function parseURL() {
var parameters=location.href.replace(/\?/ig,"&").split("&");
for (var i=0;i<parameters.length;i++) parameters[i]=parameters[i].split("=");
for (var i=1;i<parameters.length;i++) {
switch (parameters[i][0]) {
case "rq": rq = parameters[i][1];break;
case "mode": color = parseInt(parameters[i][1]);break;
case "period": period = parseInt(parameters[i][1]);break;
}
}
console.log(rq);
}
}
function set_parameter(ip,par,val,callback){
//console.log("n is "+n);
var url = "eyesis4pi_control.php?set_parameter&master_ip="+ip+"&n="+n+"&pname="+par+"&pvalue="+val;
$.ajax({
url: url,
//async: true,
async: false,
success: function(data){
//$("#status").html(data);
if (typeof callback != 'undefined') callback();
}
});
}
function set_parameter(rq,par,val,callback){
var url = "eyesis4pi_control.php?set_parameter&rq="+rq+"&pname="+par+"&pvalue="+val;
$.ajax({
url: url,
success: function(data){
//$("#status").html(data);
if (typeof callback != 'undefined') callback();
}
});
}
function enable_save_button(){
$("#save_button").prop("disabled",false);
}
</script>
</body>
......
// TAB 1: begin
function tab1_init(mode){
var tab1_contents = "";
......@@ -21,7 +22,7 @@ function tab1_init(mode){
<br/>\
<table>\
<tr>\
<td><div class="fixed_height" >Absolute footage path:</div></td>\
<td><div class="fixed_height" >Footage absolute path:</div></td>\
<td><div class="fixed_height" ><input id="footage_path" type="text" style="width:200px;" value="/data/footage" class="settings_paths" onchange="check_footage_path()"></div></td>\
<td><div id="footage_path_message"></div></td>\
</tr>\
......@@ -40,8 +41,8 @@ function tab1_init(mode){
<br/>\
<table>\
<tr>\
<td><div class="fixed_height" >Device name <span style="font-size:12px;">(/dev/hda1,&nbsp;/dev/hdb1)</span>:</div></td>\
<td><div class="fixed_height" ><input id="gpsimu_device_name" type="text" style="width:200px;" value="/dev/hda1" class="settings_paths"></div></td>\
<td><div class="fixed_height" >Device name <span style="font-size:12px;">(/dev/sda1)</span>:</div></td>\
<td><div class="fixed_height" ><input id="gpsimu_device_name" type="text" style="width:200px;" value="/dev/sda1" class="settings_paths"></div></td>\
<td>\
<button id="btn_cf_mount" onclick="cf_mount()">Mount</button>\
<button id="btn_cf_unmount" onclick="cf_unmount()">Unmount</button>\
......@@ -52,7 +53,7 @@ function tab1_init(mode){
<td><div id="cf_card_free_space"></div></td>\
</tr>\
<tr>\
<td colspan="2"><button id="btn_dl_logs" onclick="download_gps_imu_log()">Download contents to the absolute footage path</button></td>\
<td colspan="2"><button id="btn_dl_logs" onclick="download_gps_imu_log()">Download contents to the footage absolute path</button></td>\
<td>\
<button id="btn_clean_cd" onclick="clean_cf_card()">Clean</button>\
</td>\
......@@ -75,7 +76,97 @@ function tab1_init(mode){
$("#tab1_contents_").html(tab1_contents);
getSettings(settings_file,'paths');
}
// TAB 1: end
// TAB 2: begin
function white_balance_sliders_init(){
$( "#radio" ).buttonset();
$( "#red" ).slider({
orientation: "horizontal",
range: "min",
min: 100,
max: 1600,
value: 282,
slide: function( event, ui ) {
$("#red_gain").val(ui.value/100);
},
change: set_red
});
$( "#green" ).slider({
orientation: "horizontal",
range: "min",
min: 100,
max: 1600,
value: 200,
slide: function( event, ui ) {
$("#green_gain").val(ui.value/100);
},
change: set_green
});
$( "#blue" ).slider({
orientation: "horizontal",
range: "min",
min: 100,
max: 1600,
value: 245,
slide: function( event, ui ) {
$("#blue_gain").val(ui.value/100);
},
change: set_blue
});
$("#red_gain").val($("#red" ).slider("values", 1)/100 );
$("#green_gain").val($("#green" ).slider("values", 1)/100 );
$("#blue_gain").val($("#blue" ).slider("values", 1)/100 );
}
function moveslider() {
$("#red").slider( "value", 100*$("#red_gain").val());
$("#green").slider( "value", 100*$("#green_gain").val());
$("#blue").slider( "value", 100*$("#blue_gain").val());
}
function set_red(){set_gains("red");}
function set_green(){set_gains("green");}
function set_blue(){set_gains("blue");}
function set_default_gains(light) {
if (light=="sunny") {
$("#red_gain").val(2.82);
$("#green_gain").val(2);
$("#blue_gain").val(2.45);
}
if (light=="cloudy") {
$("#red_gain").val(2.82);
$("#green_gain").val(2);
$("#blue_gain").val(2.45);
}
if (light=="fluorescent") {
$("#red_gain").val(2.15);
$("#green_gain").val(2);
$("#blue_gain").val(3.82);
}
moveslider();
//set_gains();
}
function set_gains(color) {
console.log("set_gains('"+color+"')");
if (color=="red"||color=="all") set_parameter(master_ip,'GAINR' ,Math.round(65536*$("#red_gain").val()),false); // *0x10000
if (color=="green"||color=="all") {
set_parameter(master_ip,'GAING' ,Math.round(65536*$("#green_gain").val()),false);
set_parameter(master_ip,'GAINGB',Math.round(65536*$("#green_gain").val()),false);
}
if (color=="blue"||color=="all") set_parameter(master_ip,'GAINB' ,Math.round(65536*$("#blue_gain").val()),false);
//setTimeout("refresh_images()",2000);
}
// TAB 2: end
// TAB 3: begin
function tab3_init(){
var c = "<table>\n";
var tmp = "";
......@@ -93,8 +184,8 @@ function tab3_init(){
c += "<div style='padding:5px;'>Temperatures map:</div><div id='temperatures_map'></div>";
$("#tab3_contents").html(c);
}
// TAB 3: end
function previews_init(){
......@@ -127,4 +218,4 @@ function previews_init(){
$("#previews").html(c);
$("#histograms_front").html("<table><tr>"+hist_front+"</tr></table>");
}
\ 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