Remove now unused dia, insulinInterfaceId from Treatment.
This commit is contained in:
parent
6c899fbf5c
commit
97d0140614
|
@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
|
||||||
public class DetailedBolusInfo {
|
public class DetailedBolusInfo {
|
||||||
public long date = System.currentTimeMillis();
|
public long date = System.currentTimeMillis();
|
||||||
public InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin();
|
|
||||||
public String eventType = CareportalEvent.MEALBOLUS;
|
public String eventType = CareportalEvent.MEALBOLUS;
|
||||||
public double insulin = 0;
|
public double insulin = 0;
|
||||||
public double carbs = 0;
|
public double carbs = 0;
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
if (calcdate > dia_ago && calcdate <= time) {
|
if (calcdate > dia_ago && calcdate <= time) {
|
||||||
double tempBolusSize = absoluteRate() * spacing / 60d;
|
double tempBolusSize = absoluteRate() * spacing / 60d;
|
||||||
|
|
||||||
Treatment tempBolusPart = new Treatment(insulinInterface, dia);
|
Treatment tempBolusPart = new Treatment();
|
||||||
tempBolusPart.insulin = tempBolusSize;
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
tempBolusPart.date = calcdate;
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ public class TemporaryBasal implements Interval {
|
||||||
double tempBolusSize = netBasalRate * tempBolusSpacing / 60d;
|
double tempBolusSize = netBasalRate * tempBolusSpacing / 60d;
|
||||||
netBasalAmount += tempBolusSize;
|
netBasalAmount += tempBolusSize;
|
||||||
|
|
||||||
Treatment tempBolusPart = new Treatment(insulinInterface, dia);
|
Treatment tempBolusPart = new Treatment();
|
||||||
tempBolusPart.insulin = tempBolusSize;
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
tempBolusPart.date = calcdate;
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
|
|
@ -50,32 +50,9 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public boolean isSMB = false;
|
public boolean isSMB = false;
|
||||||
|
|
||||||
@DatabaseField
|
|
||||||
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN;
|
|
||||||
@DatabaseField
|
|
||||||
public double dia = Constants.defaultDIA;
|
|
||||||
|
|
||||||
public Treatment() {
|
public Treatment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treatment(long date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Treatment(InsulinInterface insulin) {
|
|
||||||
insulinInterfaceID = insulin.getId();
|
|
||||||
dia = insulin.getDia();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Treatment(InsulinInterface insulin, double dia) {
|
|
||||||
insulinInterfaceID = insulin.getId();
|
|
||||||
this.dia = dia;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMillisecondsFromStart() {
|
|
||||||
return System.currentTimeMillis() - date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Treatment{" +
|
return "Treatment{" +
|
||||||
"date= " + date +
|
"date= " + date +
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.jjoe64.graphview.series.DataPoint;
|
||||||
import com.jjoe64.graphview.series.LineGraphSeries;
|
import com.jjoe64.graphview.series.LineGraphSeries;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
@ -39,14 +38,14 @@ public class ActivityGraph extends GraphView {
|
||||||
double dia = insulin.getDia();
|
double dia = insulin.getDia();
|
||||||
int hours = (int) Math.floor(dia + 1);
|
int hours = (int) Math.floor(dia + 1);
|
||||||
|
|
||||||
Treatment t = new Treatment(insulin, dia);
|
Treatment t = new Treatment();
|
||||||
t.date = 0;
|
t.date = 0;
|
||||||
t.insulin = 1d;
|
t.insulin = 1d;
|
||||||
|
|
||||||
LineGraphSeries<DataPoint> activitySeries = null;
|
LineGraphSeries<DataPoint> activitySeries = null;
|
||||||
LineGraphSeries<DataPoint> iobSeries = null;
|
LineGraphSeries<DataPoint> iobSeries = null;
|
||||||
List<DataPoint> activityArray = new ArrayList<DataPoint>();
|
List<DataPoint> activityArray = new ArrayList<>();
|
||||||
List<DataPoint> iobArray = new ArrayList<DataPoint>();
|
List<DataPoint> iobArray = new ArrayList<>();
|
||||||
|
|
||||||
for (long time = 0; time <= hours * 60 * 60 * 1000; time += 5 * 60 * 1000L) {
|
for (long time = 0; time <= hours * 60 * 60 * 1000; time += 5 * 60 * 1000L) {
|
||||||
Iob iob = t.iobCalc(time, dia);
|
Iob iob = t.iobCalc(time, dia);
|
||||||
|
@ -56,7 +55,7 @@ public class ActivityGraph extends GraphView {
|
||||||
|
|
||||||
DataPoint[] activityDataPoints = new DataPoint[activityArray.size()];
|
DataPoint[] activityDataPoints = new DataPoint[activityArray.size()];
|
||||||
activityDataPoints = activityArray.toArray(activityDataPoints);
|
activityDataPoints = activityArray.toArray(activityDataPoints);
|
||||||
addSeries(activitySeries = new LineGraphSeries<DataPoint>(activityDataPoints));
|
addSeries(activitySeries = new LineGraphSeries<>(activityDataPoints));
|
||||||
activitySeries.setThickness(8);
|
activitySeries.setThickness(8);
|
||||||
|
|
||||||
getViewport().setXAxisBoundsManual(true);
|
getViewport().setXAxisBoundsManual(true);
|
||||||
|
@ -68,7 +67,7 @@ public class ActivityGraph extends GraphView {
|
||||||
|
|
||||||
DataPoint[] iobDataPoints = new DataPoint[iobArray.size()];
|
DataPoint[] iobDataPoints = new DataPoint[iobArray.size()];
|
||||||
iobDataPoints = iobArray.toArray(iobDataPoints);
|
iobDataPoints = iobArray.toArray(iobDataPoints);
|
||||||
getSecondScale().addSeries(iobSeries = new LineGraphSeries<DataPoint>(iobDataPoints));
|
getSecondScale().addSeries(iobSeries = new LineGraphSeries<>(iobDataPoints));
|
||||||
iobSeries.setDrawBackground(true);
|
iobSeries.setDrawBackground(true);
|
||||||
iobSeries.setColor(Color.MAGENTA);
|
iobSeries.setColor(Color.MAGENTA);
|
||||||
iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255));
|
iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255));
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
log.debug("Service is disconnected");
|
log.debug("Service is disconnected");
|
||||||
|
@ -298,7 +298,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
|
|
@ -72,8 +72,6 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
|
|
||||||
public static PumpDescription pumpDescription = new PumpDescription();
|
public static PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
String textStatus = "";
|
|
||||||
|
|
||||||
public DanaRKoreanPlugin() {
|
public DanaRKoreanPlugin() {
|
||||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||||
|
|
||||||
|
@ -107,7 +105,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
log.debug("Service is disconnected");
|
log.debug("Service is disconnected");
|
||||||
|
@ -301,7 +299,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
||||||
|
|
|
@ -73,8 +73,6 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
public static PumpDescription pumpDescription = new PumpDescription();
|
public static PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
public DanaRv2Plugin() {
|
public DanaRv2Plugin() {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
|
||||||
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
@ -105,7 +103,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
log.debug("Service is disconnected");
|
log.debug("Service is disconnected");
|
||||||
|
@ -288,7 +286,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
|
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
|
||||||
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
|
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
|
||||||
|
|
|
@ -413,7 +413,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
Treatment treatment = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment treatment = new Treatment();
|
||||||
treatment.date = detailedBolusInfo.date;
|
treatment.date = detailedBolusInfo.date;
|
||||||
treatment.source = detailedBolusInfo.source;
|
treatment.source = detailedBolusInfo.source;
|
||||||
treatment.pumpId = detailedBolusInfo.pumpId;
|
treatment.pumpId = detailedBolusInfo.pumpId;
|
||||||
|
@ -427,7 +427,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(treatment);
|
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(treatment);
|
||||||
//log.debug("Adding new Treatment record" + treatment.toString());
|
//log.debug("Adding new Treatment record" + treatment.toString());
|
||||||
if (detailedBolusInfo.carbTime != 0) {
|
if (detailedBolusInfo.carbTime != 0) {
|
||||||
Treatment carbsTreatment = new Treatment(detailedBolusInfo.insulinInterface);
|
Treatment carbsTreatment = new Treatment();
|
||||||
carbsTreatment.source = detailedBolusInfo.source;
|
carbsTreatment.source = detailedBolusInfo.source;
|
||||||
carbsTreatment.pumpId = detailedBolusInfo.pumpId; // but this should never happen
|
carbsTreatment.pumpId = detailedBolusInfo.pumpId; // but this should never happen
|
||||||
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
||||||
|
|
Loading…
Reference in a new issue