Alarm / Threshold updates

Maybe users don't understand the current Loss/PredictAR based alarms, they also want to be able to set their own target range instead of the default 80-180.

This PR aims to make the target range and alarm types configurable, this should address most of #271.  To do this 5 new ENV variables have been added.

   * `BG_HIGH` - default: **240**, the high BG outside the target range that is considered urgent
   * `BG_TARGET_TOP` - default: **180**, the top of the target range, also used to draw the line on the chart
   * `BG_TARGET_BOTTOM` - default: **80**, the bottom of the target range, also used to draw the line on the chart
   * `BG_LOW` - default: **55**, the low BG outside the target range that is considered urgent
   * `ALARM_TYPES` - default to **simple** if any `BG_`* ENV's are set, otherwise default to **predict**.  There currently 2 alarm types are supported, and can be used independently are separately.  The `simple` alarm type only compares the current BG to `BG_` thresholds above, the `predict` alarm type works as before by using a highly tuned formula that forecasts where the BG is going based on it's trend. 

Jason stipulated two high thresholds: a "high end of target range"
threshold (default 180), which would trigger a standard alarm, and a
"urgent high" threshold (default 240) that would trigger an urgent alarm.
Similar on the low end (80 and 55 IIRC).

Does that paradigm make sense to you?  Do you have any suggestions for a
better way to approach it?

On Fri, Dec 19, 2014 at 3:56 PM, Ben West <notifications@github.com> wrote:
>
> In lib/websocket.js
> <https://github.com/nightscout/cgm-remote-monitor/pull/305#discussion-diff-22136552>
> :
>
> > @@ -238,20 +238,42 @@ function loadData() {
> >            emitData( );
> >          }
> >
> > -        // compute current loss
> > -        var avgLoss = 0;
> > -        var size = Math.min(predicted.length - 1, 6);
> > -        for (var j = 0; j <= size; j++) {
> > -            avgLoss += 1 / size * Math.pow(log10(predicted[j].y / 120), 2);
> > +        var emitAlarmType = null;
> > +
> > +        if (env.alarm_types.indexOf("simple") > -1) {
> > +            var lastBG = actual[actualLength].y;
> > +
> > +            if (lastBG > env.thresholds.bg_high) {
> > +                emitAlarmType = 'urgent_alarm';
>
> Let's not conflate urgent and high.
> This should be a high alarm type not urgent, right?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/nightscout/cgm-remote-monitor/pull/305/files#r22136552>
> .
>