changeset 5216:91feaf7ac486 new-fwa

Started to accumulate time segments.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 11 May 2020 19:42:07 +0200
parents ea60b76d8abd
children 70d83b7d36ef
files pkg/controllers/fwa.go
diffstat 1 files changed, 32 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/fwa.go	Mon May 11 19:21:40 2020 +0200
+++ b/pkg/controllers/fwa.go	Mon May 11 19:42:07 2020 +0200
@@ -286,51 +286,59 @@
 
 	var shipableDays int
 
+	allClasses := make([][]time.Duration, len(validities))
+
 	// We step through the time in steps of one day.
 	for current := from; current.Before(to); {
 
 		next := current.AddDate(0, 0, 1)
 
+		// Assume that a bottleneck is shipable.
 		shipable := true
 
-		// over all bottlenecks
+		// check all bottlenecks
 		for i, validity := range validities {
 
-			if vs := validity(current, next); vs != nil {
+			// Assume that this bottleneck cannot be evaluated for this day.
+			allClasses[i] = nil
 
-				// Let's see if we have a LDC for this day.
-				ldc := vs.ldcs.find(current, next)
-				if ldc == nil {
-					// TODO: log missing LCD
-					continue
-				}
+			// Check if bottleneck is available for this day.
+			vs := validity(current, next)
+			if vs == nil {
+				continue
+			}
 
-				if shipable { // if its already not shipable we need no further tests.
-					result := bottlenecks[i].measurements.classify(
-						current, next,
-						ldc.value,
-						(*availMeasurement).getValue)
+			// Let's see if we have a LDC for this day.
+			ldc := vs.ldcs.find(current, next)
+			if ldc == nil {
+				// TODO: log missing LCD
+				continue
+			}
 
-					if result[1] < 12*time.Hour {
-						shipable = false
-					}
-				}
-
-				classes := bottlenecks[i].measurements.classify(
+			if shipable { // If its already not shipable we need no further tests.
+				result := bottlenecks[i].measurements.classify(
 					current, next,
-					chooseBreaks[vs.limiting],
-					limitingAccess[vs.limiting])
+					ldc.value,
+					(*availMeasurement).getValue)
 
-				// TODO: Compare with others.
-				_ = classes
+				if result[1] < 12*time.Hour {
+					shipable = false
+				}
+			}
 
-			}
+			allClasses[i] = bottlenecks[i].measurements.classify(
+				current, next,
+				chooseBreaks[vs.limiting],
+				limitingAccess[vs.limiting])
+
 		}
 
 		if shipable {
 			shipableDays++
 		}
 
+		// TODO: Accumulate daily statistics into time segment.
+
 		if finish(next) {
 			// TODO: depending on mode write out results.
 			l := label(current)