Commit 278cdd5e authored by Andrey Filippov's avatar Andrey Filippov

update lwir16.php and related files

parent 3b0788d7
...@@ -5,6 +5,7 @@ INSTALL = install ...@@ -5,6 +5,7 @@ INSTALL = install
DOCS= img.html \ DOCS= img.html \
index.html \ index.html \
index.php \ index.php \
index1.php \
mjpeg.html mjpeg.html
all: all:
......
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"
duration = 100 duration = 100
pre_delay = 3.0 pre_delay = 3.0
ffc_period = 30.0 ffc_period = 30.0
ffc_groups = 2 ffc_groups = 2
ffc_frames = 8 ffc_frames = 8
ffc = 1 ffc = 1
tiff_telem = 1
tiff_mn = 0
tiff_mx = 65535
tiff_bin_shift = 1
tiff_auto = 0
debug = 1 debug = 1
# no spaces around commas! # no spaces around commas!
CMD = INIT,START CMD = INIT,START
\ No newline at end of file
...@@ -36,7 +36,18 @@ ...@@ -36,7 +36,18 @@
define('CONF_LWIR16', '/etc/elphel393/lwir16.ini'); define('CONF_LWIR16', '/etc/elphel393/lwir16.ini');
define('EO_DECIMATE', 6); define('EO_DECIMATE', 6);
// GLOBALS field name // GLOBALS field name
define('CAM_IP_PREF', 'cam_'); // camera
define('CAM_PORT_SEP', '_'); // camera ip to port seperator
define('IPS', 'ips'); define('IPS', 'ips');
define('PORT_MASKS', 'port_masks');
define('ALL_PORTS', 15);
define('IMGSRV_PORT0', 2323);
define('TIFF_TELEM', 'tiff_telem');
define('TIFF_MN', 'tiff_mn');
define('TIFF_MX', 'tiff_mx');
define('TIFF_BIN_SHIFT', 'tiff_bin');
define('TIFF_STATS', 'tiff_stats');
define('TIFF_AUTO', 'tiff_auto');
define('DURATION', 'duration'); define('DURATION', 'duration');
define('DURATION_EO', 'duration_eo'); define('DURATION_EO', 'duration_eo');
define('PRE_DELAY', 'pre_delay'); define('PRE_DELAY', 'pre_delay');
...@@ -74,6 +85,13 @@ ...@@ -74,6 +85,13 @@
// $ffc = false; // $ffc = false;
$GLOBALS[FFC_GROUPS] = 2; // 1/2/4 - do not run FFC on all channels simultaneously (43 failed) $GLOBALS[FFC_GROUPS] = 2; // 1/2/4 - do not run FFC on all channels simultaneously (43 failed)
$GLOBALS[FFC_FRAMES] = 8; // read actual? $GLOBALS[FFC_FRAMES] = 8; // read actual?
/*
$GLOBALS[TIFF_TELEM] = 1; // one top line
$GLOBALS[TIFF_MN] = 0;
$GLOBALS[TIFF_MX] = 0xffff;
$GLOBALS[TIFF_BIN_SHIFT] = 1; // bin_size = 2
$GLOBALS[TIFF_AUTO] = 0; // use very min/veri max (1 - 0.1%, 2 - 0.5%, 3 - 1%, 4 - 5%, 5 - 10%)
*/
$ini = parse_ini_file(CONF_LWIR16); $ini = parse_ini_file(CONF_LWIR16);
applyConf($ini); applyConf($ini);
...@@ -94,9 +112,14 @@ ...@@ -94,9 +112,14 @@
unset($duration);unset($duration_eo); unset($duration);unset($duration_eo);
unset ($masks);
foreach($_GET as $key=>$value) { foreach($_GET as $key=>$value) {
if (($key == 'ip') || ($key == 'ips')){ // multicamera operation if (($key == 'ip') || ($key == 'ips')){ // multicamera operation
$GLOBALS[IPS] = explode(',',$value); $GLOBALS[IPS] = explode(',',$value);
unset ($GLOBALS[PORT_MASKS]); // invalidate
} else if ($key == PORT_MASKS){ //
$masks = explode(',',$value);
unset ($GLOBALS[PORT_MASKS]); // invalidate
} else if (($key == 'lwir16') || ($key == 'cmd')){ } else if (($key == 'lwir16') || ($key == 'cmd')){
$lswir16cmds = explode(',',$value); $lswir16cmds = explode(',',$value);
} else if ($key == 'pre_delay'){ } else if ($key == 'pre_delay'){
...@@ -118,11 +141,33 @@ ...@@ -118,11 +141,33 @@
} }
} }
} }
else if ($key == TIFF_TELEM) $GLOBALS[TIFF_TELEM] = (int) $value;
else if ($key == TIFF_MN) $GLOBALS[TIFF_MN] = (int) $value;
else if ($key == TIFF_MX) $GLOBALS[TIFF_MX] = (int) $value;
else if ($key == TIFF_BIN_SHIFT) $GLOBALS[TIFF_BIN_SHIFT] = (int) $value;
else if ($key == TIFF_AUTO) $GLOBALS[TIFF_AUTO] = (int) $value;
}
if (!isset($GLOBALS[PORT_MASKS])){
$GLOBALS[PORT_MASKS] = array();
for ($i = 0; $i < count($GLOBALS[IPS]); $i++){
// print ('<pre>'.$i."\n</pre>");
if (isset($masks) && (count($masks) > $i)){
$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = (int) ($masks[$i]);
} else {
$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] = ALL_PORTS;
// print ('<pre>'.$i."->".$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]."\n</pre>");
}
}
} }
// print_r($lswir16cmds); // print_r($lswir16cmds);
// exit(0); // exit(0);
/*
echo"<pre>\n"; //****************
print_r($ini);
print_r($GLOBALS);
echo"</pre>";
exit(0);
*/
if (isset($duration) && !isset($duration_eo)){ if (isset($duration) && !isset($duration_eo)){
$duration_eo = (int) ($duration/EO_DECIMATE + 1); $duration_eo = (int) ($duration/EO_DECIMATE + 1);
} }
...@@ -173,7 +218,7 @@ ...@@ -173,7 +218,7 @@
$results = runInit(); $results = runInit();
$xml = new SimpleXMLElement("<?xml version='1.0' standalone='yes'?><lwir16_init/>"); $xml = new SimpleXMLElement("<?xml version='1.0' standalone='yes'?><lwir16_init/>");
for ($i = 0; $i<count($results); $i++){ for ($i = 0; $i<count($results); $i++){
$xml_ip = $xml->addChild ('ip_'.$GLOBALS[IPS][$i]); $xml_ip = $xml->addChild (CAM_IP_PREF.$GLOBALS[IPS][$i]);
foreach ($results[$i] as $key=>$value){ foreach ($results[$i] as $key=>$value){
$xml_ip->addChild($key,$value); $xml_ip->addChild($key,$value);
} }
...@@ -232,23 +277,80 @@ ...@@ -232,23 +277,80 @@
header("Pragma: no-cache\n"); header("Pragma: no-cache\n");
printf($rslt); printf($rslt);
exit (0); exit (0);
} } else if ($cmd == TIFF_STATS) {
} /*
echo "<pre>\n"; // ****************
print_r($ini);
print_r($GLOBALS);
echo "</pre>";
exit(0);
*/
$urls = array();
$xml_names = array();
for ($i = 0; $i < count($GLOBALS[IPS]); $i ++) {
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
for ($port = 0; $port < 4; $port ++) if ($GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]] & (1 << $port)){
$url = 'http://' . $GLOBALS[IPS][$i] . ':'.(IMGSRV_PORT0+$port).
'/'.TIFF_TELEM.'='.$GLOBALS[TIFF_TELEM].
'/'.TIFF_MN.'='.$GLOBALS[TIFF_MN].
'/'.TIFF_MX.'='.$GLOBALS[TIFF_MX].
'/'.TIFF_BIN_SHIFT.'='.$GLOBALS[TIFF_BIN_SHIFT].
'/'.TIFF_STATS;
$urls[] = $url;
$xml_names[] = CAM_IP_PREF.$GLOBALS[IPS][$i].CAM_PORT_SEP.$port;
}
}
/// echo "<pre>\n"; // ****************
/// print_r($urls);
$curl_data = curl_multi_start($urls);
$enable_echo = false;
$results = curl_multi_finish($curl_data, true, 0, $enable_echo); // Switch true -> false if errors are reported (other output damaged XML)
/// print_r($xml_names);
// if ($debug) {
/// printf("--- results:\n");
/// print_r($results);
// }
// echo "</pre>";
// exit(0);
$xml = new SimpleXMLElement("<?xml version='1.0' standalone='yes'?><".TIFF_STATS."/>");
for ($i = 0; $i<count($results); $i++){
$xml_ip_port = $xml->addChild ($xml_names[$i]);
/// echo("\n".$xml_names[$i]);
/// print_r($results[$i]);
foreach ($results[$i] as $key=>$value){
$xml_ip_port->addChild($key,$value);
}
}
$rslt=$xml->asXML();
/// var_dump($xml);
/// echo $rslt;
/// echo "</pre>";
/// exit(0);
header("Content-Type: text/xml");
header("Content-Length: ".strlen($rslt)."\n");
header("Pragma: no-cache\n");
printf($rslt);
exit(0);
}
}
} else { // Just output usage? } else { // Just output usage?
echo <<<EOT echo <<<EOT
<pre> <pre>
This script supports initialization of the LWIR16 camera (16 LWIR 640x512 sensors and 4 2592x1936 color ones) This script supports initialization of the LWIR16 camera (16 LWIR 640x512 sensors and 4 2592x1936 color ones)
and capturing of short image sequences (100 frames fit into 64MB per-channel image buffer) for (relatively) and capturing of short image sequences (100 frames fit into 64MB per-channel image buffer) for (relatively)
slow recording with camogm. Untill videocompression for 16-bit TIFFs is not implemented, recording is not fast slow recording with camogm. Untill videocompression for 16-bit TIFFs is not implemented, recording is not fast
enough for continupous recording. This script should be launched in the 'master' subcamera only, it will enough for continupous recording. This script should be launched in the 'master' subcamera only, it will
communidate with the other ones. communidate with the other ones.
URL parameters: URL parameters:
<b>lwir16=init</b> - syncronize all 5 cameras, set acquisition parameters <b>lwir16=init</b> - syncronize all 5 cameras, set acquisition parameters
<b>lwir16=capture</b> - wait specified time, synchronously turn on compressors in each channel of each subcamera, <b>lwir16=capture</b> - wait specified time, synchronously turn on compressors in each channel of each subcamera,
acquire specified number of frames in each channel (reduced, and turn compressors off. acquire specified number of frames in each channel (reduced, and turn compressors off.
</pre> </pre>
EOT; EOT;
// Watch EOT w/o any spaces! // Watch EOT w/o any spaces!
} }
...@@ -436,7 +538,8 @@ EOT; ...@@ -436,7 +538,8 @@ EOT;
// $_SERVER[SCRIPT_NAME] STARTS WITH '/' // $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url = 'http://'.$GLOBALS[IPS][$i].'/capture_range.php?sensor_port='.$sensor_port; // $url = 'http://'.$GLOBALS[IPS][$i].'/capture_range.php?sensor_port='.$sensor_port; //
$url .= '&ts='.$timestamp; // &timestamp" -> ×tamp $url .= '&ts='.$timestamp; // &timestamp" -> ×tamp
$url .= '&port_mask=15'; // .$port_mask[$i]; // $url .= '&port_mask=15'; // .$port_mask[$i];
$url .= '&port_mask='.$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]; //indexed by IPs
$dur = ($i < 4) ? $GLOBALS[DURATION] : $GLOBALS[DURATION_EO]; $dur = ($i < 4) ? $GLOBALS[DURATION] : $GLOBALS[DURATION_EO];
$url .= '&duration='. $dur; $url .= '&duration='. $dur;
// $url .= '&maxahead='. $maxahead; // $url .= '&maxahead='. $maxahead;
...@@ -459,11 +562,10 @@ EOT; ...@@ -459,11 +562,10 @@ EOT;
} }
function runFFC($lwir_ips, $ffc_wait_frames, $debug=0) { // return number of frames used function runFFC($lwir_ips, $ffc_wait_frames, $debug=0) { // return number of frames used
$skipped = 0; $skipped = 0;
$port_masks =array(); $port_masks =array();
foreach ($lwir_ips as $l){ foreach ($lwir_ips as $lip){
$port_masks[] = 15; // select all 4 ports $port_masks[] = $GLOBALS[PORT_MASKS][$lip]; // select all 4 ports
} }
if ($GLOBALS[FFC_GROUPS] == 1) $group_masks = array(15); if ($GLOBALS[FFC_GROUPS] == 1) $group_masks = array(15);
else if ($GLOBALS[FFC_GROUPS] == 2) $group_masks = array(5, 10); else if ($GLOBALS[FFC_GROUPS] == 2) $group_masks = array(5, 10);
...@@ -720,7 +822,22 @@ EOT; ...@@ -720,7 +822,22 @@ EOT;
} }
function applyConf($arr){ function applyConf($arr){
if (isset($arr[IPS])) $GLOBALS[IPS] = explode(',',$arr[IPS]); //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]] = ALL_PORTS;
}
}
}
if (isset($arr[DURATION])){ if (isset($arr[DURATION])){
$GLOBALS[DURATION] = (int) $arr[DURATION]; $GLOBALS[DURATION] = (int) $arr[DURATION];
$GLOBALS[DURATION_EO] = (int) ($GLOBALS[DURATION]/EO_DECIMATE+1); $GLOBALS[DURATION_EO] = (int) ($GLOBALS[DURATION]/EO_DECIMATE+1);
...@@ -734,6 +851,11 @@ EOT; ...@@ -734,6 +851,11 @@ EOT;
if (isset($arr[DEBUG])) $GLOBALS[DEBUG] = (int) $arr[DEBUG]; 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[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[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];
} }
/** /**
......
...@@ -178,12 +178,16 @@ function curl_multi_finish($data, $use_xml=true, $ntry=0, $echo = false, $with_h ...@@ -178,12 +178,16 @@ function curl_multi_finish($data, $use_xml=true, $ntry=0, $echo = false, $with_h
$xml = simplexml_load_string (curl_multi_getcontent ($ch)); $xml = simplexml_load_string (curl_multi_getcontent ($ch));
curl_multi_remove_handle ($curl_mh, $ch); curl_multi_remove_handle ($curl_mh, $ch);
$results[$i] = array (); $results[$i] = array ();
foreach ($xml as $tag => $value) { try {
$svalue = (string) $value; foreach ($xml as $tag => $value) {
if (strlen ($svalue) > 0) { $svalue = (string) $value;
if ($svalue[0] == '"') $results[$i][$tag] = trim ($svalue, '"'); if (strlen ($svalue) > 0) {
else $results[$i][$tag] = (int) $svalue; if ($svalue[0] == '"') $results[$i][$tag] = trim ($svalue, '"');
} else $results[$i][$tag] = (int) $svalue;
}
}
} catch (exception $e) {
// empty array?
} }
} }
} else { } else {
......
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