소스 검색

add 3 config param

nana_sen 1 년 전
부모
커밋
f98e793d51
2개의 변경된 파일37개의 추가작업 그리고 30개의 파일을 삭제
  1. 30 26
      catch/api/controller/Api.php
  2. 7 4
      task_script/PAREA_STATUS_UPDATE.php

+ 30 - 26
catch/api/controller/Api.php

@@ -286,6 +286,27 @@ class Api extends CatchController
                         debug_log("parea_rfidinfos_redis_set_record","redis更新记录".json_encode($info,true));
                     }else{
                         $info = json_decode($info,true);
+
+                        $config  = $ues_redis->hget("anbang_four_wire", $info["mac"]);
+                        
+                        if (!$config) {
+                            # code...
+                            $config = [
+                                "front_in" => 65,
+                                "behind_in" => 70,
+                                "left_in" => 80,
+                                "right_in" => 70,
+                                "front_out" => 70,
+                                "behind_out" => 75,
+                                "left_out" => 82,
+                                "right_out" => 70,
+                                "expInt" => 20,
+                                "effSigNum" => 10
+                            ];     
+                        }else{
+                            $config = json_decode($config,true);
+                        }
+                        // var_dump("+++++++++++++++++",$config);
     
                         $info["time"] = $time;
                         $newRssi = [
@@ -298,16 +319,15 @@ class Api extends CatchController
                         $rssisArr = $info["rssi"];
                         
                         // var_dump("+++++++++++++++++", $time, $newRssi["time"]);
-    
+                        
                         foreach ($rssisArr as $k => $v) {
                             # code...
-                            if( ($time - $v["time"] ) > $EXP_TIME ){
+                            if( ($time - $v["time"] ) > $config['expInt'] ){
                                 unset($rssisArr[$k]);
-                                // var_dump("+++++++++++++++++", $time, $v["time"]);
                             }
                         }
                         // var_dump("+++++++++++++++++",$rssisArr);
-                        if(count($rssisArr) == $EFF_SIG_NUM){
+                        if(count($rssisArr) == $config['effSigNum']){
                             array_shift($rssisArr);
                             array_push($rssisArr, $newRssi);
                         }else{
@@ -342,7 +362,7 @@ class Api extends CatchController
     
                         if ($cacCount == $EFF_SIG_NUM) {
                             # code...
-                           $info = $this->compAndPush($info ,$ues_redis);
+                           $info = $this->compAndPush($info ,$config);
                         }
                         $ues_redis->hset("parea_rfidinfos",$field, json_encode($info,true));
                         
@@ -359,30 +379,14 @@ class Api extends CatchController
         return $text ?$text : "";
     }
     //判断进出和推送
-    public function compAndPush($info, $ues_redis){
+    public function compAndPush($info, $config ){
         //标签多,数据多时候,判断完成后放入redis,异步推送,当前暂时直接推
-        if (empty($info)) {
-            # code...
-            return false;
-        }
-        $config  = $ues_redis->hget("anbang_four_wire", $info["mac"]);
+
+        // $config  = $ues_redis->hget("anbang_four_wire", $info["mac"]);
         
         //{"front_in":44,"front_out":44,"behind_in":50,"behind_out":50,"left_in":55,"left_out":55,"right_out":44,"right_out":44}
-        if (!$config) {
-            # code...
-            $config = [
-                "front_in" => 65,
-                "behind_in" => 70,
-                "left_in" => 80,
-                "right_in" => 70,
-                "front_out" => 70,
-                "behind_out" => 75,
-                "left_out" => 82,
-                "right_out" => 70,
-            ];     
-        }else{
-            $config = json_decode($config);
-        }
+
+        
 
         $avg = $info['avg'];
         $status = $info['status'];

+ 7 - 4
task_script/PAREA_STATUS_UPDATE.php

@@ -8,7 +8,6 @@ define('HOST', '127.0.0.1');
 define('PORT', '6379');
 define('PASSWORD', '123456');
 define('DATABASE', 3);
-define('OFFLINETIMEINT', 30);
 
 
 function app_redis()
@@ -220,11 +219,15 @@ while (true) {
         rlog('INFO', 'task start');
 
         $infos = app_redis()->hgetall("parea_rfidinfos");
-
+        $offlineInt  = app_redis()->hget("anbang_four_wire", "anbang_4rssi_offint");
+        if (!$offlineInt) {
+            # code...
+            $offlineInt = 30;
+        }
         foreach ($infos as $k => $v) {
             # code...
             $data = json_decode($v, true);
-            if ( (time() - $data["time"] ) > OFFLINETIMEINT ) {
+            if ( (time() - $data["time"] ) > $offlineInt ) {
                 # code...
                 if ($data["status"] == 1) {
                     # code...
@@ -249,6 +252,6 @@ while (true) {
     } catch (\Exception $ex) {
         rlog("INFO", 'pushhttp',"推送 异常".$ex->getMessage());
     }
-    sleep(10); //1分钟遍历一次
+    sleep(floor($offlineInt/2)); //1分钟遍历一次
 }