Open
Conversation
3fb17fc to
2290441
Compare
- BetaCellPlugin : APS + PluginBase(3 args), OpenAPSFragment - BetaCellApsResult : implements APSResult directly, no injector - BetaCellPrefs : immutable snapshot via Preferences - IsfCalibrator : rolling SD on ads.bgReadings - Keys : +3 BooleanKey, +12 DoubleKey, +1 IntKey - PluginsListModule : @IntKey(222) BetaCellPlugin - build.gradle.kts : ksp/libs.* catalog format
6ea6968 to
f53870d
Compare
… loop with GlucoseStatusProviderImpl
… avoid circular call via GlucoseStatusProviderImpl
…ed — unblocks swipe refresh spinner
…ctor, BG<hypo+5 guard
… — iobTotal computed internally
|
Contributor
|
Target branch for PRs should never be master but dev No description provided? Can you explain the feature, provide screenshots, explain how it works... Several critical files are modified so you should describe impact on loop and APS calculation 😉. |
Author
|
Hi,
Thank you for the review feedback — all three points are addressed below.
…---
**1. Target branch**
Apologies for targeting master. The PR has been rebased onto dev and the
target branch updated accordingly. All three feature branches
(feature/betacell-plugin, feature/betacell-sigmoid,
feature/wear-medtrum-standalone) have been migrated from master to dev.
---
**2. Feature description**
BetaCellPlugin is a new APS algorithm that models the insulin secretion
behaviour of a healthy pancreatic β-cell in response to CGM readings.
Two selectable calculation modes via the `useNonLinear` preference:
• Linear (default): β = (BG − target) / ISF × dt
Proportional to the glucose gap — predictable, easy to validate in open
loop.
• Sigmoid²+CaState: β = maxSecretion × σ²(BG) × Ca²⁺ × dt
Non-linear response with intracellular calcium memory (caState), closer
to real β-cell physiology.
The plugin is disabled and set to open-loop-only by default
(betacell_open_loop_only = true). No insulin is delivered until explicitly
enabled by the user.
---
**3. Impact on loop and APS calculation**
APS pipeline (every 5-minute cycle):
invoke()
├─ IsfCalibrator — rolling SD of bgReadings → dynamic ISF [isfMin,
isfMax]
└─ calcBetaSecretion()
├─ Guard 1: bg < hypoBg → rate=0, smb=0 (absolute,
hardcoded floor 55 mg/dL)
├─ Guard 2: bgIn30min < hypoAlert → rate=0, smb=0 (predictive:
projection + IOB + slope)
├─ basalFactor [0.0→1.0] — smooth gradient near hypo
threshold
├─ recentBolus guard (<3 min) → SMB suspended (IOB DB write
latency)
└─ switch useNonLinear → calcLinear() or calcNonLinear()
IOB: uses native AAPS calculateIobFromBolus() +
calculateIobFromTempBasals() with full DIA curve — no custom IOB model in
the loop path. IobTotal.lastBolusTime is used for the bolus latency guard.
SMB conditions (6 guards, both modes):
smbEnabled && !recentBolus && bg > targetBg+offset && bg < hyperBg &&
bgIn30min > hypoAlert && iobTotal < smbMax×3
Files modified in existing AAPS code:
• BooleanKey.kt / DoubleKey.kt / IntKey.kt — new betacell_* preference keys
only, no existing key affected
• ApsModule.kt — +1 Fragment binding, no existing binding changed
• PluginsListModule.kt — +1 plugin binding at unused @IntKey(222)
All new keys use the betacell_ prefix. The plugin is disabled by default
and cannot affect the loop unless explicitly selected in Config Builder.
Please let me know if you need any additional information.
Best regards
Le mer. 18 mars 2026 à 21:58, Philoul ***@***.***> a écrit :
*Philoul* left a comment (nightscout/AndroidAPS#4592)
<#4592 (comment)>
Target branch for PRs should never be master but dev
No description provided? Can you explain the feature, provide screenshots,
explain how it works...
Several critical files are modified so you should describe impact on loop
and APS calculation 😉.
—
Reply to this email directly, view it on GitHub
<#4592 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BCZA5DJXTXFZGDGQ47KDZIT4RMLYPAVCNFSM6AAAAACWMFTLV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DAOBVHAYTIMZQHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




No description provided.