Search in sources :

Example 1 with ReadConfigurationBlockMessage

use of sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage 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 2 with ReadConfigurationBlockMessage

use of sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage in project SightRemote by TebbeUbben.

the class ReadConfigurationTaskRunner method run.

@Override
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
    if (message instanceof ReadConfigurationBlockMessage) {
        ReadConfigurationBlockMessage readMessage = (ReadConfigurationBlockMessage) message;
        configurationBlocks.add(readMessage.getConfigurationBlock());
    }
    if (IDs.size() != 0) {
        ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
        readMessage.setConfigurationBlockID(IDs.get(0));
        IDs.remove(0);
        return readMessage;
    } else
        finish(configurationBlocks);
    return null;
}
Also used : ReadConfigurationBlockMessage(sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage)

Aggregations

ReadConfigurationBlockMessage (sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage)2 FactoryMinBolusAmountBlock (sugar.free.sightparser.applayer.descriptors.configuration_blocks.FactoryMinBolusAmountBlock)1 MaxBolusAmountBlock (sugar.free.sightparser.applayer.descriptors.configuration_blocks.MaxBolusAmountBlock)1 AvailableBolusesMessage (sugar.free.sightparser.applayer.messages.remote_control.AvailableBolusesMessage)1 PumpStatusMessage (sugar.free.sightparser.applayer.messages.status.PumpStatusMessage)1