DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface { @Override public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile) { percentRate.setIfGreater(0, String.format(MainApp.gs(R.string.limitingpercentrate), 0, MainApp.gs(R.string.itmustbepositivevalue)), this); percentRate.setIfSmaller(getPumpDescription().maxTempPercent, String.format(MainApp.gs(R.string.limitingpercentrate), getPumpDescription().maxTempPercent, MainApp.gs(R.string.pumplimit)), this); return percentRate; } private  DanaRSPlugin(); static DanaRSPlugin getPlugin(); @Override void onStateChange(PluginType type, State oldState, State newState); @Override void updatePreferenceSummary(@NotNull Preference pref); @Override void switchAllowed(boolean newState, FragmentActivity activity, PluginType type); @Override void connect(String from); @Override boolean isConnected(); @Override boolean isConnecting(); @Override boolean isHandshakeInProgress(); @Override void finishHandshaking(); @Override void disconnect(String from); @Override void stopConnecting(); @Override void getPumpStatus(); @Override PumpEnactResult loadHistory(byte type); @Override PumpEnactResult loadEvents(); @Override PumpEnactResult setUserOptions(); @Override Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile); @Override Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile); @Override Constraint<Double> applyBolusConstraints(Constraint<Double> insulin); @Override Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin); @Override boolean isInitialized(); @Override boolean isSuspended(); @Override boolean isBusy(); @Override PumpEnactResult setNewBasalProfile(Profile profile); @Override boolean isThisProfileSet(Profile profile); @Override long lastDataTime(); @Override double getBaseBasalRate(); @Override double getReservoirLevel(); @Override int getBatteryLevel(); @Override synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo); @Override void stopBolusDelivering(); @Override synchronized PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew); @Override synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew); @Override synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes); @Override synchronized PumpEnactResult cancelTempBasal(boolean force); @Override synchronized PumpEnactResult cancelExtendedBolus(); @Override JSONObject getJSONStatus(Profile profile, String profileName); @Override ManufacturerType manufacturer(); @Override PumpType model(); @Override String serialNumber(); @Override PumpDescription getPumpDescription(); @Override String shortStatus(boolean veryShort); @Override boolean isFakingTempsByExtendedBoluses(); @Override PumpEnactResult loadTDDs(); @Override List<CustomAction> getCustomActions(); @Override void executeCustomAction(CustomActionType customActionType); @Override boolean canHandleDST(); @Override void timeDateOrTimeZoneChanged(); static String mDeviceName; static PumpDescription pumpDescription; }
@Test public void percentBasalRateShouldBeLimited() throws Exception { danaRSPlugin.setPluginEnabled(PluginType.PUMP, true); danaRSPlugin.setPluginEnabled(PluginType.PUMP, true); DanaRPump.getInstance().maxBasal = 0.8d; Constraint<Integer> c = new Constraint<>(Constants.REALLYHIGHPERCENTBASALRATE); danaRSPlugin.applyBasalPercentConstraints(c, AAPSMocker.getValidProfile()); assertEquals((Integer) 200, c.value()); assertEquals("DanaRS: Limiting percent rate to 200% because of pump limit", c.getReasons()); assertEquals("DanaRS: Limiting percent rate to 200% because of pump limit", c.getMostLimitedReasons()); }