Changeset 926


Ignore:
Timestamp:
May 10, 2022, 11:08:30 PM (2 years ago)
Author:
chronos
Message:
  • Added: Update minimum speeds in RouterOS Queue generation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php

    r899 r926  
    2929  var $LimitIn;
    3030  var $LimitOut;
     31  var $FixedSpeed;
    3132  var $SubItems;
    3233
     
    3738    if ($Parent != null) $Parent->SubItems->Add($this);
    3839    $this->SubItems = new SpeedLimitItems();
     40    $this->FixedSpeed = false;
    3941  }
    4042
     
    9496      $this->LimitOut->Min = $SpeedMinOut;
    9597      $this->LimitIn->Min = $SpeedMinIn;
     98    }
     99  }
     100
     101  function AdjustMinSpeedsToMax(float $MultiplierIn, float $MultiplierOut): void
     102  {
     103    foreach ($this->SubItems->Items as $Index => $Item)
     104    {
     105      $this->SubItems->Items[$Index]->AdjustMinSpeedsToMax($MultiplierIn, $MultiplierOut);
     106    }
     107    if ($this->FixedSpeed == false)
     108    {
     109      $this->LimitOut->Min = round($this->LimitOut->Min * $MultiplierOut);
     110      if ($this->LimitOut->Min > $this->LimitOut->Max)
     111      {
     112        echo($this->Name.': '.$this->LimitOut->Min.' > '.$this->LimitOut->Max."\n");
     113        $this->LimitOut->Min = $this->LimitOut->Max;
     114      }
     115      $this->LimitIn->Min = round($this->LimitIn->Min * $MultiplierIn);
     116      if ($this->LimitIn->Min > $this->LimitIn->Max)
     117      {
     118        echo($this->Name.': '.$this->LimitIn->Min.' > '.$this->LimitIn->Max."\n");
     119        $this->LimitIn->Min = $this->LimitIn->Max;
     120      }
    96121    }
    97122  }
     
    185210    $Free->LimitIn = new SpeedLimit($FreeInetSpeed, $FreeInetSpeed, GetMarkByComment('free-in'));
    186211    $Free->LimitOut = new SpeedLimit($FreeInetSpeed, $FreeInetSpeed, GetMarkByComment('free-out'));
     212    $Free->FixedSpeed = true;
    187213
    188214    // Process users
     
    271297    }
    272298    $Main->UpdateMinSpeeds();
     299    $Main->AdjustMinSpeedsToMax($Main->LimitIn->Max / $Main->LimitIn->Min,
     300      $Main->LimitOut->Max / $Main->LimitOut->Min);
     301
    273302    echo($Main->Print());
    274303    $ItemsQueue = $Main->GetCommands();
Note: See TracChangeset for help on using the changeset viewer.