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
3ed8b3eb
Commit
3ed8b3eb
authored
Jul 04, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
intermediate working versio with debug enabled
parent
5d1ca452
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
366 additions
and
127 deletions
+366
-127
index.html
src/lwir16/index.html
+43
-18
lwir16.ini
src/lwir16/lwir16.ini
+17
-11
lwir16.php
src/lwir16/lwir16.php
+191
-65
Makefile
src/php_top/Makefile
+1
-0
capture_range.php
src/php_top/capture_range.php
+114
-33
No files found.
src/lwir16/index.html
View file @
3ed8b3eb
...
...
@@ -18,12 +18,16 @@ var debug;// = 0;
var
sequence_num
;
// = 0;
var
last_ffc
;
// = 0;
var
time_to_ffc
;
// = 0;
var
left_capture
;
var
capture_run
;
// = 0;
var
capture_wait
;
// wait sequence end to stop
var
capture_wait_was
=
0
;
var
want_run
;
var
request_num
=
0
;
var
update_editable
=
true
;
var
apply_pending
=
false
;
console
.
log
(
"self.location.host="
+
self
.
location
.
host
);
function
parse_response
(
resp
){
var
result
=
""
;
console
.
log
(
"parse_response(), resp="
+
resp
);
...
...
@@ -58,7 +62,7 @@ function send_request(rq,callback){
function
sendStatusRequest
(){
console
.
log
(
"sendStatusRequest()"
);
var
url
=
"http://
192.168.0.41
/lwir16/lwir16.php?daemon=status"
;
var
url
=
"http://
"
+
self
.
location
.
host
+
"
/lwir16/lwir16.php?daemon=status"
;
if
(
apply_pending
)
{
console
.
log
(
"sendStatusRequest(), apply_pending"
);
var
mod_pars
=
modParameters
();
...
...
@@ -74,7 +78,7 @@ function sendStatusRequest(){
function
sendRestartRequest
(){
console
.
log
(
"sendRestartRequest()"
);
var
url
=
"http://
192.168.0.41
/lwir16/lwir16.php?daemon=restart&cmd=STATUS"
;
var
url
=
"http://
"
+
self
.
location
.
host
+
"
/lwir16/lwir16.php?daemon=restart&cmd=STATUS"
;
send_request
(
url
,
parseStatusResponse
);
}
...
...
@@ -145,12 +149,22 @@ function parseStatusResponse(resp){
document
.
getElementById
(
"idtime_to_ffc"
).
value
=
time_to_ffc
;
}
if
(
resp
.
getElementsByTagName
(
"left_capture"
).
length
!=
0
){
left_capture
=
parseFloat
(
resp
.
getElementsByTagName
(
"left_capture"
)[
0
].
childNodes
[
0
].
nodeValue
);
document
.
getElementById
(
"idleft_capture"
).
value
=
left_capture
;
}
if
(
resp
.
getElementsByTagName
(
"capture_run"
).
length
!=
0
){
capture_run
=
parseInt
(
resp
.
getElementsByTagName
(
"capture_run"
)[
0
].
childNodes
[
0
].
nodeValue
);
document
.
getElementById
(
"idcapture_run"
).
checked
=
capture_run
>
0
;
if
(
update_editable
)
{
document
.
getElementById
(
"idStartStop"
).
innerHTML
=
capture_run
?
"Stop"
:
"Start"
;
document
.
getElementById
(
"idStartStop"
).
disabled
=
false
;
if
(
resp
.
getElementsByTagName
(
"capture_wait"
).
length
!=
0
){
capture_wait_was
=
capture_wait
;
capture_wait
=
parseInt
(
resp
.
getElementsByTagName
(
"capture_wait"
)[
0
].
childNodes
[
0
].
nodeValue
);
}
document
.
getElementById
(
"idcapture_run"
).
checked
=
(
capture_run
>
0
)
||
(
capture_wait
>
0
);
// still waiting
// if (update_editable || (want_run != capture_run)) {
if
(
update_editable
||
(
capture_wait_was
&&
!
capture_wait
))
{
document
.
getElementById
(
"idStartStop"
).
innerHTML
=
capture_run
?
"Stop"
:(
capture_wait
?
"Waiting"
:
"Start"
);
document
.
getElementById
(
"idStartStop"
).
disabled
=
capture_wait
;
//false;
want_run
=
capture_run
;
}
}
...
...
@@ -227,6 +241,13 @@ function clickedApply(){
setPending
();
}
function
clickedAbort
(){
setPending
();
want_run
=
false
;
console
.
log
(
"sendAbortRequest()"
);
var
url
=
"http://"
+
self
.
location
.
host
+
"/lwir16/lwir16.php?daemon=status&cmd=ABORT"
;
send_request
(
url
,
parseStatusResponse
);
}
</script>
</head>
...
...
@@ -236,6 +257,7 @@ function clickedApply(){
<tr><td>
<button
id=
"idStartStop"
name =
"nStartStop"
onclick=
"clickedRun()"
disabled=
"true"
>
???
</button>
<button
id=
"idAbort"
name =
"nAbort"
onclick=
"clickedAbort()"
>
Abort
</button>
</td><td>
<button
id=
"idApply"
name =
"nApply"
onclick=
"clickedApply()"
disabled =
"true"
>
???
</button>
</td><td>
</td>
<td>
</td><td>
</td>
...
...
@@ -249,26 +271,26 @@ function clickedApply(){
<tr><td>
Sequence length (@60Hz)
</td><td>
<input
id=
"idduration"
name=
"nduration"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
>
</td><td>
frames
</td><td>
Request coun
t
</td><td>
<input
id=
"id
request_num"
name=
"nrequest_num
"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
frames
</td><td>
Frames lef
t
</td><td>
<input
id=
"id
left_capture"
name=
"nleft_capture
"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
</td></tr>
<tr><td>
Sequence length (@10Hz)
</td><td>
<input
id=
"idduration_eo"
name=
"nduration_eo"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
>
</td><td>
frames
</td><td>
Capture run
</td><td>
<input
id=
"idcapture_run"
name=
"ncapture_run"
type=
"checkbox"
disabled
>
</td><td>
frames
</td><td>
Request count
</td><td>
<input
id=
"idrequest_num"
name=
"nrequest_num"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
</td></tr>
<tr><td>
FFC
</td><td>
<input
id=
"idffc"
name=
"nffc"
type=
"checkbox"
>
</td><td>
</td><td>
Last FFC
</td><td>
<input
id=
"idlast_ffc"
name=
"nlast_ffc"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
sec
</td></tr>
</td><td>
</td><td>
Capture run
</td><td>
<input
id=
"idcapture_run"
name=
"ncapture_run"
type=
"checkbox"
disabled
>
</td><td>
</td></tr>
<tr><td>
FFC period
</td><td>
<input
id=
"idffc_period"
name=
"nffc_period"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
>
</td><td>
sec
</td><td>
Time to
FFC
</td><td>
<input
id=
"id
time_to_ffc"
name=
"ntime_to
_ffc"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
sec
</td><td>
Last
FFC
</td><td>
<input
id=
"id
last_ffc"
name=
"nlast
_ffc"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
sec
</td></tr>
<tr><td>
FFC groups
</td><td>
...
...
@@ -277,7 +299,10 @@ function clickedApply(){
<option
value=
"2"
>
2
</option>
<option
value=
"4"
selected=
"selected"
>
4
</option>
</select>
</td><td>
</td><td>
</td><td>
</td><td>
</td></tr>
</td><td>
</td>
<td>
Time to FFC
</td><td>
<input
id=
"idtime_to_ffc"
name=
"ntime_to_ffc"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
disabled
>
</td><td>
sec
</td></tr>
<tr><td>
FFC frames
</td><td>
<input
id=
"idffc_frames"
name=
"nffc_frames"
size=
"10"
maxlength=
"10"
value=
"?"
type=
"text"
>
...
...
src/lwir16/lwir16.ini
View file @
3ed8b3eb
...
...
@@ -7,9 +7,13 @@ 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"
duration
=
100
pre_delay
=
3.0
ffc_period
=
30.0
#1 - run/stop, 2 - continuous, 0 do not use
run_modes
=
"1,1,1,1,2"
lwir_fps
=
59.98
eo_decimate_m1
=
5
duration
=
500
pre_delay
=
2.0
ffc_period
=
180.0
ffc_groups
=
2
ffc_frames
=
8
ffc
=
1
...
...
@@ -18,6 +22,8 @@ tiff_mn = 0
tiff_mx
=
65535
tiff_bin_shift
=
1
tiff_auto
=
0
frames_idle
=
10
frames_wait
=
20
debug
=
1
output_log
=
/var/log/lwir16.log
# no spaces around commas!
...
...
src/lwir16/lwir16.php
View file @
3ed8b3eb
This diff is collapsed.
Click to expand it.
src/php_top/Makefile
View file @
3ed8b3eb
...
...
@@ -16,6 +16,7 @@ PHP_SCRIPTS=i2c.php \
ccam.php
\
diag_utils.php
\
framepars.php
\
frame_to_ts.php
\
parsedit.php
\
phpinfo.php
\
raw.php
\
...
...
src/php_top/capture_range.php
View file @
3ed8b3eb
...
...
@@ -26,6 +26,7 @@
*! -----------------------------------------------------------------------------**
*!
*/
define
(
'CAPTURE_RANGE_STATE'
,
'/var/state/capture_range.state'
);
set_include_path
(
get_include_path
()
.
PATH_SEPARATOR
.
'/www/pages/include'
);
include
'show_source_include.php'
;
include
"elphel_functions_include.php"
;
// includes curl functions
...
...
@@ -41,6 +42,7 @@
$port_mask
=
$argv
[
2
];
$frame
=
$argv
[
3
];
// absolute frame to start compressor
$duration
=
$argv
[
4
];
// number of frames to run compressor
$notify
=
$argv
[
5
];
// double-quoted URL
if
(
$frame
>
0
){
$frame
+=
1
;
// seem there is a bug - actual compressed frames numbers (and last compressed frame number) are 1 less than expected
...
...
@@ -53,6 +55,9 @@
elphel_capture_range
(
$sensor_port
,
$port_mask
,
$frame
,
$duration
);
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"elphel_capture_range DONE\n");
if
(
$notify
){
// complete url with http://
file_get_contents
(
$notify
);
}
// fclose ( $f );
exit
(
0
);
}
...
...
@@ -64,12 +69,15 @@
if
(
count
(
$_GET
)
<
1
)
{
print
(
"CGI mode"
);
// Be carefull watching that USAGE is not indented (after auto-indenting). That leads to errors such as (at much later line number)!
// Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE)
// or number (T_NUM_STRING) in /www/pages/capture_range.php on line 143
echo
<<<USAGE
<p>This script returns the timestamp for specified frame (frame=?) or expected frame number
<p>This script returns the timestamp for specified frame (frame=?) or expected frame number
when the specified timestamp (timestamp = ?.?) will be reached. If none of the frame number
and timestamp are specified - return last compressed frame number and timestamp.</p>
<p>Uses TRIG_PERIOD (in 10ns increments) for calculations.</p>
<p>sensor_port=0..3 - specify which sensor port to use, default is sensor_port=0</p>
<p>Uses TRIG_PERIOD (in 10ns increments) for calculations.</p>
<p>sensor_port=0..3 - specify which sensor port to use, default is sensor_port=0</p>
USAGE;
exit
(
0
);
}
...
...
@@ -78,6 +86,8 @@ USAGE;
$timestamp
=
0.0
;
$PARS_FRAMES
=
16
;
$minahead
=
2
;
$notify_args
=
array
();
$notify_url
=
""
;
// $port_mask = 15; // not set - same as ts2frame.php
// $duration = 1; // not set - end, set - start
// $wait = false;
...
...
@@ -85,6 +95,8 @@ USAGE;
foreach
(
$_GET
as
$key
=>
$value
)
{
if
(
$key
==
'sensor_port'
){
$sensor_port
=
(
integer
)
$value
;
}
else
if
((
$key
==
'state'
))
{
$read_state
=
1
;
// all other parameters will not be used, maybe in the future - use multi request and combine responses?
}
else
if
((
$key
==
'a'
)
||
(
$key
==
'ahead'
)){
// will overwrite timestamp with this value (in seconds) from now
$ahead_now
=
(
double
)
$value
;
}
else
if
((
$key
==
'ts'
)
||
(
$key
==
'timestamp'
)){
...
...
@@ -109,8 +121,65 @@ USAGE;
$extra
=
(
integer
)
$value
;
// not used?
}
else
if
((
$key
==
'ip'
)
||
(
$key
==
'ips'
)){
// multicamera operation
$ips
=
explode
(
','
,
$value
);
}
else
if
(
substr
(
$key
,
0
,
7
)
==
"notify_"
)
{
$nk
=
substr
(
$key
,
7
);
if
(
$nk
==
'cmd'
){
$notify_cmd
=
$value
;
}
else
if
(
substr
(
$nk
,
0
,
3
)
==
'key'
)
{
$ni
=
intval
(
substr
(
$nk
,
3
));
if
(
!
isset
(
$notify_args
[
$ni
]))
$notify_args
[
$ni
]
=
array
();
$notify_args
[
$ni
][
0
]
=
$value
;
}
else
if
(
substr
(
$nk
,
0
,
3
)
==
'val'
)
{
$ni
=
intval
(
substr
(
$nk
,
3
));
if
(
!
isset
(
$notify_args
[
$ni
]))
$notify_args
[
$ni
]
=
array
();
$notify_args
[
$ni
][
1
]
=
$value
;
}
}
}
//capture_range.php?sensor_port=0&state&frame=20 # will respond and block if there are fewer than 20 frames
if
(
isset
(
$read_state
))
{
// if $frame >0 wait if less frames are left
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><capture_range/>"
);
// does the state file exist?
$this_frame
=
0
;
$left
=
0
;
if
(
file_exists
(
CAPTURE_RANGE_STATE
))
{
$ini
=
parse_ini_file
(
CAPTURE_RANGE_STATE
);
$end_frame
=
intval
(
$ini
[
'end_frame'
]);
$this_frame
=
elphel_get_frame
(
$sensor_port
);
$left
=
$end_frame
-
$this_frame
;
if
((
$frame
>
0
)
&&
(
$left
>
0
)
&&
(
$left
<
$frame
)){
elphel_wait_frame_abs
(
$sensor_port
,
$end_frame
);
// wait and block client
}
$this_frame
=
elphel_get_frame
(
$sensor_port
);
$left
=
$end_frame
-
$this_frame
;
}
$xml
->
addChild
(
'frame'
,
$this_frame
);
$xml
->
addChild
(
'end_frame'
,
$end_frame
);
$xml
->
addChild
(
'left'
,
$left
);
$rslt
=
$xml
->
asXML
();
header
(
"Content-Type: text/xml"
);
header
(
"Content-Length: "
.
strlen
(
$rslt
)
.
"
\n
"
);
header
(
"Pragma: no-cache
\n
"
);
printf
(
$rslt
);
exit
(
0
);
}
if
(
isset
(
$notify_cmd
)){
$wait
=
false
;
$notify_url
=
'http://'
.
$notify_cmd
;
// $notify_cmd includes full url
$i
=
0
;
foreach
(
$notify_args
as
$kv
)
{
if
(
isset
(
$kv
[
0
]))
{
$notify_url
.=
(
$i
?
'&'
:
'?'
);
// $notify_url .= ($i ? '&' : '?');
$notify_url
.=
$kv
[
0
];
if
(
isset
(
$kv
[
1
]))
{
$notify_url
.=
'='
.
$kv
[
1
];
}
$i
++
;
}
}
}
if
(
isset
(
$ahead_now
)){
$this_frame
=
elphel_get_frame
(
$sensor_port
);
$this_timestamp
=
elphel_frame2ts
(
$sensor_port
,
$this_frame
);
...
...
@@ -190,47 +259,59 @@ USAGE;
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><capture_range/>"
);
$flags
=
0
;
if
(
isset
(
$port_mask
)){
// start or stop compressor
$use_daemon
=
(
$frame
!=
0
);
if
(
isset
(
$port_mask
))
{
// start or stop compressor
$this_frame
=
elphel_get_frame
(
$sensor_port
);
if
(
$frame
==
0
){
// e.g. to stop
ASAP
if
(
isset
(
$duration
))
{
if
(
!
$use_daemon
)
{
// e.g. to stop ASAP $frame=0, $duration !=0 - start
ASAP
if
(
isset
(
$duration
))
{
elphel_compressor_run
(
$sensor_port
,
0
,
$flags
,
$port_mask
);
// turn on ASAP
$xml
->
addChild
(
'compressor'
,
1
);
}
else
{
elphel_compressor_stop
(
$sensor_port
,
0
,
$flags
,
$port_mask
);
// turn off ASAP
$xml
->
addChild
(
'compressor'
,
0
);
$xml
->
addChild
(
'compressor'
,
1
);
}
else
{
// frame = 0; duration ==0 - stop ASAP
elphel_compressor_stop
(
$sensor_port
,
0
,
$flags
,
$port_mask
);
// turn off ASAP
$xml
->
addChild
(
'compressor'
,
0
);
}
$frame
=
$this_frame
+
$minahead
;
}
$ahead
=
$frame
-
$this_frame
;
if
(
$
ahead
<
$minahead
)
{
$xml
->
addChild
(
'error'
,
'TOO LATE'
);
$xml
->
addChild
(
'ahead'
,
$ahead
);
if
(
$
use_daemon
&&
(
$ahead
<
$minahead
)
)
{
$xml
->
addChild
(
'error'
,
'TOO LATE'
);
$xml
->
addChild
(
'ahead'
,
$ahead
);
}
else
{
// OK, enough time to program
if
(
!
isset
(
$duration
))
{
if
(
!
isset
(
$duration
))
{
$duration
=
0
;
}
// kill CLI mode if it was running (e.g. waiting for 100 years)
exec
(
"killall capture_range.php"
,
$output
,
$retval
);
// spawn CLI program in background duration <0 - start only, ==0 - stop only, >0 - start+stop
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"exec(/www/pages/capture_range.php $sensor_port $port_mask $frame $duration > /dev/null 2>&1 &\n");
// fclose ( $f );
exec
(
"/www/pages/capture_range.php
$sensor_port
$port_mask
$frame
$duration
> /dev/null 2>&1 &"
);
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"DONE exec\n");
// fclose ( $f );
if
(
$duration
>
0
){
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"exec(/www/pages/capture_range.php $sensor_port $port_mask $frame $duration > /dev/null 2>&1 &\n");
// fclose ( $f );
// if ($notify_url) {
// $xml->addChild ('notify_url', $notify_url); // urlencode($notify_url)); // dry run, do nothing
// } else {
if
(
$use_daemon
)
{
exec
(
"/www/pages/capture_range.php
$sensor_port
$port_mask
$frame
$duration
'
$notify_url
'> /dev/null 2>&1 &"
);
// }
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"DONE exec\n");
// fclose ( $f );
if
(
$duration
>
0
)
{
$frame
+=
$duration
;
// xml will contain end frame
}
if
(
$wait
){
file_put_contents
(
CAPTURE_RANGE_STATE
,
"end_frame =
$frame
\n
"
);
if
(
$wait
)
{
elphel_wait_frame_abs
(
$sensor_port
,
$frame
+
1
);
}
}
else
{
if
(
file_exists
(
CAPTURE_RANGE_STATE
))
{
unlink
(
CAPTURE_RANGE_STATE
);
}
}
}
}
else
{
// just ts2frame.php mode
if
(
$frame
==
0
){
$timestamp
=
elphel_frame2ts
(
$sensor_port
,
0
);
$frame
=
elphel_ts2frame
(
$sensor_port
,
0.0
);
if
(
$frame
==
0
)
{
$timestamp
=
elphel_frame2ts
(
$sensor_port
,
0
);
$frame
=
elphel_ts2frame
(
$sensor_port
,
0.0
);
}
}
$xml
->
addChild
(
'retval'
,
$retval
);
...
...
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