stanley-king 3 år sedan
förälder
incheckning
85ff74de9a

+ 0 - 1
helper/refill/LZRefillFactory.php

@@ -9,7 +9,6 @@ require_once(BASE_HELPER_PATH . '/refill/policy/IPolicy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/lingzh/policy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/ctl_item.php');
-require_once(BASE_HELPER_PATH . '/refill/policy/ratio.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchoilctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/times_caller.php');

+ 0 - 1
helper/refill/XYZRefillFactory.php

@@ -10,7 +10,6 @@ require_once(BASE_HELPER_PATH . '/rbridge/RBridgeFactory.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/IPolicy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/xyz/policy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctl.php');
-require_once(BASE_HELPER_PATH . '/refill/policy/ratio.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/ctl_item.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchoilctl.php');

+ 4 - 3
helper/refill/policy/chctl.php

@@ -50,13 +50,14 @@ class chctl
     {
         foreach ($ratios as $key => $ratio)
         {
-            $val = $ratio;
             if(array_key_exists($key,$this->mSpeedtable)) {
                 $item = $this->mSpeedtable[$key];
+                $item->set_ratio($ratio);
+                [$validatea,$commit_ratio] = $item->commit_ratio();
+                [$validateb,$notify_ratio] = $item->notify_ratio();
+                Log::record("{$key} commit {$validatea}:{$commit_ratio} notify:{$validateb}:{$notify_ratio}",Log::DEBUG);
             }
-
         }
-
     }
 
     public function load()

+ 34 - 3
helper/refill/policy/ctl_item.php

@@ -23,7 +23,11 @@ class ctl_item
     private $mOpened;
     private $mPrice;
 
-    private $mRatio;
+    private $mCommitSucc;
+    private $mCommitFail;
+    private $mNotifySucc;
+    private $mNotifyFail;
+
 
     public function __construct($chname,$card_type,$amount,$max_speed,$priority,$storge,$opened,$quality)
     {
@@ -40,7 +44,11 @@ class ctl_item
         $this->mOpened = $opened;
         $this->mRecords = [];
         $this->mPrice = 0.0;
-        $this->mRatio = new ratio();
+
+        $this->mCommitSucc = 0;
+        $this->mCommitFail = 0;
+        $this->mNotifySucc = 0;
+        $this->mNotifyFail = 0;
 
         $this->load(time() - ctl_item::speed_secs + 1);
     }
@@ -122,6 +130,29 @@ class ctl_item
         return $this->mPrice;
     }
     public function set_ratio($ratio) {
-        $this->mRatio->update($ratio);
+        $this->mCommitSucc = $ratio[0];
+        $this->mCommitFail = $ratio[1];
+        $this->mNotifySucc = $ratio[2];
+        $this->mNotifyFail = $ratio[3];
+    }
+
+    public function commit_ratio()
+    {
+        $count = $this->mCommitSucc + $this->mCommitFail;
+        if($count > 0) {
+            return [true,$this->mCommitSucc / $count];
+        } else {
+            return [false,0];
+        }
+    }
+
+    public function notify_ratio()
+    {
+        $count = $this->mNotifySucc + $this->mNotifyFail;
+        if($count > 0) {
+            return [true,$this->mCommitSucc / $count];
+        } else {
+            return [false,0];
+        }
     }
 }

+ 20 - 0
helper/refill/policy/ratio.php

@@ -24,4 +24,24 @@ class ratio
         $this->mNotifySucc = $data[2];
         $this->mNotifyFail = $data[3];
     }
+
+    public function commit_ratio()
+    {
+        $count = $this->mCommitSucc + $this->mCommitFail;
+        if($count > 0) {
+            return [true,$this->mCommitSucc / $count];
+        } else {
+            return [false,0];
+        }
+    }
+
+    public function notify_ratio()
+    {
+        $count = $this->mNotifySucc + $this->mNotifyFail;
+        if($count > 0) {
+            return [true,$this->mCommitSucc / $count];
+        } else {
+            return [false,0];
+        }
+    }
 }

+ 1 - 1
helper/refill/policy/xyz/policy.php

@@ -59,7 +59,7 @@ class policy extends ProviderManager implements IPolicy
             $names[] = $provider->name();
         }
 
-        Log::record("  mGroupCtl find_providers result=" . implode(',',$names),Log::DEBUG);
+        Log::record("mGroupCtl find_providers result=" . implode(',',$names),Log::DEBUG);
         [$hasGroup,$can_others,$channels] = $this->mGroupCtl->find_providers($mchid, $spec, $card_type, $quality);
         if($hasGroup)
         {