decoding-carelink icon indicating copy to clipboard operation
decoding-carelink copied to clipboard

Floating point accuracy fix in set_temp_basal

Open cjo20 opened this issue 8 years ago • 4 comments

Basal rates weren't being set correctly in the pump (e.g. 0.6u/hr was being set as 0.575u/hr)

if rate = 0.6:

>>> int(0.6/0.025)
23
>>> 0.6/0.025
23.999999999999996

If the user is trying to set a basal rate that the pump can support, this should always result in better behaviour than the current code. oref0 dev should only try to set supported rates.

If users try to set basal rates not supported by the pump, it could end up setting a rate up to 0.0125u/hr more than they requested.

cjo20 avatar Jul 15 '16 21:07 cjo20

Can you PR this against the openaps/decocare repo as well? Not sure which branch, but that same file is at https://github.com/openaps/decocare/blob/master/decocare/commands.py#L296 in master.

scottleibrand avatar Jul 15 '16 23:07 scottleibrand

Done here: https://github.com/openaps/decocare/pull/2

cjo20 avatar Jul 16 '16 00:07 cjo20

Merged openaps/decocare#2 and tested. Confirmed it allows setting a 0.6U/hr temp, whereas without this fix it ended up at 0.575U/hr. 👍 for merge

scottleibrand avatar Jul 17 '16 04:07 scottleibrand

Per https://github.com/openaps/decocare/pull/1 it looks like this branch is no longer used by openaps, so it's up to @bewest whether he wants to try to keep it in sync with openaps/decocare or not.

scottleibrand avatar Jul 17 '16 04:07 scottleibrand