DurchflusstabelleImpl
1
This is an example from practice. The domain is a whater flow messure system. I wrote a blog entry where I fully described the evolution of this class - in german.
class DurchflusstabelleImpl implements Durchflusstabelle {
static def QMAX_FAKTOR = 2
static def tabelle = [
(0.0..(15.0 - (Float.MIN_VALUE as BigDecimal))):
[
A:[QMIN: 0.04, QTRENN: 0.10, QMAX: QMAX_FAKTOR],
B:[QMIN: 0.02, QTRENN: 0.08, QMAX: QMAX_FAKTOR],
C:[QMIN: 0.01, QTRENN: 0.015, QMAX: QMAX_FAKTOR]
],
(15.0..(Float.MAX_VALUE as BigDecimal)):
[
A:[QMIN: 0.08, QTRENN: 0.30, QMAX: QMAX_FAKTOR],
B:[QMIN: 0.03, QTRENN: 0.20, QMAX: QMAX_FAKTOR],
C:[QMIN: 0.006, QTRENN: 0.015, QMAX: QMAX_FAKTOR]
]
]
int get(float nennweite, String metrologischeKlasse, String gesuchterWert,
float messabweichungInProzent) {
def faktor = tabelle
.find{ eintrag -> (nennweite as BigDecimal) in eintrag.key }.value
.find{ eintrag -> metrologischeKlasse == eintrag.key }.value
.find{ eintrag -> gesuchterWert == eintrag.key}.value
def durchfluss = nennweite * faktor * 1000
(durchfluss + durchfluss * messabweichungInProzent / 100).round()
}
}






There are currently no comments for this snippet.