Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
97346989
Commit
97346989
authored
Jul 11, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more debugging
parent
edaa3147
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
563 additions
and
400 deletions
+563
-400
Makefile
src/lwir16/Makefile
+1
-2
lwir16.ini
src/lwir16/lwir16.ini
+4
-3
lwir16.php
src/lwir16/lwir16.php
+176
-85
multicamconf.xml
src/lwir16/multicamconf.xml
+0
-9
multicam3.js
src/multicam/multicam3.js
+295
-135
multicam3.php
src/multicam/multicam3.php
+87
-166
No files found.
src/lwir16/Makefile
View file @
97346989
...
...
@@ -17,8 +17,7 @@ PHP_SCRIPTS_EXE=lwir16.php \
test_int.php
\
test_wpipe.php
\
test_ps.php
CONFIGS
=
lwir16.ini
\
multicamconf.xml
CONFIGS
=
lwir16.ini
all
:
@
echo
"make all in src"
...
...
src/lwir16/lwir16.ini
View file @
97346989
...
...
@@ -5,10 +5,11 @@ 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"
port_masks
=
"15,15,15,15,15"
ips
=
"192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45
,192.168.0.46
"
port_masks
=
"15,15,15,15,15
,0
"
#1 - run/stop, 2 - continuous, 0 do not use
run_modes
=
"1,1,1,1,2"
#OR-ed: 49 - master LWIR RAW, 33 - slave LWIR RAW, 42 - continuously-run slave EO RAW, 4 - slave IMS logger, file system
run_modes
=
"49,33,33,33,42,4"
lwir_fps
=
59.98
eo_decimate_m1
=
5
duration
=
500
...
...
src/lwir16/lwir16.php
View file @
97346989
...
...
@@ -29,7 +29,9 @@
define
(
'REG_FFC_RUN'
,
'SENSOR_REGS26'
);
// Register to trigger FFC
define
(
'SCRIPT_RESET'
,
'reset_frames.php'
);
// Reset frame numbers
define
(
'SCRIPT_WAIT'
,
'wait_frame.php'
);
// wait frame
define
(
'DEFAULT_IPS'
,
'192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45'
);
// define('DEFAULT_IPS', '192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45,192.168.0.45');
// define('DEFAULT_PORTS', '15,15,15,15,15,0');
// define('DEFAULT_MODES', '1,1,1,1,2,0'); // maybe make a special mode for the logger
define
(
'PIPE_CMD'
,
'/tmp/pipe_cmd'
);
define
(
'PIPE_RESPONSE'
,
'/tmp/pipe_response'
);
define
(
'PIPE_MODE'
,
0600
);
...
...
@@ -41,6 +43,21 @@
define
(
'IPS'
,
'ips'
);
define
(
'PORT_MASKS'
,
'port_masks'
);
define
(
'RUN_MODES'
,
'run_modes'
);
// OR-ed: 49 - master LWIR RAW, 33 - slave LWIR RAW, 42 - continuously-run slave EO RAW, 4 - slave IMS logger, file system
define
(
'RUN_MODE_LWIR'
,
1
);
define
(
'RUN_MODE_EO'
,
2
);
define
(
'RUN_MODE_IMS'
,
4
);
define
(
'RUN_MODE_CONT'
,
8
);
// continuously run from start to stop
define
(
'RUN_MODE_MASTER'
,
16
);
define
(
'RUN_MODE_RAWREC'
,
32
);
// raw recording, 0 - use file system
// calculated and set to globals
define
(
'IP_LWIR'
,
'ip_lwir'
);
define
(
'IP_EO'
,
'ip_eo'
);
define
(
'IP_CAMERAS'
,
'ip_cameras'
);
define
(
'IP_MASTER'
,
'ip_master'
);
define
(
'IP_IMS'
,
'ip_ims'
);
define
(
'ALL_PORTS'
,
15
);
define
(
'IMGSRV_PORT0'
,
2323
);
...
...
@@ -146,6 +163,7 @@
if
((
$key
==
'ip'
)
||
(
$key
==
'ips'
)){
// multicamera operation
$GLOBALS
[
IPS
]
=
explode
(
','
,
$value
);
unset
(
$GLOBALS
[
PORT_MASKS
]);
// invalidate
unset
(
$GLOBALS
[
RUN_MODES
]);
// invalidate
}
else
if
(
$key
==
PORT_MASKS
){
//
$masks
=
explode
(
','
,
$value
);
unset
(
$GLOBALS
[
PORT_MASKS
]);
// invalidate
...
...
@@ -180,26 +198,31 @@
else
if
(
$key
==
TIFF_AUTO
)
$GLOBALS
[
TIFF_AUTO
]
=
(
int
)
$value
;
else
if
(
$key
==
OUTPUT_LOG
)
$GLOBALS
[
OUTPUT_LOG
]
=
$value
;
}
$need_setIPs
=!
isset
(
$GLOBALS
[
PORT_MASKS
])
||
!
isset
(
$GLOBALS
[
RUN_MODES
]);
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
]);
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]]
=
intval
(
$masks
[
$i
]);
}
else
{
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]]
=
ALL_PORTS
;
// print ('<pre>'.$i."->".$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]."\n</pre>");
}
}
}
if
(
!
isset
(
$GLOBALS
[
RUN_MODES
])){
$GLOBALS
[
RUN_MODES
]
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
){
if
(
isset
(
$run_modes
)
&&
(
count
(
$run_modes
)
>
$i
)){
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
=
(
int
)
(
$run_modes
[
$i
]);
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
=
intval
(
$run_modes
[
$i
]);
}
else
{
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
=
0
;
// print ('<pre>'.$i."->".$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]."\n</pre>");
}
}
}
// print_r($lswir16cmds);
if
(
$need_setIPs
)
{
setIPs
();
// normally not used - all that data is provided by config file, not the URL
}
// print_r($lswir16cmds);
// exit(0);
/*
echo"<pre>\n"; //****************
...
...
@@ -246,10 +269,10 @@
// print("1");
// print("2");
// exit(0);
$lwir_ips
=
array
(
$GLOBALS
[
IPS
][
0
],
$GLOBALS
[
IPS
][
1
],
$GLOBALS
[
IPS
][
2
],
$GLOBALS
[
IPS
][
3
]);
//$GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] = 0;
// $ip_lwir
= array($GLOBALS[IPS][0],$GLOBALS[IPS][1],$GLOBALS[IPS][2],$GLOBALS[IPS][3]);
// $twoIPs= array($GLOBALS[IPS][0],$GLOBALS[IPS][4]);
$twoIPs
=
$GLOBALS
[
IPS
];
// array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
//
$twoIPs= $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
// print_r($lswir16cmds);
for
(
$ncmd
=
0
;
$ncmd
<
count
(
$lswir16cmds
);
$ncmd
++
){
...
...
@@ -422,27 +445,71 @@ EOT;
$FFC_FRAMES
=
8
;
$REG_FFC_FRAMES
=
'SENSOR_REGS4'
;
// Register for the number of FFC frames to integrate
$REG_FFC_RUN
=
'SENSOR_REGS26'
;
// Register to trigger FFC
$lwir_ips
=
array
(
$GLOBALS
[
IPS
][
0
],
$GLOBALS
[
IPS
][
1
],
$GLOBALS
[
IPS
][
2
],
$GLOBALS
[
IPS
][
3
]
);
$twoIPs
=
$GLOBALS
[
IPS
];
// array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
//
$lwir_ips = array(
//
$GLOBALS[IPS][0],
//
$GLOBALS[IPS][1],
//
$GLOBALS[IPS][2],
//
$GLOBALS[IPS][3]
//
);
//
$twoIPs = $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
if
(
$debug
)
{
printf
(
"---
twoIPs
:
\n
"
);
print_r
(
$
twoIPs
);
printf
(
"---
GLOBALS[IP_CAMERAS]
:
\n
"
);
print_r
(
$
GLOBALS
[
IP_CAMERAS
]
);
}
$results0
=
skipFrames
(
$twoIPs
,
2
,
$debug
);
$results0
=
skipFrames
(
$GLOBALS
[
IP_CAMERAS
],
2
,
$debug
);
// print_r($results0);
$results1
=
resetIPs
(
$GLOBALS
[
IPS
],
$debug
);
// sync channels in each subcamera
// print_r($results1);
$results2
=
skipFrames
(
$twoIPs
,
16
,
$debug
);
// was 1
// print_r($results2); print("<br/>");
$results1
=
resetIPs
(
$GLOBALS
[
IP_CAMERAS
],
$debug
);
// sync channels in each subcamera
// print_r($results1);
$results2
=
skipFrames
(
$GLOBALS
[
IP_CAMERAS
],
16
,
$debug
);
// was 1
// print_r($results2); print("<br/>");
$trig_period
=
100000000
/
$GLOBALS
[
LWIR_FPS
];
$urls
=
array
();
// eo - individual
// For LWIR - only port 0, for EO - every port
// echo "<pre>\n";
// var_dump($GLOBALS[IP_LWIR]);
// var_dump($GLOBALS);
// echo "</pre>\n";
// exit(0);
foreach
(
$GLOBALS
[
IP_LWIR
]
as
$ip
)
{
$url
=
'http://'
.
$ip
.
'/parsedit.php?immediate&sensor_port=0'
.
'&TRIG_OUT=0x66555'
.
'&TRIG_CONDITION=0x95555'
.
'&TRIG_BITLENGTH=31'
.
'&EXTERN_TIMESTAMP=1'
.
'&XMIT_TIMESTAMP=1'
.
'&TRIG_DELAY='
.
$lwir_trig_dly
.
'&*TRIG_DELAY=15'
.
// apply to all ports
'&TRIG_PERIOD='
.
$trig_period
.
'&*TRIG_PERIOD=15'
.
'&BITS=16&*BITS=15'
.
'&COLOR='
.
$COLOR_RAW
.
'&*COLOR=15'
.
'&WOI_HEIGHT='
.
(
$LWIR_HEIGHT
+
(
$LWIR_TELEMETRY
?
$LWIR_TELEMETRY_LINES
:
0
))
.
'&*WOI_HEIGHT=15'
.
'&'
.
$REG_FFC_FRAMES
.
'='
.
$FFC_FRAMES
.
'&*'
.
$REG_FFC_FRAMES
.
'=15'
.
// apply to all channels
'&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15'
;
$urls
[]
=
$url
;
}
foreach
(
$GLOBALS
[
IP_EO
]
as
$ip
)
{
for
(
$port
=
0
;
$port
<
4
;
$port
++
)
{
if
(
$GLOBALS
[
PORT_MASKS
][
$ip
]
&
(
1
<<
$port
))
{
$url
=
'http://'
.
$ip
.
'/parsedit.php?immediate&sensor_port='
.
$port
.
'&TRIG_OUT=0x66555'
.
'&TRIG_CONDITION=0x95555'
.
'&TRIG_BITLENGTH=31'
.
'&EXTERN_TIMESTAMP=1'
.
'&XMIT_TIMESTAMP=1'
.
"&COLOR="
.
$COLOR_JP4
.
"&QUALITY="
.
$eo_quality
.
"&EXPOS="
.
$exposure
.
"&AUTOEXP_EXP_MAX="
.
$autoExposureMax
.
"&AUTOEXP_ON="
.
$autoExp
.
"&GAING="
.
$gain
.
"&RSCALE="
.
$rScale
.
// "*0".
"&BSCALE="
.
$bScale
.
// "*0".
"&GSCALE="
.
$gScale
.
// "*0". // GB/G ratio
"&WB_EN="
.
$autoWB
.
// "*0".
"&DAEMON_EN_TEMPERATURE=1"
;
// "*0";
"&DAEMON_EN_TEMPERATURE=1"
;
// "*0";
if
(
lrp
.
eo_full_window
)
{
$url
.=
"&WOI_LEFT=0"
.
"&WOI_TOP=0"
.
"&WOI_WIDTH=2592"
.
"&WOI_HEIGHT=1936"
;
}
if
(
$chn
==
0
)
{
$url
.=
'&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15'
;
$url
.=
'&TRIG_DECIMATE='
.
$GLOBALS
[
EO_DECIMATE_M1
]
.
'&*TRIG_DECIMATE=15'
;
}
$urls
[]
=
$url
;
}
}
}
/*
for ($i = 0; $i < (count($GLOBALS[IPS]) + 3); $i ++) {
$nip = $i;
if ($nip >= count($GLOBALS[IPS])) {
...
...
@@ -451,19 +518,22 @@ EOT;
$urls[$i] = 'http://' . $GLOBALS[IPS][$nip] . '/parsedit.php?immediate&sensor_port=' . ($i - $nip);
$urls[$i] .= '&TRIG_OUT=0x66555' . '&TRIG_CONDITION=0x95555' . '&TRIG_BITLENGTH=31' . '&EXTERN_TIMESTAMP=1' . '&XMIT_TIMESTAMP=1';
}
*/
// print_r($urls); print("<br/>");
// exit(0);
$trig_period
=
100000000
/
$GLOBALS
[
LWIR_FPS
];
/*
for ($i = 0; $i < count($lwir_ips); $i ++) {
$urls[$i] .= '&TRIG_DELAY=' . $lwir_trig_dly . '&*TRIG_DELAY=15' . // apply to all ports
'&TRIG_PERIOD=' . $trig_period . '&*TRIG_PERIOD=15' .
'&BITS=16&*BITS=15' . '&COLOR=' . $COLOR_RAW . '&*COLOR=15' . '&WOI_HEIGHT=' . ($LWIR_HEIGHT + ($LWIR_TELEMETRY ? $LWIR_TELEMETRY_LINES : 0)) . '&*WOI_HEIGHT=15' . '&' . $REG_FFC_FRAMES . '=' . $FFC_FRAMES . '&*' . $REG_FFC_FRAMES . '=15'; // apply to all channels
$urls[$i] .= '&COMPRESSOR_RUN=2&*COMPRESSOR_RUN=15';
}
if ($debug) {
print_r($GLOBALS[IPS]);
print_r($urls);
}
for ($chn = 0; $chn < 4; $chn ++) { // last IP
$urls[count($GLOBALS[IPS]) - 1 + $chn] .=
"&COLOR=" . $COLOR_JP4 .
...
...
@@ -485,6 +555,7 @@ EOT;
$urls[count($GLOBALS[IPS]) - 1] .= '&TRIG_DECIMATE='.$GLOBALS[EO_DECIMATE_M1] .'&*TRIG_DECIMATE=15';
}
}
*/
if
(
$debug
)
{
printf
(
"--- setting camera parameters, urls:
\n
"
);
print_r
(
$urls
);
...
...
@@ -499,16 +570,24 @@ EOT;
print_r
(
$results3
);
}
$results4
=
skipFrames
(
$twoIPs
,
16
,
$debug
);
$results4
=
skipFrames
(
$GLOBALS
[
IP_CAMERAS
],
16
,
$debug
);
// set external trigger mode for all LWIR and EO cameras
$urls
=
array
();
/*
for ($i = 0; $i < count($GLOBALS[IPS]); $i ++) {
$urls[] = 'http://' . $GLOBALS[IPS][$i] .
'/parsedit.php?immediate&sensor_port=0&TRIG=4&*TRIG=15' .
'&COMPRESSOR_RUN=' . $GLOBALS[COMPRESSOR_RUN] . '*5&*COMPRESSOR_RUN=15'; // delay turning off COMPRESSOR_RUN
}
*/
foreach
(
$GLOBALS
[
IP_CAMERAS
]
as
$ip
)
{
$url
=
'http://'
.
$ip
.
'/parsedit.php?immediate&sensor_port=0&TRIG=4&*TRIG=15'
.
'&COMPRESSOR_RUN='
.
$GLOBALS
[
COMPRESSOR_RUN
]
.
'*5&*COMPRESSOR_RUN=15'
;
// delay turning off COMPRESSOR_RUN
$urls
[]
=
$url
;
}
if
(
$debug
)
{
printf
(
"--- finally setting camera parameters (see COMPRESSOR_RUN), urls:
\n
"
);
print_r
(
$urls
);
...
...
@@ -522,13 +601,13 @@ EOT;
print_r
(
$results5
);
}
$results6
=
skipFrames
(
$twoIPs
,
16
,
$debug
);
// make sure all previous parameters are applied // waits for both LWIR and EO
$results6
=
skipFrames
(
$GLOBALS
[
IP_CAMERAS
]
,
16
,
$debug
);
// make sure all previous parameters are applied // waits for both LWIR and EO
// second reset after cameras running synchronously
$results7
=
resetIPs
(
$GLOBALS
[
IP
S
]);
// sync channels in each subcamera
$results8
=
skipFrames
(
$twoIPs
,
16
,
$debug
);
// was 2
$results7
=
resetIPs
(
$GLOBALS
[
IP_CAMERA
S
]);
// sync channels in each subcamera
$results8
=
skipFrames
(
$GLOBALS
[
IP_CAMERAS
]
,
16
,
$debug
);
// was 2
$results9
=
resetIPs
(
$GLOBALS
[
IP
S
]);
// sync channels in each subcamera
$results10
=
skipFrames
(
$
twoIPs
,
16
,
$debug
);
// was 2
$results9
=
resetIPs
(
$GLOBALS
[
IP_CAMERA
S
]);
// sync channels in each subcamera
$results10
=
skipFrames
(
$
GLOBALS
[
IP_CAMERAS
]
,
16
,
$debug
);
// was 2
$results
=
$results10
;
return
$results
;
}
...
...
@@ -558,21 +637,23 @@ EOT;
$FFC_FRAMES
=
8
;
$REG_FFC_FRAMES
=
'SENSOR_REGS4'
;
// Register for the number of FFC frames to integrate
$REG_FFC_RUN
=
'SENSOR_REGS26'
;
// Register to trigger FFC
/*
$lwir_ips = array(
$GLOBALS[IPS][0],
$GLOBALS[IPS][1],
$GLOBALS[IPS][2],
$GLOBALS[IPS][3]
);
$twoIPs
=
$GLOBALS
[
IPS
];
// array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
*/
// $twoIPs = $GLOBALS[IPS]; // array($GLOBALS[IPS][0],$GLOBALS[IPS][4]); wait all
$sensor_port
=
0
;
if
(
$debug
)
{
printf
(
"--- runCapture: run_ffc=%d, wait=%d
\n
"
,
$run_ffc
,
$wait
);
print_r
(
$
lwir_ips
);
print_r
(
$
GLOBALS
[
IP_LWIR
]
);
}
if
(
$run_ffc
){
// may move after measuring time, but need to make sure it will be not too late
runFFC
(
$
lwir_ips
,
$ffc_wait_frames
,
$debug
);
runFFC
(
$
GLOBALS
[
IP_LWIR
]
,
$ffc_wait_frames
,
$debug
);
}
if
(
$GLOBALS
[
I_AM_MASTER
])
{
$this_frame
=
elphel_get_frame
(
$sensor_port
);
...
...
@@ -581,37 +662,27 @@ EOT;
}
// $timestamp = $this_timestamp + $GLOBALS[PRE_DELAY]; // this will be a delay between capture sequences (default - 3s)
$urls
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
>
0
){
// 0 - do not use this camera at all
// for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] > 0){ // 0 - do not use this camera at all
foreach
(
$GLOBALS
[
IP_CAMERAS
]
as
$ip
)
{
// already filtered
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
// $url = 'http://'.$GLOBALS[IPS][$i].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port='.$sensor_port; //
$url
=
'http://'
.
$ip
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
if
(
$GLOBALS
[
I_AM_MASTER
])
{
$url
.=
'&ts='
.
$timestamp
;
// ×tamp" -> ×tamp
}
else
{
$url
.=
'&a='
.
$GLOBALS
[
PRE_DELAY
];
// ×tamp" -> ×tamp
}
// $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
];
// maybe turn on EO forever
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
==
2
)
{
// continuous run mode
/*
if ($first_run) {
$dur = -1; // start only, no stop
} else {
continue; // nothing to do for this camera, it is supposed to already be running. Or just enable compressor anyway?
}
*/
// $url .= '&port_mask='.$GLOBALS[PORT_MASKS][$GLOBALS[IPS][$i]]; //indexed by IPs
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$ip
];
//indexed by IPs
// $dur = ($i < 4) ? $GLOBALS[DURATION] : $GLOBALS[DURATION_EO]; // maybe turn on EO forever
$dur
=
(
$GLOBALS
[
RUN_MODES
][
$ip
]
&
RUN_MODE_LWIR
)
?
$GLOBALS
[
DURATION
]
:
$GLOBALS
[
DURATION_EO
];
// if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] == 2) {// continuous run mode
// TODO: Make conditional?
if
(
$GLOBALS
[
RUN_MODES
][
$ip
]
&
RUN_MODE_CONT
)
{
// continuous run mode
$dur
=
-
1
;
// start only, no stop
}
$url
.=
'&duration='
.
$dur
;
// $url .= '&maxahead='. $maxahead;
// $url .= '&minahead='. $minahead;
$url
.=
'&extra='
.
CR_EXTRA
;
// $extra;
//
/* disabling $wait
if ($wait && ($i == (count($GLOBALS[IPS]) - 1))){ // addd to the last ip in a list maybe to the first?
$url .= '&wait';
}
*/
$urls
[]
=
$url
;
}
if
(
$debug
)
{
...
...
@@ -699,7 +770,6 @@ EOT;
function
skipFrames
(
$ips
,
$skip
,
$debug
=
0
)
{
$urls
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$ips
);
$i
++
){
// $url = 'http://'.$ips[$i].$_SERVER[SCRIPT_NAME].'?frame='.$frame; //
$url
=
'http://'
.
$ips
[
$i
]
.
'/'
.
SCRIPT_WAIT
.
'?frame='
.
(
-
$skip
);
//
$urls
[]
=
$url
;
}
...
...
@@ -722,7 +792,7 @@ EOT;
if
(
file_exists
(
PIPE_CMD
)){
unlink
(
PIPE_CMD
);
//delete pipe if it was already there - waiting prevents signal handling!
}
$url_wait_capture
;
$url_wait_capture
;
// ???
$GLOBALS
[
DAEMON_RUN
]
=
1
;
$GLOBALS
[
CAPTURE_RUN
]
=
0
;
// until command
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
...
...
@@ -834,12 +904,6 @@ EOT;
if
(
$GLOBALS
[
DEBUG
]){
printf
(
"--- got from pipe: ---
\n
"
);
}
/*
$f = fopen(PIPE_CMD,"r");
if ($GLOBALS[DEBUG]) echo "(r) opened cmd\n";
$cmd_lines = fgets($f);
fclose ($f);
*/
$cmd_lines
=
file_get_contents
(
PIPE_CMD
);
if
(
$GLOBALS
[
DEBUG
])
echo
$cmd_lines
.
"
\n
"
;
if
(
$GLOBALS
[
DEBUG
])
echo
"(r) closed cmd
\n
"
;
...
...
@@ -849,8 +913,6 @@ EOT;
print_r
(
$ini
);
}
unset
(
$GLOBALS
[
DAEMON_CMD
]);
applyConf
(
$ini
);
// update $GLOBALS
$from_pipe
=
true
;
if
(
$GLOBALS
[
DEBUG
]
>
1
){
...
...
@@ -867,7 +929,8 @@ EOT;
// or maybe monitor one of the cameras until done?
// $skip = 1; // OK if more
// $rslt = skipFrames($ips0,$skip);
$url
=
'http://'
.
$GLOBALS
[
IPS
][
0
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port=0&state&frame='
.
$GLOBALS
[
FRAMES_WAIT
];
//
// $url = 'http://'.$GLOBALS[IPS][0].'/'.SCRIPT_CAPTURE_RANGE.'?sensor_port=0&state&frame='.$GLOBALS[FRAMES_WAIT]; //
$url
=
'http://'
.
$GLOBALS
[
IP_LWIR
][
0
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port=0&state&frame='
.
$GLOBALS
[
FRAMES_WAIT
];
// or use IP_MASTER?
$resp
=
file_get_contents
(
$url
);
$spos
=
strpos
(
$resp
,
'<left>'
)
+
strlen
(
'<left>'
);
$epos
=
strpos
(
$resp
,
'</left>'
,
$spos
);
...
...
@@ -884,10 +947,11 @@ EOT;
$sensor_port
=
0
;
$urls
=
array
();
// stop all started cameras, including started-only, but not inactive. TODO - add inactive to skip initialization?
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
>
0
){
// 0 - do not use this camera at all
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
// for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] > 0){ // 0 - do not use this camera at all
foreach
(
$GLOBALS
[
IP_CAMERAS
]
as
$ip
)
{
// already filtered
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$ip
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$ip
];
//indexed by IPs
$url
.=
'&frame=0&duration=0'
;
// immediately stop compressors, do not use daemon
$urls
[]
=
$url
;
}
...
...
@@ -907,7 +971,7 @@ EOT;
/// if (($left_frames > 0) && !$abort_sequence){
if
(
$left_frames
>
0
)
{
// skip some frames as there is nothing to do
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IPS
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IP_LWIR
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
}
$abort_sequence
=
0
;
...
...
@@ -919,7 +983,6 @@ EOT;
$run_ffc
=
true
;
$GLOBALS
[
LAST_FFC
]
=
$now
;
}
// $result = runCapture($run_ffc, false, $GLOBALS[$GLOBALS[DEBUG]]);
$result
=
runCapture
(
$run_ffc
,
false
,
$need_service
,
$GLOBALS
[
DEBUG
]);
$need_service
=
0
;
$GLOBALS
[
SEQUENCE_NUM
]
++
;
...
...
@@ -932,16 +995,18 @@ EOT;
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- idle: need_service=
$need_service
: ---
\n
"
);
}
if
(
$need_service
)
{
// need to stop those that were continuously running. FIXME: now will not wor if all are continuously running
if
(
$need_service
)
{
// need to stop those that were continuously running. FIXME: now will not wor
k
if all are continuously running
$sensor_port
=
0
;
$urls
=
array
();
// stop all continuously run cameras, but not inactive. TODO - add inactive to skip initialization?
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
==
2
)
{
// only continuously running
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
$url
.=
'&frame=0&duration=0'
;
// immediately stop compressors, do not use daemon
$urls
[]
=
$url
;
//for ($i = 0; $i<count($GLOBALS[IPS]); $i++) if ($GLOBALS[RUN_MODES][$GLOBALS[IPS][$i]] ==2) { // only continuously running
foreach
(
$GLOBALS
[
IP_CAMERAS
]
as
$ip
)
{
if
(
$GLOBALS
[
RUN_MODES
][
$ip
]
&
RUN_MODE_CONT
)
{
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
$url
.=
'&frame=0&duration=0'
;
// immediately stop compressors, do not use daemon
$urls
[]
=
$url
;
}
}
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- stopping continuously running cameras: URLs:
\n
"
);
...
...
@@ -963,7 +1028,7 @@ EOT;
$need_service
=
0
;
}
// skip some frames as there is nothing to do
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IP
S
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IP
_LWIR
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
}
}
if
(
$GLOBALS
[
DEBUG
]){
...
...
@@ -1016,6 +1081,7 @@ EOT;
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
=
0
;
}
}
setIPs
();
// set ip arrays ($GLOBALS[IP_LWIR], ...) that depend on RUN_MODES
}
if
(
isset
(
$arr
[
DURATION
])){
$GLOBALS
[
DURATION
]
=
(
int
)
$arr
[
DURATION
];
...
...
@@ -1277,5 +1343,30 @@ EOT;
$camera_state
=
parse_ini_file
(
$camera_state_file
);
return
$camera_state
[
'state'
];
}
function
setIPs
(){
$GLOBALS
[
IP_LWIR
]
=
array
();
$GLOBALS
[
IP_EO
]
=
array
();
$GLOBALS
[
IP_CAMERAS
]
=
array
();
$GLOBALS
[
IP_MASTER
]
=
array
();
// normally just one, use [0]
$GLOBALS
[
IP_IMS
]
=
array
();
// normally just one, use [0]
foreach
(
$GLOBALS
[
RUN_MODES
]
as
$ip
=>
$smode
){
$mode
=
intval
(
$smode
);
// just in case, should already be integer
if
(
$mode
&
RUN_MODE_MASTER
)
{
$GLOBALS
[
IP_MASTER
][]
=
$ip
;
// use [0]
}
if
(
$mode
&
RUN_MODE_LWIR
)
{
$GLOBALS
[
IP_LWIR
][]
=
$ip
;
$GLOBALS
[
IP_CAMERAS
][]
=
$ip
;
}
if
(
$mode
&
RUN_MODE_EO
)
{
$GLOBALS
[
IP_EO
][]
=
$ip
;
$GLOBALS
[
IP_CAMERAS
][]
=
$ip
;
}
if
(
$mode
&
RUN_MODE_IMS
)
{
$GLOBALS
[
IP_IMS
]
=
$ip
;
}
}
}
?>
src/lwir16/multicamconf.xml
deleted
100644 → 0
View file @
edaa3147
<?xml version="1.0" encoding="iso-8859-1"?>
<multicam>
<ips>
192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45
</ips>
<port_masks>
15,15,15,15,15
</port_masks>
<multicam_dir>
office_04
</multicam_dir>
<multicam_rperiod>
5
</multicam_rperiod>
<multicam_speriod>
10
</multicam_speriod>
<multicam_conf>
/etc/elphel393/multicamconf.xml
</multicam_conf>
</multicam>
src/multicam/multicam3.js
View file @
97346989
// port class
const
CAM_MODE_LWIR
=
1
;
const
CAM_MODE_EO
=
2
;
const
CAM_MODE_IMS
=
4
;
const
CAM_MODE_CONT
=
8
;
const
CAM_MODE_MASTER
=
16
;
const
CAM_MODE_RAWREC
=
32
;
var
Port
=
function
(
options
){
var
defaults
=
{
...
...
@@ -60,7 +68,8 @@ var Camera = function(options){
recording
:
false
,
mounted
:
false
,
restarts
:
0
,
ports
:
[]
ports
:
[],
mode
:
0
};
this
.
_data
=
$
.
extend
(
defaults
,
options
);
...
...
@@ -69,8 +78,27 @@ var Camera = function(options){
this
.
init
=
this
.
_data
.
init
;
this
.
status
=
this
.
_data
.
status
;
this
.
ports
=
this
.
_data
.
ports
;
this
.
is_lwir
=
function
(){
return
(
this
.
mode
&
CAM_MODE_LWIR
)
!=
0
;
};
this
.
is_eo
=
function
(){
return
(
this
.
mode
&
CAM_MODE_EO
)
!=
0
;
};
this
.
is_ims
=
function
(){
return
(
this
.
mode
&
CAM_MODE_IMS
)
!=
0
;
};
this
.
is_cont
=
function
(){
return
(
this
.
mode
&
CAM_MODE_CONT
)
!=
0
;
};
this
.
is_master
=
function
(){
return
(
this
.
mode
&
CAM_MODE_MASTER
)
!=
0
;
};
this
.
is_raw
=
function
(){
return
(
this
.
mode
&
CAM_MODE_RAWREC
)
!=
0
;
};
this
.
is_camera
=
function
(){
return
this
.
is_lwir
()
||
this
.
is_eo
();
};
};
// global
...
...
@@ -87,7 +115,7 @@ var record_en = 0;
var
multicam_dir
=
""
;
var
multicam_rperiod
=
5.0
;
// image refresh period
var
multicam_speriod
=
2.0
;
// status refresh period
var
use_file_system
=
0
;
// 1; // no fast recording
//
var use_file_system = 0; // 1; // no fast recording
var
rec_running_intvl
;
var
refresh_status_intvl
;
var
refresh_previews_intvl
;
...
...
@@ -149,9 +177,15 @@ function init1(){
var
ips
=
$
(
response
).
find
(
"ip"
);
ips
.
each
(
function
(){
console
.
log
(
'index='
+
(
$
(
this
).
attr
(
"index"
))
+
", text="
+
$
(
this
).
text
());
let
run_mode
=
parseInt
(
$
(
this
).
attr
(
"run_modes"
).
replace
(
/"/gm
,
''
));
cams
[
$
(
this
).
attr
(
"index"
)]
=
new
Camera
({
ip
:
$
(
this
).
text
()});
cams
[
$
(
this
).
attr
(
"index"
)].
mode
=
run_mode
;
console
.
log
(
cams
[
$
(
this
).
attr
(
"index"
)]);
console
.
log
(
"is_camera="
+
cams
[
$
(
this
).
attr
(
"index"
)].
is_camera
());
console
.
log
(
"mode="
+
cams
[
$
(
this
).
attr
(
"index"
)].
mode
);
console
.
log
(
"run_mode="
+
run_mode
);
});
console
.
log
(
'Got IPs from master camera config, ips.length='
+
ips
.
length
);
console
.
log
(
'Got IPs
, masks and run_modes
from master camera config, ips.length='
+
ips
.
length
);
init2
();
// should be done only after request responce!
}
});
...
...
@@ -176,7 +210,7 @@ function init2(){
function
get_ports
(){
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
)
{
//} if (cams[i].is_camera())
{
console
.
log
(
"get_ports():"
+
i
);
$
.
ajax
({
url
:
"http://"
+
cams
[
i
].
ip
+
"/multicam/multicam3.php?cmd=ports"
,
...
...
@@ -199,6 +233,7 @@ function get_ports(){
});
// check camogm is alive
check_camogm
(
index
);
console
.
log
(
"Got ports for "
+
this
.
index
+
" "
+
cams
[
this
.
index
].
ip
+
" (ports.length="
+
ports
.
length
);
init3
(
index
);
...
...
@@ -256,7 +291,8 @@ function camogm_launch(cam_i){
}
function
check_camogm_status
(
cam_i
){
// full check, slow
if
(
use_file_system
)
{
// console.log(cam_i);
if
(
!
(
cams
[
cam_i
].
is_raw
()))
{
// }use_file_system) {
// console.log("check_camogm_status("+cam_i+")1, use_file_system="+use_file_system);
$
.
ajax
({
url
:
"http://"
+
cams
[
cam_i
].
ip
+
"/camogm_interface.php?cmd=state"
,
// shorter version, just state
...
...
@@ -275,14 +311,50 @@ function check_camogm_status(cam_i){ // full check, slow
}
}
}).
fail
(
function
(
data
,
status
){
console
.
log
(
"check_camogm_status()
use_file_system
: status request failed)."
);
//CORS
console
.
log
(
"check_camogm_status(): status request failed)."
);
//CORS
console
.
log
(
data
);
// CORS
console
.
log
(
status
);
console
.
log
(
cam_i
);
});
}
else
{
// raw file system
console
.
log
(
"check_camogm_status("
+
cam_i
+
")2, use_file_system="
+
use_file_system
);
console
.
log
(
"check_camogm_status("
+
cam_i
+
")2, use_file_system="
+!
cams
[
cam_i
].
is_raw
());
// use_file_system);
check_camogm_raw_space
(
cam_i
);
}
}
function
check_camogm_free_space
(
cam_i
){
// file system, no raw
$
.
ajax
({
url
:
"http://"
+
cams
[
cam_i
].
ip
+
"/camogm_interface.php?cmd=get_hdd_space"
,
cam_i
:
cam_i
,
success
:
function
(
res
){
var
cam
=
cams
[
this
.
cam_i
];
// console.log("check_camogm_free_space for "+cam_i+" success");
if
(
$
(
res
).
find
(
'get_hdd_space'
).
length
!=
0
){
var
free_space
=
parseInt
(
$
(
res
).
find
(
'get_hdd_space'
).
text
());
var
sdd_found
=
free_space
>
0
;
cam
.
mounted
=
sdd_found
;
free_space
/=
1024
*
1024
*
1024
;
free_space
=
Math
.
round
(
100
*
free_space
)
/
100
;
var
se
=
$
(
"#display_status"
).
find
(
"tr[ip='"
+
cam
.
ip
+
"']"
);
// device
se
.
find
(
"#s_device"
).
html
(
multicam_dir
);
// free space
se
.
find
(
"#s_space"
).
html
(
free_space
+
" GB"
);
var
bgcol
=
sdd_found
?
"rgb(200, 255, 200)"
:
"rgb(255, 100,100)"
;
// add yellow for low space
se
.
find
(
"#s_space"
).
attr
(
"style"
,
"background-color:"
+
bgcol
+
";"
);
console
.
log
(
"hdd: "
+
cam
.
ip
+
", mounted="
+
cam
.
mounted
);
}
}
}).
fail
(
function
(
data
,
status
){
console
.
log
(
"check_camogm_free_space("
+
cam_i
+
")status request failed)."
);
console
.
log
(
data
);
console
.
log
(
status
);
console
.
log
(
cam_i
);
});
}
function
check_camogm_raw_space
(
cam_i
){
// raw file system
console
.
log
(
"check_camogm_status("
+
cam_i
+
")2, use_file_system="
+!
cams
[
cam_i
].
is_raw
());
// use_file_system);
$
.
ajax
({
url
:
"http://"
+
cams
[
cam_i
].
ip
+
"/camogm_interface.php?cmd=status"
,
cam_i
:
cam_i
,
...
...
@@ -347,38 +419,8 @@ function check_camogm_status(cam_i){ // full check, slow
});
}
}
function
check_camogm_free_space
(
cam_i
){
// file system, no raw
$
.
ajax
({
url
:
"http://"
+
cams
[
cam_i
].
ip
+
"/camogm_interface.php?cmd=get_hdd_space"
,
cam_i
:
cam_i
,
success
:
function
(
res
){
var
cam
=
cams
[
this
.
cam_i
];
// console.log("check_camogm_free_space for "+cam_i+" success");
if
(
$
(
res
).
find
(
'get_hdd_space'
).
length
!=
0
){
var
free_space
=
parseInt
(
$
(
res
).
find
(
'get_hdd_space'
).
text
());
var
sdd_found
=
free_space
>
0
;
cam
.
mounted
=
sdd_found
;
free_space
/=
1024
*
1024
*
1024
;
free_space
=
Math
.
round
(
100
*
free_space
)
/
100
;
var
se
=
$
(
"#display_status"
).
find
(
"tr[ip='"
+
cam
.
ip
+
"']"
);
// device
se
.
find
(
"#s_device"
).
html
(
multicam_dir
);
// free space
se
.
find
(
"#s_space"
).
html
(
free_space
+
" GB"
);
var
bgcol
=
sdd_found
?
"rgb(200, 255, 200)"
:
"rgb(255, 100,100)"
;
// add yellow for low space
se
.
find
(
"#s_space"
).
attr
(
"style"
,
"background-color:"
+
bgcol
+
";"
);
console
.
log
(
"hdd: "
+
cam
.
ip
+
", mounted="
+
cam
.
mounted
);
}
}
}).
fail
(
function
(
data
,
status
){
console
.
log
(
"check_camogm_free_space("
+
cam_i
+
")status request failed)."
);
console
.
log
(
data
);
console
.
log
(
status
);
console
.
log
(
cam_i
);
});
}
var
all_ready_init_run
=
true
;
...
...
@@ -389,7 +431,7 @@ function rec_button_update_state(){
var
any_running
=
false
;
var
any_stopped
=
false
;
const
elapsed_millis
=
Date
.
now
()
-
start_date
;
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
)
if
(
cams
[
i
].
is_camera
()){
// only test cameras, not IMS
if
(
cams
[
i
].
init
){
if
((
cams
[
i
].
camogm
==
'on'
)
&&
(
!
cams
[
i
].
recording
)){
all_ready
=
false
;
...
...
@@ -408,7 +450,7 @@ function rec_button_update_state(){
if
(
any_running
&&
any_stopped
){
console
.
log
(
"WARNING: some camogms are running, some are stopped, time="
+
(
elapsed_millis
/
1000
)
+
"s"
);
// false
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
)
if
(
cams
[
i
].
is_camera
())
{
console
.
log
(
i
+
": "
+
cams
[
i
].
recording
);
}
}
...
...
@@ -447,10 +489,10 @@ function startStopRefresh (){
refresh_previews_intvl
=
setInterval
(
refresh_previews
,
multicam_rperiod
*
1000
);
refresh_previews
();
// first time - immediately
}
console
.
log
(
"setInterval(refresh_previews_intvl); refresh_previews_intvl="
+
refresh_previews_intvl
+
', period='
+
(
multicam_rperiod
*
1000
));
console
.
log
(
"setInterval(refresh_previews_intvl); refresh_previews_intvl="
+
refresh_previews_intvl
+
', period='
+
(
multicam_rperiod
*
1000
)
+
" recording="
+
recording
);
}
else
{
clearInterval
(
refresh_previews_intvl
);
console
.
log
(
"clearInterval(refresh_previews_intvl); refresh_previews_intvl="
+
refresh_previews_intvl
);
console
.
log
(
"clearInterval(refresh_previews_intvl); refresh_previews_intvl="
+
refresh_previews_intvl
+
" recording="
+
recording
);
refresh_previews_intvl
=
null
;
blankBackground
(
$
(
'#display_previews'
));
}
...
...
@@ -589,40 +631,41 @@ function init3(index){
var
img_str
=
""
;
var
hst_str
=
""
;
console
.
log
(
cam
);
if
(
cam
.
is_camera
())
{
for
(
var
i
=
0
;
i
<
cam
.
ports
.
length
;
i
++
){
//img_src = 'http://'+cam.ip+':'+cam.ports[i].port+'/img?'+ts;
//hst_src = 'http://'+cam.ip+'/pnghist.cgi?sensor_port='+cam.ports[i].index+'&sqrt=1&scale=5&average=5&height=128&fillz=1&linterpz=0&draw=2&colors=41&_time='+ts;
img_str
+=
[
' <td>'
,
' <div class=
\'
port_preview
\'
index=
\'
'
+
i
+
'
\'
></div>'
,
' </td>'
].
join
(
'
\
n'
);
hst_str
+=
[
' <td>'
,
' <img class=
\'
hist_preview
\'
index=
\'
'
+
i
+
'
\'
/>'
,
' </td>'
].
join
(
'
\
n'
);
}
for
(
var
i
=
0
;
i
<
cam
.
ports
.
length
;
i
++
){
//img_src = 'http://'+cam.ip+':'+cam.ports[i].port+'/img?'+ts;
//hst_src = 'http://'+cam.ip+'/pnghist.cgi?sensor_port='+cam.ports[i].index+'&sqrt=1&scale=5&average=5&height=128&fillz=1&linterpz=0&draw=2&colors=41&_time='+ts;
img_str
+=
[
' <td>'
,
' <div class=
\'
port_preview
\'
index=
\'
'
+
i
+
'
\'
></div>'
,
' </td>'
].
join
(
'
\
n'
);
hst_str
+=
[
' <td>'
,
' <img class=
\'
hist_preview
\'
index=
\'
'
+
i
+
'
\'
/>'
,
' </td>'
].
join
(
'
\
n'
);
var
display_str
=
[
' <tr>'
,
' <td class="ip_text">'
+
cam
.
ip
+
':</td>'
,
' </tr>'
,
' <tr>'
,
img_str
,
' </tr>'
,
' <tr>'
,
hst_str
,
' </tr>'
].
join
(
'
\
n'
);
$
(
"#display_previews"
).
find
(
"table[ip=
\
'"
+
cam
.
ip
+
"
\
']"
).
html
(
$
(
display_str
));
}
var
display_str
=
[
' <tr>'
,
' <td class="ip_text">'
+
cam
.
ip
+
':</td>'
,
' </tr>'
,
' <tr>'
,
img_str
,
' </tr>'
,
' <tr>'
,
hst_str
,
' </tr>'
].
join
(
'
\
n'
);
$
(
"#display_previews"
).
find
(
"table[ip=
\
'"
+
cam
.
ip
+
"
\
']"
).
html
(
$
(
display_str
));
// and status
var
status_str
=
[
'<td id=
\'
s_ip
\'
>'
+
cam
.
ip
+
'</td>'
,
...
...
@@ -635,6 +678,16 @@ function init3(index){
].
join
(
'
\
n'
);
$
(
"#display_status"
).
find
(
"tr[ip=
\
'"
+
cam
.
ip
+
"
\
']"
).
html
(
$
(
status_str
));
var
bgcol
=
"rgb(255, 255, 255)"
;
if
(
cam
.
is_lwir
())
{
bgcol
=
"rgb(255, 235, 235)"
;
}
else
if
(
cam
.
is_eo
())
{
bgcol
=
"rgb(235, 255, 235)"
;
}
else
if
(
cam
.
is_ims
())
{
bgcol
=
"rgb(235, 235, 255)"
;
}
$
(
"#display_status"
).
find
(
"tr[ip=
\
'"
+
cam
.
ip
+
"
\
']"
).
attr
(
"style"
,
"background-color:"
+
bgcol
+
";"
);
}
...
...
@@ -729,8 +782,21 @@ function init_rec_button(){
// recording = !recording;
// rec_button_switch(recording);
if
(
recording
){
// simple, always works
url
=
"camogm_interface.php?cmd=stop"
;
multi_ajax
(
url
,
function
(
res
){
var
urls
=
[];
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
is_camera
())
{
// only run camogm for cameras
url
=
cams
[
i
].
ip
+
"/camogm_interface.php?cmd=stop"
;
console
.
log
(
"Stopping url = "
+
url
);
urls
.
push
(
url
);
}
else
if
(
cams
[
i
].
is_ims
())
{
// only run camogm for cameras
url
=
cams
[
i
].
ip
+
"/logger_launcher.php?cmd=stop"
;
console
.
log
(
"Stopping url = "
+
url
);
urls
.
push
(
url
);
}
}
// url = "camogm_interface.php?cmd=stop";
// multi_ajax(url,function(res){
multi_ajax_urls
(
urls
,
function
(
res
){
console
.
log
(
this
.
ip
+
": rec = "
+
recording
);
});
recording
=
0
;
...
...
@@ -747,24 +813,40 @@ function init_rec_button(){
recording
=
1
;
rec_button_switch
(
recording
);
// mkdir for recording
if
(
use_file_system
){
url
=
"camogm_interface.php?cmd=dir_prefix&name="
+
multicam_dir
;
console
.
log
(
"Setting camogm directory/prefix, url="
+
url
);
}
else
{
url
=
"camogm_interface.php?cmd=set_prefix_raw&prefix="
+
multicam_dir
;
console
.
log
(
"Setting camogm raw prefix, url="
+
url
);
}
multi_ajax
(
url
,
function
(){
console
.
log
(
"starting recording in the camera "
+
this
.
ip
+
" to "
+
multicam_dir
);
var
urls
=
[];
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
is_camera
())
{
// only run camogm for cameras
if
(
cams
[
i
].
is_raw
())
{
url
=
cams
[
i
].
ip
+
"/camogm_interface.php?cmd=set_prefix_raw&prefix="
+
multicam_dir
;
console
.
log
(
"Starting url = "
+
url
);
}
else
{
url
=
cams
[
i
].
ip
+
"/camogm_interface.php?cmd=dir_prefix&name="
+
multicam_dir
;
console
.
log
(
"Starting url = "
+
url
);
}
urls
.
push
(
url
);
}
else
if
(
cams
[
i
].
is_ims
()
&&
!
cams
[
i
].
is_raw
())
{
// ims and not raw
url
=
cams
[
i
].
ip
+
"/logger_launcher.php?cmd=start&logger_dir="
+
multicam_dir
;
console
.
log
(
"Starting url = "
+
url
);
urls
.
push
(
url
);
}
}
multi_ajax_urls
(
urls
,
function
(){
console
.
log
(
"starting recording in the camera "
+
this
.
ip
+
" to "
+
multicam_dir
);
// find camera type by IP
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
)
{
if
(
cams
[
i
].
ip
==
this
.
ip
)
{
if
(
!
cams
[
i
].
is_camera
())
{
console
.
log
(
this
.
ip
+
": is IMS, no need for the second command"
);
return
;
}
}
}
// launch recording
$
.
ajax
({
url
:
"http://"
+
this
.
ip
+
"/"
+
"camogm_interface.php?cmd=start"
,
ip
:
this
.
ip
,
success
:
function
(
res
){
console
.
log
(
this
.
ip
+
": rec = "
+
recording
);
// got false on 41?
// recording = 1;
// rec_button_switch(recording);
console
.
log
(
"Started recording "
+
this
.
ip
+
": rec = "
+
recording
);
// got false on 41?
}
// multi_ajax function
});
// ajax
});
//multi_ajax
...
...
@@ -785,7 +867,8 @@ function rec_button_switch(state){
//$(".rec_inner").removeClass("rec_inner_running");
rec_running
(
false
);
}
console
.
log
(
"will update refresh"
);
startStopRefresh
();
}
...
...
@@ -822,24 +905,30 @@ function addrs_create_tables(){
'</table>'
].
join
(
'
\
n'
));
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
var
tbl
=
[
'<div>'
,
' <table ip=
\'
'
+
cams
[
i
].
ip
+
'
\'
>'
,
' </table>'
,
'</div>'
].
join
(
'
\
n'
);
$
(
"#display_previews"
).
append
(
$
(
tbl
));
var
tbl_row
=
[
'<tr ip=
\'
'
+
cams
[
i
].
ip
+
'
\'
>'
,
'</tr>'
].
join
(
'
\
n'
);
$
(
"#display_status"
).
find
(
"table"
).
append
(
$
(
tbl_row
));
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
)
{
if
(
cams
[
i
].
is_camera
())
{
console
.
log
(
"Initializing preview for camera "
+
i
);
var
tbl
=
[
'<div>'
,
' <table ip=
\'
'
+
cams
[
i
].
ip
+
'
\'
>'
,
' </table>'
,
'</div>'
].
join
(
'
\
n'
);
$
(
"#display_previews"
).
append
(
$
(
tbl
));
}
if
(
cams
[
i
].
is_camera
()
||
cams
[
i
].
is_ims
())
{
console
.
log
(
"Initializing status for camera or IMS "
+
i
);
var
tbl_row
=
[
'<tr ip=
\'
'
+
cams
[
i
].
ip
+
'
\'
>'
,
'</tr>'
].
join
(
'
\
n'
);
$
(
"#display_status"
).
find
(
"table"
).
append
(
$
(
tbl_row
));
}
}
}
function
addrs_ips2addrs
(){
$
(
"#addrs"
).
html
(
""
);
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
...
...
@@ -869,6 +958,7 @@ function addrs_ips2ta(){
}
str
=
arr
.
join
(
"
\n
"
);
$
(
"#eai_text"
).
val
(
str
);
addrs_ips2addrs
();
...
...
@@ -912,14 +1002,21 @@ function init_awb_toggle(){
wb_en
=
1
;
}
button_switch
(
$
(
this
),
wb_en
);
var
urls
=
[];
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
is_eo
())
{
// only run camogm for EO cameras
url
=
cams
[
i
].
ip
+
"/parsedit.php?immediate&sensor_port=0&WB_EN="
+
wb_en
+
"&*WB_EN=0xf"
urls
.
push
(
url
);
}
}
multi_ajax_urls
(
urls
,
function
(){
// will it work without port 0?
url
=
"parsedit.php?immediate&sensor_port=0&WB_EN="
+
wb_en
+
"&*WB_EN=0xf"
;
multi_ajax
(
url
,
function
(
res
){
// url = "parsedit.php?immediate&sensor_port=0&WB_EN="+wb_en+"&*WB_EN=0xf";
// multi_ajax(url,function(res){
console
.
log
(
this
.
ip
+
": awb "
+
wb_en
);
},
'mt9p006'
);
//
}, 'mt9p006');
});
// no need to filter
});
}
...
...
@@ -982,11 +1079,21 @@ function updateAexpExpQuality(){
var
exp_us
=
Math
.
round
(
1000
*
exp_ms
);
quality
=
Math
.
round
(
$
(
'#jpeg_quality'
).
val
());
var
exp_us
=
Math
.
round
(
1000
*
exp_ms
);
url
=
"parsedit.php?immediate&sensor_port=0&AUTOEXP_ON="
+
aexp_en
+
"&*AUTOEXP_ON=0xf&EXPOS="
+
exp_us
+
"&*EXPOS=0xf&QUALITY="
+
quality
+
"&*QUALITY=0xf"
;
console
.
log
(
"updateAexpExpQuality(): url="
+
url
);
multi_ajax
(
url
,
function
(
res
){
var
urls
=
[];
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
is_eo
())
{
// only run camogm for EO cameras
url
=
cams
[
i
].
ip
+
"/parsedit.php?immediate&sensor_port=0&AUTOEXP_ON="
+
aexp_en
+
"&*AUTOEXP_ON=0xf&EXPOS="
+
exp_us
+
"&*EXPOS=0xf&QUALITY="
+
quality
+
"&*QUALITY=0xf"
;
urls
.
push
(
url
);
}
}
multi_ajax_urls
(
urls
,
function
(){
// url = "parsedit.php?immediate&sensor_port=0&AUTOEXP_ON="+aexp_en+"&*AUTOEXP_ON=0xf&EXPOS="+exp_us+"&*EXPOS=0xf&QUALITY="+quality+"&*QUALITY=0xf";
// console.log("updateAexpExpQuality(): url="+url);
// multi_ajax(url,function(res){
console
.
log
(
this
.
ip
+
": "
+
aexp_en
);
},
'mt9p006'
);
// }, 'mt9p006');
});
// no need to filter
}
...
...
@@ -1007,6 +1114,42 @@ function multi_ajax(url,callback,sensor_type=""){
}
}
/*
first - XOR mode
then check all must bits are set
then check that any of any bits are set
*/
function
multi_ajax_xma
(
url
,
callback
,
xor
,
must
=
0
,
any
=
0
){
console
.
log
(
"multi_ajax_xma(): url="
+
url
+
", xor="
+
xor
+
", must="
+
must
+
", any="
+
any
);
let
filter
=
(
xor
|
must
|
any
)
!=
0
;
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
status
){
let
cx
=
cam
[
i
].
mode
^
xor
;
if
(
!
filter
||
(((
cx
&
must
)
==
must
)
&&
((
cx
&
any
)
!=
0
)
))
{
$
.
ajax
({
url
:
"http://"
+
cams
[
i
].
ip
+
"/"
+
url
,
ip
:
cams
[
i
].
ip
,
success
:
callback
});
}
}
}
}
/*
Provide array of URLs, urls start from ip.
*/
function
multi_ajax_urls
(
urls
,
callback
){
console
.
log
(
"multi_ajax_url()"
);
for
(
var
i
=
0
;
i
<
urls
.
length
;
i
++
){
$
.
ajax
({
url
:
"http://"
+
urls
[
i
],
ip
:
urls
[
i
].
substring
(
0
,
urls
[
i
].
indexOf
(
'/'
)),
success
:
callback
});
}
}
function
initBosonFFC
(){
console
.
log
(
"initBosonFFC()"
);
for
(
var
ffc_name
in
boson_ffc
)
{
...
...
@@ -1024,13 +1167,21 @@ function updateBosonFFC(ffc_name) {
boson_ffc
[
ffc_name
]
=
(
in_type
==
'text'
)
?
(
$
(
'#'
+
ffc_name
).
val
()):
((
$
(
'#'
+
ffc_name
).
is
(
':checked'
))?
1
:
0
);
console
.
log
(
"updateBosonFFC(): ffc_name="
+
ffc_name
+
": "
+
boson_ffc
[
ffc_name
]
+
" val="
+
(
$
(
'#'
+
ffc_name
).
val
()
+
" type="
+
(
$
(
'#'
+
ffc_name
).
attr
(
"type"
))
));
var
sensor_reg
=
"SENSOR_REGS"
+
BOSON_FFCS_REG
[
ffc_name
];
url
=
"parsedit.php?immediate&sensor_port=0&"
+
sensor_reg
+
"="
+
boson_ffc
[
ffc_name
]
+
"&*"
+
sensor_reg
+
"=0xf"
;
console
.
log
(
"updateBosonFFC(): url="
+
url
);
multi_ajax
(
url
,
function
(
res
){
var
urls
=
[];
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
is_lwir
())
{
// only for LWIR cameras
url
=
cams
[
i
].
ip
+
"/parsedit.php?immediate&sensor_port=0&"
+
sensor_reg
+
"="
+
boson_ffc
[
ffc_name
]
+
"&*"
+
sensor_reg
+
"=0xf"
;
urls
.
push
(
url
);
}
}
multi_ajax_urls
(
urls
,
function
(){
// url = "parsedit.php?immediate&sensor_port=0&"+sensor_reg+"="+boson_ffc[ffc_name]+"&*"+sensor_reg+"=0xf";
// console.log("updateBosonFFC(): url="+url);
// multi_ajax(url,function(res){
console
.
log
(
this
.
ip
+
": "
+
url
);
},
'boson640'
);
// }, 'boson640');
});
// no need to filter
// TODO: add FFC command after changes? Need to spread not to overpower
}
...
...
@@ -1053,7 +1204,6 @@ function init_snapshot_button(){
},
'mt9p006'
);
// download images
});
}
function
snapshot_find_latest_ts
(
ptrs
){
...
...
@@ -1448,24 +1598,34 @@ function updateConfifs(){ // write modified settings to the master camera persis
}
function
setDirMulti
(){
// url = "camogm_interface.php?cmd=dir_prefix&name=" + multicam_dir;
if
(
use_file_system
){
url
=
"camogm_interface.php?cmd=set_prefix&prefix="
+
multicam_dir
;
// can not mkdir before mounted
}
else
{
url
=
"camogm_interface.php?cmd=set_prefix_raw&prefix="
+
multicam_dir
;
// can not mkdir before mounted
}
console
.
log
(
"setDirMulti(), url="
+
url
);
multi_ajax
(
url
,
function
(){
var
urls
=
[];
for
(
var
i
=
0
;
i
<
cams
.
length
;
i
++
){
if
(
cams
[
i
].
is_camera
())
{
// only run camogm for cameras
if
(
cams
[
i
].
is_raw
())
{
url
=
cams
[
i
].
ip
+
"/camogm_interface.php?cmd=set_prefix_raw&prefix="
+
multicam_dir
;
}
else
{
url
=
cams
[
i
].
ip
+
"/camogm_interface.php?cmd=dir_prefix&name="
+
multicam_dir
;
}
urls
.
push
(
url
);
}
}
// console.log("setDirMulti(), url="+url);
multi_ajax_urls
(
urls
,
function
(){
// if (use_file_system ){
// url = "camogm_interface.php?cmd=set_prefix&prefix=" + multicam_dir; // can not mkdir before mounted
// } else {
// url = "camogm_interface.php?cmd=set_prefix_raw&prefix=" + multicam_dir; // can not mkdir before mounted
// }
// multi_ajax(url,function(){
console
.
log
(
this
.
ip
+
": prefix "
+
multicam_dir
+
", url="
+
url
);
});
}
var
appply_pending
=
0
;
function
setDirSingle
(
cam_i
){
// set recording directory for one camera (after starting camogm), request status
console
.
log
(
"setDirSingle("
+
cam_i
+
"):"
+
multicam_dir
+
"use_file_system="
+
use_file_system
);
if
(
use_file_system
){
console
.
log
(
"setDirSingle("
+
cam_i
+
"):"
+
multicam_dir
+
"use_file_system="
+
!
cams
[
cam_i
].
is_raw
()
);
if
(
!
cams
[
cam_i
].
is_raw
())
{
//}
use_file_system ){
$
.
ajax
({
// url: "http://"+cams[cam_i].ip+"/camogm_interface.php?cmd=dir_prefix&name=" + multicam_dir, // should never be done before partition is mounted!
url
:
"http://"
+
cams
[
cam_i
].
ip
+
"/camogm_interface.php?cmd=SET_prefix&name="
+
multicam_dir
,
// can not mkdir before mounted
cam_i
:
cam_i
,
success
:
function
(){
...
...
src/multicam/multicam3.php
View file @
97346989
...
...
@@ -4,6 +4,15 @@ include "../include/elphel_functions_include.php";
define
(
'CONF_LWIR16'
,
'/etc/elphel393/lwir16.ini'
);
define
(
'IPS'
,
'ips'
);
define
(
'PORT_MASKS'
,
'port_masks'
);
define
(
'RUN_MODES'
,
'run_modes'
);
// OR-ed: 49 - master LWIR RAW, 33 - slave LWIR RAW, 42 - continuously-run slave EO RAW, 4 - slave IMS logger, file system
define
(
'RUN_MODE_LWIR'
,
1
);
define
(
'RUN_MODE_EO'
,
2
);
define
(
'RUN_MODE_IMS'
,
4
);
define
(
'RUN_MODE_CONT'
,
8
);
// continuously run from start to stop
define
(
'RUN_MODE_MASTER'
,
16
);
define
(
'RUN_MODE_RAWREC'
,
32
);
// raw recording, 0 - use file system
define
(
'NUM_PORTS'
,
4
);
define
(
'IMGSRV_PORT0'
,
2323
);
define
(
'PORTSPATH'
,
'/sys/devices/soc0/elphel393-detect_sensors@0'
);
...
...
@@ -18,30 +27,6 @@ if (isset($_GET['cmd']))
else
if
(
isset
(
$argv
[
1
]))
$cmd
=
$argv
[
1
];
///$ini = parse_ini_file(CONF_LWIR16);
//$cmd = "donothing";
//$config = "/var/volatile/html/multicam.xml";
// path to sysfs for port scanning
//$portspath = "/sys/devices/soc0/elphel393-detect_sensors@0";
// total number of ports in 10393
//$nports = 4;
//$port0 = 2323;
// extract ip addresses
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
"POST"
){
$list
=
file_get_contents
(
"php://input"
);
}
else
{
if
(
isset
(
$_GET
[
'ip'
])){
$list
=
$_GET
[
'ip'
];
}
else
{
$list
=
$_SERVER
[
'SERVER_ADDR'
];
}
}
$ips
=
explode
(
','
,
$list
);
// allow CORS
header
(
'Access-Control-Allow-Origin: *'
);
...
...
@@ -49,23 +34,15 @@ header('Access-Control-Allow-Origin: *');
// does not need configs
switch
(
$cmd
){
case
"ports"
:
xml_header
();
print
(
getports
());
send_response
(
getports
());
exit
(
0
);
}
getIni
();
// wil exit OK now
//print ("<!--");
//print_r($lwir16_ini);
//print ("-->");
//exit(0);
getIni
();
switch
(
$cmd
){
case
"ips"
:
xml_header
();
print
(
getIps
());
send_response
(
getIps
());
exit
(
0
);
case
"update"
:
foreach
(
$_GET
as
$key
=>
$value
)
{
...
...
@@ -75,29 +52,10 @@ switch($cmd){
}
writeConfig
();
exitXmlOK
();
exit
(
0
);
//
case
"configs"
:
// return xml with all $GLOBALS[MULTICAM_INI]
xml_header
();
print
(
getConfigs
());
send_response
(
getConfigs
());
exit
(
0
);
// obsolete old commands
/*
case "write":
// write
// use get and post requests
write_config($config,$ips);
print("ok");
break;
case "snapshot":
send_zipped_images($ips);
break;
case "read":
default:
// will never need read - config is in http://camip/var/multicam.xml
// read
/// print(file_get_contents($config));
* */
default
:
exitXmlOK
(
"Unknown"
);
}
...
...
@@ -105,13 +63,12 @@ switch($cmd){
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
];
applyConf
(
$ini
);
$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
];
// $GLOBALS[MULTICAM_INI][MULTICAM_CONF] = $ini[MULTICAM_CONF];
$GLOBALS
[
MULTICAM_CONF
]
=
$ini
[
MULTICAM_CONF
];
// copy other default parameters
// try to read xml if exists
$multi_xml
=
0
;
...
...
@@ -126,168 +83,132 @@ function getIni() {
}
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
setIPs
();
}
// encoding='iso-8859-1'
function
writeConfig
(){
$xml
=
"<?xml version=
\"
1.0
\"
encoding=
\"
iso-8859-1
\"
?>
\n
<multicam>
\n
"
;
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><multicam/>"
)
;
foreach
(
$GLOBALS
[
MULTICAM_INI
]
as
$key
=>
$value
){
$xml
.=
"
\t
<"
.
$key
.
'>'
.
$value
.
'</'
.
$key
.
">
\n
"
;
$xml
->
addChild
(
$key
,
$value
)
;
}
$xml
.=
"</multicam>
\n
"
;
file_put_contents
(
$GLOBALS
[
MULTICAM_INI
][
MULTICAM_CONF
],
$xml
);
file_put_contents
(
$GLOBALS
[
MULTICAM_CONF
],
$xml
->
asXML
());
exec
(
'sync'
);
/*
print ("<!--\n");
print("WRITING to ".$GLOBALS[MULTICAM_INI][MULTICAM_CONF]."\n");
print($xml);
print ("-->");
*/
}
function
printToComment
(
$str
)
{
echo
"<!--"
.
$str
.
"-->"
;
}
function
write_config
(
$config
,
$ips
){
$list
=
""
;
foreach
(
$ips
as
$ip
){
$list
.=
"
\t
<camera>
$ip
</camera>
\n
"
;
}
$xml
=
"<?xml version='1.0' encoding=
\"
iso-8859-1
\"
standalone='yes'?>
\n
"
;
$xml
.=
"<Document>
\n
"
;
$xml
.=
$list
;
$xml
.=
"</Document>
\n
"
;
file_put_contents
(
$config
,
$xml
);
return
0
;
}
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
"
;
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><configs/>"
);
$xml
->
addChild
(
MULTICAM_DIR
,
$GLOBALS
[
MULTICAM_INI
][
MULTICAM_DIR
]);
$xml
->
addChild
(
MULTICAM_RPERIOD
,
$GLOBALS
[
MULTICAM_INI
][
MULTICAM_RPERIOD
]);
$xml
->
addChild
(
MULTICAM_SPERIOD
,
$GLOBALS
[
MULTICAM_INI
][
MULTICAM_SPERIOD
]);
return
$xml
;
}
function
getports
(){
$
res
=
"
\t
<camera ip='"
.
$_SERVER
[
'SERVER_ADDR'
]
.
"'>
\n
"
;
$
xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><camera/>"
)
;
for
(
$i
=
0
;
$i
<
NUM_PORTS
;
$i
++
){
$sensor
=
PORTSPATH
.
"/sensor
{
$i
}
0"
;
// the file is always there actually
if
(
is_file
(
$sensor
)){
$c
=
trim
(
file_get_contents
(
$sensor
));
$p
=
IMGSRV_PORT0
+
$i
;
$res
.=
"
\t\t
<port index='
$i
' port='
$p
'>
$c
</port>
\n
"
;
$xp
=
$xml
->
addChild
(
'port'
,
$c
);
$xp
->
addAttribute
(
'index'
,
$i
);
$xp
->
addAttribute
(
'port'
,
$p
);
}
}
$res
.=
"
\t
</camera>
\n
"
;
$xml
.=
"<Document>
\n
"
;
$xml
.=
$res
;
$xml
.=
"</Document>
\n
"
;
return
$xml
;
}
function
getIps
(){
//$GLOBALS[IPS]
$xml
=
"<cameras>
\n
"
;
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><camera/>"
);
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
){
$xml
.=
"
\t
<ip index='
$i
'>"
.
$GLOBALS
[
IPS
][
$i
]
.
"</ip>
\n
"
;
$xp
=
$xml
->
addChild
(
'ip'
,
$GLOBALS
[
IPS
][
$i
]);
$xp
->
addAttribute
(
'index'
,
$i
);
$xp
->
addAttribute
(
PORT_MASKS
,
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]]);
$xp
->
addAttribute
(
RUN_MODES
,
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]);
}
$xml
.=
"</cameras>
\n
"
;
return
$xml
;
}
function
exitXmlOK
(
$str
=
"ok"
){
xml_header
(
);
print
(
'<'
.
$str
.
'/>'
);
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><
$str
/>"
);
send_response
(
$xml
);
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
){
function
applyConf
(
$arr
){
// not used at all
//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
]);
}
if
(
isset
(
$arr
[
RUN_MODES
])){
$run_modes
=
explode
(
','
,
$arr
[
RUN_MODES
]);
}
// Add port masks incdexed by IPs. Changing IPs resets masks
$GLOBALS
[
PORT_MASKS
]
=
array
();
$GLOBALS
[
RUN_MODES
]
=
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
;
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]]
=
ALL_PORTS
;
}
if
(
isset
(
$run_modes
)
&&
(
count
(
$run_modes
)
>
$i
)){
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
=
(
int
)
$run_modes
[
$i
];
}
else
{
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
=
0
;
}
}
setIPs
();
// set ip arrays ($GLOBALS[IP_LWIR], ...) that depend on RUN_MODES
}
/*
if (isset($arr[DURATION])){
$GLOBALS[DURATION] = (int) $arr[DURATION];
$GLOBALS[DURATION_EO] = (int) ($GLOBALS[DURATION]/EO_DECIMATE+1);
}
function
setIPs
(){
$GLOBALS
[
IP_LWIR
]
=
array
();
$GLOBALS
[
IP_EO
]
=
array
();
$GLOBALS
[
IP_CAMERAS
]
=
array
();
$GLOBALS
[
IP_MASTER
]
=
array
();
// normally just one, use [0]
$GLOBALS
[
IP_IMS
]
=
array
();
// normally just one, use [0]
foreach
(
$GLOBALS
[
RUN_MODES
]
as
$ip
=>
$smode
){
$mode
=
intval
(
$smode
);
// just in case, should already be integer
if
(
$mode
&
RUN_MODE_MASTER
)
{
$GLOBALS
[
IP_MASTER
][]
=
$ip
;
// use [0]
}
if
(
$mode
&
RUN_MODE_LWIR
)
{
$GLOBALS
[
IP_LWIR
][]
=
$ip
;
$GLOBALS
[
IP_CAMERAS
][]
=
$ip
;
}
if
(
$mode
&
RUN_MODE_EO
)
{
$GLOBALS
[
IP_EO
][]
=
$ip
;
$GLOBALS
[
IP_CAMERAS
][]
=
$ip
;
}
if
(
$mode
&
RUN_MODE_IMS
)
{
$GLOBALS
[
IP_IMS
]
=
$ip
;
}
}
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_response
(
$xml
){
$rslt
=
$xml
->
asXML
();
header
(
"Content-Type: text/xml"
);
header
(
"Content-Length: "
.
strlen
(
$rslt
)
.
"
\n
"
);
header
(
"Pragma: no-cache
\n
"
);
printf
(
$rslt
);
flush
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment