- fixed problem parsing Bolus
- reworked storing of Profile, instead of Profile we use Profile.ProfileValue[]
This commit is contained in:
parent
7097689c28
commit
d58075a93c
|
@ -29,5 +29,26 @@ public class ProfileUtil {
|
|||
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.RecyclerView;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -24,7 +22,6 @@ import java.util.Collections;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashActivity;
|
||||
|
@ -255,23 +252,20 @@ public class PodHistoryActivity extends NoSplashActivity {
|
|||
if (historyEntry.isSuccess()) {
|
||||
switch (historyEntry.getPodDbEntryType()) {
|
||||
|
||||
case FillCannulaSetBasalProfile: {
|
||||
if (historyEntry.getData() != null) {
|
||||
setProfileValue(historyEntry.getData(), valueView);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SetTemporaryBasal: {
|
||||
TempBasalPair tempBasalPair = OmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class);
|
||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes()));
|
||||
}
|
||||
break;
|
||||
|
||||
case FillCannulaSetBasalProfile:
|
||||
case SetBasalSchedule: {
|
||||
setProfileValue(historyEntry.getData(), valueView);
|
||||
if (historyEntry.getData() != null) {
|
||||
setProfileValue(historyEntry.getData(), valueView);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GetPodStatus:
|
||||
break;
|
||||
case GetPodInfo:
|
||||
|
@ -281,10 +275,10 @@ public class PodHistoryActivity extends NoSplashActivity {
|
|||
|
||||
case SetBolus: {
|
||||
if (historyEntry.getData().contains(";")) {
|
||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData())));
|
||||
} else {
|
||||
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])));
|
||||
} else {
|
||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData())));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -313,11 +307,13 @@ public class PodHistoryActivity extends NoSplashActivity {
|
|||
|
||||
private void setProfileValue(String data, TextView valueView) {
|
||||
LOG.debug("Profile json:\n" + data);
|
||||
Profile profile = null;
|
||||
|
||||
try {
|
||||
profile = new Profile(new JSONObject(data), Constants.MGDL);
|
||||
valueView.setText(ProfileUtil.getProfileDisplayable(profile, PumpType.Insulet_Omnipod));
|
||||
} catch (JSONException e) {
|
||||
Profile.ProfileValue[] profileValuesArray = OmnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class);
|
||||
|
||||
//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);
|
||||
valueView.setText("");
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
throw new CommandInitializationException("Basal profile mapping failed", ex);
|
||||
}
|
||||
delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled());
|
||||
addSuccessToHistory(time, PodHistoryEntryType.SetBasalSchedule, profile);
|
||||
addSuccessToHistory(time, PodHistoryEntryType.SetBasalSchedule, profile.getBasalValues());
|
||||
} catch (Exception ex) {
|
||||
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||
addToHistory(time, PodHistoryEntryType.SetBasalSchedule, "Uncertain failure", false);
|
||||
|
@ -583,7 +583,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
|
||||
addToHistory(time, PodHistoryEntryType.PairAndPrime, comment, res.getResultType().isSuccess());
|
||||
} 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);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
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.defs.MedtronicCommandType;
|
||||
|
@ -22,12 +22,12 @@ public class MedtronicConverterUTest {
|
|||
//@Test
|
||||
public void testDecoding554() {
|
||||
byte[] data = ByteUtil
|
||||
.createByteArrayFromString("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");
|
||||
.createByteArrayFromString("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");
|
||||
|
||||
MedtronicUtil.setMedtronicPumpModel(MedtronicDeviceType.Medtronic_554_Veo);
|
||||
|
||||
Map<String, PumpSettingDTO> settings = (Map<String, PumpSettingDTO>)converter.convertResponse(
|
||||
MedtronicCommandType.Settings, data);
|
||||
Map<String, PumpSettingDTO> settings = (Map<String, PumpSettingDTO>) converter.convertResponse(
|
||||
MedtronicCommandType.Settings, data);
|
||||
|
||||
for (PumpSettingDTO pumpSettingDTO : settings.values()) {
|
||||
System.out.println("" + pumpSettingDTO.key + " = " + pumpSettingDTO.value);
|
||||
|
@ -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 };
|
||||
}
|
||||
|
||||
|
||||
//@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