Loop new implementation test@5

This commit is contained in:
xdrm-brackets 2017-09-28 10:59:24 +02:00
parent ac2f5929d3
commit 5bd826c752
1 changed files with 6 additions and 7 deletions

View File

@ -98,16 +98,17 @@
/* PROCESS ACTIONS IF ACTION CAN BE PERFORMED BY USER (DEPENDING ON TIMEOUT/STATE)
*
* @user<array> Current user information
* @cur_timeout<int> The real timeout (diff in sec)
*
* @return success<bool> If success (action performed) | FALSE
*
*/
function act($user){
function act($user, $cur_timeout){
/* [1] Export global caches + variables
=========================================================*/
/* (1) Variables */
global $timeout, $last_to;
global $last_to;
/* (2) Caches */
global $actions;
@ -123,9 +124,6 @@
return false;
$cur_timeout = floor(microtime(true) - $timeout);
slog("timeout($timeout), cur($cur_timeout)", "daemon");
/* [2] Manage timeout
=========================================================*/
@ -411,7 +409,8 @@
/* [4] Manage action
=========================================================*/
/* (1) Try to process action */
$performed = act($user);
$cur_timeout = floor(microtime(true) - $timeout);
$performed = act($user, $cur_timeout);
/* (2) If performed -> update chip according to new state */
if( $performed ){
@ -428,7 +427,7 @@
/* (3) If not performed -> log error */
}else
slog("Cannot perform action by '$code' at timeout $timeout", 'rfid-read:loop');
slog("Cannot perform action by '$code' at timeout $cur_timeout", 'rfid-read:loop');
/* (4) Store user for next loop */
$last_user = $user['id'];