ctl_itemex.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace refill;
  3. class ctl_itemex
  4. {
  5. private $mName;
  6. private $mCardType;
  7. private $mAmount;
  8. private $mQuality;
  9. private $mMaxSpeed;
  10. private $mPrefix;
  11. private $mPriority;
  12. private $mStorge;
  13. private $mOpened;
  14. private $mPrice;
  15. private $mSpeed;
  16. private $mRatio;
  17. private $mRatioCommit;
  18. private $mNotifyTime;
  19. public function __construct($chname, $card_type, $amount, $max_speed, $priority, $storge, $opened, $quality)
  20. {
  21. $this->mPrefix = "{$chname}-{$quality}-{$card_type}-{$amount}";
  22. $this->mName = $chname;
  23. $this->mCardType = $card_type;
  24. $this->mAmount = $amount;
  25. $this->mQuality = $quality;
  26. $this->mMaxSpeed = $max_speed;
  27. $this->mPriority = $priority;
  28. $this->mStorge = $storge;
  29. $this->mOpened = $opened;
  30. $this->mPrice = 0.0;
  31. $this->mSpeed = 0;
  32. $this->mRatio = 0.0;
  33. $this->mRatioCommit = 0;
  34. $this->mNotifyTime = 0;
  35. }
  36. public function name()
  37. {
  38. return $this->mName;
  39. }
  40. public function priority()
  41. {
  42. return $this->mPriority;
  43. }
  44. public function storge()
  45. {
  46. return $this->mStorge;
  47. }
  48. public function opened()
  49. {
  50. return $this->mOpened;
  51. }
  52. public function quality()
  53. {
  54. return $this->mQuality;
  55. }
  56. public function spec()
  57. {
  58. return $this->mAmount;
  59. }
  60. public function card_type()
  61. {
  62. return $this->mCardType;
  63. }
  64. public function set_price($price)
  65. {
  66. $this->mPrice = $price;
  67. }
  68. public function price()
  69. {
  70. return $this->mPrice;
  71. }
  72. public function prefix() {
  73. return $this->mPrefix;
  74. }
  75. public function update_params($parms)
  76. {
  77. [$this->mSpeed, $this->mRatio, $this->mRatioCommit, $notifyTime,$monitorCommit] = $parms;
  78. $this->mSpeed = intval($this->mSpeed);
  79. $this->mNotifyTime = $notifyTime <= 0 ? 300 : $notifyTime;
  80. }
  81. public function update_maxspeeds($speed)
  82. {
  83. $this->mMaxSpeed = max($speed, 0);
  84. }
  85. public function max_speed()
  86. {
  87. return $this->mMaxSpeed;
  88. }
  89. public function zero_speed(): bool
  90. {
  91. $zero = $this->mMaxSpeed > 0 && $this->mSpeed == 0;
  92. return $zero;
  93. }
  94. public function speed_overload(): bool
  95. {
  96. if ($this->mMaxSpeed < 0) {
  97. return false;
  98. } else {
  99. return $this->mSpeed >= $this->mMaxSpeed;
  100. }
  101. }
  102. public function speed_stoped() {
  103. return $this->mMaxSpeed == 0;
  104. }
  105. public function cur_speed()
  106. {
  107. return $this->mSpeed;
  108. }
  109. public function notify_ratio() {
  110. return $this->mRatio;
  111. }
  112. public function submits() {
  113. return $this->mRatioCommit;
  114. }
  115. public function notify_time() {
  116. return $this->mNotifyTime;
  117. }
  118. public function compile_val($profit_ratio)
  119. {
  120. $time_factor = 60;
  121. $val = $this->mRatio * $profit_ratio * 100 / (log($this->mNotifyTime) + $time_factor);
  122. return round($val,9);
  123. }
  124. }