public void Evaluate(RollingAverage signal) { if (signal.IsWindowFull == false) { return; } var negTotal = 0.0; for (var i = 0; i < signal.Samples.Length; i++) { if (signal.Samples[i] < 0) { negTotal += -signal.Samples[i]; } } var threshold = signal.Average; var gettingWarmThreshold = 25f; var coolingDownThreshold = 40f; var gettingWarmNegThreshold = 100f; var gettingHotNegThreshold = 200f; if (State == RealTimeState.Cold) { if (negTotal >= gettingHotNegThreshold) { ChangeState(RealTimeState.Hot); } else if (threshold <= gettingWarmThreshold || negTotal >= gettingWarmNegThreshold) { ChangeState(RealTimeState.Warm); } } else if (State == RealTimeState.Warm) { if (negTotal >= gettingHotNegThreshold) { ChangeState(RealTimeState.Hot); } else if (threshold > coolingDownThreshold && StateHasSettled) { ChangeState(RealTimeState.Cold); } } else if (State == RealTimeState.Hot) { if (negTotal == 0 && StateHasSettled) { ChangeState(threshold > coolingDownThreshold ? RealTimeState.Cold : RealTimeState.Warm); } } else { throw new NotSupportedException(); } }