Commit 10412f81 authored by Andrey Filippov's avatar Andrey Filippov

working on LWIR16 control

parent 2c148fb3
...@@ -26,7 +26,7 @@ var apply_pending = false; ...@@ -26,7 +26,7 @@ var apply_pending = false;
function parse_response(resp){ function parse_response(resp){
var result = ""; var result = "";
console.log(resp); console.log("parse_response(), resp="+resp);
if (resp.getElementsByTagName("result").length!=0){ if (resp.getElementsByTagName("result").length!=0){
result = resp.getElementsByTagName("result")[0].childNodes[0].nodeValue; result = resp.getElementsByTagName("result")[0].childNodes[0].nodeValue;
}else if (resp.getElementsByTagName("reboot").length!=0){ }else if (resp.getElementsByTagName("reboot").length!=0){
...@@ -40,11 +40,13 @@ function parse_response(resp){ ...@@ -40,11 +40,13 @@ function parse_response(resp){
} }
function send_request(rq,callback){ function send_request(rq,callback){
console.log("send_request(), rq="+rq);
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.open('GET', rq, true); request.open('GET', rq, true);
request.onreadystatechange = function() { request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
var resp = this.responseXML; var resp = this.responseXML;
console.log("send_request(), callback, resp="+resp);
callback(resp); callback(resp);
} }
}; };
...@@ -55,8 +57,10 @@ function send_request(rq,callback){ ...@@ -55,8 +57,10 @@ function send_request(rq,callback){
} }
function sendStatusRequest(){ function sendStatusRequest(){
console.log("sendStatusRequest()");
var url = "http://192.168.0.41/lwir16/lwir16.php?daemon=status"; var url = "http://192.168.0.41/lwir16/lwir16.php?daemon=status";
if (apply_pending) { if (apply_pending) {
console.log("sendStatusRequest(), apply_pending");
var mod_pars = modParameters(); var mod_pars = modParameters();
// console.log('mod_pars members:'); // console.log('mod_pars members:');
for(const p in mod_pars) { for(const p in mod_pars) {
...@@ -69,6 +73,7 @@ function sendStatusRequest(){ ...@@ -69,6 +73,7 @@ function sendStatusRequest(){
} }
function sendRestartRequest(){ function sendRestartRequest(){
console.log("sendRestartRequest()");
var url = "http://192.168.0.41/lwir16/lwir16.php?daemon=restart&cmd=STATUS"; var url = "http://192.168.0.41/lwir16/lwir16.php?daemon=restart&cmd=STATUS";
send_request(url,parseStatusResponse); send_request(url,parseStatusResponse);
} }
...@@ -76,6 +81,7 @@ function sendRestartRequest(){ ...@@ -76,6 +81,7 @@ function sendRestartRequest(){
function parseStatusResponse(resp){ function parseStatusResponse(resp){
console.log("parseStatusResponse(), resp="+resp);
var result = ""; var result = "";
// console.log(resp); // console.log(resp);
if (update_editable) { if (update_editable) {
...@@ -158,6 +164,7 @@ function parseStatusResponse(resp){ ...@@ -158,6 +164,7 @@ function parseStatusResponse(resp){
request_num++; request_num++;
document.getElementById("idrequest_num").value = request_num; document.getElementById("idrequest_num").value = request_num;
update_editable = false; update_editable = false;
console.log("parseStatusResponse() almost Done, sending again sendStatusRequest()");
sendStatusRequest(); sendStatusRequest();
} }
......
#configuration for LWIR 16 camera
multicam_dir = "footage01"
multicam_rperiod = 5.0
multicam_speriod = 2.0
#save current settings to overwrite those in this file
multicam_conf = "/etc/elphel393/multicamconf.xml"
ips = "192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45" ips = "192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45"
port_masks= "15,15,15,15,15" port_masks= "15,15,15,15,15"
duration = 100 duration = 100
......
...@@ -487,7 +487,7 @@ EOT; ...@@ -487,7 +487,7 @@ EOT;
return $results; return $results;
} }
function runCapture($run_ffc, $nowait = 0, $debug=0) { function runCapture($run_ffc, $nowait = 0, $debug=0) { // works, but the main script hangs
// TODO: use lwir16.ini // TODO: use lwir16.ini
// $eo_quality = 97; // $eo_quality = 97;
// $exposure = 1000; // 1 ms // $exposure = 1000; // 1 ms
...@@ -662,7 +662,7 @@ EOT; ...@@ -662,7 +662,7 @@ EOT;
$GLOBALS[CAPTURE_RUN] = 0; // until command $GLOBALS[CAPTURE_RUN] = 0; // until command
$GLOBALS[LAST_FFC] = 0; // overdue $GLOBALS[LAST_FFC] = 0; // overdue
$GLOBALS[SECUENCE_NUM] = 0; $GLOBALS[SECUENCE_NUM] = 0;
if ($GLOBALS[DEBUG > 1]) { if ($GLOBALS[DEBUG] > 1) { // was if ($GLOBALS[DEBUG > 1]) {
printf("--- GLOBALS: ---\n"); printf("--- GLOBALS: ---\n");
print_r($GLOBALS); print_r($GLOBALS);
} }
......
...@@ -11,7 +11,8 @@ DOCS= index.html \ ...@@ -11,7 +11,8 @@ DOCS= index.html \
multicam.css \ multicam.css \
multicam2.css \ multicam2.css \
multicam.php \ multicam.php \
multicam2.php multicam2.php \
reboot.html
ZIPDOCS= zip/deflate.js \ ZIPDOCS= zip/deflate.js \
zip/inflate.js \ zip/inflate.js \
......
...@@ -25,7 +25,90 @@ ...@@ -25,7 +25,90 @@
<div id='display_controls'> <div id='display_controls'>
<button type="button" class="collapsible">Recording Status</button> <button type="button" class="collapsible">Recording Status</button>
<div id='display_status'></div> <div id='display_status'></div>
<button type="button" class="collapsible">LWIR16 Status</button>
<div id='lwir16_status'>
<table><tr><td>
<table>
<tr><td><label for="seq_num" >Seq Num</label></td><td><input type="text" id="idsequence_num" name="seq_num" size="5" value="?" disabled="disabled"></td></tr>
<tr><td><label for="request_num">Requests</label></td><td><input type="text" id="idrequest_num" name="request_num" size="5" value="?" disabled="disabled"></td></tr>
<tr><td><label for="capture_run">Running</label></td><td><input type="checkbox" id="idcapture_run" name="capture_run" disabled="disabled"></td></tr>
</table>
</td><td>
<table>
<tr><td><label for="last_ffc" >Last FFC</label></td><td><input type="text" id="idlast_ffc" name="last_ffc" size="5" value="?" disabled="disabled">s</td></tr>
<tr><td><label for="time_to_ffc" >To FFC</label></td><td><input type="text" id="idtime_to_ffc" name="time_to_ffc" size="5" value="?" disabled="disabled">s</td></tr>
<tr><td colspan = "2">&nbsp;</td></tr>
</table>
</td></tr></table>
</div>
<button type="button" class="collapsible">LWIR16 Controls</button>
<div id='lwir16_controls'>
<table><tr><td>
<table>
<tr><td><button id="idStartStop" name = "nStartStop" disabled="true">???</button></td>
<td><button id="idApply" name = "nApply" disabled = "true">???</button></td>
</tr>
<tr><td><label for="idpre_delay" >Inter-Delay</label></td><td><input type="text" id="idpre_delay" name="pre_delay" size="5" value="?">s</td></tr>
<tr><td><label for="duration" >LWIR frames</label></td><td><input type="text" id="idduration" name="duration" size="5" value="?"></td></tr>
<tr><td><label for="duration_eo" >RGB frames</label></td><td><input type="text" id="idduration_eo" name="duration_eo" size="5" value="?"></td></tr>
<tr><td><label for="compressor_run">Compress Init</label></td><td><input type="checkbox" id="idcompressor_run" name="compressor_run"></td></tr>
</table>
</td><td>
<table>
<tr><td><label for="ffc" >FFC</label></td><td><input type="checkbox" id="idffc" name="ffc"></td></tr>
<tr><td><label for="ffc_period" >FFC period</label></td><td><input type="text" id="idffc_period" name="ffc_period" size="5" value="?"></td></tr>
<tr><td><label for="ffc_groups" >FFC groups</label></td><td><select id="idffc_groups" name="idffc_groups">
<option value="1">1</option>
<option value="2">2</option>
<option value="4" selected="selected">4</option>
</select>
</td></tr>
<tr><td><label for="ffc_frames" >FFC frames</label></td><td><input type="text" id="idffc_frames" name="ffc_frames" size="5" value="?"></td></tr>
<tr><td><label for="debug" >Debug</label></td><td><input type="text" id="iddebug" name="debug" size="5" value="?"></td></tr>
</table>
</td></tr></table>
</div>
<button type="button" class="collapsible">Multicam Controls</button>
<div id='multicam settings'>
<table>
<tr>
<td>
<table>
<th><td colspan="2">Image Refresh<td> </th>
<tr> <td><label>Enable</label></td>
<td>
<div id="toggle_refresh" class="btn-group btn-toggle">
<button class="btn btn-xs btn-success active">ON</button>
<button class="btn btn-xs btn-default">OFF</button>
</div>
</td> </tr>
<tr><td><label for="ref_rate">Images</label></td>
<td><input type="text" id="ref_rate" name="ref_rate" size="4">s</td>
</tr><tr>
<td><label for="sref_rate">Status</label></td>
<td><input type="text" id="sref_rate" name="sref_rate" size="4">s
</td> </tr>
</table>
</td>
<td>
<table><th><td colspan="2">SSD Recording<td> </th>
<tr><td><label>Record</label></td>
<td><div id="toggle_record" class="btn-group btn-toggle">
<button class="btn btn-xs btn-success active">ON</button>
<button class="btn btn-xs btn-default">OFF</button>
</div>
</td>
</tr><tr> <td><label id = "root_dir" for="ssd_directory">/mnt/sda1/</label></td>
<td><input type="text" id="dir_name" name="ssd_directory" size="10"></td>
</tr><tr><td colspan="2">&nbsp;</td></tr></table>
</td>
</tr>
</table>
</div>
<button type="button" class="collapsible">Eyesis Controls</button> <button type="button" class="collapsible">Eyesis Controls</button>
<div id='settings'> <div id='settings'>
<table> <table>
...@@ -57,6 +140,17 @@ ...@@ -57,6 +140,17 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr id="manual_exposure_div" title='Manual Exposure'>
<td><label for="exposure_ms">Manual</label></td>
<td><input type="text" id="exposure_ms" name="exposure_ms" size="6" value="50">ms</td>
</tr>
<tr id="image_quality_div" title='Image Quality'>
<td><label for="jpeg_quality">Quality</label></td>
<td><input type="text" id="jpeg_quality" name="jpeg_quality" size="6" value="97">%</td>
</tr>
<tr> <tr>
<td> <td>
<button id='system_tests' title='system info' class="btn btn-sm btn-success">tests</button> <button id='system_tests' title='system info' class="btn btn-sm btn-success">tests</button>
......
This diff is collapsed.
<?php <?php
include "../include/elphel_functions_include.php"; include "../include/elphel_functions_include.php";
define('CONF_LWIR16', '/etc/elphel393/lwir16.ini');
$cmd = "donothing"; define('IPS', 'ips');
define('PORT_MASKS', 'port_masks');
define('NUM_PORTS', 4);
define('IMGSRV_PORT0', 2323);
define('PORTSPATH', '/sys/devices/soc0/elphel393-detect_sensors@0');
define('MULTICAM_INI', 'multicam_ini');
define('MULTICAM_DIR', 'multicam_dir');
define('MULTICAM_RPERIOD', 'multicam_rperiod');
define('MULTICAM_SPERIOD', 'multicam_speriod');
define('MULTICAM_CONF', 'multicam_conf');
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];
$config = "/var/volatile/html/multicam.xml"; ///$ini = parse_ini_file(CONF_LWIR16);
//$cmd = "donothing";
//$config = "/var/volatile/html/multicam.xml";
// path to sysfs for port scanning // path to sysfs for port scanning
$portspath = "/sys/devices/soc0/elphel393-detect_sensors@0"; //$portspath = "/sys/devices/soc0/elphel393-detect_sensors@0";
// total number of ports in 10393 // total number of ports in 10393
$nports = 4; //$nports = 4;
$port0 = 2323; //$port0 = 2323;
// extract ip addresses // extract ip addresses
if ($_SERVER['REQUEST_METHOD']==="POST"){ if ($_SERVER['REQUEST_METHOD']==="POST"){
...@@ -27,16 +41,48 @@ if ($_SERVER['REQUEST_METHOD']==="POST"){ ...@@ -27,16 +41,48 @@ if ($_SERVER['REQUEST_METHOD']==="POST"){
$list = $_SERVER['SERVER_ADDR']; $list = $_SERVER['SERVER_ADDR'];
} }
} }
$ips = explode(',',$list); $ips = explode(',',$list);
// allow CORS // allow CORS
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
// does not need configs
switch($cmd){ switch($cmd){
case "ports": case "ports":
xml_header();
print(getports()); print(getports());
break; exit (0);
}
getIni(); // wil exit OK now
//print ("<!--");
//print_r($lwir16_ini);
//print ("-->");
//exit(0);
switch($cmd){
case "ips":
xml_header();
print(getIps());
exit (0);
case "update":
foreach($_GET as $key=>$value) {
if (array_key_exists($key, $GLOBALS[MULTICAM_INI])){
$GLOBALS[MULTICAM_INI][$key] = $value;
}
}
writeConfig();
exitXmlOK();
exit(0); //
case "configs": // return xml with all $GLOBALS[MULTICAM_INI]
xml_header();
print(getConfigs());
exit(0);
// obsolete old commands
/*
case "write": case "write":
// write // write
// use get and post requests // use get and post requests
...@@ -50,7 +96,82 @@ switch($cmd){ ...@@ -50,7 +96,82 @@ switch($cmd){
default: default:
// will never need read - config is in http://camip/var/multicam.xml // will never need read - config is in http://camip/var/multicam.xml
// read // read
print(file_get_contents($config)); /// print(file_get_contents($config));
* */
default:
exitXmlOK("Unknown");
}
function getIni() {
$ini= parse_ini_file(CONF_LWIR16);
// define parameter type here
$GLOBALS[MULTICAM_INI][IPS] = $ini[IPS];
$GLOBALS[MULTICAM_INI][PORT_MASKS] = $ini[PORT_MASKS];
$GLOBALS[MULTICAM_INI][MULTICAM_DIR] = $ini[MULTICAM_DIR];
$GLOBALS[MULTICAM_INI][MULTICAM_RPERIOD] = $ini[MULTICAM_RPERIOD];
$GLOBALS[MULTICAM_INI][MULTICAM_SPERIOD] = $ini[MULTICAM_SPERIOD];
$GLOBALS[MULTICAM_INI][MULTICAM_CONF] = $ini[MULTICAM_CONF];
// copy other default parameters
// try to read xml if exists
$multi_xml = 0;
if (file_exists($ini[MULTICAM_CONF])) {
$multi_xml = simplexml_load_file($ini[MULTICAM_CONF]);
}
if ($multi_xml) { // if file exists
$multi_ini = array();
foreach ( $multi_xml->children () as $entry ) {
$GLOBALS[MULTICAM_INI][$entry->getName ()] = (string) $entry;
}
} else {
writeConfig();
}
/*
print ("<!--");
var_dump($GLOBALS[MULTICAM_INI]);
print ("-->");
exit (0);
*/
if (isset($GLOBALS[MULTICAM_INI][IPS])) {
$GLOBALS[IPS] = explode(',',$GLOBALS[MULTICAM_INI][IPS]);
if (isset ($GLOBALS[MULTICAM_INI][PORT_MASKS])){
$masks = explode(',',$GLOBALS[MULTICAM_INI][PORT_MASKS]);
}
// Add port masks incdexed by IPs. Changing IPs resets masks
$GLOBALS[PORT_MASKS] = array();
for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
if (isset($masks) && (count($masks) > $i)){
$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (int) $masks[$i];
} else {
$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (1 << NUM_PORTS) -1;
}
}
}
/*
print ("<!--");
var_dump($GLOBALS[MULTICAM_INI]);
echo "------------------------";
var_dump($GLOBALS[IPS]);
echo "------------------------";
var_dump($GLOBALS[PORT_MASKS]);
print ("-->");
exit (0);
*/
// exitXmlOK(); // exit for now
}
function writeConfig(){
$xml="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<multicam>\n";
foreach($GLOBALS[MULTICAM_INI] as $key=>$value){
$xml .= "\t<".$key.'>'.$value.'</'.$key.">\n";
}
$xml .= "</multicam>\n";
file_put_contents($GLOBALS[MULTICAM_INI][MULTICAM_CONF],$xml);
exec('sync');
}
function printToComment($str) {
echo "<!--".$str."-->";
} }
function write_config($config,$ips){ function write_config($config,$ips){
...@@ -59,7 +180,7 @@ function write_config($config,$ips){ ...@@ -59,7 +180,7 @@ function write_config($config,$ips){
foreach($ips as $ip){ foreach($ips as $ip){
$list .= "\t<camera>$ip</camera>\n"; $list .= "\t<camera>$ip</camera>\n";
} }
$xml = "<?xml version='1.0' standalone='yes'?>\n"; $xml = "<?xml version='1.0' encoding=\"iso-8859-1\" standalone='yes'?>\n";
$xml .= "<Document>\n"; $xml .= "<Document>\n";
$xml .= $list; $xml .= $list;
$xml .= "</Document>\n"; $xml .= "</Document>\n";
...@@ -69,32 +190,108 @@ function write_config($config,$ips){ ...@@ -69,32 +190,108 @@ function write_config($config,$ips){
return 0; return 0;
} }
function getports(){ function getConfigs(){
$xml .= "<configs>\n";
// Add more when available. not Using foreach to keep order
$xml .= xmlEntry(MULTICAM_DIR, $GLOBALS[MULTICAM_INI][MULTICAM_DIR], 1);
$xml .= xmlEntry(MULTICAM_RPERIOD, $GLOBALS[MULTICAM_INI][MULTICAM_RPERIOD], 1);
$xml .= xmlEntry(MULTICAM_SPERIOD, $GLOBALS[MULTICAM_INI][MULTICAM_SPERIOD], 1);
$xml .= "</configs>\n";
return $xml;
}
global $nports, $portspath, $port0;
$res = "\t<camera ip='".$_SERVER['SERVER_ADDR']."'>\n";
for($i=0;$i<$nports;$i++){ function getports(){
$sensor = $portspath."/sensor{$i}0"; $res = "\t<camera ip='".$_SERVER['SERVER_ADDR']."'>\n";
for($i=0;$i<NUM_PORTS;$i++){
$sensor = PORTSPATH."/sensor{$i}0";
// the file is always there actually // the file is always there actually
if(is_file($sensor)){ if(is_file($sensor)){
$c = trim(file_get_contents($sensor)); $c = trim(file_get_contents($sensor));
$p = $port0+$i; $p = IMGSRV_PORT0+$i;
$res .= "\t\t<port index='$i' port='$p'>$c</port>\n"; $res .= "\t\t<port index='$i' port='$p'>$c</port>\n";
} }
} }
$res .= "\t</camera>\n"; $res .= "\t</camera>\n";
$xml = "<?xml version='1.0' standalone='yes'?>\n";
$xml .= "<Document>\n"; $xml .= "<Document>\n";
$xml .= $res; $xml .= $res;
$xml .= "</Document>\n"; $xml .= "</Document>\n";
return $xml;
}
function getIps(){
//$GLOBALS[IPS]
$xml = "<cameras>\n";
for($i=0;$i< count($GLOBALS[IPS]);$i++){
$xml .= "\t<ip index='$i'>".$GLOBALS[IPS][$i]."</ip>\n";
}
$xml .= "</cameras>\n";
return $xml; return $xml;
} }
function exitXmlOK($str="ok"){
xml_header();
print ('<'.$str.'/>');
exit(0);
}
function xml_header() {
header("Content-type: text/xml");
header("Pragma: no-cache\n");
// allow CORS: needed for multi cams unified control
header('Access-Control-Allow-Origin: *');
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
}
function xmlEntry($key,$value,$ind=0){
$res = '';
for ($i = 0; $i < $ind; $i++) $res.="\t";
$res .= '<'.$key.'>'.$value.'</'.$key.">\n";
return $res;
}
function applyConf($arr){
//port_masks= "15,15,15,15,15"
if (isset($arr[IPS])) {
$GLOBALS[IPS] = explode(',',$arr[IPS]);
if (isset ($arr[PORT_MASKS])){
$masks = explode(',',$arr[PORT_MASKS]);
}
// Add port masks incdexed by IPs. Changing IPs resets masks
$GLOBALS[PORT_MASKS] = array();
for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
if (isset($masks) && (count($masks) > $i)){
$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (int) $masks[$i];
} else {
$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (1 << NUM_PORTS) -1;
}
}
}
/*
if (isset($arr[DURATION])){
$GLOBALS[DURATION] = (int) $arr[DURATION];
$GLOBALS[DURATION_EO] = (int) ($GLOBALS[DURATION]/EO_DECIMATE+1);
}
if (isset($arr[DURATION_EO])) $GLOBALS[DURATION_EO] = (int) $arr[DURATION_EO];
if (isset($arr[PRE_DELAY])) $GLOBALS[PRE_DELAY] = (double) $arr[PRE_DELAY];
if (isset($arr[FFC_PERIOD])) $GLOBALS[FFC_PERIOD] = (double) $arr[FFC_PERIOD];
if (isset($arr[FFC_GROUPS])) $GLOBALS[FFC_GROUPS] = (int) $arr[FFC_GROUPS];
if (isset($arr[FFC_FRAMES])) $GLOBALS[FFC_FRAMES] = (int) $arr[FFC_FRAMES];
if (isset($arr[DAEMON_CMD])) $GLOBALS[DAEMON_CMD] = $arr[DAEMON_CMD];
if (isset($arr[DEBUG])) $GLOBALS[DEBUG] = (int) $arr[DEBUG];
if (isset($arr[COMPRESSOR_RUN])) $GLOBALS[COMPRESSOR_RUN] = (int) $arr[COMPRESSOR_RUN]; // only after INIT
if (isset($arr[FFC])) $GLOBALS[FFC] = $arr[FFC]?1:0;
if (isset($arr[TIFF_TELEM])) $GLOBALS[TIFF_TELEM] = (int) $arr[TIFF_TELEM];
if (isset($arr[TIFF_MN])) $GLOBALS[TIFF_MN] = (int) $arr[TIFF_MN];
if (isset($arr[TIFF_MX])) $GLOBALS[TIFF_MX] = (int) $arr[TIFF_MX];
if (isset($arr[TIFF_BIN_SHIFT])) $GLOBALS[TIFF_BIN_SHIFT] = (int) $arr[TIFF_BIN_SHIFT];
if (isset($arr[TIFF_AUTO])) $GLOBALS[TIFF_AUTO] = (int) $arr[TIFF_AUTO];
*/
}
function send_zipped_images($ips){ function send_zipped_images($ips){
......
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