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