forked from LupusNobilis/java-org.hwo
57 lines
712 B
Java
57 lines
712 B
Java
package org.hwo;
|
|
|
|
public class Smoother {
|
|
|
|
private int lastValue;
|
|
private int summe;
|
|
private int wert;
|
|
private int tn;
|
|
|
|
public Smoother()
|
|
{
|
|
setSumme(0);
|
|
setWert(0);
|
|
setTn(1);
|
|
}
|
|
|
|
public int cycle(int value)
|
|
{
|
|
lastValue = value;
|
|
summe += value;
|
|
wert = summe / tn;
|
|
summe -= wert;
|
|
return wert;
|
|
}
|
|
|
|
public int getSumme() {
|
|
return summe;
|
|
}
|
|
|
|
public void setSumme(int summe) {
|
|
this.summe = summe;
|
|
}
|
|
|
|
public int getWert() {
|
|
return wert;
|
|
}
|
|
|
|
public void setWert(int wert) {
|
|
this.setSumme( (wert * tn) - wert );
|
|
this.wert = wert;
|
|
}
|
|
|
|
public int getTn() {
|
|
return tn;
|
|
}
|
|
|
|
public void setTn(int tn) {
|
|
this.tn = tn;
|
|
}
|
|
|
|
public int getLastValue(){
|
|
return lastValue;
|
|
}
|
|
|
|
|
|
}
|