- fixed problem parsing Bolus
- reworked storing of Profile, instead of Profile we use Profile.ProfileValue[]
This commit is contained in:
parent
7097689c28
commit
d58075a93c
4 changed files with 60 additions and 24 deletions
|
@ -29,5 +29,26 @@ public class ProfileUtil {
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getBasalProfilesDisplayable(Profile.ProfileValue[] profiles, PumpType pumpType) {
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (Profile.ProfileValue basalValue : profiles) {
|
||||||
|
|
||||||
|
double basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value);
|
||||||
|
|
||||||
|
int hour = basalValue.timeAsSeconds / (60 * 60);
|
||||||
|
|
||||||
|
stringBuilder.append((hour < 10 ? "0" : "") + hour + ":00");
|
||||||
|
|
||||||
|
stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValueValue));
|
||||||
|
stringBuilder.append(", ");
|
||||||
|
}
|
||||||
|
if (stringBuilder.length() > 3)
|
||||||
|
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
|
||||||
|
else
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ import android.widget.TextView;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -24,7 +22,6 @@ import java.util.Collections;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashActivity;
|
import info.nightscout.androidaps.activities.NoSplashActivity;
|
||||||
|
@ -255,23 +252,20 @@ public class PodHistoryActivity extends NoSplashActivity {
|
||||||
if (historyEntry.isSuccess()) {
|
if (historyEntry.isSuccess()) {
|
||||||
switch (historyEntry.getPodDbEntryType()) {
|
switch (historyEntry.getPodDbEntryType()) {
|
||||||
|
|
||||||
case FillCannulaSetBasalProfile: {
|
|
||||||
if (historyEntry.getData() != null) {
|
|
||||||
setProfileValue(historyEntry.getData(), valueView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SetTemporaryBasal: {
|
case SetTemporaryBasal: {
|
||||||
TempBasalPair tempBasalPair = OmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class);
|
TempBasalPair tempBasalPair = OmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class);
|
||||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes()));
|
valueView.setText(MainApp.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FillCannulaSetBasalProfile:
|
||||||
case SetBasalSchedule: {
|
case SetBasalSchedule: {
|
||||||
|
if (historyEntry.getData() != null) {
|
||||||
setProfileValue(historyEntry.getData(), valueView);
|
setProfileValue(historyEntry.getData(), valueView);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetPodStatus:
|
case GetPodStatus:
|
||||||
break;
|
break;
|
||||||
case GetPodInfo:
|
case GetPodInfo:
|
||||||
|
@ -281,10 +275,10 @@ public class PodHistoryActivity extends NoSplashActivity {
|
||||||
|
|
||||||
case SetBolus: {
|
case SetBolus: {
|
||||||
if (historyEntry.getData().contains(";")) {
|
if (historyEntry.getData().contains(";")) {
|
||||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData())));
|
|
||||||
} else {
|
|
||||||
String[] splitVal = historyEntry.getData().split(";");
|
String[] splitVal = historyEntry.getData().split(";");
|
||||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1])));
|
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1])));
|
||||||
|
} else {
|
||||||
|
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -313,11 +307,13 @@ public class PodHistoryActivity extends NoSplashActivity {
|
||||||
|
|
||||||
private void setProfileValue(String data, TextView valueView) {
|
private void setProfileValue(String data, TextView valueView) {
|
||||||
LOG.debug("Profile json:\n" + data);
|
LOG.debug("Profile json:\n" + data);
|
||||||
Profile profile = null;
|
|
||||||
try {
|
try {
|
||||||
profile = new Profile(new JSONObject(data), Constants.MGDL);
|
Profile.ProfileValue[] profileValuesArray = OmnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class);
|
||||||
valueView.setText(ProfileUtil.getProfileDisplayable(profile, PumpType.Insulet_Omnipod));
|
|
||||||
} catch (JSONException e) {
|
//profile = new Profile(new JSONObject(data), Constants.MGDL);
|
||||||
|
valueView.setText(ProfileUtil.getBasalProfilesDisplayable(profileValuesArray, PumpType.Insulet_Omnipod));
|
||||||
|
} catch (Exception e) {
|
||||||
LOG.error("Problem parsing Profile json. Ex: {}, Data:\n{}", e.getMessage(), data);
|
LOG.error("Problem parsing Profile json. Ex: {}, Data:\n{}", e.getMessage(), data);
|
||||||
valueView.setText("");
|
valueView.setText("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
throw new CommandInitializationException("Basal profile mapping failed", ex);
|
throw new CommandInitializationException("Basal profile mapping failed", ex);
|
||||||
}
|
}
|
||||||
delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled());
|
delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled());
|
||||||
addSuccessToHistory(time, PodHistoryEntryType.SetBasalSchedule, profile);
|
addSuccessToHistory(time, PodHistoryEntryType.SetBasalSchedule, profile.getBasalValues());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||||
addToHistory(time, PodHistoryEntryType.SetBasalSchedule, "Uncertain failure", false);
|
addToHistory(time, PodHistoryEntryType.SetBasalSchedule, "Uncertain failure", false);
|
||||||
|
@ -583,7 +583,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
|
if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
|
||||||
addToHistory(time, PodHistoryEntryType.PairAndPrime, comment, res.getResultType().isSuccess());
|
addToHistory(time, PodHistoryEntryType.PairAndPrime, comment, res.getResultType().isSuccess());
|
||||||
} else {
|
} else {
|
||||||
addToHistory(time, PodHistoryEntryType.FillCannulaSetBasalProfile, res.getResultType().isSuccess() ? profile : comment, res.getResultType().isSuccess());
|
addToHistory(time, PodHistoryEntryType.FillCannulaSetBasalProfile, res.getResultType().isSuccess() ? profile.getBasalValues() : comment, res.getResultType().isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
podInitReceiver.returnInitTaskStatus(podInitActionType, res.getResultType().isSuccess(), comment);
|
podInitReceiver.returnInitTaskStatus(podInitActionType, res.getResultType().isSuccess(), comment);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
||||||
|
@ -36,4 +36,23 @@ public class MedtronicConverterUTest {
|
||||||
// byte[] data = new byte[] { 00 03 00 05 01 00 C8 00 A0 01 01 00 01 00 00 64 01 05 00 14 00 64 01 00 00 };
|
// byte[] data = new byte[] { 00 03 00 05 01 00 C8 00 A0 01 01 00 01 00 00 64 01 05 00 14 00 64 01 00 00 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void testLocale() {
|
||||||
|
Locale l = new Locale("en", "IE");
|
||||||
|
|
||||||
|
Locale.setDefault(l);
|
||||||
|
|
||||||
|
Date date = new Date();
|
||||||
|
|
||||||
|
System.out.println("Date: toLocaleString: " + date.toLocaleString());
|
||||||
|
System.out.println("Date: toString: " + date.toString());
|
||||||
|
System.out.println("Date: toGMTString: " + date.toGMTString());
|
||||||
|
|
||||||
|
|
||||||
|
for (String isoCountry : Locale.getISOCountries()) {
|
||||||
|
//System.out.println("ISO country: " + isoCountry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue