display minDeviationSlope

This commit is contained in:
Milos Kozak 2017-10-24 17:15:49 +02:00
parent fe0376206e
commit 29b075e700
3 changed files with 38 additions and 1 deletions

View file

@ -28,6 +28,8 @@ public class Config {
public static final boolean ALLPREFERENCES = !BuildConfig.NSCLIENTOLNY;
public static final boolean displayDeviationSlope = true;
public static final boolean detailedLog = true;
public static final boolean logFunctionCalls = true;
public static final boolean logIncommingData = true;

View file

@ -1281,6 +1281,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
boolean useCobForScale = false;
boolean useDevForScale = false;
boolean useRatioForScale = false;
boolean useDSForScale = false;
if (showIobView.isChecked()) {
useIobForScale = true;
@ -1290,6 +1291,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
useDevForScale = true;
} else if (showRatiosView.isChecked()) {
useRatioForScale = true;
} else if (Config.displayDeviationSlope) {
useDSForScale = true;
}
if (showIobView.isChecked())
@ -1300,8 +1303,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
secondGraphData.addDeviations(iobGraph, fromTime, now, useDevForScale, 1d);
if (showRatiosView.isChecked())
secondGraphData.addRatio(iobGraph, fromTime, now, useRatioForScale, 1d);
if (Config.displayDeviationSlope)
secondGraphData.addDeviationSlope(iobGraph, fromTime, now, useDSForScale, 1d);
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked() || Config.displayDeviationSlope) {
iobGraph.setVisibility(View.VISIBLE);
} else {
iobGraph.setVisibility(View.GONE);

View file

@ -428,6 +428,36 @@ public class GraphData {
addSeriesWithoutInvalidate(graph, ratioSeries);
}
// scale in % of vertical size (like 0.3)
public void addDeviationSlope(GraphView graph, long fromTime, long toTime, boolean useForScale, double scale) {
LineGraphSeries<DataPoint> dsSeries;
List<DataPoint> dsArray = new ArrayList<>();
Double maxDSValueFound = 0d;
Scale dsScale = new Scale();
for (long time = fromTime; time <= toTime; time += 5 * 60 * 1000L) {
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
if (autosensData != null) {
dsArray.add(new DataPoint(time, autosensData.minDeviationSlope));
maxDSValueFound = Math.max(maxDSValueFound, Math.abs(autosensData.minDeviationSlope));
}
}
// RATIOS
DataPoint[] ratioData = new DataPoint[dsArray.size()];
ratioData = dsArray.toArray(ratioData);
dsSeries = new LineGraphSeries<>(ratioData);
dsSeries.setColor(Color.MAGENTA);
dsSeries.setThickness(3);
if (useForScale)
maxY = maxDSValueFound;
dsScale.setMultiplier(maxY * scale / maxDSValueFound);
addSeriesWithoutInvalidate(graph, dsSeries);
}
// scale in % of vertical size (like 0.3)
public void addNowLine(GraphView graph, long now) {
LineGraphSeries<DataPoint> seriesNow;