123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace refill;
- class ctl_itemex
- {
- const feed_threshold = 2;
- private $mName;
- private $mCardType;
- private $mAmount;
- private $mQuality;
- private $mMaxSpeed;
- private $mPrefix;
- private $mPriority;
- private $mStorge;
- private $mOpened;
- private $mPrice;
- private $mSpeed;
- private $mRatio;
- private $mRatioCommit;
- private $mNotifyTime;
- private $mMonitorCommit;
- public function __construct($chname, $card_type, $amount, $max_speed, $priority, $storge, $opened, $quality)
- {
- $this->mPrefix = "{$chname}-{$quality}-{$card_type}-{$amount}";
- $this->mName = $chname;
- $this->mCardType = $card_type;
- $this->mAmount = $amount;
- $this->mQuality = $quality;
- $this->mMaxSpeed = $max_speed;
- $this->mPriority = $priority;
- $this->mStorge = $storge;
- $this->mOpened = $opened;
- $this->mPrice = 0.0;
- $this->mSpeed = 0;
- $this->mRatio =0.0;
- $this->mRatioCommit = 0;
- $this->mNotifyTime = 0;
- $this->mMonitorCommit = 0;
- }
- public function name()
- {
- return $this->mName;
- }
- public function priority()
- {
- return $this->mPriority;
- }
- public function storge()
- {
- return $this->mStorge;
- }
- public function opened()
- {
- return $this->mOpened;
- }
- public function quality()
- {
- return $this->mQuality;
- }
- public function spec()
- {
- return $this->mAmount;
- }
- public function card_type()
- {
- return $this->mCardType;
- }
- public function set_price($price)
- {
- $this->mPrice = $price;
- }
- public function price()
- {
- return $this->mPrice;
- }
- public function prefix() {
- return $this->mPrefix;
- }
- public function update_params($parms)
- {
- [$this->mSpeed, $this->mRatio, $this->mRatioCommit, $this->mNotifyTime,$this->mMonitorCommit] = $parms;
- if($this->mNotifyTime == 0) {
- $this->mNotifyTime = 1;
- }
- }
- public function max_speed()
- {
- return $this->mMaxSpeed;
- }
- public function speed_overload(): bool
- {
- if ($this->mMaxSpeed < 0) {
- return false;
- } elseif ($this->mMaxSpeed == 0) {
- return true;
- } else {
- return $this->mSpeed >= $this->mMaxSpeed;
- }
- }
- public function cur_speed()
- {
- return $this->mSpeed;
- }
- public function notify_ratio() {
- return $this->mRatio;
- }
- public function submits() {
- return $this->mRatioCommit;
- }
- public function notify_time() {
- return $this->mNotifyTime;
- }
- public function need_feed()
- {
- if(self::feed_threshold >= $this->mMaxSpeed) {
- return $this->mMonitorCommit < $this->mMaxSpeed;
- } else {
- return $this->mMonitorCommit < self::feed_threshold;
- }
- }
- public function compile_val($profit_ratio)
- {
- $val = $this->mRatio * $profit_ratio * 100 / $this->mNotifyTime;
- return round($val,5);
- }
- }
|