SaturatedModepublic class SaturatedMode extends Object implements ComparableCreated on May 21, 2007
Created by Alan Snyder
Copyright (C) 2007 Aelitis, All Rights Reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
AELITIS, SAS au capital de 63.529,40 euros
8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France. |
Fields Summary |
---|
public static final SaturatedMode | AT_LIMIT | public static final SaturatedMode | HIGH | public static final SaturatedMode | MED | public static final SaturatedMode | LOW | public static final SaturatedMode | NONE | private final String | name | private final float | percentCapacity |
Constructors Summary |
---|
private SaturatedMode(String _name, float _percent)
name = _name;
percentCapacity = _percent;
|
Methods Summary |
---|
public int | compareTo(com.aelitis.azureus.core.speedmanager.impl.v2.SaturatedMode satMode)
if( percentCapacity < satMode.getThreshold() ){
return -1;
}
else if( percentCapacity > satMode.getThreshold() ){
return +1;
}
return 0;
| public int | compareTo(java.lang.Object obj)
if( !(obj instanceof SaturatedMode) ){
throw new ClassCastException("Only comparable to SaturatedMode class.");
}
SaturatedMode casted = (SaturatedMode) obj;
return compareTo(casted);
| public static com.aelitis.azureus.core.speedmanager.impl.v2.SaturatedMode | getSaturatedMode(int currentRate, int limit)From the currentRate and limit determine the mode.
//unlimited mode has this value as zero.
if(limit==0){
//put a value in so it will not stay in downloading mode.
limit = SMConst.START_DOWNLOAD_RATE_MAX;
}
float percent = (float)currentRate/(float)limit;
if( percent > AT_LIMIT.getThreshold() ){
return AT_LIMIT;
}
else if( percent > HIGH.getThreshold() ){
return HIGH;
}
else if( percent > MED.getThreshold() ){
return MED;
}
else if( percent > LOW.getThreshold() ){
return LOW;
}
return NONE;
| private float | getThreshold()
return percentCapacity;
| public boolean | isGreater(com.aelitis.azureus.core.speedmanager.impl.v2.SaturatedMode mode)
if( this.compareTo(mode)>0 ){
return true;
}
return false;
| public java.lang.String | toString()
return name;
|
|