From 5bd826c752d4413483a907424bda0078a84ca224 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 28 Sep 2017 10:59:24 +0200 Subject: [PATCH] Loop new implementation test@5 --- feature/rfid-read/source/loop.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/feature/rfid-read/source/loop.php b/feature/rfid-read/source/loop.php index f6f91f0..22706f3 100755 --- a/feature/rfid-read/source/loop.php +++ b/feature/rfid-read/source/loop.php @@ -98,16 +98,17 @@ /* PROCESS ACTIONS IF ACTION CAN BE PERFORMED BY USER (DEPENDING ON TIMEOUT/STATE) * * @user Current user information + * @cur_timeout The real timeout (diff in sec) * * @return success 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'];