Commit d4670440 authored by Andrey Filippov's avatar Andrey Filippov

porting autocampars.php

parent 36b7ea7e
...@@ -183,21 +183,24 @@ ...@@ -183,21 +183,24 @@
CVSLOG; CVSLOG;
set_include_path ( get_include_path () . PATH_SEPARATOR . '/www/pages/include' ); set_include_path ( get_include_path () . PATH_SEPARATOR . '/www/pages/include' );
require 'i2c_include.php'; // / to read 10359 info //TODO NC393 - update to read sensor port! require 'i2c_include.php'; // / to read 10359 info //TODO NC393 - update to read sensor port!
// main() //*************** TODO: make Makefile insert revision from bitbake using sed *************
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
//$sensor_port = 0; //var_dump($_SERVER);
$GLOBALS['VERSION'] = '___VERSION___';
$GLOBALS['SRCREV'] = '___SRCREV___';
$GLOBALS['STATES']=array("BOOT","POWERED", "BITSTREAM", "SENSORS_DETECTED", "SENSORS_SYNCHRONIZED", "SENSORS_CONFIGURED"); $GLOBALS['STATES']=array("BOOT","POWERED", "BITSTREAM", "SENSORS_DETECTED", "SENSORS_SYNCHRONIZED", "SENSORS_CONFIGURED");
$p = strpos ( $cvslog, "Revision" ); $p = strpos ( $cvslog, "Revision" );
$version = strtok ( substr ( $cvslog, $p + strlen ( "Revision" ), 20 ), " " ); $GLOBALS['version'] = strtok ( substr ( $cvslog, $p + strlen ( "Revision" ), 20 ), " " );
// echo "<pre>"; // echo "<pre>";
// echo $version; // echo $version;
// echo "</pre>"; // echo "</pre>";
// $version="1.0"; // $version="1.0";
$thisScript = $_SERVER ['argv'] [0]; $thisScript = $_SERVER ['argv'] [0];
$numBackups = 5; $GLOBALS['numBackups'] = 5;
$parseditPath = "/parsedit.php"; $GLOBALS['parseditPath'] = "/parsedit.php";
$embedImageScale = 0.15; $GLOBALS['embedImageScale'] = 0.15;
$twoColumns = false; $GLOBALS['twoColumns'] = false;
$logFilePath = "/var/log/autocampars.log"; $logFilePath = "/var/log/autocampars.log";
$GLOBALS['sysfs_detect_sensors'] = '/sys/devices/soc0/elphel393-detect_sensors@0'; // /sensor00 $GLOBALS['sysfs_detect_sensors'] = '/sys/devices/soc0/elphel393-detect_sensors@0'; // /sensor00
$GLOBALS['sysfs_frame_seq'] = '/sys/devices/soc0/elphel393-framepars@0/this_frame'; //[0..3] 0 (write <16 will reset the hardware sequencer) $GLOBALS['sysfs_frame_seq'] = '/sys/devices/soc0/elphel393-framepars@0/this_frame'; //[0..3] 0 (write <16 will reset the hardware sequencer)
...@@ -246,30 +249,7 @@ $GLOBALS['configs'] = array(); ...@@ -246,30 +249,7 @@ $GLOBALS['configs'] = array();
log_open(); log_open();
/*
$FS = fopen ( '/var/volatile/state/APPLICATION', 'w' );
fprintf ( $FS, "%s", strtoupper ( ( string ) $xml->app ) );
fclose ( $FS );
if (file_exists ( $sensor_state_file ))
$sensor_board = parse_ini_file ( $sensor_state_file );
else
$sensor_board = array (
"ctype" => "NONE"
);
if ($sensor_board ['ctype'] == 'NONE') {
echo "No board is detected on the sensor port, exiting\n";
exit ( 1 );
}
$config_file=fopen ($config_file_path,"w+");
foreach ($config as $key=>$value) fwrite($config_file,$key.'='.$value."\n");
fclose($config_file);
}
write_php_ini($array, $file)
$GLOBALS['STATES']=array("BOOT","POWERED", "BITSTREAM", "SENSORS_DETECTED", "SENSORS_SYNCHRONIZED", "SENSORS_CONFIGURED");
*/
get_application_mode(); // initializes state file (first time slow reading 10389 get_application_mode(); // initializes state file (first time slow reading 10389
$GLOBALS['camera_state'] = $GLOBALS['camera_state_arr']['state']; $GLOBALS['camera_state'] = $GLOBALS['camera_state_arr']['state'];
if (! in_array ( $camera_state, $GLOBALS['STATES'] )) { if (! in_array ( $camera_state, $GLOBALS['STATES'] )) {
...@@ -286,14 +266,14 @@ if (($_GET ['load'] != '') && ($GLOBALS['sensor_port'] >=0) && ($GLOBALS['camera ...@@ -286,14 +266,14 @@ if (($_GET ['load'] != '') && ($GLOBALS['sensor_port'] >=0) && ($GLOBALS['camera
$load_filename = $_GET ['load']; $load_filename = $_GET ['load'];
if (is_file ( $load_filename )) { if (is_file ( $load_filename )) {
// load file // load file
$GLOBALS['config'][$GLOBALS['sensor_port']] = parseConfig ( $load_filename ); $GLOBALS['configs'][$GLOBALS['sensor_port']] = parseConfig ( $load_filename );
// / skip revision check // / skip revision check
// / and simulate loading of the page '0' with GET request // / and simulate loading of the page '0' with GET request
$_GET ['ignore-revision'] = 'true'; $_GET ['ignore-revision'] = 'true';
// and apply page '0' // and apply page '0'
$groupMask = 0; $groupMask = 0;
for($i = 0; $i < count ( $config ['groupNames'] ); $i ++) { for($i = 0; $i < count ( $GLOBALS['configs'][$GLOBALS['sensor_port']]['groupNames'] ); $i ++) {
$name = $config ['groupNames'] [$i]; $name = $GLOBALS['configs'][$GLOBALS['sensor_port']]['groupNames'] [$i];
$shift = - 1; $shift = - 1;
// echo $name."\n"; // echo $name."\n";
if ($name != "") { if ($name != "") {
...@@ -314,7 +294,7 @@ if (($_GET ['load'] != '') && ($GLOBALS['sensor_port'] >=0) && ($GLOBALS['camera ...@@ -314,7 +294,7 @@ if (($_GET ['load'] != '') && ($GLOBALS['sensor_port'] >=0) && ($GLOBALS['camera
$groupMask |= (1 << (( integer ) $shift)); $groupMask |= (1 << (( integer ) $shift));
} }
echo $groupMask . "\n"; echo $groupMask . "\n";
// var_dump($config['groupNames']); // var_dump($GLOBALS['configs'][$GLOBALS['sensor_port']] ['groupNames']);
$page = setParsFromPage ( $GLOBALS['sensor_port'], 0, $groupMask, false ); // /only init parameters? $page = setParsFromPage ( $GLOBALS['sensor_port'], 0, $groupMask, false ); // /only init parameters?
exit ( 0 ); exit ( 0 );
} }
...@@ -344,22 +324,25 @@ if ($sensor_board ['ctype'] == 'NONE') { ...@@ -344,22 +324,25 @@ if ($sensor_board ['ctype'] == 'NONE') {
$init = false; $init = false;
$daemon = false; $daemon = false;
$initPage = $GLOBALS['useDefaultPageNumber']; $initPage = $GLOBALS['useDefaultPageNumber'];
if ((array_key_exists ( 'new', $_GET )) || (array_key_exists ( '--new', $_SERVER ['argv'] ))) { //echo "=== Checking for 'new' or '--new', _SERVER ['argv']=".print_r( $_SERVER ['argv'],1).', $_GET='.print_r($_GET,1)."\n";
if (file_exists ( $configPath )) { if ((array_key_exists ( 'new', $_GET )) || (in_array ( '--new', $_SERVER ['argv'] ))) {
rotateConfig ( $numBackups ); // log_msg("rotating, _SERVER ['argv']=".print_r( $_SERVER ['argv'],1));
foreach ( $GLOBALS ['ports'] as $port ) {
log_msg ("Rotating configs for port $port");
if (file_exists ($GLOBALS['configPaths'][$port])) {
rotateConfig ($port, $GLOBALS['numBackups'] );
}
} }
} }
// $needDetection=true; /// we need sensor detection to be started before we can read 10359 eeprom and so select default parameters
echo "get_eyesis_mode()->".get_eyesis_mode()."\n"; log_msg("get_eyesis_mode()->".get_eyesis_mode());
echo "get_mt9p006_mode()->".get_mt9p006_mode()."\n"; log_msg("get_mt9p006_mode()->".get_mt9p006_mode());
if (get_eyesis_mode()!=0){ if (get_eyesis_mode()!=0){
echo "+++ eyesis\n"; log_msg("+++ eyesis");
process_eyesis(); process_eyesis();
} else if (get_mt9p006_mode ()!=0){ } else if (get_mt9p006_mode ()!=0){
echo "+++ mt9p006\n"; log_msg("+++ mt9p006");
process_mt9p006(); process_mt9p006();
} }
// Todo: Add a single camera with 10359? // Todo: Add a single camera with 10359?
...@@ -385,33 +368,36 @@ if ($needDetection) { // sensor number is 0 ...@@ -385,33 +368,36 @@ if ($needDetection) { // sensor number is 0
if ($multisensor) if ($multisensor)
$eyesis_mode = get_application_mode (); // / will create /var/volatile/state/ * $eyesis_mode = get_application_mode (); // / will create /var/volatile/state/ *
} }
for($port = 0; $port < 4; $port ++) { foreach ( $GLOBALS ['ports'] as $port ) {
if ($GLOBALS ['sensors'] [$port] [0] == 'mt9p006') { if (! file_exists ( $GLOBALS ['configPaths'] [$port] )) {
if (! file_exists ($GLOBALS['configPaths'][$port])) { $confFile = fopen ( $GLOBALS ['configPaths'] [$port], "w+" );
$confFile = fopen ( $GLOBALS['configPaths'][$port], "w+" ); fwrite ( $confFile, createDefaultConfig ( $GLOBALS['version'], $multisensor, $eyesis_mode ) ); // use multisensor defaults if 10359 +sensors present
fwrite ( $confFile, createDefaultConfig ( $version, $multisensor, $eyesis_mode ) ); // use multisensor defaults if 10359 +sensors present
fclose ( $confFile ); fclose ( $confFile );
log_msg ( "autocampars.php created a new configuration file $configPath from defaults." . ($multisensor ? (($eyesis_mode > 0) ? (' Used Eyesis mode, camera ' . $eyesis_mode) : ' Used multisensor mode.') : '') ); log_msg ( "autocampars.php created a new configuration file $configPath from defaults." . ($multisensor ? (($eyesis_mode > 0) ? (' Used Eyesis mode, camera ' . $eyesis_mode) : ' Used multisensor mode.') : '') );
exec ( 'sync' ); exec ( 'sync' );
} }
$GLOBALS['configs'][$port] = parseConfig ( $GLOBALS['configPaths'][$port] ); $GLOBALS ['configs'] [$port] = parseConfig($GLOBALS ['configPaths'] [$port] );
log_msg ( "autocampars.php parsed configuration file {$GLOBALS ['configPaths'] [$port]}.");
}
} }
log_msg ( "Configuration data: ".print_r($GLOBALS ['configs'],1));
//print_r($GLOBALS['configs'][0]); // just first, others are similar //print_r($GLOBALS['configs'][0]); // just first, others are similar
log_close(); //log_close();
exit ( 0 ); //exit ( 0 );
if ($_SERVER ['REQUEST_METHOD'] == "GET") { if ($_SERVER ['REQUEST_METHOD'] == "GET") {
processGet (); processGet ($GLOBALS['sensor_port']);
exit ( 0 ); exit ( 0 );
} else if ($_SERVER ['REQUEST_METHOD'] == "POST") { } else if ($_SERVER ['REQUEST_METHOD'] == "POST") {
processPost (); log_msg ( "Going to processPost ({$GLOBALS['sensor_port']}), config= " . print_r($GLOBALS ['configs'][$GLOBALS['sensor_port']],1) );
processGet ();
processPost ($GLOBALS['sensor_port']);
processGet ($GLOBALS['sensor_port']);
exit ( 0 ); exit ( 0 );
} else { } else {
$old_version = $config ['version']; $old_versions=array();
foreach ( $GLOBALS ['ports'] as $port ) {
$old_versions[]=$GLOBALS['configs'][$port]['version'];
}
foreach ( $_SERVER ['argv'] as $param ) { foreach ( $_SERVER ['argv'] as $param ) {
if (substr ( $param, 0, 6 ) == "--init") { if (substr ( $param, 0, 6 ) == "--init") {
$param = substr ( $param, 7 ); $param = substr ( $param, 7 );
...@@ -425,19 +411,30 @@ if ($_SERVER ['REQUEST_METHOD'] == "GET") { ...@@ -425,19 +411,30 @@ if ($_SERVER ['REQUEST_METHOD'] == "GET") {
} else if (substr ( $param, 0, 14 ) == "--sensor_port=") { // should have port? } else if (substr ( $param, 0, 14 ) == "--sensor_port=") { // should have port?
$GLOBALS['sensor_port']=intval(substr ( $param, 14, 1 )); $GLOBALS['sensor_port']=intval(substr ( $param, 14, 1 ));
} else if ($param == '--ignore-revision') { } else if ($param == '--ignore-revision') {
$config ['version'] = $version; //get_port_index($port)
saveRotateConfig ( $numBackups ); foreach ( $GLOBALS ['ports'] as $port ) {
$GLOBALS['configs'][$port]['version'] = $GLOBALS['version'];
log_msg("processPost($port) --ignore_revision");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
}
} }
} }
if (! $daemon && ! $init) { if (! $daemon && ! $init) {
$configs = print_r($GLOBALS ['configPaths'],1);
echo <<<USAGE echo <<<USAGE
Usage: {$_SERVER['argv'][0]} --init[=page_number] Usage: {$_SERVER['argv'][0]} --init[=page_number]
Initialise parameters using the saved ones in $configPath, page number 0<='page_number'<15) Initialise parameters using the saved ones in per-sensor port config files,
page number 0<='page_number'<15)
If page number is not specified the current default one will be used. If page number is not specified the current default one will be used.
Other functionality (parameters save/restore is provided when this script is called from the daemon, Other functionality (parameters save/restore is provided when this script is called from the daemon,
in that case command is read from the AUTOCAMPARS_* parameter in that case command is read from the AUTOCAMPARS_* parameter.
Configuration files are here:
$configs
USAGE; USAGE;
log_close(); log_close();
...@@ -445,18 +442,19 @@ USAGE; ...@@ -445,18 +442,19 @@ USAGE;
} }
} }
log_close(); //log_close();
exit(0); // for now //exit(0); // for now
if ($version != $old_version) { // issue warning if mismatch, but may continue foreach ( $GLOBALS ['ports'] as $port ) {
$old_version = $old_versions[get_port_index($port)];
if ($GLOBALS['version'] != $old_version) { // issue warning if mismatch, but may continue
$warn = <<<WARN $warn = <<<WARN
Warning! Version numbers of this script and the config file mismatch: Warning! Version numbers of this script and the config file for port $port mismatch:
Script ({$_SERVER['argv'][0]}): $version. Script ({$_SERVER['argv'][0]}):{$GLOBALS['version']}.
Config file ($configPath): {$old_version} Config file ({$GLOBALS ['configPaths'][$port]}): {$old_version}
This may (or may not) cause errors. You have several options: This may (or may not) cause errors. You have several options:
1 - re-run this script with '--ignore-revision' - the file will have 1 - re-run this script with '--ignore-revision' - the file will have
new revision number written new revision number written
...@@ -467,38 +465,47 @@ http://192.168.0.9/autocampars.php?new ...@@ -467,38 +465,47 @@ http://192.168.0.9/autocampars.php?new
WARN; WARN;
echo $warn; echo $warn;
log_msg($warn);
fwrite ( $GLOBALS['logFile'], $warn ); fwrite ( $GLOBALS['logFile'], $warn );
// echo "version=$version\n"; if ($GLOBALS['version'] != $GLOBALS['configs'][$port]['version']){
// echo "old_version=$old_version\n"; log_close();
// echo "config['version']=".$config['version']."\n";
if ($version != $config ['version'])
exit ( 1 ); // / abort exit ( 1 ); // / abort
}
}
} }
if ($init) { if ($init) {
$page = processInit ( $initPage, $needDetection ); $page = processInit ( $initPage, $needDetection );
if ($page < 0) { if ($page < 0) {
echo "Sensor failed to initialize, see $logFilePath for detailes\n"; log_msg ("Sensor failed to initialize, see $logFilePath for detailes");
exit ( 1 ); exit ( 1 );
} else { } else {
echo "Sensor was successfully initialized at " . date ( "F j, Y, g:i a" ) . " from $configPath page $page\n"; $port_list_string= implode(", ",$GLOBALS ['ports'] );
$page_list_string= implode(", ",$page);
log_msg ("Sensors on ports: $port_list_string were successfully initialized at " . date ( "F j, Y, g:i a" ) . " from configuration files pages $page_list_string");
// / Currently - only for eyesis // / Currently - only for eyesis
sync2master (); /// sync2master ();
} }
// echo "*version=$version\n"; // echo "*version=$version\n";
// echo "*old_version=$old_version\n"; if ($GLOBALS['version'] != $GLOBALS['configs'][$port]['version'])
// echo "*config['version']=".$config['version']."\n"; close_log();
if ($version != $old_version)
exit ( 1 ); exit ( 1 );
exit ( 0 ); exit ( 0 );
} }
if ($daemon) { if ($daemon) {
processDaemon (); processDaemon ($GLOBALS['sensor_port']);
exit ( 0 ); exit ( 0 );
} }
log_close();
exit ( 0 ); exit ( 0 );
// ============ Functions ============= // ============ Functions =============
function get_port_index($port){
for ($i = 0; $i < count($GLOBALS ['ports']); $i++) if ( $GLOBALS ['ports'][$i] == $port ) return $i;
return -1;
}
function process_eyesis(){ function process_eyesis(){
echo "process_eyesis()"; echo "process_eyesis()";
...@@ -510,11 +517,10 @@ function process_mt9p006(){ ...@@ -510,11 +517,10 @@ function process_mt9p006(){
$GLOBALS['camera_state_arr']['max_latency'] = 5; // frames to manually advance $GLOBALS['camera_state_arr']['max_latency'] = 5; // frames to manually advance
write_php_ini ($GLOBALS['camera_state_arr'], $GLOBALS['camera_state_path'] ); write_php_ini ($GLOBALS['camera_state_arr'], $GLOBALS['camera_state_path'] );
$sensor_code = 52; $sensor_code = 52;
echo "process_mt9p006()"; print_r($GLOBALS['sensors']); log_msg("process_mt9p006()".print_r($GLOBALS['sensors'],1));
$GLOBALS ['ports'] = array(); // list of enabled ports $GLOBALS ['ports'] = array(); // list of enabled ports
for ($port=0; $port < 4; $port++) if ($GLOBALS['sensors'][$port][0] == 'mt9p006') $GLOBALS ['ports'][] = $port; for ($port=0; $port < 4; $port++) if ($GLOBALS['sensors'][$port][0] == 'mt9p006') $GLOBALS ['ports'][] = $port;
echo "ports:"; print_r($GLOBALS['ports']); log_msg("ports:".print_r($GLOBALS['ports'],1));
switch ($GLOBALS['camera_state']){ switch ($GLOBALS['camera_state']){
/* /*
...@@ -539,7 +545,7 @@ function process_mt9p006(){ ...@@ -539,7 +545,7 @@ function process_mt9p006(){
*/ */
// single command (power+post_power) // single command (power+post_power)
case "BOOT": case "BOOT":
echo "boot\n"; log_msg("boot");
// correct sysfs sensor data // correct sysfs sensor data
$sensor_mask = get_mt9p006_mode (); $sensor_mask = get_mt9p006_mode ();
$needupdate=0; $needupdate=0;
...@@ -615,6 +621,7 @@ function process_mt9p006(){ ...@@ -615,6 +621,7 @@ function process_mt9p006(){
$f = fopen ( $GLOBALS['sysfs_i2c_seq'].$port, 'w' ); fwrite($f,'3',1); fclose ( $f ); // reset+run (copy frame number from frame_seq) $f = fopen ( $GLOBALS['sysfs_i2c_seq'].$port, 'w' ); fwrite($f,'3',1); fclose ( $f ); // reset+run (copy frame number from frame_seq)
// if ($GLOBALS['sensors'][$port][0] != 'mt9p006') { // if ($GLOBALS['sensors'][$port][0] != 'mt9p006') {
if (!in_array($port, $GLOBALS['ports'])) { if (!in_array($port, $GLOBALS['ports'])) {
log_msg("Disabling sensor port ".$port);
$f = fopen ( $GLOBALS['sysfs_chn_en'].$port, 'w' ); fwrite($f,'0',1); fclose ( $f ); // disable sensor channel $f = fopen ( $GLOBALS['sysfs_chn_en'].$port, 'w' ); fwrite($f,'0',1); fclose ( $f ); // disable sensor channel
} }
} }
...@@ -632,9 +639,9 @@ function process_mt9p006(){ ...@@ -632,9 +639,9 @@ function process_mt9p006(){
// + Or just apply all parameters through the sequencer and apply certain number of pulses? // + Or just apply all parameters through the sequencer and apply certain number of pulses?
break; break;
default: default:
echo "camera_state=".$GLOBALS['camera_state']; log_msg("camera_state=".$GLOBALS['camera_state']);
} }
echo "ports:"; print_r($GLOBALS['ports']); log_msg("ports:". print_r($GLOBALS['ports'],1));
} }
...@@ -684,7 +691,7 @@ function log_open(){ ...@@ -684,7 +691,7 @@ function log_open(){
$GLOBALS['logFile'] = fopen ( $GLOBALS['logFilePath'], "a" ); $GLOBALS['logFile'] = fopen ( $GLOBALS['logFilePath'], "a" );
} }
function log_msg($msg) { function log_msg($msg) {
echo $msg."\n"; if (!array_key_exists('REQUEST_METHOD',$_SERVER)) echo $msg."\n";
fwrite ( $GLOBALS['logFile'], $msg . " at " . date ( "F j, Y, G:i:s" ) . "\n" ); fwrite ( $GLOBALS['logFile'], $msg . " at " . date ( "F j, Y, G:i:s" ) . "\n" );
} }
...@@ -825,7 +832,7 @@ function get_application_mode() { ...@@ -825,7 +832,7 @@ function get_application_mode() {
} }
write_php_ini ($GLOBALS['camera_state_arr'], $GLOBALS['camera_state_path'] ); write_php_ini ($GLOBALS['camera_state_arr'], $GLOBALS['camera_state_path'] );
} else { } else {
echo "Parsing existing ini file...\n"; log_msg("Parsing existing ini file...");
$GLOBALS['camera_state_arr'] = parse_ini_file ( $GLOBALS['camera_state_path'] ); $GLOBALS['camera_state_arr'] = parse_ini_file ( $GLOBALS['camera_state_path'] );
} }
return $GLOBALS['camera_state_arr']; return $GLOBALS['camera_state_arr'];
...@@ -850,21 +857,6 @@ function get_eyesis_mode() { ...@@ -850,21 +857,6 @@ function get_eyesis_mode() {
return 0; return 0;
} }
/*
if (!file_exists ( $camera_state_path )) {
$camera_state_array = array (
"state" => "BOOT"
);
write_php_ini ( $camera_state_array, $camera_state_path );
}
$GLOBALS['camera_state'] = parse_ini_file ( $camera_state_path ) ['state'];
if (! in_array ( $camera_state, $STATES )) {
log_error ( "Invalid camera state:" . $camera_state . ", valid states are:\n" . print_r ( $STATES, 1 ));
}
*/
function detectSensor() { function detectSensor() {
global $logFile, $framepars_path; global $logFile, $framepars_path;
...@@ -897,10 +889,8 @@ function detectSensor() { ...@@ -897,10 +889,8 @@ function detectSensor() {
return true; // / Sensor started OK return true; // / Sensor started OK
} }
/** Appllies to all sesnors */ /** Appllies to all sensors */
function processInit($initPage, $needDetection = true) { function processInit($initPage, $needDetection = true) {
global $config;
$waitDaemons = 5.0; // / Wait for daemons to stop (when disabled) before resetting frame number. $waitDaemons = 5.0; // / Wait for daemons to stop (when disabled) before resetting frame number.
// / They should look at thei enable bit periodically and restart if the frame is // / They should look at thei enable bit periodically and restart if the frame is
// / the frame is not what they were expecting to be // / the frame is not what they were expecting to be
...@@ -936,9 +926,8 @@ function processInit($initPage, $needDetection = true) { ...@@ -936,9 +926,8 @@ function processInit($initPage, $needDetection = true) {
* frame 11 (0xb) - normal total_pixels=0x4c920 * frame 11 (0xb) - normal total_pixels=0x4c920
*/ */
} }
function processDaemon() { function processDaemon($port) {
global $config, $numBackups; //TODO: Make sure $port >=0
$AUTOCAMPARS = elphel_get_P_arr ( $GLOBALS ['sensor_port'], array ( $AUTOCAMPARS = elphel_get_P_arr ( $GLOBALS ['sensor_port'], array (
"AUTOCAMPARS_CMD" => null, "AUTOCAMPARS_CMD" => null,
"AUTOCAMPARS_GROUPS" => null, "AUTOCAMPARS_GROUPS" => null,
...@@ -950,39 +939,49 @@ function processDaemon() { ...@@ -950,39 +939,49 @@ function processDaemon() {
$groupMask = myval ( $AUTOCAMPARS ['AUTOCAMPARS_GROUPS'] ); $groupMask = myval ( $AUTOCAMPARS ['AUTOCAMPARS_GROUPS'] );
switch (( integer ) $AUTOCAMPARS ['AUTOCAMPARS_CMD']) { switch (( integer ) $AUTOCAMPARS ['AUTOCAMPARS_CMD']) {
case ELPHEL_CONST_AUTOCAMPARS_CMD_RESTORE : case ELPHEL_CONST_AUTOCAMPARS_CMD_RESTORE :
$page = setParsFromPage ( $page, $groupMask ); $page = setParsFromPage ($port, $page, $groupMask );
// echo "ELPHEL_CONST_AUTOCAMPARS_CMD_RESTORE\n"; // echo "ELPHEL_CONST_AUTOCAMPARS_CMD_RESTORE\n";
break; break;
case ELPHEL_CONST_AUTOCAMPARS_CMD_SAVE : case ELPHEL_CONST_AUTOCAMPARS_CMD_SAVE :
// echo "ELPHEL_CONST_AUTOCAMPARS_CMD_SAVE\n"; // echo "ELPHEL_CONST_AUTOCAMPARS_CMD_SAVE\n";
$page = readParsToPage ( $page ); $page = readParsToPage ($port, $page );
saveRotateConfig ( $numBackups ); log_msg("processDaemon($port) daemon: ELPHEL_CONST_AUTOCAMPARS_CMD_SAVE");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
break; break;
case ELPHEL_CONST_AUTOCAMPARS_CMD_DFLT : case ELPHEL_CONST_AUTOCAMPARS_CMD_DFLT :
// echo "ELPHEL_CONST_AUTOCAMPARS_CMD_DFLT\n"; // echo "ELPHEL_CONST_AUTOCAMPARS_CMD_DFLT\n";
if (($page >= 0) && ($page < $GLOBALS['useDefaultPageNumber']) && ($page != $GLOBALS['useDefaultPageNumber'])) { if (($page >= 0) && ($page < $GLOBALS['useDefaultPageNumber']) && ($page != $GLOBALS['useDefaultPageNumber'])) {
$config ['defaultPage'] = $page; $GLOBALS['configs'][$port]['defaultPage'] = $page;
saveRotateConfig ( $numBackups ); log_msg("processDaemon($port) daemon: ELPHEL_CONST_AUTOCAMPARS_CMD_DFLT");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
} }
break; break;
case ELPHEL_CONST_AUTOCAMPARS_CMD_SAVEDFLT : case ELPHEL_CONST_AUTOCAMPARS_CMD_SAVEDFLT :
// echo "ELPHEL_CONST_AUTOCAMPARS_CMD_SAVEDFLT\n"; // echo "ELPHEL_CONST_AUTOCAMPARS_CMD_SAVEDFLT\n";
$page = readParsToPage ( $page ); $page = readParsToPage ($port, $page );
$config ['defaultPage'] = $page; $GLOBALS['configs'][$port] ['defaultPage'] = $page;
saveRotateConfig ( $numBackups ); log_msg("processDaemon($port) daemon: ELPHEL_CONST_AUTOCAMPARS_CMD_SAVEDFLT");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
break; break;
/*
* Disabled in NC393, as init is about all ports and daemon - single camera port
case ELPHEL_CONST_AUTOCAMPARS_CMD_INIT : case ELPHEL_CONST_AUTOCAMPARS_CMD_INIT :
// echo "ELPHEL_CONST_AUTOCAMPARS_CMD_INIT\n"; // echo "ELPHEL_CONST_AUTOCAMPARS_CMD_INIT\n";
$pages = processInit ( $page, true ); // needs sensor reset/detection $pages = processInit ( $page, true ); // needs sensor reset/detection
// /NOTE: If $page<0 here - sensor failed to initialize, if this script was called from the daemon - it will never restart on it's own. Log record is made // /NOTE: If $page<0 here - sensor failed to initialize, if this script was called from the daemon - it will never restart on it's own. Log record is made
break; break;
*/
default : default :
echo $_SERVER ['argv'] [0] . ": Unknown command=" . $AUTOCAMPARS ['AUTOCAMPARS_CMD']; echo $_SERVER ['argv'] [0] . ": Unknown command=" . $AUTOCAMPARS ['AUTOCAMPARS_CMD'];
} }
// print_r($config); // print_r($config);
} }
function processPost() { function processPost($port) {
global $config; log_msg("processPost($port)");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
// /Updating comments? // /Updating comments?
$needle = "update_comment_"; $needle = "update_comment_";
foreach ( $_POST as $key => $value ) foreach ( $_POST as $key => $value )
...@@ -990,25 +989,32 @@ function processPost() { ...@@ -990,25 +989,32 @@ function processPost() {
$page = substr ( $key, strlen ( $needle ) ); $page = substr ( $key, strlen ( $needle ) );
$comment = $_POST ['comment_' . $page]; $comment = $_POST ['comment_' . $page];
// echo "updating comment for page $page, it will be $comment\n"; // echo "updating comment for page $page, it will be $comment\n";
$config ['paramSets'] [$page] ['comment'] = $comment; $GLOBALS['configs'][$port]['paramSets'] [$page] ['comment'] = $comment;
saveRotateConfig ( $numBackups ); log_msg("processPost($port) - updating comment");
processGet (); log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
processGet ($port);
exit ( 0 ); exit ( 0 );
} }
if (array_key_exists ( 'update_default', $_POST )) { if (array_key_exists ( 'update_default', $_POST )) {
$config ['defaultPage'] = $_POST ['default_page']; $GLOBALS['configs'] ['defaultPage'] = $_POST ['default_page'];
saveRotateConfig ( $numBackups ); log_msg("processPost($port) - updating default");
processGet (); log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
processGet ($port);
exit ( 0 ); exit ( 0 );
} }
$needle = "save_"; $needle = "save_";
foreach ( $_POST as $key => $value ) foreach ( $_POST as $key => $value )
if (substr ( $key, 0, strlen ( $needle ) ) == $needle) { if (substr ( $key, 0, strlen ( $needle ) ) == $needle) {
$page = substr ( $key, strlen ( $needle ) ); $page = substr ( $key, strlen ( $needle ) );
$page = readParsToPage ( $page ); $page = readParsToPage ($port, $page );
$config ['defaultPage'] = $page; $GLOBALS['configs'] ['defaultPage'] = $page;
saveRotateConfig ( $numBackups ); log_msg("processPost($port) - save_");
processGet (); log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
processGet ($port);
exit ( 0 ); exit ( 0 );
} }
$needle = "restore_"; $needle = "restore_";
...@@ -1021,8 +1027,8 @@ function processPost() { ...@@ -1021,8 +1027,8 @@ function processPost() {
if (substr ( $key, 0, strlen ( $needle ) ) == $needle) { if (substr ( $key, 0, strlen ( $needle ) ) == $needle) {
$groupMask |= (1 << (( integer ) substr ( $key, strlen ( $needle ) ))); $groupMask |= (1 << (( integer ) substr ( $key, strlen ( $needle ) )));
} }
$page = setParsFromPage ( $page, $groupMask ); $page = setParsFromPage ($port, $page, $groupMask );
processGet (); processGet ($port);
exit ( 0 ); exit ( 0 );
} }
...@@ -1032,25 +1038,36 @@ function processPost() { ...@@ -1032,25 +1038,36 @@ function processPost() {
exit ( 0 ); exit ( 0 );
} }
// /TODO: Make the contol page aware of stuck sensor (sleep 1, then 5)? and suggest init if frame is not changing // /TODO: Make the contol page aware of stuck sensor (sleep 1, then 5)? and suggest init if frame is not changing
function processGet() { function processGet($port) {
global $config, $twoColumns, $configPath, $version, $sensor_port; /** NOT YET PORTED */
// if ($GLOBALS['sensor_port']<0){
if ($port<0){
$warn = <<<WARN_PORT
<center><h4>Sensor port (sensor_port) is not specified</h4></center>
<p>Only one sensor port parameters can be edited currently. You may add
'sensor_port=value' to the request URL to fix thgis problem.</p>
WARN_PORT;
echo $warn;
endPage ();
exit ( 1 );
}
// New in NC393 - get sensor port from URL - moved to startup of the script // New in NC393 - get sensor port from URL - moved to startup of the script
// if (array_key_exists('sensor_port',$_GET)) {
// $sensor_port = (int) $_GET['sensor_port'];
// } // }
if (array_key_exists ( 'ignore-revision', $_GET ) && ($version != $config ['version'])) { if (array_key_exists ( 'ignore-revision', $_GET ) && ($GLOBALS['version'] != $GLOBALS['configs'][$port] ['version'])) {
$config ['version'] = $version; $GLOBALS['configs'][$port]['version'] = $GLOBALS['version'];
saveRotateConfig ( $numBackups ); log_msg("processGet($port) - processGet ignore-revision");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
saveRotateConfig ($port, $GLOBALS['numBackups'] );
} }
if ($version != $config ['version']) { if ($GLOBALS['version'] != $GLOBALS['configs'][$port]['version']) {
startPage ( "Warning: version numbers mismatch", "function updateLink(){}" ); startPage ( "Warning: version numbers mismatch", "function updateLink(){}" );
$warn = <<<WARN $warn = <<<WARN
<center><h4>Warning! Version numbers of this script and the config file mismatch:</h4></center> <center><h4>Warning! Version numbers of this script and the config file mismatch:</h4></center>
Script: <b>$version</b>.<br/> Script: <b>{$GLOBALS['version']}</b>.<br/>
Config file ($configPath): <b>{$config['version']}</b><br/> Config file ({$GLOBALS['configPaths'][$port]}): <b>{$GLOBALS['configs'][$port]['version']}</b><br/>
<ol>This may (or may not) cause errors. You have several options: <ol>This may (or may not) cause errors. You have several options:
<li> Follow <a href="?new">this link </a> and create a new config file </li> <li> Follow <a href="?new&sensor_port={$port}">this link </a> and create a new config file </li>
<li> Follow <a href="?ignore-revision">this other link </a> to ignore the warning and write a new revision number to the config file</li> <li> Follow <a href="?ignore-revision&sensor_port={$port}">this other link </a> to ignore the warning and write a new revision number to the config file</li>
<li> First update the version number with the link above, then manually edit/merge old and new data</li> <li> First update the version number with the link above, then manually edit/merge old and new data</li>
</ol> </ol>
WARN; WARN;
...@@ -1059,17 +1076,17 @@ WARN; ...@@ -1059,17 +1076,17 @@ WARN;
exit ( 1 ); exit ( 1 );
} }
$page_title = "Model 393 Camera Parameters save/restore"; $page_title = "Model 393 Camera Parameters save/restore, sensor port {$port}";
startPage ( $page_title, mainJavascript () ); startPage ( $page_title, mainJavascript ($port) );
if ($twoColumns) if ($GLOBALS['twoColumns'])
printf ( "<table><tr><td style='vertical-align: top'>\n" ); printf ( "<table><tr><td style='vertical-align: top'>\n" );
writeGroupsTable (); writeGroupsTable ($port);
if ($twoColumns) if ($GLOBALS['twoColumns'])
printf ( "</td><td>\n" ); printf ( "</td><td>\n" );
else else
printf ( "<br/>\n" ); printf ( "<br/>\n" );
writePagesTable (); writePagesTable ($port);
if ($twoColumns) if ($GLOBALS['twoColumns'])
printf ( "</td></tr></table>\n" ); printf ( "</td></tr></table>\n" );
endPage (); endPage ();
} }
...@@ -1103,18 +1120,17 @@ HEAD; ...@@ -1103,18 +1120,17 @@ HEAD;
function endPage() { function endPage() {
echo "\n</form></body></html>\n"; echo "\n</form></body></html>\n";
} }
function writeGroupsTable() { function writeGroupsTable($sensor_port) {
global $config;
printf ( "<table border='1' style='font-family: Courier, monospace;'>\n" ); printf ( "<table border='1' style='font-family: Courier, monospace;'>\n" );
printf ( "<tr>" ); printf ( "<tr>" );
printf ( "<td><input type='button' value='&nbsp;Select&nbsp;\nAll' onclick='checkAll()' title='Select all parameter groups'/></td>\n" ); printf ( "<td><input type='button' value='&nbsp;Select&nbsp;\nAll' onclick='checkAll()' title='Select all parameter groups'/></td>\n" );
printf ( "<td style='text-align:center'>Bit</td><td style='text-align:center'>Name</td><td style='text-align:center'>Description</td></tr>\n" ); printf ( "<td style='text-align:center'>Bit</td><td style='text-align:center'>Name</td><td style='text-align:center'>Description</td></tr>\n" );
foreach ( $config ['groupBits'] as $name => $bit ) { foreach ( $GLOBALS['configs'][$sensor_port]['groupBits'] as $name => $bit ) {
printf ( "<tr>" ); printf ( "<tr>" );
printf ( "<td style='text-align:center'><input type='checkbox' name='group_%d' value='1' id='id_group_%d' onclick='updateLink();'/></td>", $bit, $bit ); printf ( "<td style='text-align:center'><input type='checkbox' name='group_%d' value='1' id='id_group_%d' onclick='updateLink();'/></td>", $bit, $bit );
printf ( "<td style='text-align:right' >%d</td>", $bit ); printf ( "<td style='text-align:right' >%d</td>", $bit );
printf ( "<td style='text-align:left' >%s</td>", $name ); printf ( "<td style='text-align:left' >%s</td>", $name );
printf ( "<td style='text-align:left' >%s</td>", $config ['groupDescriptions'] [$bit] ); printf ( "<td style='text-align:left' >%s</td>", $GLOBALS['configs'][$sensor_port]['groupDescriptions'] [$bit] );
printf ( "</tr>\n" ); printf ( "</tr>\n" );
} }
printf ( "<tr>" ); printf ( "<tr>" );
...@@ -1123,8 +1139,7 @@ function writeGroupsTable() { ...@@ -1123,8 +1139,7 @@ function writeGroupsTable() {
printf ( "<label style='border: 0px solid #000;' for='id_embed_image' title='Include image with the parameter edit window'>&nbsp;&nbsp;<input type='checkbox' name='embed' value='1' id='id_embed_image' onclick='updateLink();' checked/>Include image</label></td></tr>\n" ); printf ( "<label style='border: 0px solid #000;' for='id_embed_image' title='Include image with the parameter edit window'>&nbsp;&nbsp;<input type='checkbox' name='embed' value='1' id='id_embed_image' onclick='updateLink();' checked/>Include image</label></td></tr>\n" );
printf ( "</table>\n" ); printf ( "</table>\n" );
} }
function writePagesTable() { function writePagesTable($sensor_port) {
global $config;
printf ( "<table border='1' style='font-family: Courier, monospace;'>\n" ); printf ( "<table border='1' style='font-family: Courier, monospace;'>\n" );
printf ( "<tr>" ); printf ( "<tr>" );
printf ( "<td style='text-align:center'>Page</td>" ); printf ( "<td style='text-align:center'>Page</td>" );
...@@ -1140,24 +1155,24 @@ function writePagesTable() { ...@@ -1140,24 +1155,24 @@ function writePagesTable() {
printf ( "<tr>" ); printf ( "<tr>" );
printf ( "<td style='text-align:right'>%d</td>", $i ); printf ( "<td style='text-align:right'>%d</td>", $i );
if (array_key_exists ( $i, $config ['paramSets'] )) { if (array_key_exists ( $i, $GLOBALS['configs'][$sensor_port]['paramSets'] )) {
printf ( "<td style='text-align:center'><input type='radio' name='default_page' value='%d' id='id_default_page_%d' %s" . " title='Select config file page %d as default (boot up) page' /></td>", $i, $i, ($i == $config ['defaultPage']) ? "checked" : "", $i ); printf ( "<td style='text-align:center'><input type='radio' name='default_page' value='%d' id='id_default_page_%d' %s" . " title='Select config file page %d as default (boot up) page' /></td>", $i, $i, ($i == $GLOBALS['configs'][$sensor_port]['defaultPage']) ? "checked" : "", $i );
} else { } else {
printf ( "<td>&nbsp;</td>" ); printf ( "<td>&nbsp;</td>" );
} }
if ($i == $GLOBALS['protectedPage']) { if ($i == $GLOBALS['protectedPage']) {
printf ( "<td>&nbsp;</td>" ); printf ( "<td>&nbsp;</td>" );
} else { } else {
printf ( "<td style='text-align:center'><input type='submit' name='save_%d' value='%s' id='id_save_page_%d' title='Save current parameters to the config file as page %d'/></td>", $i, array_key_exists ( $i, $config ['paramSets'] ) ? "Overwrite" : "Save", $i, $i ); printf ( "<td style='text-align:center'><input type='submit' name='save_%d' value='%s' id='id_save_page_%d' title='Save current parameters to the config file as page %d'/></td>", $i, array_key_exists ( $i, $GLOBALS['configs'][$sensor_port]['paramSets'] ) ? "Overwrite" : "Save", $i, $i );
} }
if (array_key_exists ( $i, $config ['paramSets'] )) { if (array_key_exists ( $i, $GLOBALS['configs'][$sensor_port]['paramSets'] )) {
printf ( "<td style='text-align:center'><input type='submit' name='restore_%d' value='Restore' id='id_restore_page_%d' title='Restore parameters from the config file page %d'/></td>", $i, $i, $i ); printf ( "<td style='text-align:center'><input type='submit' name='restore_%d' value='Restore' id='id_restore_page_%d' title='Restore parameters from the config file page %d'/></td>", $i, $i, $i );
printf ( "<td style='text-align:left'>%s</td>", $config ['paramSets'] [$i] ['timestamp'] ? date ( "F j, Y, g:i a", $config ['paramSets'] [$i] ['timestamp'] ) : "&nbsp;" ); printf ( "<td style='text-align:left'>%s</td>", $GLOBALS['configs'][$sensor_port]['paramSets'] [$i] ['timestamp'] ? date ( "F j, Y, g:i a", $GLOBALS['configs'][$sensor_port]['paramSets'] [$i] ['timestamp'] ) : "&nbsp;" );
printf ( "<td>" ); printf ( "<td>" );
if ($i == $GLOBALS['protectedPage']) if ($i == $GLOBALS['protectedPage'])
printf ( "%s&nbsp;", $config ['paramSets'] [$i] ['comment'] ); printf ( "%s&nbsp;", $GLOBALS['configs'][$sensor_port]['paramSets'] [$i] ['comment'] );
else { else {
printf ( "<input type='text' name='comment_%d' size='40' value='%s' id='id_comment_%d' style='text-align:left'/>", $i, $config ['paramSets'] [$i] ['comment'], $i ); printf ( "<input type='text' name='comment_%d' size='40' value='%s' id='id_comment_%d' style='text-align:left'/>", $i, $GLOBALS['configs'][$sensor_port]['paramSets'] [$i] ['comment'], $i );
printf ( "<input type='submit' name='update_comment_%d' value='Update' id='id_update_comment_%d' title='Update comment in the config file'/>", $i, $i ); printf ( "<input type='submit' name='update_comment_%d' value='Update' id='id_update_comment_%d' title='Update comment in the config file'/>", $i, $i );
} }
...@@ -1169,19 +1184,18 @@ function writePagesTable() { ...@@ -1169,19 +1184,18 @@ function writePagesTable() {
} }
printf ( "</table>\n" ); printf ( "</table>\n" );
} }
function mainJavascript() { function mainJavascript($sensor_port) {
global $config, $parseditPath, $embedImageScale;
$checkboxNumbers = ""; $checkboxNumbers = "";
foreach ( $config ['groupBits'] as $name => $bit ) { foreach ( $GLOBALS['configs'][$sensor_port]['groupBits'] as $name => $bit ) {
$checkboxNumbers .= $bit . ","; $checkboxNumbers .= $bit . ",";
} }
$checkboxNumbers = rtrim ( $checkboxNumbers, "," ); $checkboxNumbers = rtrim ( $checkboxNumbers, "," );
$groupNames = ""; $groupNames = "";
for($i = 0; $i < 32; $i ++) for($i = 0; $i < 32; $i ++)
$groupNames .= '"' . $config ['groupNames'] [$i] . '",'; $groupNames .= '"' . $GLOBALS['configs'][$sensor_port]['groupNames'] [$i] . '",';
$groupNames = rtrim ( $groupNames, "," ); $groupNames = rtrim ( $groupNames, "," );
$groupList = "{"; $groupList = "{";
foreach ( $config ['groups'] as $name => $value ) { foreach ( $GLOBALS['configs'][$sensor_port]['groups'] as $name => $value ) {
if (($name != 'comment') && ($name != 'timestamp')) // / Fixing bug for the group "init" if (($name != 'comment') && ($name != 'timestamp')) // / Fixing bug for the group "init"
$groupList .= $name . ":" . $value . ","; $groupList .= $name . ":" . $value . ",";
} }
...@@ -1225,8 +1239,8 @@ function updateLink() { ...@@ -1225,8 +1239,8 @@ function updateLink() {
if (groups[i] & mask) selectedPars[selectedPars.length]=i; if (groups[i] & mask) selectedPars[selectedPars.length]=i;
} }
// alert (selectedPars.toString()); // alert (selectedPars.toString());
document.getElementById('id_editLink').href="$parseditPath?"+ document.getElementById('id_editLink').href="{$GLOBALS['parseditPath']}?sensor_port={$sensor_port}&"+
((document.getElementById('id_embed_image').checked)?"embed=$embedImageScale&":"")+ ((document.getElementById('id_embed_image').checked)?"embed={$GLOBALS['embedImageScale']}&":"")+
"title=Parameters+for+groups:+"+selectedGroups; "title=Parameters+for+groups:+"+selectedGroups;
for (i in selectedPars) { for (i in selectedPars) {
document.getElementById('id_editLink').href+="&"+selectedPars[i]; document.getElementById('id_editLink').href+="&"+selectedPars[i];
...@@ -1266,7 +1280,7 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) { ...@@ -1266,7 +1280,7 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) {
// / AS there is a hardware limit of 64 parameters/frame in the sequencers (64 for the i2c, 64 - for the FPGA registers) // / AS there is a hardware limit of 64 parameters/frame in the sequencers (64 for the i2c, 64 - for the FPGA registers)
// For that it is possible to use ASAP mode - driver will wait for the i2c command to be sent // For that it is possible to use ASAP mode - driver will wait for the i2c command to be sent
log_msg("setParsFromPage($sensor_port, $page, $mask, $initmode)");
if ($initmode) { if ($initmode) {
//$GLOBALS['configs'] //$GLOBALS['configs']
// New way (for nc393) // New way (for nc393)
...@@ -1277,9 +1291,9 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) { ...@@ -1277,9 +1291,9 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) {
$page = $GLOBALS ['configs'] [$port] ['defaultPage']; $page = $GLOBALS ['configs'] [$port] ['defaultPage'];
} }
$parToSet = array (); $parToSet = array ();
foreach ( $config ['groups'] as $par => $parMask ) { foreach ( $GLOBALS ['configs'] [$port] ['groups'] as $par => $parMask ) {
if (($mask & $parMask) && array_key_exists ( $par, $config ['paramSets'] [$page] ) && (! $config ['parTypes'] [$par])) // / not 'text' if (($mask & $parMask) && array_key_exists ( $par, $GLOBALS ['configs'] [$port] ['paramSets'] [$page] ) && (! $GLOBALS ['configs'] [$port] ['parTypes'] [$par])) // / not 'text'
$parToSet [$par] = myval ( $config ['paramSets'] [$page] [$par] ); $parToSet [$par] = myval ( $GLOBALS ['configs'] [$port] ['paramSets'] [$page] [$par] );
} }
// /NOTE: Important ; add gamma tables if parameters modified involve setting/chnaging them // /NOTE: Important ; add gamma tables if parameters modified involve setting/chnaging them
addGammas ( $parToSet ); addGammas ( $parToSet );
...@@ -1288,8 +1302,11 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) { ...@@ -1288,8 +1302,11 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) {
// Separate $delayed_par_names from other values, // Separate $delayed_par_names from other values,
foreach ( $parToSet as $key => $value ) { foreach ( $parToSet as $key => $value ) {
if (in_array ( $key, $delayed_par_names )) { if (in_array ( $key, $delayed_par_names )) {
echo $key." is in ".print_r($delayed_par_names)."\n";
$delayed_params [$key] = $value; $delayed_params [$key] = $value;
unset ( $delayed_params [$key] ); unset ( $parToSet [$key] );
} else{
echo " ".$key." ";
} }
} }
// Similar things for nc353 // Similar things for nc353
...@@ -1346,7 +1363,7 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) { ...@@ -1346,7 +1363,7 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) {
} }
$frame_to_set = elphel_get_frame ( $GLOBALS ['master_port'] ) + ELPHEL_CONST_FRAME_DEAFAULT_AHEAD; $frame_to_set = elphel_get_frame ( $GLOBALS ['master_port'] ) + ELPHEL_CONST_FRAME_DEAFAULT_AHEAD;
// If it was called from already running // If it was called from already running
if (elphel_get_P_value ( $port, COMPRESSOR_RUN ) || elphel_get_P_value ( $port, DAEMON_EN )) { if (elphel_get_P_value ( $port, ELPHEL_COMPRESSOR_RUN ) || elphel_get_P_value ( $port, ELPHEL_DAEMON_EN )) {
// Should we stop sequencers? // Should we stop sequencers?
elphel_set_P_arr ( $port, array ( elphel_set_P_arr ( $port, array (
'COMPRESSOR_RUN' => 0, 'COMPRESSOR_RUN' => 0,
...@@ -1354,16 +1371,17 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) { ...@@ -1354,16 +1371,17 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) {
), $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // was -1 ("this frame") ), $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // was -1 ("this frame")
$frame_to_set += 2; $frame_to_set += 2;
} }
log_msg ( "port ".$port. " setting @".$frame_to_set.": " .print_r($parToSet) );
elphel_set_P_arr ( $port, $parToSet, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_arr ( $port, $parToSet, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
$frame_to_set += 2; $frame_to_set += 2;
log_msg ( "port ".$port. " setting @".$frame_to_set." COMPRESSOR_RUN= " . $compressor_run ['COMPRESSOR_RUN'] );
elphel_set_P_arr ( $port, $compressor_run, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_arr ( $port, $compressor_run, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
log_msg ( "setting COMPRESSOR_RUN=" . $compressor_run ['COMPRESSOR_RUN'] );
$frame_to_set += 4; // /Adjust? So streamer will have at least 2 good frames in buffer? $frame_to_set += 4; // /Adjust? So streamer will have at least 2 good frames in buffer?
log_msg ( "port ".$port. " setting @".$frame_to_set." DAEMON_EN= " . print_r ( $daemon_en, 1 ) );
elphel_set_P_arr ( $port, $daemon_en, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_arr ( $port, $daemon_en, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
log_msg ( "setting DAEMON_EN= " . print_r ( $daemon_en, 1 ) );
$frame_to_set += 1; $frame_to_set += 1;
log_msg ( "port ".$port. " setting @".$frame_to_set." delayed trigger parameters= " . print_r ( $delayed_params, 1 ) );
elphel_set_P_arr ( $port, $delayed_params, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); elphel_set_P_arr ( $port, $delayed_params, $frame_to_set, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
log_msg ( "setting delayed trigger parameters= " . print_r ( $delayed_params, 1 ) );
$pages[]=$page; $pages[]=$page;
} }
$numSkip=$frame_to_set-elphel_get_frame($GLOBALS['master_port'])+1; // +1 - to be safe? $numSkip=$frame_to_set-elphel_get_frame($GLOBALS['master_port'])+1; // +1 - to be safe?
...@@ -1379,32 +1397,50 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) { ...@@ -1379,32 +1397,50 @@ function setParsFromPage($sensor_port, $page, $mask, $initmode = false) {
$page = $GLOBALS['configs'][$sensor_port]['defaultPage']; $page = $GLOBALS['configs'][$sensor_port]['defaultPage'];
} }
$parToSet = array (); $parToSet = array ();
foreach ( $config ['groups'] as $par => $parMask ) { log_msg("page = $page");
if (($mask & $parMask) && array_key_exists ( $par, $config ['paramSets'] [$page] ) && (! $config ['parTypes'] [$par])) // / not 'text' foreach ( $GLOBALS ['configs'][$sensor_port] ['groups'] as $par => $parMask ) {
$parToSet [$par] = myval ( $config ['paramSets'] [$page] [$par] ); if (($mask & $parMask) &&
array_key_exists ( $par, $GLOBALS ['configs'] [$sensor_port] ['paramSets'] [$page] ) &&
(! $GLOBALS ['configs'] [$sensor_port] ['parTypes'] [$par])) // / not 'text'
$parToSet [$par] = myval ( $GLOBALS ['configs'] [$sensor_port] ['paramSets'] [$page] [$par] );
log_msg(print_r($parToSet,1));
} }
// /NOTE: Important ; add gamma tables if parameters modified involve setting/chnaging them // /NOTE: Important ; add gamma tables if parameters modified involve setting/chnaging them
addGammas ( $parToSet ); addGammas ( $parToSet );
log_msg('$parToSet == '. print_r($parToSet,1));
elphel_set_P_arr ( $sensor_port, $parToSet ); elphel_set_P_arr ( $sensor_port, $parToSet );
} }
return $page; return $page;
} }
/*
global $config, $useDefaultPageNumber;
if ($page==$useDefaultPageNumber) $page=$config['defaultPage'];
$parToSet=array();
foreach ($config['groups'] as $par=>$parMask) {
if (($mask & $parMask) &&
array_key_exists($par, $config['paramSets'][$page]) &&
(!$config['parTypes'][$par])) /// not 'text'
$parToSet[$par]=myval($config['paramSets'][$page][$par]);
}
///NOTE: Important ; add gamma tables if parameters modified involve setting/chnaging them
addGammas($parToSet);
*/
function readParsToPage($sensor_port, $page) { function readParsToPage($sensor_port, $page) {
global $config; log_msg("readParsToPage($sensor_port, $page)");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
if (($page == $GLOBALS['protectedPage']) || ($page < 0) || ($page > $GLOBALS['useDefaultPageNumber'])) if (($page == $GLOBALS['protectedPage']) || ($page < 0) || ($page > $GLOBALS['useDefaultPageNumber']))
return - 1; return - 1;
if ($page == $GLOBALS['useDefaultPageNumber']) if ($page == $GLOBALS['useDefaultPageNumber'])
$page = $config ['nextPage']; // / 0 is write protected $page = $GLOBALS ['configs'] [$sensor_port] ['nextPage']; // / 0 is write protected
if ($page == $GLOBALS['protectedPage']) if ($page == $GLOBALS['protectedPage'])
$page = findNextPage ( $page ); $page = findNextPage ( $page );
// echo "\nbefore:";print_r($config); $GLOBALS ['configs'] [$sensor_port] ['paramSets'] [$page] = elphel_get_P_arr ( $sensor_port, $GLOBALS ['configs'] [$sensor_port] ['groups'] ); // / 'text' parameters will be just ignored
$config ['paramSets'] [$page] = elphel_get_P_arr ( $sensor_port, $config ['groups'] ); // / 'text' parameters will be just ignored $GLOBALS ['configs'] [$sensor_port] ['paramSets'] [$page] ['comment'] = "Saved on " . date ( "F j, Y, g:i a" );
$config ['paramSets'] [$page] ['comment'] = "Saved on " . date ( "F j, Y, g:i a" ); $GLOBALS ['configs'] [$sensor_port] ['paramSets'] [$page] ['timestamp'] = time ();
$config ['paramSets'] [$page] ['timestamp'] = time (); $GLOBALS ['configs'] [$sensor_port] ['nextPage'] = findNextPage ( $page );
// echo "\nafter:";print_r($config);
$config ['nextPage'] = findNextPage ( $page );
elphel_set_P_arr ( $sensor_port, array ( elphel_set_P_arr ( $sensor_port, array (
"AUTOCAMPARS_PAGE" => $page + 0 "AUTOCAMPARS_PAGE" => $page + 0
) ); // / will set some (3?) frames ahead so not yet available until waited enough ) ); // / will set some (3?) frames ahead so not yet available until waited enough
...@@ -1414,33 +1450,34 @@ function readParsToPage($sensor_port, $page) { ...@@ -1414,33 +1450,34 @@ function readParsToPage($sensor_port, $page) {
} }
// elphel_parse_P_name // elphel_parse_P_name
function saveRotateConfig($sensor_port, $numBackups) { function saveRotateConfig($sensor_port, $numBackups) {
// global $config, $configPath, $backupConfigPath; log_msg("saveRotateConfig($sensor_port, $numBackups)");
log_msg("GLOBALS['configs']=".print_r($GLOBALS['configs'],1));
rotateConfig ($sensor_port, $numBackups ); rotateConfig ($sensor_port, $numBackups );
$confFile = fopen ( $GLOBALS['configPath'][$sensor_port], "w+" ); $confFile = fopen ( $GLOBALS['configPaths'][$sensor_port], "w+" );
fwrite ( $confFile, encodeConfig ( $GLOBALS['config'][$sensor_port] ) ); fwrite ( $confFile, encodeConfig ( $GLOBALS['configs'][$sensor_port] ) );
fclose ( $confFile ); fclose ( $confFile );
exec ( 'sync' ); exec ( 'sync' );
} }
function rotateConfig($sensor_port,$numBackups) { function rotateConfig($sensor_port,$numBackups) {
// global $config, $configPath, $backupConfigPath; log_msg("rotateConfig($sensor_port,$numBackups)");
if (file_exists ( backupName ($sensor_port, $numBackups ) )) if (file_exists ( backupName ($sensor_port, $numBackups ) ))
unlink ( backupName ($sensor_port, $numBackups ) ); unlink ( backupName ($sensor_port, $numBackups ) );
for($i = $numBackups - 1; $i > 0; $i --) for($i = $numBackups - 1; $i > 0; $i --)
if (file_exists ( backupName ($sensor_port, $i - 1 ) )) if (file_exists ( backupName ($sensor_port, $i - 1 ) ))
rename ( backupName ($sensor_port, $i - 1 ), backupName ($sensor_port, $i ) ); rename ( backupName ($sensor_port, $i - 1 ), backupName ($sensor_port, $i ) );
if (($numBackups > 0) && (file_exists ( $GLOBALS['configPath'][$sensor_port]))) log_msg("cheking path ".$GLOBALS['configPaths'][$sensor_port].": ".file_exists ( $GLOBALS['configPaths'][$sensor_port]));
rename ( $GLOBALS['configPath'][$sensor_port], backupName ($sensor_port, 0 ) ); if (($numBackups > 0) && (file_exists ( $GLOBALS['configPaths'][$sensor_port])))
rename ( $GLOBALS['configPaths'][$sensor_port], backupName ($sensor_port, 0 ) );
} }
function backupName($sensor_port, $num) { function backupName($sensor_port, $num) {
// global $backupConfigPath;
if ($num > 0) if ($num > 0)
return $GLOBALS['backupConfigPath'][$sensor_port] . $num; return $GLOBALS['backupConfigPaths'][$sensor_port] . $num;
else else
return $GLOBALS['backupConfigPath'][$sensor_port]; return $GLOBALS['backupConfigPaths'][$sensor_port];
} }
function findNextPage($page) { function findNextPage($page) {
global $config;
$page ++; $page ++;
while ( ($page == $GLOBALS['protectedPage']) || ($page == $GLOBALS['useDefaultPageNumber']) ) { while ( ($page == $GLOBALS['protectedPage']) || ($page == $GLOBALS['useDefaultPageNumber']) ) {
$page ++; $page ++;
...@@ -1494,8 +1531,9 @@ function parseConfig($filename) { ...@@ -1494,8 +1531,9 @@ function parseConfig($filename) {
} }
return $config; return $config;
} }
function encodeConfig($config) { function encodeConfig($config) {
// echo "encodeConfig()";print_r($config); log_msg("encodeConfig(): sensor_port=".$GLOBALS['sensor_port'].", config=".print_r($config,1));
$xml = "<?xml version=\"1.0\" standalone=\"yes\"?>\n<!-- This file is generated by " . $_SERVER ['argv'] [0] . " -->\n"; $xml = "<?xml version=\"1.0\" standalone=\"yes\"?>\n<!-- This file is generated by " . $_SERVER ['argv'] [0] . " -->\n";
$xml .= " <autocampars>\n"; $xml .= " <autocampars>\n";
$xml .= "<!-- File version -->\n"; $xml .= "<!-- File version -->\n";
...@@ -1546,6 +1584,7 @@ function encodeConfig($config) { ...@@ -1546,6 +1584,7 @@ function encodeConfig($config) {
$xml .= " </autocampars>\n"; $xml .= " </autocampars>\n";
return $xml; return $xml;
} }
function myval($s) { function myval($s) {
$s = trim ( $s, "\" " ); $s = trim ( $s, "\" " );
if (strtoupper ( substr ( $s, 0, 2 ) ) == "0X") if (strtoupper ( substr ( $s, 0, 2 ) ) == "0X")
...@@ -1623,9 +1662,9 @@ function calculateDefaultPhases() { ...@@ -1623,9 +1662,9 @@ function calculateDefaultPhases() {
//http://stackoverflow.com/questions/5695145/how-to-read-and-write-to-an-ini-file-with-php //http://stackoverflow.com/questions/5695145/how-to-read-and-write-to-an-ini-file-with-php
function write_php_ini($array, $file) { function write_php_ini($array, $file) {
echo "write_php_ini\n"; // echo "write_php_ini\n";
// var_dump($array); // var_dump($array);
print_r($array); // print_r($array);
$res = array (); $res = array ();
foreach ( $array as $key => $val ) { foreach ( $array as $key => $val ) {
if (is_array ( $val )) { if (is_array ( $val )) {
...@@ -1664,14 +1703,13 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -1664,14 +1703,13 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
$thisScript = $_SERVER ['argv'] [0]; $thisScript = $_SERVER ['argv'] [0];
// /overwrites // /overwrites
$TRIG_MASTER = 0; // modify for bottom 2 for eyesis? or rely on auto? $TRIG_MASTER = 0; // modify for bottom 2 for eyesis? or rely on auto?
$TRIG = $multisensor ? 4 : 0; $TRIG = 4; // $multisensor ? 4 : 0;
$TRIG_CONDITION = $eyesis_mode ? 0x20000 : 0; $TRIG_PERIOD = $eyesis_mode ?25000000 : 10000000; // 10 fps
$TRIG_OUT = $eyesis_mode ? 0x80000 : 0; $TRIG_CONDITION = $eyesis_mode ? 0x59555 : 0x55555;
$TRIG_PERIOD = $eyesis_mode ? 38400000 : 0; $TRIG_OUT = $eyesis_mode ? 0x65555 : 0x55555;
$MULTI_MODE = $multisensor ? 1 : 0; $MULTI_MODE = $multisensor ? 1 : 0;
$GAMMA_CORR = $eyesis_mode ? 0x09320400 : 0x0a390400; $GAMMA_CORR = $eyesis_mode ? 0x09320400 : 0x0a390400;
$SATURATION = $eyesis_mode ? 220 : 200; // / should be changed with gamma (lower the gamma - higher the required saturation) $SATURATION = $eyesis_mode ? 220 : 200; // / should be changed with gamma (lower the gamma - higher the required saturation)
$WB_EN = $eyesis_mode ? 0 : 1; $WB_EN = $eyesis_mode ? 0 : 1;
$GAINR = $eyesis_mode ? 0x2d26e : 0x20000; $GAINR = $eyesis_mode ? 0x2d26e : 0x20000;
$GAING = $eyesis_mode ? 0x20000 : 0x20000; $GAING = $eyesis_mode ? 0x20000 : 0x20000;
...@@ -1696,7 +1734,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -1696,7 +1734,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
$HISTWND_RHEIGHT = 0x8000; $HISTWND_RHEIGHT = 0x8000;
$HISTWND_RLEFT = 0x8000; $HISTWND_RLEFT = 0x8000;
$HISTWND_RTOP = 0x8000; $HISTWND_RTOP = 0x8000;
$COLOR = 1; $COLOR = 0;
switch ($eyesis_mode) { switch ($eyesis_mode) {
case 1 : case 1 :
...@@ -1766,6 +1804,38 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -1766,6 +1804,38 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
$COLOR = 5; $COLOR = 5;
break; break;
} }
/*
elphel_set_P_value ( $sensor_port, ELPHEL_MAXAHEAD, 2, 0, 8 ); // / When servicing interrupts, try programming up to 2 frames ahead of due time)
// 2016/09/09: Seems that with defualt 63, even on a single-channel autoexposure+ moving WOI breaks acquisition)
// With increased delay - seems OK
// Resizing - still breaks, probably for different reason
elphel_set_P_value ( $sensor_port, ELPHEL_MEMSENSOR_DLY, 1024, $frame + 2, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_FPGA_XTRA, 1000, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // /compressor needs extra 1000 cycles to compress a frame (estimate)
// elphel_set_P_value ( $sensor_port, ELPHEL_EXTERN_TIMESTAMP, 1, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / only used with async trigger
// / good (latency should be changed, but for now that will make a correct initialization - maybe obsolete)
elphel_set_P_value ( $sensor_port, ELPHEL_BITS, 8, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_QUALITY, 80, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR, ELPHEL_CONST_COLORMODE_COLOR, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_BLUE, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_RED, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_BAYER, 0, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAING, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAINGB, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAINR, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_GAINB, 0x10000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_VIGNET_C, 0x8000, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_VIGNET_SHL, 1, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COMPRESSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / run compressor
*/
// will create $SENSOR_PHASE=...;MULTI_PHASE1=...;MULTI_PHASE3=...;) // will create $SENSOR_PHASE=...;MULTI_PHASE1=...;MULTI_PHASE3=...;)
extract ( calculateDefaultPhases () ); // read sensor phases from memory or calculate from the eeproms for newer devices extract ( calculateDefaultPhases () ); // read sensor phases from memory or calculate from the eeproms for newer devices
// / Now select window orientations based on eyesis_mode // / Now select window orientations based on eyesis_mode
...@@ -1838,8 +1908,8 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -1838,8 +1908,8 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<FPGATEST>"Replace the image from the sensor with the internally generated test pattern. Currently only two values are supported: 0 - npormal image, 1 horizontal gradient.</FPGATEST> <FPGATEST>"Replace the image from the sensor with the internally generated test pattern. Currently only two values are supported: 0 - npormal image, 1 horizontal gradient.</FPGATEST>
<TESTSENSOR>"Sensor internal test modes: 0x10000 - enable, lower bits - test mode value"</TESTSENSOR> <TESTSENSOR>"Sensor internal test modes: 0x10000 - enable, lower bits - test mode value"</TESTSENSOR>
<COLOR>"Compressor modes (only modes 0..2 can be processed with standard libjpeg):` <COLOR>"Compressor modes (only modes 0..2 can be processed with standard libjpeg):`
0 - mono6, monochrome (color YCbCr 4:2:0 with zeroed out color componets)` 0 - color, YCbCr 4:2:0, 3x3 pixels`
1 - color, YCbCr 4:2:0, 3x3 pixels` 1 - mono6, monochrome (color YCbCr 4:2:0 with zeroed out color componets)`
2 - jp46 - original jp4, encoded as 4:2:0 with zeroed color components` 2 - jp46 - original jp4, encoded as 4:2:0 with zeroed color components`
3 - jp46dc, modified jp46 so each color component uses individual DC diffenential encoding` 3 - jp46dc, modified jp46 so each color component uses individual DC diffenential encoding`
4 - reserved for color with 5x5 conversion (not yet implemented)` 4 - reserved for color with 5x5 conversion (not yet implemented)`
...@@ -1935,6 +2005,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -1935,6 +2005,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<RFOCUS_WIDTH>"init"</RFOCUS_WIDTH> <RFOCUS_WIDTH>"init"</RFOCUS_WIDTH>
<RFOCUS_TOP>"init"</RFOCUS_TOP> <RFOCUS_TOP>"init"</RFOCUS_TOP>
<RFOCUS_HEIGHT>"init"</RFOCUS_HEIGHT> <RFOCUS_HEIGHT>"init"</RFOCUS_HEIGHT>
<MEMSENSOR_DLY>"Delay in memsensor from frame sync (start of command processing) and SoF when it is started"</MEMSENSOR_DLY>
<FOCUS_LEFT>"Focus WOI left margin, in pixels, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block width)"</FOCUS_LEFT> <FOCUS_LEFT>"Focus WOI left margin, in pixels, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block width)"</FOCUS_LEFT>
<FOCUS_WIDTH>"Focus WOI width (3 LSB will be zeroed as it should be multiple of 8x8 block width)"</FOCUS_WIDTH> <FOCUS_WIDTH>"Focus WOI width (3 LSB will be zeroed as it should be multiple of 8x8 block width)"</FOCUS_WIDTH>
<FOCUS_TOP>"focus WOI top margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block height)"</FOCUS_TOP> <FOCUS_TOP>"focus WOI top margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block height)"</FOCUS_TOP>
...@@ -2212,7 +2283,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2212,7 +2283,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<DGAINB>"init,vignet"</DGAINB> <DGAINB>"init,vignet"</DGAINB>
<CORING_PAGE>"init,image"</CORING_PAGE> <CORING_PAGE>"init,image"</CORING_PAGE>
<TILES></TILES> <TILES></TILES>
<SENSOR_PHASE>"init,unsafe,diagn"</SENSOR_PHASE> <SENSOR_PHASE>"unsafe,diagn"</SENSOR_PHASE>
<TEMPERATURE_PERIOD>"init,diagn"</TEMPERATURE_PERIOD> <TEMPERATURE_PERIOD>"init,diagn"</TEMPERATURE_PERIOD>
<AUTOEXP_ON>"init,autoexposure"</AUTOEXP_ON> <AUTOEXP_ON>"init,autoexposure"</AUTOEXP_ON>
<HISTWND_RWIDTH>"init,histWnd"</HISTWND_RWIDTH> <HISTWND_RWIDTH>"init,histWnd"</HISTWND_RWIDTH>
...@@ -2237,6 +2308,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2237,6 +2308,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<RFOCUS_WIDTH>"init"</RFOCUS_WIDTH> <RFOCUS_WIDTH>"init"</RFOCUS_WIDTH>
<RFOCUS_TOP>"init"</RFOCUS_TOP> <RFOCUS_TOP>"init"</RFOCUS_TOP>
<RFOCUS_HEIGHT>"init"</RFOCUS_HEIGHT> <RFOCUS_HEIGHT>"init"</RFOCUS_HEIGHT>
<MEMSENSOR_DLY>"init"</MEMSENSOR_DLY>
<FOCUS_LEFT></FOCUS_LEFT> <FOCUS_LEFT></FOCUS_LEFT>
<FOCUS_WIDTH></FOCUS_WIDTH> <FOCUS_WIDTH></FOCUS_WIDTH>
<FOCUS_TOP></FOCUS_TOP> <FOCUS_TOP></FOCUS_TOP>
...@@ -2253,7 +2325,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2253,7 +2325,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<SKIP_FRAMES>"init"</SKIP_FRAMES> <SKIP_FRAMES>"init"</SKIP_FRAMES>
<I2C_QPERIOD>"unsafe"</I2C_QPERIOD> <I2C_QPERIOD>"unsafe"</I2C_QPERIOD>
<I2C_BYTES>"unsafe"</I2C_BYTES> <I2C_BYTES>"unsafe"</I2C_BYTES>
<IRQ_SMART>"init,trigger"</IRQ_SMART> <IRQ_SMART></IRQ_SMART>
<OVERSIZE>"init"</OVERSIZE> <OVERSIZE>"init"</OVERSIZE>
<GTAB_R>"init,image,whiteBalance"</GTAB_R> <GTAB_R>"init,image,whiteBalance"</GTAB_R>
<GTAB_G>"init,image,whiteBalance"</GTAB_G> <GTAB_G>"init,image,whiteBalance"</GTAB_G>
...@@ -2328,17 +2400,17 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2328,17 +2400,17 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<HIST_DIM_23>"init,autoexposure"</HIST_DIM_23> <HIST_DIM_23>"init,autoexposure"</HIST_DIM_23>
<AE_INTEGERR></AE_INTEGERR> <AE_INTEGERR></AE_INTEGERR>
<WB_INTEGERR></WB_INTEGERR> <WB_INTEGERR></WB_INTEGERR>
<TASKLET_CTL>"init,diagn"</TASKLET_CTL> <TASKLET_CTL>"diagn"</TASKLET_CTL>
<GFOCUS_VALUE></GFOCUS_VALUE> <GFOCUS_VALUE></GFOCUS_VALUE>
<HISTMODE_Y>"init,diagn"</HISTMODE_Y> <HISTMODE_Y>"diagn"</HISTMODE_Y>
<HISTMODE_C>"init,diagn"</HISTMODE_C> <HISTMODE_C>"diagn"</HISTMODE_C>
<SKIP_DIFF_FRAME>"init,streamer"</SKIP_DIFF_FRAME> <SKIP_DIFF_FRAME>"streamer"</SKIP_DIFF_FRAME>
<HIST_LAST_INDEX></HIST_LAST_INDEX> <HIST_LAST_INDEX></HIST_LAST_INDEX>
<HIST_Y_FRAME></HIST_Y_FRAME> <HIST_Y_FRAME></HIST_Y_FRAME>
<HIST_C_FRAME></HIST_C_FRAME> <HIST_C_FRAME></HIST_C_FRAME>
<DAEMON_ERR></DAEMON_ERR> <DAEMON_ERR></DAEMON_ERR>
<DAEMON_RETCODE></DAEMON_RETCODE> <DAEMON_RETCODE></DAEMON_RETCODE>
<PROFILING_EN>"init,diagn"</PROFILING_EN> <PROFILING_EN>"diagn"</PROFILING_EN>
<STROP_MCAST_EN>"init,streamer"</STROP_MCAST_EN> <STROP_MCAST_EN>"init,streamer"</STROP_MCAST_EN>
<STROP_MCAST_IP>"init,streamer"</STROP_MCAST_IP> <STROP_MCAST_IP>"init,streamer"</STROP_MCAST_IP>
<STROP_MCAST_PORT>"init,streamer"</STROP_MCAST_PORT> <STROP_MCAST_PORT>"init,streamer"</STROP_MCAST_PORT>
...@@ -2472,6 +2544,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2472,6 +2544,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<RFOCUS_WIDTH>0x8000</RFOCUS_WIDTH> <RFOCUS_WIDTH>0x8000</RFOCUS_WIDTH>
<RFOCUS_TOP>0x8000</RFOCUS_TOP> <RFOCUS_TOP>0x8000</RFOCUS_TOP>
<RFOCUS_HEIGHT>0x8000</RFOCUS_HEIGHT> <RFOCUS_HEIGHT>0x8000</RFOCUS_HEIGHT>
<MEMSENSOR_DLY>1024</MEMSENSOR_DLY>
<FOCUS_FILTER>0</FOCUS_FILTER> <FOCUS_FILTER>0</FOCUS_FILTER>
<TRIG_CONDITION>$TRIG_CONDITION</TRIG_CONDITION> <TRIG_CONDITION>$TRIG_CONDITION</TRIG_CONDITION>
<TRIG_DELAY>0</TRIG_DELAY> <TRIG_DELAY>0</TRIG_DELAY>
...@@ -2480,8 +2553,8 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2480,8 +2553,8 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<TRIG_BITLENGTH>31</TRIG_BITLENGTH> <TRIG_BITLENGTH>31</TRIG_BITLENGTH>
<EXTERN_TIMESTAMP>1</EXTERN_TIMESTAMP> <EXTERN_TIMESTAMP>1</EXTERN_TIMESTAMP>
<XMIT_TIMESTAMP>1</XMIT_TIMESTAMP> <XMIT_TIMESTAMP>1</XMIT_TIMESTAMP>
<SKIP_FRAMES>0</SKIP_FRAMES> <!-- <SKIP_FRAMES>0</SKIP_FRAMES>
<IRQ_SMART>3</IRQ_SMART> <IRQ_SMART>3</IRQ_SMART> -->
<OVERSIZE>0</OVERSIZE> <OVERSIZE>0</OVERSIZE>
<GTAB_R>$GAMMA_CORR</GTAB_R> <GTAB_R>$GAMMA_CORR</GTAB_R>
<GTAB_G>$GAMMA_CORR</GTAB_G> <GTAB_G>$GAMMA_CORR</GTAB_G>
...@@ -2489,7 +2562,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2489,7 +2562,7 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<GTAB_B>$GAMMA_CORR</GTAB_B> <GTAB_B>$GAMMA_CORR</GTAB_B>
<COMPRESSOR_RUN>$COMPRESSOR_RUN</COMPRESSOR_RUN> <COMPRESSOR_RUN>$COMPRESSOR_RUN</COMPRESSOR_RUN>
<COMPMOD_BYRSH>0</COMPMOD_BYRSH> <COMPMOD_BYRSH>0</COMPMOD_BYRSH>
<COMPMOD_TILSH>0</COMPMOD_TILSH> <!-- <COMPMOD_TILSH>0</COMPMOD_TILSH> -->
<COMPMOD_DCSUB>0</COMPMOD_DCSUB> <COMPMOD_DCSUB>0</COMPMOD_DCSUB>
<SENSOR_REGS></SENSOR_REGS> <SENSOR_REGS></SENSOR_REGS>
<DAEMON_EN>0</DAEMON_EN> <DAEMON_EN>0</DAEMON_EN>
...@@ -2524,17 +2597,21 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2524,17 +2597,21 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<FTP_TIMEOUT>360</FTP_TIMEOUT> <FTP_TIMEOUT>360</FTP_TIMEOUT>
<FTP_UPDATE>600</FTP_UPDATE> <FTP_UPDATE>600</FTP_UPDATE>
<DEBUG>0</DEBUG> <DEBUG>0</DEBUG>
<MAXAHEAD>2</MAXAHEAD> <MAXAHEAD>3</MAXAHEAD>
<HIST_DIM_01>0x0a000a00</HIST_DIM_01>
<HIST_DIM_23>0x0a000a00</HIST_DIM_23> <!-- <HIST_DIM_01>0x0a000a00</HIST_DIM_01>
<HIST_DIM_23>0x0a000a00</HIST_DIM_23> -->
<AE_INTEGERR></AE_INTEGERR> <AE_INTEGERR></AE_INTEGERR>
<WB_INTEGERR></WB_INTEGERR> <WB_INTEGERR></WB_INTEGERR>
<TASKLET_CTL>0</TASKLET_CTL> <TASKLET_CTL>0</TASKLET_CTL>
<GFOCUS_VALUE></GFOCUS_VALUE> <GFOCUS_VALUE></GFOCUS_VALUE>
<HISTMODE_Y>$HISTMODE_Y</HISTMODE_Y>
<!-- <HISTMODE_Y>$HISTMODE_Y</HISTMODE_Y>
<HISTMODE_C>$HISTMODE_C</HISTMODE_C> <HISTMODE_C>$HISTMODE_C</HISTMODE_C>
<SKIP_DIFF_FRAME>4</SKIP_DIFF_FRAME> <SKIP_DIFF_FRAME>4</SKIP_DIFF_FRAME>
<PROFILING_EN>0</PROFILING_EN> <PROFILING_EN>0</PROFILING_EN> -->
<STROP_MCAST_EN>0</STROP_MCAST_EN> <STROP_MCAST_EN>0</STROP_MCAST_EN>
<STROP_MCAST_IP>0</STROP_MCAST_IP> <STROP_MCAST_IP>0</STROP_MCAST_IP>
<STROP_MCAST_PORT>20020</STROP_MCAST_PORT> <STROP_MCAST_PORT>20020</STROP_MCAST_PORT>
...@@ -2548,10 +2625,12 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) { ...@@ -2548,10 +2625,12 @@ function createDefaultConfig($version, $multisensor = false, $eyesis_mode = 0) {
<MULTI_FLIPH> $MULTI_FLIPH</MULTI_FLIPH> <MULTI_FLIPH> $MULTI_FLIPH</MULTI_FLIPH>
<MULTI_FLIPV> $MULTI_FLIPV</MULTI_FLIPV> <MULTI_FLIPV> $MULTI_FLIPV</MULTI_FLIPV>
<MULTI_SELECTED>$MULTI_SELECTED</MULTI_SELECTED> <MULTI_SELECTED>$MULTI_SELECTED</MULTI_SELECTED>
<SENSOR_PHASE>$SENSOR_PHASE</SENSOR_PHASE>
<!-- <SENSOR_PHASE>$SENSOR_PHASE</SENSOR_PHASE>
<MULTI_PHASE1>$MULTI_PHASE1</MULTI_PHASE1> <MULTI_PHASE1>$MULTI_PHASE1</MULTI_PHASE1>
<MULTI_PHASE2>$MULTI_PHASE2</MULTI_PHASE2> <MULTI_PHASE2>$MULTI_PHASE2</MULTI_PHASE2>
<MULTI_PHASE3>$MULTI_PHASE3</MULTI_PHASE3> <MULTI_PHASE3>$MULTI_PHASE3</MULTI_PHASE3> -->
<TEMPERATURE01>-1</TEMPERATURE01> <TEMPERATURE01>-1</TEMPERATURE01>
<TEMPERATURE23>-1</TEMPERATURE23> <TEMPERATURE23>-1</TEMPERATURE23>
</set> </set>
......
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