- fixed 16, 17, 18

- added some code for db
This commit is contained in:
Andy Rozman 2019-12-15 16:48:59 +00:00
parent b4abf00d98
commit 24430a5c81
5 changed files with 77 additions and 27 deletions

View file

@ -207,11 +207,13 @@ class OmnipodFragment : Fragment() {
omnipod_pod_expiry.text = "-" omnipod_pod_expiry.text = "-"
omnipod_pod_status.text = MainApp.gs(R.string.omnipod_pod_no_pod_connected) omnipod_pod_status.text = MainApp.gs(R.string.omnipod_pod_no_pod_connected)
pumpStatus.podAvailable = false pumpStatus.podAvailable = false
pumpStatus.podNumber == null
} else { } else {
podAvailable = true podAvailable = true
pumpStatus.podAvailable = true pumpStatus.podAvailable = true
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString() omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
pumpStatus.podNumber == pumpStatus.podSessionState.address.toString()
//pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState, //pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState,
// OmnipodUtil.getPodSessionState()) as PodSessionState? // OmnipodUtil.getPodSessionState()) as PodSessionState?

View file

@ -576,9 +576,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true); TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
// we subtract insulin, exact amount will be visible with next remainingInsulin update. // we subtract insulin, exact amount will be visible with next remainingInsulin update.
// if (getPodPumpStatusObject().reservoirRemainingUnits != 0) { if (getPodPumpStatusObject().reservoirRemainingUnits != 0 &&
// getPodPumpStatusObject().reservoirRemainingUnits -= detailedBolusInfo.insulin; getPodPumpStatusObject().reservoirRemainingUnits != 75 ) {
// } getPodPumpStatusObject().reservoirRemainingUnits -= detailedBolusInfo.insulin;
}
incrementStatistics(detailedBolusInfo.isSMB ? OmnipodConst.Statistics.SMBBoluses incrementStatistics(detailedBolusInfo.isSMB ? OmnipodConst.Statistics.SMBBoluses
: OmnipodConst.Statistics.StandardBoluses); : OmnipodConst.Statistics.StandardBoluses);

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.NoSplashActivity import info.nightscout.androidaps.activities.NoSplashActivity
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodWizardModel import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodWizardModel
@ -27,6 +28,7 @@ import kotlinx.android.synthetic.main.omnipod_pod_mgmt.*
class PodManagementActivity : NoSplashActivity() { class PodManagementActivity : NoSplashActivity() {
private var initPodChanged = false private var initPodChanged = false
private var podSessionFullyInitalized = false
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -83,7 +85,7 @@ class PodManagementActivity : NoSplashActivity() {
wizardPagerContext.clearContext() wizardPagerContext.clearContext()
wizardPagerContext.pagerSettings = pagerSettings wizardPagerContext.pagerSettings = pagerSettings
wizardPagerContext.wizardModel = InitPodWizardModel(applicationContext) wizardPagerContext.wizardModel = InitPodWizardModel(applicationContext, !podSessionFullyInitalized)
val myIntent = Intent(this@PodManagementActivity, WizardPagerActivity::class.java) val myIntent = Intent(this@PodManagementActivity, WizardPagerActivity::class.java)
this@PodManagementActivity.startActivity(myIntent) this@PodManagementActivity.startActivity(myIntent)
@ -129,7 +131,14 @@ class PodManagementActivity : NoSplashActivity() {
fun refreshButtons() { fun refreshButtons() {
val isPodSessionActive = (OmnipodUtil.getPodSessionState()!=null) val isPodSessionActive = (OmnipodUtil.getPodSessionState()!=null)
initpod_init_pod.isEnabled = !isPodSessionActive if (isPodSessionActive) {
podSessionFullyInitalized = !OmnipodUtil.getPodSessionState().getSetupProgress().isBefore(SetupProgress.COMPLETED)
initpod_init_pod.isEnabled = !podSessionFullyInitalized
} else {
podSessionFullyInitalized = false
initpod_init_pod.isEnabled = true
}
initpod_remove_pod.isEnabled = isPodSessionActive initpod_remove_pod.isEnabled = isPodSessionActive
initpod_reset_pod.isEnabled = isPodSessionActive initpod_reset_pod.isEnabled = isPodSessionActive
} }

View file

@ -33,34 +33,57 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.PodI
* Created by andy on 12/11/2019 * Created by andy on 12/11/2019
*/ */
public class InitPodWizardModel extends AbstractWizardModel { public class InitPodWizardModel extends AbstractWizardModel {
public InitPodWizardModel(Context context) {
boolean isFullInit = true;
public InitPodWizardModel(Context context, boolean isFullInit) {
super(context); super(context);
this.isFullInit = isFullInit;
} }
@Override @Override
protected PageList onNewRootPageList() { protected PageList onNewRootPageList() {
return new PageList(
new DisplayTextPage(this, if (isFullInit) {
R.string.omnipod_init_pod_wizard_step1_title,
R.string.omnipod_init_pod_wizard_step1_desc,
R.style.WizardPagePodContent).setRequired(true).setCancelReason("None"),
new InitActionPage(this, return new PageList(
R.string.omnipod_init_pod_wizard_step2_title,
PodInitActionType.PairAndPrimeWizardStep
).setRequired(true).setCancelReason("Cancel"),
new DisplayTextPage(this, new DisplayTextPage(this,
R.string.omnipod_init_pod_wizard_step3_title, R.string.omnipod_init_pod_wizard_step1_title,
R.string.omnipod_init_pod_wizard_step3_desc, R.string.omnipod_init_pod_wizard_step1_desc,
R.style.WizardPagePodContent).setRequired(true).setCancelReason("Cancel"), R.style.WizardPagePodContent).setRequired(true).setCancelReason("None"),
new InitActionPage(this, new InitActionPage(this,
R.string.omnipod_init_pod_wizard_step4_title, R.string.omnipod_init_pod_wizard_step2_title,
PodInitActionType.FillCannulaSetBasalProfileWizardStep PodInitActionType.PairAndPrimeWizardStep
).setRequired(true).setCancelReason("Cancel") ).setRequired(true).setCancelReason("Cancel"),
);
new DisplayTextPage(this,
R.string.omnipod_init_pod_wizard_step3_title,
R.string.omnipod_init_pod_wizard_step3_desc,
R.style.WizardPagePodContent).setRequired(true).setCancelReason("Cancel"),
new InitActionPage(this,
R.string.omnipod_init_pod_wizard_step4_title,
PodInitActionType.FillCannulaSetBasalProfileWizardStep
).setRequired(true).setCancelReason("Cancel")
);
} else {
return new PageList(
new DisplayTextPage(this,
R.string.omnipod_init_pod_wizard_step3_title,
R.string.omnipod_init_pod_wizard_step3_desc,
R.style.WizardPagePodContent).setRequired(true).setCancelReason("Cancel"),
new InitActionPage(this,
R.string.omnipod_init_pod_wizard_step4_title,
PodInitActionType.FillCannulaSetBasalProfileWizardStep
).setRequired(true).setCancelReason("Cancel")
);
}
} }

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
@ -43,6 +44,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedu
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry; import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged; import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged; import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
@ -419,10 +421,23 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
} }
} }
private void addToHistory(long requestTime, PodHistoryEntryType entryType, String data, boolean success) { public void addToHistory(long requestTime, PodHistoryEntryType entryType, Object data, boolean success) {
// TODO andy needs to be refactored
PodHistory podHistory = new PodHistory(requestTime, entryType);
if (data!=null) {
if (data instanceof String) {
podHistory.setData((String)data);
} else {
podHistory.setData(OmnipodUtil.getGsonInstance().toJson(data));
}
}
podHistory.setSuccess(success);
podHistory.setPodSerial(pumpStatus.podNumber);
MainApp.getDbHelper().createOrUpdate(podHistory);
//PodDbEntry entry = new PodDbEntry(requestTime, entryType);
} }
private void handleSetupActionResult(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, SetupActionResult res) { private void handleSetupActionResult(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, SetupActionResult res) {