Search in sources :

Example 1 with PumpStatusMessage

use of sugar.free.sightparser.applayer.messages.status.PumpStatusMessage in project SightRemote by TebbeUbben.

the class TemporaryBasalRateActivity method statusChanged.

@Override
protected void statusChanged(Status status) {
    if (status == Status.CONNECTED) {
        new SingleMessageTaskRunner(getServiceConnector(), new PumpStatusMessage()).fetch(this);
        showLoadingIndicator();
        hideManualOverlay();
    } else {
        if (confirmationDialog != null)
            confirmationDialog.hide();
        showManualOverlay();
        hideLoadingIndicator();
    }
}
Also used : PumpStatusMessage(sugar.free.sightparser.applayer.messages.status.PumpStatusMessage) SingleMessageTaskRunner(sugar.free.sightparser.handling.SingleMessageTaskRunner)

Example 2 with PumpStatusMessage

use of sugar.free.sightparser.applayer.messages.status.PumpStatusMessage in project SightRemote by TebbeUbben.

the class BolusPreparationTaskRunner method run.

@Override
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
    if (message == null)
        return new PumpStatusMessage();
    else if (message instanceof PumpStatusMessage) {
        preperationResult.pumpStarted = ((PumpStatusMessage) message).getPumpStatus().equals(PumpStatus.STARTED);
        if (preperationResult.pumpStarted)
            return new AvailableBolusesMessage();
        else {
            ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
            readMessage.setConfigurationBlockID(FactoryMinBolusAmountBlock.ID);
            return readMessage;
        }
    } else if (message instanceof AvailableBolusesMessage) {
        preperationResult.availableBoluses = (AvailableBolusesMessage) message;
        ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
        readMessage.setConfigurationBlockID(FactoryMinBolusAmountBlock.ID);
        return readMessage;
    } else {
        ReadConfigurationBlockMessage readMessage = (ReadConfigurationBlockMessage) message;
        if (readMessage.getConfigurationBlock() instanceof FactoryMinBolusAmountBlock) {
            preperationResult.minBolusAmount = ((FactoryMinBolusAmountBlock) readMessage.getConfigurationBlock()).getMinimumAmount();
            readMessage = new ReadConfigurationBlockMessage();
            readMessage.setConfigurationBlockID(MaxBolusAmountBlock.ID);
            return readMessage;
        } else if (readMessage.getConfigurationBlock() instanceof MaxBolusAmountBlock) {
            preperationResult.maxBolusAmount = ((MaxBolusAmountBlock) readMessage.getConfigurationBlock()).getMaximumAmount();
            finish(preperationResult);
        }
    }
    return null;
}
Also used : PumpStatusMessage(sugar.free.sightparser.applayer.messages.status.PumpStatusMessage) FactoryMinBolusAmountBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.FactoryMinBolusAmountBlock) MaxBolusAmountBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.MaxBolusAmountBlock) AvailableBolusesMessage(sugar.free.sightparser.applayer.messages.remote_control.AvailableBolusesMessage) ReadConfigurationBlockMessage(sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage)

Example 3 with PumpStatusMessage

use of sugar.free.sightparser.applayer.messages.status.PumpStatusMessage in project SightRemote by TebbeUbben.

the class TemporaryBasalRateActivity method onResult.

@Override
public void onResult(Object result) {
    if (result instanceof PumpStatusMessage) {
        PumpStatusMessage pumpStatusMessage = (PumpStatusMessage) result;
        if (pumpStatusMessage.getPumpStatus() != PumpStatus.STARTED) {
            showManualOverlay();
            hideLoadingIndicator();
            showSnackbar(Snackbar.make(getRootView(), R.string.pump_not_started, Snackbar.LENGTH_INDEFINITE));
        } else {
            hideLoadingIndicator();
            hideManualOverlay();
            dismissSnackbar();
        }
    } else {
        Answers.getInstance().logCustom(new CustomEvent("TBR Programmed"));
        finish();
    }
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent) PumpStatusMessage(sugar.free.sightparser.applayer.messages.status.PumpStatusMessage)

Aggregations

PumpStatusMessage (sugar.free.sightparser.applayer.messages.status.PumpStatusMessage)3 CustomEvent (com.crashlytics.android.answers.CustomEvent)1 FactoryMinBolusAmountBlock (sugar.free.sightparser.applayer.descriptors.configuration_blocks.FactoryMinBolusAmountBlock)1 MaxBolusAmountBlock (sugar.free.sightparser.applayer.descriptors.configuration_blocks.MaxBolusAmountBlock)1 ReadConfigurationBlockMessage (sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage)1 AvailableBolusesMessage (sugar.free.sightparser.applayer.messages.remote_control.AvailableBolusesMessage)1 SingleMessageTaskRunner (sugar.free.sightparser.handling.SingleMessageTaskRunner)1