Merge branch 'dev' into ench_1455_custom_actions
This commit is contained in:
commit
b0fe8fc5aa
587 changed files with 33123 additions and 13509 deletions
|
@ -1,10 +1,10 @@
|
|||
Reporting bugs
|
||||
--------------
|
||||
- Note the precise time the problem occurred and describe the circumstances and steps that caused
|
||||
- **Note the precise time the problem occurred** and describe the circumstances and steps that caused
|
||||
the problem
|
||||
- Note the Build version (found in the About dialog in the app, when pressing the three dots in the
|
||||
upper-right corner).
|
||||
- Obtain the app's log files, which can be found on the phone in
|
||||
_/storage/emulated/0/Android/data/info.nightscout.androidaps/_
|
||||
See https://github.com/MilosKozak/AndroidAPS/wiki/Accessing-logfiles
|
||||
- Open an issue at https://github.com/MilosKozak/AndroidAPS/issues/new
|
||||
- Open an issue at https://github.com/MilosKozak/AndroidAPS/issues/new
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# AndroidAPS
|
||||
|
||||
* Check the wiki: https://github.com/MilosKozak/AndroidAPS/wiki
|
||||
* Check the wiki: http://wiki.androidaps.org
|
||||
* Everyone who’s been looping with AndroidAPS needs to fill out the form after 3 days of looping https://docs.google.com/forms/d/14KcMjlINPMJHVt28MDRupa4sz4DDIooI4SrW0P3HSN8/viewform?c=0&w=1
|
||||
|
||||
[![Gitter](https://badges.gitter.im/MilosKozak/AndroidAPS.svg)](https://gitter.im/MilosKozak/AndroidAPS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
|
|
@ -63,7 +63,7 @@ android {
|
|||
targetSdkVersion 25
|
||||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
version "2.0g-dev"
|
||||
version "2.0"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||
|
@ -197,6 +197,7 @@ dependencies {
|
|||
implementation "com.google.android.gms:play-services-wearable:7.5.0"
|
||||
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
|
||||
implementation(name: "sightparser-release", ext: "aar")
|
||||
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
||||
|
||||
implementation("com.google.android:flexbox:0.3.0") {
|
||||
exclude group: "com.android.support"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_MMS" />
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.SEND_MMS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
@ -30,10 +31,13 @@
|
|||
android:name=".MainApp"
|
||||
android:allowBackup="true"
|
||||
android:icon="${appIcon}"
|
||||
android:roundIcon="${appIconRound}"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="${appIconRound}"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.car.application"
|
||||
android:resource="@xml/automotive_app_desc" />
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -84,6 +88,8 @@
|
|||
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" />
|
||||
<!-- Receiver from DexcomG5 -->
|
||||
<action android:name="com.dexcom.cgm.DATA" />
|
||||
<action android:name="com.dexcom.cgm.AndroidAPSEVGCallback.BROADCAST" />
|
||||
<action android:name="com.dexcom.cgm.g5.AndroidAPSEVGCallback.BROADCAST" />
|
||||
<!-- Receiver from Poctech -->
|
||||
<action android:name="com.china.poctech.data" />
|
||||
</intent-filter>
|
||||
|
@ -177,6 +183,8 @@
|
|||
android:exported="false" />
|
||||
|
||||
<service android:name=".plugins.Persistentnotification.DummyService" />
|
||||
<service android:name=".plugins.PumpInsightLocal.connection_service.InsightConnectionService" />
|
||||
<service android:name=".plugins.PumpInsightLocal.InsightAlertService" />
|
||||
|
||||
<meta-data
|
||||
android:name="io.fabric.ApiKey"
|
||||
|
@ -185,12 +193,25 @@
|
|||
<activity
|
||||
android:name=".setupwizard.SetupWizardActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/title_activity_setup_wizard" />
|
||||
android:label="@string/title_activity_setup_wizard"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity android:name=".activities.SingleFragmentActivity"
|
||||
<activity
|
||||
android:name=".activities.SingleFragmentActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".plugins.Maintenance.activities.LogSettingActivity"></activity>
|
||||
<activity
|
||||
android:name=".plugins.PumpInsightLocal.activities.InsightPairingActivity"
|
||||
android:theme="@style/AppTheme"
|
||||
android:label="@string/insight_pairing" />
|
||||
<activity
|
||||
android:name=".plugins.PumpInsightLocal.activities.InsightAlertActivity"
|
||||
android:label="@string/pump_alert"
|
||||
android:theme="@style/InsightAlertDialog" />
|
||||
<activity
|
||||
android:name=".plugins.PumpInsightLocal.activities.InsightPairingInformationActivity"
|
||||
android:theme="@style/AppTheme"
|
||||
android:label="@string/pairing_information" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -9,33 +9,32 @@ var tempBasalFunctions = {};
|
|||
|
||||
tempBasalFunctions.getMaxSafeBasal = function getMaxSafeBasal(profile) {
|
||||
|
||||
var max_daily_safety_multiplier = (isNaN(profile.max_daily_safety_multiplier) || profile.max_daily_safety_multiplier == null) ? 3 : profile.max_daily_safety_multiplier;
|
||||
var current_basal_safety_multiplier = (isNaN(profile.current_basal_safety_multiplier) || profile.current_basal_safety_multiplier == null) ? 4 : profile.current_basal_safety_multiplier;
|
||||
|
||||
return Math.min(profile.max_basal, max_daily_safety_multiplier * profile.max_daily_basal, current_basal_safety_multiplier * profile.current_basal);
|
||||
var max_daily_safety_multiplier = (isNaN(profile.max_daily_safety_multiplier) || profile.max_daily_safety_multiplier == null) ? 3 : profile.max_daily_safety_multiplier;
|
||||
var current_basal_safety_multiplier = (isNaN(profile.current_basal_safety_multiplier) || profile.current_basal_safety_multiplier == null) ? 4 : profile.current_basal_safety_multiplier;
|
||||
|
||||
return Math.min(profile.max_basal, max_daily_safety_multiplier * profile.max_daily_basal, current_basal_safety_multiplier * profile.current_basal);
|
||||
};
|
||||
|
||||
tempBasalFunctions.setTempBasal = function setTempBasal(rate, duration, profile, rT, currenttemp) {
|
||||
//var maxSafeBasal = Math.min(profile.max_basal, 3 * profile.max_daily_basal, 4 * profile.current_basal);
|
||||
|
||||
|
||||
var maxSafeBasal = tempBasalFunctions.getMaxSafeBasal(profile);
|
||||
var round_basal = require('./round-basal');
|
||||
|
||||
if (rate < 0) {
|
||||
rate = 0;
|
||||
} // if >30m @ 0 required, zero temp will be extended to 30m instead
|
||||
else if (rate > maxSafeBasal) {
|
||||
rate = maxSafeBasal;
|
||||
var round_basal = require('./round-basal');
|
||||
|
||||
if (rate < 0) {
|
||||
rate = 0;
|
||||
} else if (rate > maxSafeBasal) {
|
||||
rate = maxSafeBasal;
|
||||
}
|
||||
|
||||
var suggestedRate = round_basal(rate, profile);
|
||||
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && typeof(currenttemp.rate) !== 'undefined' && currenttemp.duration > (duration-10) && currenttemp.duration <= 120 && suggestedRate <= currenttemp.rate * 1.2 && suggestedRate >= currenttemp.rate * 0.8) {
|
||||
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && typeof(currenttemp.rate) !== 'undefined' && currenttemp.duration > (duration-10) && currenttemp.duration <= 120 && suggestedRate <= currenttemp.rate * 1.2 && suggestedRate >= currenttemp.rate * 0.8 && duration > 0 ) {
|
||||
rT.reason += " "+currenttemp.duration+"m left and " + currenttemp.rate + " ~ req " + suggestedRate + "U/hr: no temp required";
|
||||
return rT;
|
||||
}
|
||||
|
||||
if (suggestedRate === profile.current_basal) {
|
||||
if (profile.skip_neutral_temps) {
|
||||
if (profile.skip_neutral_temps === true) {
|
||||
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && currenttemp.duration > 0) {
|
||||
reason(rT, 'Suggested rate is same as profile rate, a temp basal is active, canceling current temp');
|
||||
rT.duration = 0;
|
||||
|
@ -58,4 +57,4 @@ var round_basal = require('./round-basal');
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = tempBasalFunctions;
|
||||
module.exports = tempBasalFunctions;
|
||||
|
|
|
@ -182,7 +182,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventRefreshGui ev) {
|
||||
String lang = SP.getString("language", "en");
|
||||
String lang = SP.getString(R.string.key_language, "en");
|
||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
||||
runOnUiThread(() -> {
|
||||
if (ev.recreate) {
|
||||
|
@ -326,6 +326,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
case AndroidPermission.CASE_LOCATION:
|
||||
case AndroidPermission.CASE_SMS:
|
||||
case AndroidPermission.CASE_BATTERY:
|
||||
case AndroidPermission.CASE_PHONESTATE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.LocalInsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
|
||||
|
@ -67,6 +68,8 @@ import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref1Plugin;
|
|||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG6Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceEversensePlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
|
@ -93,7 +96,6 @@ public class MainApp extends Application {
|
|||
public static Resources sResources;
|
||||
|
||||
private static DatabaseHelper sDatabaseHelper = null;
|
||||
private static ConfigBuilderPlugin sConfigBuilder = null;
|
||||
private static ConstraintChecker sConstraintsChecker = null;
|
||||
|
||||
private static ArrayList<PluginBase> pluginsList = null;
|
||||
|
@ -158,9 +160,10 @@ public class MainApp extends Application {
|
|||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS && engineeringMode) pluginsList.add(LocalInsightPlugin.getInstance());
|
||||
pluginsList.add(CareportalPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS && engineeringMode)
|
||||
pluginsList.add(InsightPlugin.getPlugin()); // <-- Enable Insight plugin here
|
||||
/*if (Config.PUMPDRIVERS && engineeringMode)
|
||||
pluginsList.add(InsightPlugin.getPlugin());*/
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||
pluginsList.add(VirtualPumpPlugin.getPlugin());
|
||||
|
@ -179,7 +182,9 @@ public class MainApp extends Application {
|
|||
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
||||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
|
||||
pluginsList.add(SourceDexcomG6Plugin.getPlugin());
|
||||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||
pluginsList.add(SourceEversensePlugin.getPlugin());
|
||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
||||
|
@ -189,18 +194,18 @@ public class MainApp extends Application {
|
|||
pluginsList.add(NSClientPlugin.getPlugin());
|
||||
pluginsList.add(MaintenancePlugin.initPlugin(this));
|
||||
|
||||
pluginsList.add(sConfigBuilder = ConfigBuilderPlugin.getPlugin());
|
||||
pluginsList.add(ConfigBuilderPlugin.getPlugin());
|
||||
|
||||
MainApp.getConfigBuilder().initialize();
|
||||
ConfigBuilderPlugin.getPlugin().initialize();
|
||||
}
|
||||
|
||||
NSUpload.uploadAppStart();
|
||||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (pump != null) {
|
||||
new Thread(() -> {
|
||||
SystemClock.sleep(5000);
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Initialization", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Initialization", null);
|
||||
startKeepAliveService();
|
||||
}).start();
|
||||
}
|
||||
|
@ -297,10 +302,6 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
public static ConfigBuilderPlugin getConfigBuilder() {
|
||||
return sConfigBuilder;
|
||||
}
|
||||
|
||||
public static ConstraintChecker getConstraintChecker() {
|
||||
return sConstraintsChecker;
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
|||
if (noProfile == null || buttonDate == null || buttonZoom == null || bgGraph == null || iobGraph == null || seekBar == null)
|
||||
return;
|
||||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.preference.PreferenceActivity;
|
|||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
|
@ -190,6 +191,17 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginType.GENERAL);
|
||||
}
|
||||
|
||||
if (Config.NSCLIENT) {
|
||||
PreferenceScreen scrnAdvancedSettings = (PreferenceScreen)findPreference(getString(R.string.key_advancedsettings));
|
||||
if (scrnAdvancedSettings != null) {
|
||||
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_warning)));
|
||||
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_res_critical)));
|
||||
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_warning)));
|
||||
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_statuslights_bat_critical)));
|
||||
scrnAdvancedSettings.removePreference(getPreference(getString(R.string.key_show_statuslights)));
|
||||
}
|
||||
}
|
||||
|
||||
initSummary(getPreferenceScreen());
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ public class TDDStatsActivity extends Activity {
|
|||
}
|
||||
totalBaseBasal.setText(TBB);
|
||||
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad)
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().needsManualTDDLoad)
|
||||
reloadButton.setVisibility(View.GONE);
|
||||
|
||||
// stats table
|
||||
|
@ -239,7 +239,7 @@ public class TDDStatsActivity extends Activity {
|
|||
statsMessage.setText(MainApp.gs(R.string.danar_stats_warning_Message));
|
||||
}
|
||||
});
|
||||
ConfigBuilderPlugin.getCommandQueue().loadTDDs( new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadTDDs( new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadDataFromDB();
|
||||
|
@ -440,7 +440,7 @@ public class TDDStatsActivity extends Activity {
|
|||
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||
}
|
||||
|
||||
if (isOldData(historyList) && ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) {
|
||||
if (isOldData(historyList) && ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().needsManualTDDLoad) {
|
||||
statsMessage.setVisibility(View.VISIBLE);
|
||||
statsMessage.setText(MainApp.gs(R.string.danar_stats_olddata_Message));
|
||||
|
||||
|
@ -545,7 +545,7 @@ public class TDDStatsActivity extends Activity {
|
|||
|
||||
|
||||
public static boolean isOldData(List<TDD> historyList) {
|
||||
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
||||
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
|
|
|
@ -42,6 +42,10 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
return isSMBModeEnabled(new Constraint<>(true));
|
||||
}
|
||||
|
||||
public Constraint<Boolean> isUAMEnabled() {
|
||||
return isUAMEnabled(new Constraint<>(true));
|
||||
}
|
||||
|
||||
public Constraint<Boolean> isAdvancedFilteringEnabled() {
|
||||
return isAdvancedFilteringEnabled(new Constraint<>(true));
|
||||
}
|
||||
|
@ -130,6 +134,18 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
|
||||
|
||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.isUAMEnabled(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
|
||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
|
|
|
@ -12,17 +12,18 @@ import java.text.DecimalFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.MidnightTime;
|
||||
|
||||
public class Profile {
|
||||
private static Logger log = LoggerFactory.getLogger(Profile.class);
|
||||
|
@ -221,7 +222,7 @@ public class Profile {
|
|||
|
||||
if (isValid) {
|
||||
// Check for hours alignment
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (pump != null && !pump.getPumpDescription().is30minBasalRatesCapable) {
|
||||
for (int index = 0; index < basal_v.size(); index++) {
|
||||
long secondsFromMidnight = basal_v.keyAt(index);
|
||||
|
@ -381,7 +382,7 @@ public class Profile {
|
|||
}
|
||||
|
||||
public double getIsf() {
|
||||
return getIsfTimeFromMidnight(secondsFromMidnight(System.currentTimeMillis()));
|
||||
return getIsfTimeFromMidnight(secondsFromMidnight());
|
||||
}
|
||||
|
||||
public double getIsf(long time) {
|
||||
|
@ -397,11 +398,11 @@ public class Profile {
|
|||
public String getIsfList() {
|
||||
if (isf_v == null)
|
||||
isf_v = convertToSparseArray(isf);
|
||||
return getValuesList(isf_v, null, new DecimalFormat("0.0"), getUnits() + "/U");
|
||||
return getValuesList(isf_v, null, new DecimalFormat("0.0"), getUnits() + MainApp.gs(R.string.profile_per_unit));
|
||||
}
|
||||
|
||||
public double getIc() {
|
||||
return getIcTimeFromMidnight(secondsFromMidnight(System.currentTimeMillis()));
|
||||
return getIcTimeFromMidnight(secondsFromMidnight());
|
||||
}
|
||||
|
||||
public double getIc(long time) {
|
||||
|
@ -417,11 +418,11 @@ public class Profile {
|
|||
public String getIcList() {
|
||||
if (ic_v == null)
|
||||
ic_v = convertToSparseArray(ic);
|
||||
return getValuesList(ic_v, null, new DecimalFormat("0.0"), "g/U");
|
||||
return getValuesList(ic_v, null, new DecimalFormat("0.0"), MainApp.gs(R.string.profile_carbs_per_unit));
|
||||
}
|
||||
|
||||
public double getBasal() {
|
||||
return getBasalTimeFromMidnight(secondsFromMidnight(System.currentTimeMillis()));
|
||||
return getBasalTimeFromMidnight(secondsFromMidnight());
|
||||
}
|
||||
|
||||
public double getBasal(long time) {
|
||||
|
@ -438,7 +439,7 @@ public class Profile {
|
|||
public String getBasalList() {
|
||||
if (basal_v == null)
|
||||
basal_v = convertToSparseArray(basal);
|
||||
return getValuesList(basal_v, null, new DecimalFormat("0.00"), "U/h");
|
||||
return getValuesList(basal_v, null, new DecimalFormat("0.00"), MainApp.gs(R.string.profile_ins_units_per_hout));
|
||||
}
|
||||
|
||||
public class BasalValue {
|
||||
|
@ -465,7 +466,7 @@ public class Profile {
|
|||
}
|
||||
|
||||
public double getTarget() {
|
||||
return getTarget(secondsFromMidnight(System.currentTimeMillis()));
|
||||
return getTarget(secondsFromMidnight());
|
||||
}
|
||||
|
||||
protected double getTarget(int timeAsSeconds) {
|
||||
|
@ -473,7 +474,7 @@ public class Profile {
|
|||
}
|
||||
|
||||
public double getTargetLow() {
|
||||
return getTargetLowTimeFromMidnight(secondsFromMidnight(System.currentTimeMillis()));
|
||||
return getTargetLowTimeFromMidnight(secondsFromMidnight());
|
||||
}
|
||||
|
||||
public double getTargetLow(long time) {
|
||||
|
@ -487,7 +488,7 @@ public class Profile {
|
|||
}
|
||||
|
||||
public double getTargetHigh() {
|
||||
return getTargetHighTimeFromMidnight(secondsFromMidnight(System.currentTimeMillis()));
|
||||
return getTargetHighTimeFromMidnight(secondsFromMidnight());
|
||||
}
|
||||
|
||||
public double getTargetHigh(long time) {
|
||||
|
@ -518,24 +519,13 @@ public class Profile {
|
|||
}
|
||||
|
||||
public static int secondsFromMidnight() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
long now = c.getTimeInMillis();
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
long passed = now - c.getTimeInMillis();
|
||||
long passed = DateUtil.now() - MidnightTime.calc();
|
||||
return (int) (passed / 1000);
|
||||
}
|
||||
|
||||
public static int secondsFromMidnight(long date) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTimeInMillis(date);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
long passed = date - c.getTimeInMillis();
|
||||
long midnight = MidnightTime.calc(date);
|
||||
long passed = date - midnight;
|
||||
return (int) (passed / 1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -220,14 +220,8 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
@Override
|
||||
public int getColor() {
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
Double lowLine = SP.getDouble("low_mark", 0d);
|
||||
Double highLine = SP.getDouble("high_mark", 0d);
|
||||
if (lowLine < 1) {
|
||||
lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
|
||||
}
|
||||
if (highLine < 1) {
|
||||
highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
|
||||
}
|
||||
Double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
||||
Double highLine = OverviewPlugin.getPlugin().determineHighLine(units);
|
||||
int color = MainApp.gc(R.color.inrange);
|
||||
if (isPrediction())
|
||||
return getPredectionColor();
|
||||
|
|
|
@ -90,8 +90,8 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
|||
return System.currentTimeMillis() - date;
|
||||
}
|
||||
|
||||
public long getHoursFromStart() {
|
||||
return (System.currentTimeMillis() - date) / (60 * 60 * 1000);
|
||||
public double getHoursFromStart() {
|
||||
return (System.currentTimeMillis() - date) / (60 * 60 * 1000.0);
|
||||
}
|
||||
|
||||
public String age() {
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -43,11 +44,15 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
|||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.database.InsightBolusID;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.database.InsightHistoryOffset;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.database.InsightPumpID;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.utils.JsonHelper;
|
||||
import info.nightscout.utils.PercentageSplitter;
|
||||
|
@ -74,8 +79,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
||||
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
||||
public static final String DATABASE_TDDS = "TDDs";
|
||||
public static final String DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets";
|
||||
public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs";
|
||||
public static final String DATABASE_INSIGHT_PUMP_IDS = "InsightPumpIDs";
|
||||
|
||||
private static final int DATABASE_VERSION = 9;
|
||||
private static final int DATABASE_VERSION = 10;
|
||||
|
||||
public static Long earliestDataChange = null;
|
||||
|
||||
|
@ -120,6 +128,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, TDD.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class);
|
||||
} catch (SQLException e) {
|
||||
log.error("Can't create database", e);
|
||||
throw new RuntimeException(e);
|
||||
|
@ -136,6 +147,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
log.debug("Upgrading database from v7 to v8");
|
||||
} else if (oldVersion == 8 && newVersion == 9) {
|
||||
log.debug("Upgrading database from v8 to v9");
|
||||
} else if (oldVersion == 9 && newVersion == 10) {
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class);
|
||||
} else {
|
||||
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||
|
@ -154,6 +169,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
log.info("Do nothing for downgrading...");
|
||||
log.debug("oldVersion: {}, newVersion: {}", oldVersion, newVersion);
|
||||
}
|
||||
|
||||
public int getOldVersion() {
|
||||
return oldVersion;
|
||||
}
|
||||
|
@ -319,6 +340,18 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
return getDao(ProfileSwitch.class);
|
||||
}
|
||||
|
||||
private Dao<InsightPumpID, Long> getDaoInsightPumpID() throws SQLException {
|
||||
return getDao(InsightPumpID.class);
|
||||
}
|
||||
|
||||
private Dao<InsightBolusID, Long> getDaoInsightBolusID() throws SQLException {
|
||||
return getDao(InsightBolusID.class);
|
||||
}
|
||||
|
||||
private Dao<InsightHistoryOffset, String> getDaoInsightHistoryOffset() throws SQLException {
|
||||
return getDao(InsightHistoryOffset.class);
|
||||
}
|
||||
|
||||
public static long roundDateToSec(long date) {
|
||||
long rounded = date - date % 1000;
|
||||
if (rounded != date)
|
||||
|
@ -395,7 +428,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
||||
queryBuilder.orderBy("date", false);
|
||||
queryBuilder.limit(1L);
|
||||
queryBuilder.where().gt("value", 38).and().eq("isValid", true);
|
||||
queryBuilder.where().ge("value", 39).and().eq("isValid", true);
|
||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||
bgList = daoBgReadings.query(preparedQuery);
|
||||
|
||||
|
@ -433,7 +466,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
||||
queryBuilder.orderBy("date", ascending);
|
||||
Where where = queryBuilder.where();
|
||||
where.ge("date", mills).and().gt("value", 38).and().eq("isValid", true);
|
||||
where.ge("date", mills).and().ge("value", 39).and().eq("isValid", true);
|
||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||
bgReadings = daoBgreadings.query(preparedQuery);
|
||||
return bgReadings;
|
||||
|
@ -450,7 +483,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
||||
queryBuilder.orderBy("date", ascending);
|
||||
Where where = queryBuilder.where();
|
||||
where.between("date", start, end).and().gt("value", 38).and().eq("isValid", true);
|
||||
where.between("date", start, end).and().ge("value", 39).and().eq("isValid", true);
|
||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||
bgReadings = daoBgreadings.query(preparedQuery);
|
||||
return bgReadings;
|
||||
|
@ -699,7 +732,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
|
||||
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
|
||||
try {
|
||||
String units = JsonHelper.safeGetString(trJson, "units", ProfileFunctions.getInstance().getProfileUnits());
|
||||
String units = JsonHelper.safeGetString(trJson, "units", Constants.MGDL);
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.date(trJson.getLong("mills"))
|
||||
.duration(trJson.getInt("duration"))
|
||||
|
@ -1141,6 +1174,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public ExtendedBolus getExtendedBolusByPumpId(long pumpId) {
|
||||
try {
|
||||
return getDaoExtendedBolus().queryBuilder()
|
||||
.where().eq("pumpId", pumpId)
|
||||
.queryForFirst();
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void delete(ExtendedBolus extendedBolus) {
|
||||
try {
|
||||
getDaoExtendedBolus().delete(extendedBolus);
|
||||
|
@ -1584,7 +1628,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
if (trJson.has("profileJson"))
|
||||
profileSwitch.profileJson = trJson.getString("profileJson");
|
||||
else {
|
||||
ProfileInterface profileInterface = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||
ProfileInterface profileInterface = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface();
|
||||
if (profileInterface != null) {
|
||||
ProfileStore store = profileInterface.getProfile();
|
||||
if (store != null) {
|
||||
|
@ -1648,5 +1692,67 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
// ---------------- Insight history handling ---------------
|
||||
|
||||
public void createOrUpdate(InsightHistoryOffset offset) {
|
||||
try {
|
||||
getDaoInsightHistoryOffset().createOrUpdate(offset);
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public InsightHistoryOffset getInsightHistoryOffset(String pumpSerial) {
|
||||
try {
|
||||
return getDaoInsightHistoryOffset().queryForId(pumpSerial);
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createOrUpdate(InsightBolusID bolusID) {
|
||||
try {
|
||||
getDaoInsightBolusID().createOrUpdate(bolusID);
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public InsightBolusID getInsightBolusID(String pumpSerial, int bolusID, long timestamp) {
|
||||
try {
|
||||
return getDaoInsightBolusID().queryBuilder()
|
||||
.where().eq("pumpSerial", pumpSerial)
|
||||
.and().eq("bolusID", bolusID)
|
||||
.and().between("timestamp", timestamp - 259200000, timestamp + 259200000)
|
||||
.queryForFirst();
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createOrUpdate(InsightPumpID pumpID) {
|
||||
try {
|
||||
getDaoInsightPumpID().createOrUpdate(pumpID);
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public InsightPumpID getPumpStoppedEvent(String pumpSerial, long before) {
|
||||
try {
|
||||
return getDaoInsightPumpID().queryBuilder()
|
||||
.orderBy("timestamp", false)
|
||||
.where().eq("pumpSerial", pumpSerial)
|
||||
.and().in("eventType", "PumpStopped", "PumpPaused")
|
||||
.and().lt("timestamp", before)
|
||||
.queryForFirst();
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------- Food handling ---------------
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
|||
|
||||
public IobTotal iobCalc(long time) {
|
||||
IobTotal result = new IobTotal(time);
|
||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
||||
|
||||
int realDuration = getDurationToTime(time);
|
||||
|
||||
|
|
|
@ -101,6 +101,11 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
|||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: the name returned here is used as the PS name when uploading to NS. When such a PS is retrieved
|
||||
* again from NS, the added parts must be removed again, see
|
||||
* {@link info.nightscout.utils.PercentageSplitter#pureName}
|
||||
*/
|
||||
public String getCustomizedName() {
|
||||
String name = profileName;
|
||||
if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){
|
||||
|
|
|
@ -228,7 +228,7 @@ public class TemporaryBasal implements Interval {
|
|||
}
|
||||
|
||||
IobTotal result = new IobTotal(time);
|
||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
|
||||
|
||||
int realDuration = getDurationToTime(time);
|
||||
double netBasalAmount = 0d;
|
||||
|
|
|
@ -27,6 +27,10 @@ public interface ConstraintsInterface {
|
|||
return value;
|
||||
}
|
||||
|
||||
default Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
default Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ public abstract class PluginBase {
|
|||
if (getType() == PluginType.PUMP) {
|
||||
new Thread(() -> {
|
||||
SystemClock.sleep(3000);
|
||||
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
|
||||
CommandQueue commandQueue = ConfigBuilderPlugin.getPlugin().getCommandQueue();
|
||||
if (commandQueue != null)
|
||||
commandQueue.readStatus("Pump driver changed.", null);
|
||||
}).start();
|
||||
|
|
|
@ -37,6 +37,10 @@ public interface PumpInterface {
|
|||
|
||||
double getBaseBasalRate(); // base basal rate, not temp basal
|
||||
|
||||
double getReservoirLevel();
|
||||
|
||||
int getBatteryLevel(); // in percent as integer
|
||||
|
||||
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
|
||||
void stopBolusDelivering();
|
||||
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew);
|
||||
|
|
|
@ -99,13 +99,13 @@ public class L {
|
|||
private static void initialize() {
|
||||
logElements = new ArrayList<>();
|
||||
logElements.add(new LogElement(APS, true));
|
||||
logElements.add(new LogElement(AUTOSENS, true));
|
||||
logElements.add(new LogElement(AUTOSENS, false));
|
||||
logElements.add(new LogElement(BGSOURCE, true));
|
||||
logElements.add(new LogElement(CONFIGBUILDER, true));
|
||||
logElements.add(new LogElement(CONFIGBUILDER, false));
|
||||
logElements.add(new LogElement(CONSTRAINTS, true));
|
||||
logElements.add(new LogElement(CORE, true));
|
||||
logElements.add(new LogElement(DATABASE, true));
|
||||
logElements.add(new LogElement(DATAFOOD, true));
|
||||
logElements.add(new LogElement(DATAFOOD, false));
|
||||
logElements.add(new LogElement(DATASERVICE, true));
|
||||
logElements.add(new LogElement(DATATREATMENTS, true));
|
||||
logElements.add(new LogElement(EVENTS, false, true));
|
||||
|
|
|
@ -141,7 +141,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) {
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
|
||||
profileSwitch.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
profileSwitch.setVisibility(View.GONE);
|
||||
|
@ -157,7 +157,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
return;
|
||||
}
|
||||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
final boolean basalprofileEnabled = MainApp.isEngineeringModeOrRelease()
|
||||
&& pump.getPumpDescription().isSetBasalProfileCapable;
|
||||
|
||||
|
@ -225,7 +225,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
|
||||
CustomAction customAction = this.pumpCustomActions.get(btn.getText().toString());
|
||||
|
||||
ConfigBuilderPlugin.getActivePump().executeCustomAction(customAction.getCustomActionType());
|
||||
ConfigBuilderPlugin.getPlugin().getActivePump().executeCustomAction(customAction.getCustomActionType());
|
||||
|
||||
};
|
||||
|
||||
|
@ -258,7 +258,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
btn.setLayoutParams(layoutParams);
|
||||
btn.setOnClickListener(pumpCustomActionsListener);
|
||||
|
||||
Drawable top = getResources().getDrawable(R.drawable.icon_actions_profileswitch);
|
||||
Drawable top = getResources().getDrawable(customAction.getIconResourceId());
|
||||
btn.setCompoundDrawablesWithIntrinsicBounds(null, top, null, null);
|
||||
|
||||
ll.addView(btn);
|
||||
|
@ -312,13 +312,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
break;
|
||||
case R.id.actions_extendedbolus_cancel:
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelExtended(null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(null);
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelExtended"));
|
||||
}
|
||||
break;
|
||||
case R.id.actions_canceltempbasal:
|
||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, null);
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -11,12 +11,19 @@ public class CustomAction {
|
|||
private int name;
|
||||
private String iconName;
|
||||
private CustomActionType customActionType;
|
||||
private int iconResourceId;
|
||||
|
||||
|
||||
public CustomAction(int nameResourceId, CustomActionType actionType)
|
||||
{
|
||||
public CustomAction(int nameResourceId, CustomActionType actionType) {
|
||||
this.name = nameResourceId;
|
||||
this.customActionType = actionType;
|
||||
this.iconResourceId = R.drawable.icon_actions_profileswitch;
|
||||
}
|
||||
|
||||
public CustomAction(int nameResourceId, CustomActionType actionType, int iconResourceId) {
|
||||
this.name = nameResourceId;
|
||||
this.customActionType = actionType;
|
||||
this.iconResourceId = iconResourceId;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,23 +32,16 @@ public class CustomAction {
|
|||
return name;
|
||||
}
|
||||
|
||||
public String getIconName() {
|
||||
|
||||
return iconName;
|
||||
}
|
||||
|
||||
public void setIconName(String iconName) {
|
||||
|
||||
this.iconName = iconName;
|
||||
}
|
||||
|
||||
public CustomActionType getCustomActionType() {
|
||||
|
||||
return customActionType;
|
||||
}
|
||||
|
||||
public void setCustomActionType(CustomActionType customActionType) {
|
||||
|
||||
this.customActionType = customActionType;
|
||||
public int getIconResourceId() {
|
||||
return iconResourceId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
insulinCartridgeChangeCheckbox = view.findViewById(R.id.fill_cartridge_change);
|
||||
|
||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
||||
editInsulin = view.findViewById(R.id.fill_insulinamount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
|
||||
|
@ -185,7 +185,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
confirmMessage.add(MainApp.gs(R.string.fillwarning));
|
||||
confirmMessage.add("");
|
||||
confirmMessage.add(MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.colorCarbsButton) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + "U" + "</font>");
|
||||
if (!insulinAfterConstraints.equals(insulin))
|
||||
if (Math.abs(insulinAfterConstraints - insulin) > 0.01d)
|
||||
confirmMessage.add("<font color='" + MainApp.gc(R.color.low) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>");
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||
detailedBolusInfo.notes = notes;
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -48,8 +48,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false);
|
||||
|
||||
double extendedDurationStep = ConfigBuilderPlugin.getActivePump().getPumpDescription().extendedBolusDurationStep;
|
||||
double extendedMaxDuration = ConfigBuilderPlugin.getActivePump().getPumpDescription().extendedBolusMaxDuration;
|
||||
double extendedDurationStep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusDurationStep;
|
||||
double extendedMaxDuration = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusMaxDuration;
|
||||
editDuration = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_duration);
|
||||
editDuration.setParams(extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, new DecimalFormat("0"), false);
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute_radio);
|
||||
typeSelectorLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout);
|
||||
|
||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription();
|
||||
|
||||
basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
|
||||
double maxTempPercent = pumpDescription.maxTempPercent;
|
||||
|
@ -163,9 +163,9 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
}
|
||||
};
|
||||
if (setAsPercent) {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, true, profile, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, true, profile, callback);
|
||||
} else {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, profile, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, profile, callback);
|
||||
}
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("TempBasal"));
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
@ -100,7 +101,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
|||
noProfileView = view.findViewById(R.id.profileview_noprofile);
|
||||
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
||||
|
||||
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface() != null ? MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() : null;
|
||||
ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null ? ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() : null;
|
||||
if (profileStore == null) {
|
||||
noProfileView.setVisibility(View.VISIBLE);
|
||||
butonsLayout.setVisibility(View.GONE);
|
||||
|
|
|
@ -49,14 +49,15 @@ import info.nightscout.androidaps.db.ProfileSwitch;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DefaultValueHelper;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.HardLimits;
|
||||
import info.nightscout.utils.JsonHelper;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
@ -173,7 +174,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
|
||||
// profile
|
||||
profile = ProfileFunctions.getInstance().getProfile();
|
||||
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||
profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile();
|
||||
if (profileStore == null) {
|
||||
if (options.eventType == R.id.careportal_profileswitch) {
|
||||
log.error("Profile switch called but plugin doesn't contain valid profile");
|
||||
|
@ -269,7 +270,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
if (profile == null) {
|
||||
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, bgTextWatcher);
|
||||
editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
} else if (profile.getUnits().equals(Constants.MMOL)) {
|
||||
} else if (units.equals(Constants.MMOL)) {
|
||||
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, bgTextWatcher);
|
||||
editTemptarget.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
} else {
|
||||
|
@ -278,7 +279,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
}
|
||||
|
||||
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
Double bg1 = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile.getUnits());
|
||||
Double bg1 = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
||||
if (savedInstanceState != null && savedInstanceState.getDouble("editBg") != bg1) {
|
||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
||||
} else {
|
||||
|
@ -458,7 +459,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
if ((data.size() > 0) &&
|
||||
(data.get(0).date > millis - 7 * 60 * 1000L) &&
|
||||
(data.get(0).date < millis + 7 * 60 * 1000L)) {
|
||||
editBg.setValue(Profile.fromMgdlToUnits(data.get(0).value, profile != null ? profile.getUnits() : Constants.MGDL));
|
||||
editBg.setValue(Profile.fromMgdlToUnits(data.get(0).value, units));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -735,8 +736,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
.reason(reason)
|
||||
.source(Source.USER);
|
||||
if (tempTarget.durationInMinutes != 0) {
|
||||
tempTarget.low(Profile.toMgdl(targetBottom, profile.getUnits()))
|
||||
.high(Profile.toMgdl(targetTop, profile.getUnits()));
|
||||
tempTarget.low(Profile.toMgdl(targetBottom, units))
|
||||
.high(Profile.toMgdl(targetTop, units));
|
||||
} else {
|
||||
tempTarget.low(0).high(0);
|
||||
}
|
||||
|
@ -767,7 +768,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = profileName;
|
||||
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
|
||||
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
profileSwitch.timeshift = timeshift;
|
||||
|
@ -789,7 +790,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = ProfileFunctions.getInstance().getProfileName(System.currentTimeMillis(), false);
|
||||
profileSwitch.profileJson = ProfileFunctions.getInstance().getProfile().getData().toString();
|
||||
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
profileSwitch.timeshift = timeshift;
|
||||
|
|
|
@ -19,7 +19,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
|
@ -42,16 +41,15 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
}
|
||||
|
||||
private BgSourceInterface activeBgSource;
|
||||
private static PumpInterface activePump;
|
||||
private static ProfileInterface activeProfile;
|
||||
private static TreatmentsInterface activeTreatments;
|
||||
private static APSInterface activeAPS;
|
||||
private static InsulinInterface activeInsulin;
|
||||
private static SensitivityInterface activeSensitivity;
|
||||
private PumpInterface activePump;
|
||||
private ProfileInterface activeProfile;
|
||||
private APSInterface activeAPS;
|
||||
private InsulinInterface activeInsulin;
|
||||
private SensitivityInterface activeSensitivity;
|
||||
|
||||
private static ArrayList<PluginBase> pluginList;
|
||||
private ArrayList<PluginBase> pluginList;
|
||||
|
||||
private static CommandQueue commandQueue = new CommandQueue();
|
||||
private CommandQueue commandQueue = new CommandQueue();
|
||||
|
||||
public ConfigBuilderPlugin() {
|
||||
super(new PluginDescription()
|
||||
|
@ -230,7 +228,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
public static CommandQueue getCommandQueue() {
|
||||
public CommandQueue getCommandQueue() {
|
||||
return commandQueue;
|
||||
}
|
||||
|
||||
|
@ -242,19 +240,19 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
return activeProfile;
|
||||
}
|
||||
|
||||
public static InsulinInterface getActiveInsulin() {
|
||||
public InsulinInterface getActiveInsulin() {
|
||||
return activeInsulin;
|
||||
}
|
||||
|
||||
public static APSInterface getActiveAPS() {
|
||||
public APSInterface getActiveAPS() {
|
||||
return activeAPS;
|
||||
}
|
||||
|
||||
public static PumpInterface getActivePump() {
|
||||
public PumpInterface getActivePump() {
|
||||
return activePump;
|
||||
}
|
||||
|
||||
public static SensitivityInterface getActiveSensitivity() {
|
||||
public SensitivityInterface getActiveSensitivity() {
|
||||
return activeSensitivity;
|
||||
}
|
||||
|
||||
|
@ -322,7 +320,6 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);
|
||||
|
||||
// PluginType.TREATMENT
|
||||
activeTreatments = this.determineActivePlugin(PluginType.TREATMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ProfileFunctions {
|
|||
public void onProfileSwitch(EventProfileSwitchChange ignored) {
|
||||
if (L.isEnabled(L.PROFILE))
|
||||
log.debug("onProfileSwitch");
|
||||
MainApp.getConfigBuilder().getCommandQueue().setProfile(getProfile(), new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().setProfile(getProfile(), new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -79,7 +79,7 @@ public class ProfileFunctions {
|
|||
|
||||
public String getProfileName(long time, boolean customized) {
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||
ProfileInterface activeProfile = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface();
|
||||
|
||||
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
|
@ -114,7 +114,7 @@ public class ProfileFunctions {
|
|||
@Nullable
|
||||
public Profile getProfile(long time) {
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||
ProfileInterface activeProfile = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface();
|
||||
|
||||
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
||||
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
|
|||
|
||||
@Override
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class Objective1 extends Objective {
|
|||
tasks.add(new Task(R.string.apsselected) {
|
||||
@Override
|
||||
public boolean isCompleted() {
|
||||
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||
APSInterface usedAPS = ConfigBuilderPlugin.getPlugin().getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS))
|
||||
return true;
|
||||
return false;
|
||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
|||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref1Plugin;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.HardLimits;
|
||||
import info.nightscout.utils.Round;
|
||||
|
@ -52,7 +53,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
**/
|
||||
@Override
|
||||
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable)
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable)
|
||||
value.set(false, MainApp.gs(R.string.pumpisnottempbasalcapable), this);
|
||||
return value;
|
||||
}
|
||||
|
@ -94,9 +95,20 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
|
||||
boolean enabled = SP.getBoolean(R.string.key_use_uam, false);
|
||||
if (!enabled)
|
||||
value.set(false, MainApp.gs(R.string.uamdisabledinpreferences), this);
|
||||
boolean oref1Enabled = SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY);
|
||||
if (!oref1Enabled)
|
||||
value.set(false, MainApp.gs(R.string.uamdisabledoref1notselected), this);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
|
||||
BgSourceInterface bgSource = MainApp.getConfigBuilder().getActiveBgSource();
|
||||
BgSourceInterface bgSource = ConfigBuilderPlugin.getPlugin().getActiveBgSource();
|
||||
|
||||
if (bgSource != null) {
|
||||
if (!bgSource.advancedFilteringSupported())
|
||||
|
@ -124,7 +136,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
|
||||
absoluteRate.setIfSmaller(HardLimits.maxBasal(), String.format(MainApp.gs(R.string.limitingbasalratio), HardLimits.maxBasal(), MainApp.gs(R.string.hardlimit)), this);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
// check for pump max
|
||||
if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||
double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose();
|
||||
|
@ -150,7 +162,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
applyBasalConstraints(absoluteConstraint, profile);
|
||||
percentRate.copyReasons(absoluteConstraint);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue();
|
||||
if (pump != null) {
|
||||
|
@ -179,7 +191,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
|
||||
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (pump != null) {
|
||||
double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value()));
|
||||
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
||||
|
@ -196,7 +208,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
|
||||
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingextendedbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (pump != null) {
|
||||
double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value()));
|
||||
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
||||
|
|
|
@ -50,10 +50,10 @@ public class InsulinFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void updateGUI() {
|
||||
insulinName.setText(ConfigBuilderPlugin.getActiveInsulin().getFriendlyName());
|
||||
insulinComment.setText(ConfigBuilderPlugin.getActiveInsulin().getComment());
|
||||
insulinDia.setText(MainApp.gs(R.string.dia) + " " + Double.toString(ConfigBuilderPlugin.getActiveInsulin().getDia()) + "h");
|
||||
insulinGraph.show(ConfigBuilderPlugin.getActiveInsulin());
|
||||
insulinName.setText(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getFriendlyName());
|
||||
insulinComment.setText(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getComment());
|
||||
insulinDia.setText(MainApp.gs(R.string.dia) + " " + Double.toString(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getDia()) + "h");
|
||||
insulinGraph.show(ConfigBuilderPlugin.getPlugin().getActiveInsulin());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.Overview.graphExtensions.Scale;
|
|||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +41,7 @@ public class AutosensData implements DataPointWithLabelInterface {
|
|||
double min5minCarbImpact = 0d;
|
||||
double remaining = 0d;
|
||||
|
||||
public CarbsInPast(Treatment t) {
|
||||
CarbsInPast(Treatment t) {
|
||||
time = t.date;
|
||||
carbs = t.carbs;
|
||||
remaining = t.carbs;
|
||||
|
@ -56,6 +57,18 @@ public class AutosensData implements DataPointWithLabelInterface {
|
|||
min5minCarbImpact = SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact);
|
||||
}
|
||||
}
|
||||
|
||||
CarbsInPast (CarbsInPast other) {
|
||||
this.time = other.time;
|
||||
this.carbs = other.carbs;
|
||||
this.min5minCarbImpact = other.min5minCarbImpact;
|
||||
this.remaining = other.remaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("CarbsInPast: time: %s carbs: %.02f min5minCI: %.02f remaining: %.2f", new Date(time).toLocaleString(), carbs, min5minCarbImpact, remaining);
|
||||
}
|
||||
}
|
||||
|
||||
public long time = 0L;
|
||||
|
@ -89,11 +102,18 @@ public class AutosensData implements DataPointWithLabelInterface {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " avgDelta=" + avgDelta + " Bgi=" + bgi + " Deviation=" + deviation + " avgDeviation=" + avgDeviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob + " autosensRatio=" + autosensResult.ratio + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation=" + slopeFromMinDeviation;
|
||||
return String.format("AutosensData: %s pastSensitivity=%s delta=%.02f avgDelta=%.02f bgi=%.02f deviation=%.02f avgDeviation=%.02f absorbed=%.02f carbsFromBolus=%.02f cob=%.02f autosensRatio=%.02f slopeFromMaxDeviation=%.02f slopeFromMinDeviation=%.02f activeCarbsList=%s",
|
||||
new Date(time).toLocaleString(), pastSensitivity, delta, avgDelta, bgi, deviation, avgDeviation, absorbed, carbsFromBolus, cob, autosensResult.ratio, slopeFromMaxDeviation, slopeFromMinDeviation, activeCarbsList.toString());
|
||||
}
|
||||
|
||||
public int minOld() {
|
||||
return (int) ((System.currentTimeMillis() - time) / 1000 / 60);
|
||||
public List<CarbsInPast> cloneCarbsList() {
|
||||
List<CarbsInPast> newActiveCarbsList = new ArrayList<>();
|
||||
|
||||
for(CarbsInPast c: activeCarbsList) {
|
||||
newActiveCarbsList.add(new CarbsInPast(c));
|
||||
}
|
||||
|
||||
return newActiveCarbsList;
|
||||
}
|
||||
|
||||
// remove carbs older than timeframe
|
||||
|
@ -111,7 +131,7 @@ public class AutosensData implements DataPointWithLabelInterface {
|
|||
if (c.remaining > 0)
|
||||
cob -= c.remaining;
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " + after " + maxAbsorptionHours + "h :" + new Date(c.time).toLocaleString());
|
||||
log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " after " + maxAbsorptionHours + "h > " + c.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,8 +146,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
double averageDiff = totalDiff / (bgReadings.size() - 1) / 1000d;
|
||||
boolean is5mindata = averageDiff < 10;
|
||||
long averageDiff = totalDiff / bgReadings.size() / 1000;
|
||||
boolean is5mindata = averageDiff < 1;
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff + "[s] is5minData: " + is5mindata);
|
||||
return is5mindata;
|
||||
|
@ -231,13 +231,15 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
|
||||
bucketed_data = new ArrayList<>();
|
||||
bucketed_data.add(bgReadings.get(0));
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString());
|
||||
int j = 0;
|
||||
for (int i = 1; i < bgReadings.size(); ++i) {
|
||||
long bgTime = bgReadings.get(i).date;
|
||||
long lastbgTime = bgReadings.get(i - 1).date;
|
||||
//log.error("Processing " + i + ": " + new Date(bgTime).toString() + " " + bgReadings.get(i).value + " Previous: " + new Date(lastbgTime).toString() + " " + bgReadings.get(i - 1).value);
|
||||
if (bgReadings.get(i).value < 39 || bgReadings.get(i - 1).value < 39) {
|
||||
continue;
|
||||
throw new IllegalStateException("<39");
|
||||
}
|
||||
|
||||
long elapsed_minutes = (bgTime - lastbgTime) / (60 * 1000);
|
||||
|
@ -294,6 +296,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
long adjusted = (msecDiff - T.mins(5).msecs()) / 1000;
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec");
|
||||
if (Math.abs(adjusted) > 90) {
|
||||
// too big adjustment, fallback to non 5 min data
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Fallback to non 5 min data");
|
||||
createBucketedDataRecalculated();
|
||||
return;
|
||||
}
|
||||
current.date = previous.date + T.mins(5).msecs();
|
||||
}
|
||||
|
||||
|
@ -530,7 +539,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
|
||||
public AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
|
||||
synchronized (dataLock) {
|
||||
return ConfigBuilderPlugin.getActiveSensitivity().detectSensitivity(this, fromTime, toTime);
|
||||
return ConfigBuilderPlugin.getPlugin().getActiveSensitivity().detectSensitivity(this, fromTime, toTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,7 +606,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
log.debug("Ignoring event for non default instance");
|
||||
return;
|
||||
}
|
||||
if (MainApp.getConfigBuilder() == null)
|
||||
if (ConfigBuilderPlugin.getPlugin() == null)
|
||||
return; // app still initializing
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
|
||||
|
@ -35,7 +36,10 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
|||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.MidnightTime;
|
||||
import info.nightscout.utils.Profiler;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static info.nightscout.utils.DateUtil.now;
|
||||
|
@ -73,11 +77,12 @@ public class IobCobOref1Thread extends Thread {
|
|||
|
||||
@Override
|
||||
public final void run() {
|
||||
long start = DateUtil.now();
|
||||
mWakeLock.acquire();
|
||||
try {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("AUTOSENSDATA thread started: " + from);
|
||||
if (MainApp.getConfigBuilder() == null) {
|
||||
if (ConfigBuilderPlugin.getPlugin() == null) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
|
||||
return; // app still initializing
|
||||
|
@ -147,7 +152,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
AutosensData autosensData = new AutosensData();
|
||||
autosensData.time = bgTime;
|
||||
if (previous != null)
|
||||
autosensData.activeCarbsList = new ArrayList<>(previous.activeCarbsList);
|
||||
autosensData.activeCarbsList = previous.cloneCarbsList();
|
||||
else
|
||||
autosensData.activeCarbsList = new ArrayList<>();
|
||||
|
||||
|
@ -241,6 +246,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
for (int ir = 0; ir < recentTreatments.size(); ir++) {
|
||||
autosensData.carbsFromBolus += recentTreatments.get(ir).carbs;
|
||||
autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir)));
|
||||
autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentTreatments.get(ir).carbs) + "g]";
|
||||
}
|
||||
|
||||
|
||||
|
@ -338,19 +344,19 @@ public class IobCobOref1Thread extends Thread {
|
|||
// Exclude meal-related deviations (carb absorption) from autosens
|
||||
if (autosensData.type.equals("non-meal")) {
|
||||
if (Math.abs(deviation) < Constants.DEVIATION_TO_BE_EQUAL) {
|
||||
autosensData.pastSensitivity = "=";
|
||||
autosensData.pastSensitivity += "=";
|
||||
autosensData.validDeviation = true;
|
||||
} else if (deviation > 0) {
|
||||
autosensData.pastSensitivity = "+";
|
||||
autosensData.pastSensitivity += "+";
|
||||
autosensData.validDeviation = true;
|
||||
} else {
|
||||
autosensData.pastSensitivity = "-";
|
||||
autosensData.pastSensitivity += "-";
|
||||
autosensData.validDeviation = true;
|
||||
}
|
||||
} else if (autosensData.type.equals("uam")) {
|
||||
autosensData.pastSensitivity = "u";
|
||||
autosensData.pastSensitivity += "u";
|
||||
} else {
|
||||
autosensData.pastSensitivity = "x";
|
||||
autosensData.pastSensitivity += "x";
|
||||
}
|
||||
//log.debug("TIME: " + new Date(bgTime).toString() + " BG: " + bg + " SENS: " + sens + " DELTA: " + delta + " AVGDELTA: " + avgDelta + " IOB: " + iob.iob + " ACTIVITY: " + iob.activity + " BGI: " + bgi + " DEVIATION: " + deviation);
|
||||
|
||||
|
@ -390,8 +396,11 @@ public class IobCobOref1Thread extends Thread {
|
|||
} finally {
|
||||
mWakeLock.release();
|
||||
MainApp.bus().post(new EventIobCalculationProgress(""));
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
if (L.isEnabled(L.AUTOSENS)) {
|
||||
log.debug("AUTOSENSDATA thread ended: " + from);
|
||||
log.debug("Midnights: " + MidnightTime.log());
|
||||
}
|
||||
Profiler.log(log, "IobCobOref1Thread", start);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
|
||||
|
@ -35,7 +36,10 @@ import info.nightscout.androidaps.plugins.Sensitivity.SensitivityWeightedAverage
|
|||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.MidnightTime;
|
||||
import info.nightscout.utils.Profiler;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static info.nightscout.utils.DateUtil.now;
|
||||
|
@ -72,11 +76,12 @@ public class IobCobThread extends Thread {
|
|||
|
||||
@Override
|
||||
public final void run() {
|
||||
long start = DateUtil.now();
|
||||
mWakeLock.acquire();
|
||||
try {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("AUTOSENSDATA thread started: " + from);
|
||||
if (MainApp.getConfigBuilder() == null) {
|
||||
if (ConfigBuilderPlugin.getPlugin() == null) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
|
||||
return; // app still initializing
|
||||
|
@ -146,7 +151,7 @@ public class IobCobThread extends Thread {
|
|||
AutosensData autosensData = new AutosensData();
|
||||
autosensData.time = bgTime;
|
||||
if (previous != null)
|
||||
autosensData.activeCarbsList = new ArrayList<>(previous.activeCarbsList);
|
||||
autosensData.activeCarbsList = previous.cloneCarbsList();
|
||||
else
|
||||
autosensData.activeCarbsList = new ArrayList<>();
|
||||
|
||||
|
@ -240,6 +245,7 @@ public class IobCobThread extends Thread {
|
|||
for (int ir = 0; ir < recentTreatments.size(); ir++) {
|
||||
autosensData.carbsFromBolus += recentTreatments.get(ir).carbs;
|
||||
autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir)));
|
||||
autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentTreatments.get(ir).carbs) + "g]";
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,17 +289,17 @@ public class IobCobThread extends Thread {
|
|||
// calculate autosens only without COB
|
||||
if (autosensData.cob <= 0) {
|
||||
if (Math.abs(deviation) < Constants.DEVIATION_TO_BE_EQUAL) {
|
||||
autosensData.pastSensitivity = "=";
|
||||
autosensData.pastSensitivity += "=";
|
||||
autosensData.validDeviation = true;
|
||||
} else if (deviation > 0) {
|
||||
autosensData.pastSensitivity = "+";
|
||||
autosensData.pastSensitivity += "+";
|
||||
autosensData.validDeviation = true;
|
||||
} else {
|
||||
autosensData.pastSensitivity = "-";
|
||||
autosensData.pastSensitivity += "-";
|
||||
autosensData.validDeviation = true;
|
||||
}
|
||||
} else {
|
||||
autosensData.pastSensitivity = "C";
|
||||
autosensData.pastSensitivity += "C";
|
||||
}
|
||||
//log.debug("TIME: " + new Date(bgTime).toString() + " BG: " + bg + " SENS: " + sens + " DELTA: " + delta + " AVGDELTA: " + avgDelta + " IOB: " + iob.iob + " ACTIVITY: " + iob.activity + " BGI: " + bgi + " DEVIATION: " + deviation);
|
||||
|
||||
|
@ -317,8 +323,11 @@ public class IobCobThread extends Thread {
|
|||
} finally {
|
||||
mWakeLock.release();
|
||||
MainApp.bus().post(new EventIobCalculationProgress(""));
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
if (L.isEnabled(L.AUTOSENS)) {
|
||||
log.debug("AUTOSENSDATA thread ended: " + from);
|
||||
log.debug("Midnights: " + MidnightTime.log());
|
||||
}
|
||||
Profiler.log(log, "IobCobThread", start);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class APSResult {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (isChangeRequested()) {
|
||||
String ret;
|
||||
// rate
|
||||
|
@ -115,7 +115,7 @@ public class APSResult {
|
|||
}
|
||||
|
||||
public Spanned toSpanned() {
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (isChangeRequested()) {
|
||||
String ret;
|
||||
// rate
|
||||
|
@ -304,9 +304,14 @@ public class APSResult {
|
|||
|
||||
long now = System.currentTimeMillis();
|
||||
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
log.error("FALSE: No Profile");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usePercent) {
|
||||
if (activeTemp == null && percent == 100) {
|
||||
if (L.isEnabled(L.APS))
|
||||
|
|
|
@ -140,7 +140,7 @@ public class LoopPlugin extends PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ public class LoopPlugin extends PluginBase {
|
|||
MainApp.bus().post(new EventLoopSetLastRunGui(message));
|
||||
return;
|
||||
}
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
APSResult result = null;
|
||||
|
||||
if (!isEnabled(PluginType.LOOP))
|
||||
|
@ -293,7 +293,7 @@ public class LoopPlugin extends PluginBase {
|
|||
// Check if pump info is loaded
|
||||
if (pump.getBaseBasalRate() < 0.01d) return;
|
||||
|
||||
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||
APSInterface usedAPS = ConfigBuilderPlugin.getPlugin().getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS)) {
|
||||
usedAPS.invoke(initiator, tempBasalFallback);
|
||||
result = usedAPS.getLastAPSResult();
|
||||
|
@ -358,8 +358,8 @@ public class LoopPlugin extends PluginBase {
|
|||
|
||||
if (closedLoopEnabled.value()) {
|
||||
if (resultAfterConstraints.isChangeRequested()
|
||||
&& !ConfigBuilderPlugin.getCommandQueue().bolusInQueue()
|
||||
&& !ConfigBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BOLUS)) {
|
||||
&& !ConfigBuilderPlugin.getPlugin().getCommandQueue().bolusInQueue()
|
||||
&& !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BOLUS)) {
|
||||
final PumpEnactResult waiting = new PumpEnactResult();
|
||||
waiting.queued = true;
|
||||
if (resultAfterConstraints.tempBasalRequested)
|
||||
|
@ -409,8 +409,10 @@ public class LoopPlugin extends PluginBase {
|
|||
.setAutoCancel(true)
|
||||
.setPriority(Notification.PRIORITY_HIGH)
|
||||
.setCategory(Notification.CATEGORY_ALARM)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||
.setLocalOnly(true);
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
if (SP.getBoolean("wearcontrol", false)) {
|
||||
builder.setLocalOnly(true);
|
||||
}
|
||||
|
||||
// Creates an explicit intent for an Activity in your app
|
||||
Intent resultIntent = new Intent(MainApp.instance().getApplicationContext(), MainActivity.class);
|
||||
|
@ -489,7 +491,7 @@ public class LoopPlugin extends PluginBase {
|
|||
return;
|
||||
}
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
|
||||
if (!pump.isInitialized()) {
|
||||
|
@ -520,7 +522,7 @@ public class LoopPlugin extends PluginBase {
|
|||
if (activeTemp != null) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: cancelTempBasal()");
|
||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(false, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(false, callback);
|
||||
} else {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: Basal set correctly");
|
||||
|
@ -543,14 +545,14 @@ public class LoopPlugin extends PluginBase {
|
|||
} else {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: tempBasalPercent()");
|
||||
MainApp.getConfigBuilder().getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback);
|
||||
}
|
||||
} else {
|
||||
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
||||
if (activeTemp != null) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: cancelTempBasal()");
|
||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(false, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(false, callback);
|
||||
} else {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: Basal set correctly");
|
||||
|
@ -573,7 +575,7 @@ public class LoopPlugin extends PluginBase {
|
|||
} else {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: setTempBasalAbsolute()");
|
||||
MainApp.getConfigBuilder().getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +585,7 @@ public class LoopPlugin extends PluginBase {
|
|||
return;
|
||||
}
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
|
||||
long lastBolusTime = activeTreatments.getLastBolusTime();
|
||||
|
@ -629,15 +631,15 @@ public class LoopPlugin extends PluginBase {
|
|||
detailedBolusInfo.deliverAt = request.deliverAt;
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("applyAPSRequest: bolus()");
|
||||
MainApp.getConfigBuilder().getCommandQueue().bolus(detailedBolusInfo, callback);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, callback);
|
||||
}
|
||||
|
||||
public void disconnectPump(int durationInMinutes, Profile profile) {
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
|
||||
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
||||
MainApp.getConfigBuilder().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -646,7 +648,7 @@ public class LoopPlugin extends PluginBase {
|
|||
}
|
||||
});
|
||||
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
|
||||
MainApp.getConfigBuilder().getCommandQueue().cancelExtended(new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -660,7 +662,7 @@ public class LoopPlugin extends PluginBase {
|
|||
|
||||
public void suspendLoop(int durationInMinutes) {
|
||||
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
|
||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -73,8 +73,8 @@ public class MaintenancePlugin extends PluginBase {
|
|||
}
|
||||
|
||||
public void sendLogs() {
|
||||
String recipient = SP.getString("key_maintenance_logs_email", "logs@androidaps.org");
|
||||
int amount = SP.getInt("key_maintenance_logs_amount", 2);
|
||||
String recipient = SP.getString(R.string.key_maintenance_logs_email, "logs@androidaps.org");
|
||||
int amount = SP.getInt(R.string.key_maintenance_logs_amount, 2);
|
||||
|
||||
String logDirectory = LoggerUtils.getLogDirectory();
|
||||
List<File> logs = this.getLogfiles(logDirectory, amount);
|
||||
|
@ -103,7 +103,7 @@ public class MaintenancePlugin extends PluginBase {
|
|||
Arrays.sort(files, (f1, f2) -> f1.getName().compareTo(f2.getName()));
|
||||
|
||||
List<File> delFiles = Arrays.asList(files);
|
||||
int amount = SP.getInt("key_logshipper_amount", 2);
|
||||
int amount = SP.getInt(R.string.key_logshipper_amount, 2);
|
||||
int keepIndex = amount - 1;
|
||||
|
||||
if (keepIndex < delFiles.size()) {
|
||||
|
@ -213,6 +213,10 @@ public class MaintenancePlugin extends PluginBase {
|
|||
builder.append("ADD TIME OF EVENT HERE: " + System.lineSeparator());
|
||||
builder.append("ADD ISSUE DESCRIPTION OR GITHUB ISSUE REFERENCE NUMBER: " + System.lineSeparator());
|
||||
builder.append("-------------------------------------------------------" + System.lineSeparator());
|
||||
builder.append("(Please remember this will send only very recent logs." + System.lineSeparator());
|
||||
builder.append("If you want to provide logs for event older than a few hours," + System.lineSeparator());
|
||||
builder.append("you have to do it manually)" + System.lineSeparator());
|
||||
builder.append("-------------------------------------------------------" + System.lineSeparator());
|
||||
builder.append(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION + System.lineSeparator());
|
||||
if (Config.NSCLIENT)
|
||||
builder.append("NSCLIENT" + System.lineSeparator());
|
||||
|
|
|
@ -249,7 +249,7 @@ public class NSUpload {
|
|||
log.debug("OpenAPS data too old to upload");
|
||||
}
|
||||
deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL;
|
||||
JSONObject pumpstatus = ConfigBuilderPlugin.getActivePump().getJSONStatus(profile, profileName);
|
||||
JSONObject pumpstatus = ConfigBuilderPlugin.getPlugin().getActivePump().getJSONStatus(profile, profileName);
|
||||
if (pumpstatus != null) {
|
||||
deviceStatus.pump = pumpstatus;
|
||||
}
|
||||
|
@ -470,14 +470,14 @@ public class NSUpload {
|
|||
DbLogger.dbAdd(intent, data.toString());
|
||||
}
|
||||
|
||||
public static void uploadBg(BgReading reading) {
|
||||
public static void uploadBg(BgReading reading, String source) {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("action", "dbAdd");
|
||||
bundle.putString("collection", "entries");
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("device", "AndroidAPS-DexcomG5");
|
||||
data.put("device", source);
|
||||
data.put("date", reading.date);
|
||||
data.put("dateString", DateUtil.toISOString(reading.date));
|
||||
data.put("sgv", reading.value);
|
||||
|
|
|
@ -67,13 +67,13 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialShowInListCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
|
@ -188,7 +188,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
lastAutosensResult.ratio, //autosensDataRatio
|
||||
isTempTarget
|
||||
);
|
||||
|
|
|
@ -66,13 +66,13 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialShowInListCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
|
@ -168,7 +168,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
start = System.currentTimeMillis();
|
||||
try {
|
||||
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData);
|
||||
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData);
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -211,6 +211,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
double autosensDataRatio,
|
||||
boolean tempTargetSet,
|
||||
boolean microBolusAllowed,
|
||||
boolean uamAllowed,
|
||||
boolean advancedFiltering
|
||||
) throws JSONException {
|
||||
|
||||
|
@ -247,7 +248,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
// mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
|
||||
//}
|
||||
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
|
||||
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
|
||||
mProfile.put("enableUAM", uamAllowed);
|
||||
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
||||
mProfile.put("enableSMB_with_COB", SP.getBoolean(R.string.key_enableSMB_with_COB, false));
|
||||
mProfile.put("enableSMB_with_temptarget", SP.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
||||
|
|
|
@ -72,13 +72,13 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialShowInListCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
|
@ -198,6 +198,10 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering);
|
||||
inputConstraints.copyReasons(advancedFiltering);
|
||||
|
||||
Constraint<Boolean> uam = new Constraint<>(true);
|
||||
MainApp.getConstraintChecker().isUAMEnabled(uam);
|
||||
inputConstraints.copyReasons(uam);
|
||||
|
||||
if (L.isEnabled(L.APS))
|
||||
Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart);
|
||||
if (L.isEnabled(L.APS))
|
||||
|
@ -205,10 +209,11 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
|
||||
start = System.currentTimeMillis();
|
||||
try {
|
||||
determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
lastAutosensResult.ratio, //autosensDataRatio
|
||||
isTempTarget,
|
||||
smbAllowed.value(),
|
||||
uam.value(),
|
||||
advancedFiltering.value()
|
||||
);
|
||||
} catch (JSONException e) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
super.onResume();
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("onResume");
|
||||
if (!ConfigBuilderPlugin.getCommandQueue().bolusInQueue()) {
|
||||
if (!ConfigBuilderPlugin.getPlugin().getCommandQueue().bolusInQueue()) {
|
||||
bolusEnded = true;
|
||||
}
|
||||
if (bolusEnded) {
|
||||
|
@ -107,9 +107,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
|
||||
@Override
|
||||
public void onPause() {
|
||||
running = false;
|
||||
super.onPause();
|
||||
MainApp.unsubscribe(this);
|
||||
running = false;
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("onPause");
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
stopPressed = true;
|
||||
stopPressedView.setVisibility(View.VISIBLE);
|
||||
stopButton.setVisibility(View.INVISIBLE);
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelAllBoluses();
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelAllBoluses();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -173,10 +173,12 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("executing");
|
||||
try {
|
||||
dismiss();
|
||||
if (running) {
|
||||
if (L.isEnabled(L.UI))
|
||||
log.debug("executing");
|
||||
dismiss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||
|
||||
editInsulin = view.findViewById(R.id.newinsulin_amount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
|
||||
Button plus1Button = view.findViewById(R.id.newinsulin_plus05);
|
||||
plus1Button.setOnClickListener(this);
|
||||
|
@ -212,7 +212,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
|
||||
try {
|
||||
Profile currentProfile = ProfileFunctions.getInstance().getProfile();
|
||||
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (currentProfile == null || pump == null)
|
||||
return;
|
||||
|
||||
|
@ -293,7 +293,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
} else {
|
||||
detailedBolusInfo.date = now();
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -105,7 +105,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
|
||||
recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only);
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
okClicked = true;
|
||||
|
||||
try {
|
||||
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (pump == null)
|
||||
return;
|
||||
|
@ -177,8 +177,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
if (!(recordOnlyCheckbox.isChecked() && (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo))) {
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
if (!(recordOnlyCheckbox.isChecked() && (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo))) {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
|
|
@ -270,7 +270,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
|
||||
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
||||
editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
initDialog();
|
||||
|
@ -327,7 +327,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
okClicked = true;
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (pump != null && profile != null && (calculatedTotalInsulin > 0d || calculatedCarbs > 0d)) {
|
||||
String confirmMessage = MainApp.gs(R.string.entertreatmentquestion);
|
||||
|
@ -369,7 +369,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||
}
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -394,8 +394,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
detailedBolusInfo.boluscalc = boluscalcJSON;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.notes = finalNotes;
|
||||
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -429,7 +429,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
|
||||
private void initDialog() {
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface() != null ? MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() : null;
|
||||
ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null ? ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() : null;
|
||||
|
||||
if (profile == null || profileStore == null) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
|
||||
|
@ -473,7 +473,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
|
||||
private void calculateInsulin() {
|
||||
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||
ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile();
|
||||
if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null)
|
||||
return; // not initialized yet
|
||||
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
import android.arch.core.util.Function;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -97,6 +98,7 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
|||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewCarbsDialog;
|
||||
|
@ -108,6 +110,7 @@ import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
|||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationRecyclerViewAdapter;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG6Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
|
||||
|
@ -162,6 +165,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
TextView sage;
|
||||
TextView pbage;
|
||||
|
||||
TextView iageView;
|
||||
TextView cageView;
|
||||
TextView reservoirView;
|
||||
TextView sageView;
|
||||
TextView batteryView;
|
||||
LinearLayout statuslightsLayout;
|
||||
|
||||
RecyclerView notificationsView;
|
||||
LinearLayoutManager llm;
|
||||
|
||||
|
@ -258,8 +268,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
||||
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
||||
|
||||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||
iageView = (TextView) view.findViewById(R.id.overview_insulinage);
|
||||
cageView = (TextView) view.findViewById(R.id.overview_canulaage);
|
||||
reservoirView = (TextView) view.findViewById(R.id.overview_reservoirlevel);
|
||||
sageView = (TextView) view.findViewById(R.id.overview_sensorage);
|
||||
batteryView = (TextView) view.findViewById(R.id.overview_batterylevel);
|
||||
statuslightsLayout = (LinearLayout) view.findViewById(R.id.overview_statuslights);
|
||||
|
||||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||
|
||||
treatmentButton = (SingleClickButton) view.findViewById(R.id.overview_treatmentbutton);
|
||||
treatmentButton.setOnClickListener(this);
|
||||
|
@ -446,7 +463,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
if (v == apsModeView) {
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||
final PumpDescription pumpDescription =
|
||||
ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription();
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("ContexMenuCreation"))
|
||||
return;
|
||||
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
||||
|
@ -457,23 +475,27 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
menu.add(MainApp.gs(R.string.suspendloopfor2h));
|
||||
menu.add(MainApp.gs(R.string.suspendloopfor3h));
|
||||
menu.add(MainApp.gs(R.string.suspendloopfor10h));
|
||||
if (pumpDescription.tempDurationStep15mAllowed)
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
|
||||
if (pumpDescription.tempDurationStep30mAllowed)
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor30m));
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor1h));
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor2h));
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor3h));
|
||||
} else {
|
||||
menu.add(MainApp.gs(R.string.resume));
|
||||
} else {
|
||||
if (!loopPlugin.isDisconnected()) {
|
||||
menu.add(MainApp.gs(R.string.resume));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!loopPlugin.isEnabled(PluginType.LOOP))
|
||||
|
||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
menu.add(MainApp.gs(R.string.enableloop));
|
||||
}
|
||||
|
||||
if (!loopPlugin.isDisconnected()) {
|
||||
showSuspendtPump(menu, pumpDescription);
|
||||
} else {
|
||||
menu.add(MainApp.gs(R.string.reconnect));
|
||||
}
|
||||
|
||||
} else if (v == activeProfileView) {
|
||||
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
||||
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) {
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
|
||||
menu.add(MainApp.gs(R.string.careportal_profileswitch));
|
||||
}
|
||||
} else if (v == tempTargetView) {
|
||||
|
@ -488,6 +510,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
}
|
||||
|
||||
private void showSuspendtPump(ContextMenu menu,
|
||||
PumpDescription pumpDescription) {
|
||||
if (pumpDescription.tempDurationStep15mAllowed)
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
|
||||
if (pumpDescription.tempDurationStep30mAllowed)
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor30m));
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor1h));
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor2h));
|
||||
menu.add(MainApp.gs(R.string.disconnectpumpfor3h));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
@ -497,9 +530,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
||||
loopPlugin.setFragmentVisible(PluginType.LOOP, false);
|
||||
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("DisablingLoop");
|
||||
updateGUI("suspendmenu");
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -512,14 +545,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true);
|
||||
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("EnablingLoop");
|
||||
updateGUI("suspendmenu");
|
||||
NSUpload.uploadOpenAPSOffline(0);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.resume)) ||
|
||||
item.getTitle().equals(MainApp.gs(R.string.reconnect))) {
|
||||
loopPlugin.suspendTo(0L);
|
||||
updateGUI("suspendmenu");
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -631,6 +665,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public void onClick(View v) {
|
||||
boolean xdrip = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
boolean g5 = SourceDexcomG5Plugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
boolean g6 = SourceDexcomG6Plugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
|
@ -653,7 +688,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (xdrip) {
|
||||
CalibrationDialog calibrationDialog = new CalibrationDialog();
|
||||
calibrationDialog.show(manager, "CalibrationDialog");
|
||||
} else if (g5) {
|
||||
} else if (g5 || g6) {
|
||||
try {
|
||||
Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity");
|
||||
startActivity(i);
|
||||
|
@ -669,6 +704,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
openCgmApp("com.dexcom.cgm.region5.mgdl");
|
||||
else if (g5 && units.equals(Constants.MMOL))
|
||||
openCgmApp("com.dexcom.cgm.region5.mmol");
|
||||
else if (g6 && units.equals(Constants.MGDL))
|
||||
openCgmApp("com.dexcom.g6.region3.mgdl");
|
||||
else if (g6 && units.equals(Constants.MMOL))
|
||||
openCgmApp("com.dexcom.g6.region3.mmol");
|
||||
break;
|
||||
case R.id.overview_treatmentbutton:
|
||||
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
|
||||
|
@ -681,8 +720,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
new NewCarbsDialog().show(manager, "CarbsDialog");
|
||||
break;
|
||||
case R.id.overview_pumpstatus:
|
||||
if (ConfigBuilderPlugin.getActivePump().isSuspended() || !ConfigBuilderPlugin.getActivePump().isInitialized())
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("RefreshClicked", null);
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended() || !ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized())
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("RefreshClicked", null);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -784,7 +823,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
confirmMessage += "\n" + MainApp.gs(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
|
||||
confirmMessage += "\n" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||
|
||||
if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
||||
if (Math.abs(insulinAfterConstraints - wizard.calculatedTotalInsulin) >= 0.01 || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
|
||||
|
@ -808,14 +847,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
return;
|
||||
}
|
||||
accepted = true;
|
||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||
if (Math.abs(insulinAfterConstraints - wizard.calculatedTotalInsulin) >= 0.01 || finalCarbsAfterConstraints > 0) {
|
||||
if (wizard.superBolus) {
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
|
||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||
}
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -836,8 +875,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.boluscalc = boluscalcJSON;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
if (finalInsulinAfterConstraints > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
if (finalInsulinAfterConstraints > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -1043,7 +1082,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
BgReading actualBG = DatabaseHelper.actualBg();
|
||||
BgReading lastBG = DatabaseHelper.lastBg();
|
||||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
|
@ -1088,25 +1127,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
if (Config.APS && pump.getPumpDescription().isTempBasalCapable) {
|
||||
apsModeView.setVisibility(View.VISIBLE);
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.loopenabled));
|
||||
apsModeView.setTextColor(Color.BLACK);
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
|
||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend()));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isDisconnected()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (loopPlugin.isDisconnected()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonCritical));
|
||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend()));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical));
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
|
||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (pump.isSuspended()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
|
||||
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
if (closedLoopEnabled.value()) {
|
||||
apsModeView.setText(MainApp.gs(R.string.closedloop));
|
||||
|
@ -1114,9 +1153,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
apsModeView.setText(MainApp.gs(R.string.openloop));
|
||||
}
|
||||
} else {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.loopdisabled));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonCritical));
|
||||
apsModeView.setText(MainApp.gs(R.string.disabledloop));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical));
|
||||
}
|
||||
} else {
|
||||
apsModeView.setVisibility(View.GONE);
|
||||
|
@ -1125,13 +1164,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
// temp target
|
||||
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||
if (tempTarget != null) {
|
||||
tempTargetView.setTextColor(Color.BLACK);
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.tempTargetBackground));
|
||||
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
|
||||
tempTargetView.setVisibility(View.VISIBLE);
|
||||
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end()));
|
||||
} else {
|
||||
tempTargetView.setTextColor(Color.WHITE);
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.tempTargetDisabledBackground));
|
||||
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
|
||||
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
|
||||
tempTargetView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -1230,7 +1269,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
activeProfileView.setText(ProfileFunctions.getInstance().getProfileName());
|
||||
activeProfileView.setBackgroundColor(Color.GRAY);
|
||||
if (profile.getPercentage() != 100 || profile.getTimeshift() != 0) {
|
||||
activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
|
||||
activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else {
|
||||
activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
|
||||
activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
}
|
||||
|
||||
// QuickWizard button
|
||||
QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||
|
@ -1248,7 +1293,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
// **** Various treatment buttons ****
|
||||
if (carbsButton != null) {
|
||||
if (SP.getBoolean(R.string.key_show_carbs_button, true)
|
||||
&& (!ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo ||
|
||||
&& (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo ||
|
||||
(pump.isInitialized() && !pump.isSuspended()))) {
|
||||
carbsButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -1335,6 +1380,56 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
cobView.setText(cobText);
|
||||
}
|
||||
|
||||
if (statuslightsLayout != null) {
|
||||
if (SP.getBoolean(R.string.key_show_statuslights, false)) {
|
||||
CareportalEvent careportalEvent;
|
||||
NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance();
|
||||
double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 96);
|
||||
double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 72);
|
||||
double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 72);
|
||||
double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 48);
|
||||
double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 166);
|
||||
double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 164);
|
||||
//double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360);
|
||||
//double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240);
|
||||
double batUrgent = SP.getDouble(R.string.key_statuslights_bat_critical, 5.0);
|
||||
double batWarn = SP.getDouble(R.string.key_statuslights_bat_warning, 25.0);
|
||||
double resUrgent = SP.getDouble(R.string.key_statuslights_res_critical, 10.0);
|
||||
double resWarn = SP.getDouble(R.string.key_statuslights_res_warning, 80.0);
|
||||
|
||||
if (cageView != null) {
|
||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
||||
double canAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE;
|
||||
applyStatuslight(cageView, "CAN", canAge, cageWarn, cageUrgent, Double.MAX_VALUE, true);
|
||||
}
|
||||
|
||||
if (iageView != null) {
|
||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
||||
double insulinAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE;
|
||||
applyStatuslight(iageView, "INS", insulinAge, iageWarn, iageUrgent, Double.MAX_VALUE, true);
|
||||
}
|
||||
|
||||
if (reservoirView != null) {
|
||||
double reservoirLevel = pump.isInitialized() ? pump.getReservoirLevel() : -1;
|
||||
applyStatuslight(reservoirView, "RES", reservoirLevel, resWarn, resUrgent, -1, false);
|
||||
}
|
||||
|
||||
if (sageView != null) {
|
||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
||||
double sensorAge = careportalEvent != null ? careportalEvent.getHoursFromStart() : Double.MAX_VALUE;
|
||||
applyStatuslight(sageView, "SEN", sensorAge, sageWarn, sageUrgent, Double.MAX_VALUE, true);
|
||||
}
|
||||
|
||||
if (batteryView != null) {
|
||||
double batteryLevel = pump.isInitialized() ? pump.getBatteryLevel() : -1;
|
||||
applyStatuslight(batteryView, "BAT", batteryLevel, batWarn, batUrgent, -1, false);
|
||||
}
|
||||
statuslightsLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
statuslightsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
boolean predictionsAvailable;
|
||||
if (Config.APS)
|
||||
predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions;
|
||||
|
@ -1364,7 +1459,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
// Sensitivity
|
||||
if (sensitivityView != null) {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("Overview");
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensData("Overview");
|
||||
if (autosensData != null)
|
||||
sensitivityView.setText(String.format("%.0f%%", autosensData.autosensResult.ratio * 100));
|
||||
else
|
||||
|
@ -1525,4 +1620,21 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
}
|
||||
|
||||
public static void applyStatuslight(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid, boolean checkAscending) {
|
||||
Function<Double, Boolean> check = checkAscending ? (Double threshold) -> value >= threshold : (Double threshold) -> value <= threshold;
|
||||
if (value != invalid) {
|
||||
view.setText(text);
|
||||
if (check.apply(urgentThreshold)) {
|
||||
view.setTextColor(MainApp.gc(R.color.ribbonCritical));
|
||||
} else if (check.apply(warnThreshold)) {
|
||||
view.setTextColor(MainApp.gc(R.color.ribbonWarning));
|
||||
} else {
|
||||
view.setTextColor(MainApp.gc(R.color.ribbonDefault));
|
||||
}
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ public class GraphData {
|
|||
}
|
||||
|
||||
// Extended bolus
|
||||
if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
List<ExtendedBolus> extendedBoluses = TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().getList();
|
||||
|
||||
for (int tx = 0; tx < extendedBoluses.size(); tx++) {
|
||||
|
|
|
@ -68,6 +68,11 @@ public class Notification {
|
|||
public static final int NSMALFUNCTION = 40;
|
||||
public static final int NEWVERSIONDETECTED = 41;
|
||||
public static final int SENDLOGFILES = 42;
|
||||
public static final int DEVICENOTPAIRED = 43;
|
||||
public static final int MEDTRONIC_PUMP_ALARM = 44;
|
||||
public static final int RILEYLINK_CONNECTION = 45;
|
||||
public static final int PERMISSION_PHONESTATE = 46;
|
||||
public static final int INSIGHT_DATE_TIME_UPDATED = 47;
|
||||
|
||||
|
||||
public int id;
|
||||
|
|
|
@ -13,6 +13,14 @@ import android.os.Build;
|
|||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
|
||||
// Android Auto
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.support.v4.app.RemoteInput;
|
||||
|
||||
|
||||
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
|
@ -60,6 +68,18 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
public static final int ONGOING_NOTIFICATION_ID = 4711;
|
||||
private final Context ctx;
|
||||
|
||||
/// For Android Auto
|
||||
/// Intents are not declared in manifest and not consumed, this is intentionally because actually we can't do anything with
|
||||
private static final String PACKAGE = "info.nightscout";
|
||||
private static final String READ_ACTION =
|
||||
"info.nightscout.androidaps.ACTION_MESSAGE_READ";
|
||||
private static final String REPLY_ACTION =
|
||||
"info.nightscout.androidaps.ACTION_MESSAGE_REPLY";
|
||||
private static final String CONVERSATION_ID = "conversation_id";
|
||||
private static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
|
||||
/// End Android Auto
|
||||
|
||||
|
||||
public PersistentNotificationPlugin(Context ctx) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
|
@ -107,9 +127,10 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
return null;
|
||||
}
|
||||
|
||||
String line1 = "";
|
||||
String line1;
|
||||
String line1_aa;
|
||||
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || !ProfileFunctions.getInstance().isProfileValid("Notificiation"))
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() == null || !ProfileFunctions.getInstance().isProfileValid("Notificiation"))
|
||||
return null;
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
|
@ -118,22 +139,25 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
|
||||
if (lastBG != null) {
|
||||
line1 = lastBG.valueToUnitsToString(units);
|
||||
line1 = line1_aa = lastBG.valueToUnitsToString(units);
|
||||
if (glucoseStatus != null) {
|
||||
line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)
|
||||
+ " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units);
|
||||
line1_aa += " " + lastBG.directionToSymbol();
|
||||
} else {
|
||||
line1 += " " +
|
||||
MainApp.gs(R.string.old_data) +
|
||||
" ";
|
||||
line1_aa += line1 + ".";
|
||||
}
|
||||
} else {
|
||||
line1 = MainApp.gs(R.string.missed_bg_readings);
|
||||
line1 = line1_aa = MainApp.gs(R.string.missed_bg_readings);
|
||||
}
|
||||
|
||||
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (activeTemp != null) {
|
||||
line1 += " " + activeTemp.toStringShort();
|
||||
line1_aa += " " + activeTemp.toStringShort() + ".";
|
||||
}
|
||||
|
||||
//IOB
|
||||
|
@ -143,12 +167,55 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||
|
||||
|
||||
String line2 = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob)+": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString();;
|
||||
|
||||
String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h";
|
||||
String line2 = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob)+": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString();
|
||||
String line2_aa = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U. " + MainApp.gs(R.string.cob)+": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString() + ".";
|
||||
|
||||
|
||||
String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h";
|
||||
String line3_aa = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h.";
|
||||
|
||||
|
||||
line3 += " - " + ProfileFunctions.getInstance().getProfileName();
|
||||
line3_aa += " - " + ProfileFunctions.getInstance().getProfileName() + ".";
|
||||
|
||||
/// For Android Auto
|
||||
Intent msgReadIntent = new Intent()
|
||||
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
||||
.setAction(READ_ACTION)
|
||||
.putExtra(CONVERSATION_ID, ONGOING_NOTIFICATION_ID)
|
||||
.setPackage(PACKAGE);
|
||||
|
||||
PendingIntent msgReadPendingIntent =
|
||||
PendingIntent.getBroadcast(ctx,
|
||||
ONGOING_NOTIFICATION_ID,
|
||||
msgReadIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Intent msgReplyIntent = new Intent()
|
||||
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
||||
.setAction(REPLY_ACTION)
|
||||
.putExtra(CONVERSATION_ID, ONGOING_NOTIFICATION_ID)
|
||||
.setPackage(PACKAGE);
|
||||
|
||||
PendingIntent msgReplyPendingIntent = PendingIntent.getBroadcast(
|
||||
ctx,
|
||||
ONGOING_NOTIFICATION_ID,
|
||||
msgReplyIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
// Build a RemoteInput for receiving voice input from devices
|
||||
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).build();
|
||||
|
||||
// Create the UnreadConversation
|
||||
NotificationCompat.CarExtender.UnreadConversation.Builder unreadConversationBuilder =
|
||||
new NotificationCompat.CarExtender.UnreadConversation.Builder(line1_aa + "\n" + line2_aa)
|
||||
.setLatestTimestamp(System.currentTimeMillis())
|
||||
.setReadPendingIntent(msgReadPendingIntent)
|
||||
.setReplyAction(msgReplyPendingIntent, remoteInput);
|
||||
|
||||
/// Add dot to produce a "more natural sounding result"
|
||||
unreadConversationBuilder.addMessage(line3_aa);
|
||||
/// End Android Auto
|
||||
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
|
||||
|
@ -167,6 +234,11 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
builder.setContentTitle(line1);
|
||||
builder.setContentText(line2);
|
||||
builder.setSubText(line3);
|
||||
/// Android Auto
|
||||
builder.extend(new NotificationCompat.CarExtender()
|
||||
.setUnreadConversation(unreadConversationBuilder.build()));
|
||||
/// End Android Auto
|
||||
|
||||
|
||||
Intent resultIntent = new Intent(ctx, MainActivity.class);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription();
|
||||
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
||||
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
||||
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
||||
|
@ -96,7 +96,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
|
||||
invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
|
||||
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
public String getSumLabel() {
|
||||
ProfileStore profile = LocalProfilePlugin.getPlugin().createProfileStore();
|
||||
if (profile != null)
|
||||
return " ∑" + DecimalFormatter.to2Decimal(profile.getDefaultProfile().baseBasalSum()) + "U";
|
||||
return " ∑" + DecimalFormatter.to2Decimal(profile.getDefaultProfile().baseBasalSum()) + MainApp.gs(R.string.insulin_unit_shortname);
|
||||
else
|
||||
return MainApp.gs(R.string.localprofile);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ public class NSProfileFragment extends SubscriberFragment {
|
|||
TextView isf;
|
||||
@BindView(R.id.profileview_basal)
|
||||
TextView basal;
|
||||
@BindView(R.id.profileview_basaltotal)
|
||||
TextView basaltotal;
|
||||
@BindView(R.id.profileview_target)
|
||||
TextView target;
|
||||
@BindView(R.id.basal_graph)
|
||||
|
@ -116,6 +118,7 @@ public class NSProfileFragment extends SubscriberFragment {
|
|||
ic.setText(profile.getIcList());
|
||||
isf.setText(profile.getIsfList());
|
||||
basal.setText(profile.getBasalList());
|
||||
basaltotal.setText(String.format(MainApp.gs(R.string.profile_total), DecimalFormatter.to2Decimal(profile.baseBasalSum())));
|
||||
target.setText(profile.getTargetList());
|
||||
basalGraph.show(profile);
|
||||
}
|
||||
|
@ -141,6 +144,7 @@ public class NSProfileFragment extends SubscriberFragment {
|
|||
ic.setText("");
|
||||
isf.setText("");
|
||||
basal.setText("");
|
||||
basaltotal.setText("");
|
||||
target.setText("");
|
||||
activateButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
|||
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
||||
invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile);
|
||||
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
|
||||
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
|||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
boolean isValid = SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid(MainApp.gs(R.string.simpleprofile));
|
||||
if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended() || !isValid) {
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized() || ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended() || !isValid) {
|
||||
profileswitchButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
profileswitchButton.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
switch (view.getId()) {
|
||||
case R.id.combo_refresh_button:
|
||||
refreshButton.setEnabled(false);
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("User request", new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("User request", new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(() -> refreshButton.setEnabled(true));
|
||||
|
@ -124,7 +124,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
activityView.setTextColor(Color.WHITE);
|
||||
activityView.setTextSize(14);
|
||||
activityView.setText(activity);
|
||||
} else if (ConfigBuilderPlugin.getCommandQueue().size() > 0) {
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getCommandQueue().size() > 0) {
|
||||
activityView.setTextColor(Color.WHITE);
|
||||
activityView.setTextSize(14);
|
||||
activityView.setText("");
|
||||
|
|
|
@ -437,6 +437,23 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
return pump.basalProfile.hourlyRates[currentHour];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() {
|
||||
return pump.reservoirLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryLevel() {
|
||||
switch (pump.state.batteryState) {
|
||||
case PumpState.EMPTY:
|
||||
return 5;
|
||||
case PumpState.LOW:
|
||||
return 25;
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
private static BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
|
||||
EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance();
|
||||
switch (state) {
|
||||
|
@ -655,11 +672,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a DetailedBolusInfo from a pump bolus and adds it as a Treatment to the DB.
|
||||
* Handles edge cases when dates aren't unique which are extremely unlikely to occur,
|
||||
* but if they do, the user should be warned since a bolus will be missing from calculations.
|
||||
*/
|
||||
/** Creates a treatment record based on the request in DetailBolusInfo and the delivered bolus. */
|
||||
private boolean addBolusToTreatments(DetailedBolusInfo detailedBolusInfo, Bolus lastPumpBolus) {
|
||||
DetailedBolusInfo dbi = detailedBolusInfo.copy();
|
||||
dbi.date = calculateFakeBolusDate(lastPumpBolus);
|
||||
|
@ -667,15 +680,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
dbi.source = Source.PUMP;
|
||||
dbi.insulin = lastPumpBolus.amount;
|
||||
try {
|
||||
boolean treatmentCreated = TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, false);
|
||||
if (!treatmentCreated) {
|
||||
log.error("Adding treatment record overrode an existing record: " + dbi);
|
||||
if (dbi.isSMB) {
|
||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, true);
|
||||
} catch (Exception e) {
|
||||
log.error("Adding treatment record failed", e);
|
||||
if (dbi.isSMB) {
|
||||
|
@ -900,7 +905,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, null);
|
||||
}
|
||||
updateLocalData(commandResult);
|
||||
}
|
||||
|
@ -1079,7 +1084,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
n.soundId = R.raw.alarm;
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
violationWarningRaisedForBolusAt = lowSuspendOnlyLoopEnforcedUntil;
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1151,6 +1156,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
return historyResult.success;
|
||||
}
|
||||
|
||||
/** Return value indicates whether a new record was created. */
|
||||
private boolean updateDbFromPumpHistory(@NonNull PumpHistory history) {
|
||||
boolean updated = false;
|
||||
for (Bolus pumpBolus : history.bolusHistory) {
|
||||
|
@ -1160,8 +1166,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
dbi.source = Source.PUMP;
|
||||
dbi.insulin = pumpBolus.amount;
|
||||
dbi.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||
if (TreatmentsPlugin.getPlugin().getService().getPumpRecordById(dbi.pumpId) == null) {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, false);
|
||||
if (TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, true)) {
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public enum PumpType {
|
|||
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01d, 0.1d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||
|
||||
AccuChekSpirit("Accu-Chek Spirit", 0.1d, null, //
|
||||
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||
|
@ -50,13 +50,13 @@ public enum PumpType {
|
|||
new DoseSettings(0.05d, 15, 24*60, 0.05d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 12*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.02d, 0.1d, null, PumpCapability.InsightCapabilities), //
|
||||
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //
|
||||
|
||||
// Animas
|
||||
AnimasVibe("Animas Vibe", 0.05d, null, // AnimasBolus?
|
||||
new DoseSettings(0.05d, 30, 12*60, 0.05d), //
|
||||
PumpTempBasalType.Percent, //
|
||||
new DoseSettings(10, 30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
new DoseSettings(10, 30, 24*60, 0d, 300d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
AnimasPing("Animas Ping", AnimasVibe),
|
||||
|
|
|
@ -155,6 +155,12 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
return DanaRPump.getInstance().currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return DanaRPump.getInstance().reservoirRemainingUnits; }
|
||||
|
||||
@Override
|
||||
public int getBatteryLevel() { return DanaRPump.getInstance().batteryRemaining; }
|
||||
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
if (sExecutionService == null) {
|
||||
|
|
|
@ -148,7 +148,7 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Clicked connect to pump");
|
||||
DanaRPump.getInstance().lastConnection = 0;
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Clicked connect to pump", null);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -228,9 +228,9 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h");
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
|
@ -265,7 +265,7 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
bolusStepView.setText("" + pump.bolusStep);
|
||||
serialNumberView.setText("" + pump.serialNumber);
|
||||
if (queueView != null) {
|
||||
Spanned status = ConfigBuilderPlugin.getCommandQueue().spannedStatus();
|
||||
Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus();
|
||||
if (status.toString().equals("")) {
|
||||
queueView.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@ import info.nightscout.utils.SP;
|
|||
* Created by mike on 04.07.2016.
|
||||
*/
|
||||
public class DanaRPump {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private static DanaRPump instance = null;
|
||||
|
||||
|
@ -30,6 +30,7 @@ public class DanaRPump {
|
|||
}
|
||||
|
||||
public static void reset() {
|
||||
log.debug("DanaRPump reset");
|
||||
instance = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ProfileViewDialog extends DialogFragment {
|
|||
refreshButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("ProfileViewDialog", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("ProfileViewDialog", null);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
@ -71,13 +71,13 @@ public class ProfileViewDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
private void setContent() {
|
||||
ProfileStore store = ((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfile();
|
||||
ProfileStore store = ((ProfileInterface)ConfigBuilderPlugin.getPlugin().getActivePump()).getProfile();
|
||||
if (store != null) {
|
||||
noProfile.setVisibility(View.GONE);
|
||||
Profile profile = store.getDefaultProfile();
|
||||
units.setText(profile.getUnits());
|
||||
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||
activeProfile.setText(((ProfileInterface) MainApp.getConfigBuilder().getActivePump()).getProfileName());
|
||||
activeProfile.setText(((ProfileInterface) ConfigBuilderPlugin.getPlugin().getActivePump()).getProfileName());
|
||||
ic.setText(profile.getIcList());
|
||||
isf.setText(profile.getIsfList());
|
||||
basal.setText(profile.getBasalList());
|
||||
|
|
|
@ -148,7 +148,7 @@ public class DanaRHistoryActivity extends Activity {
|
|||
statusView.setVisibility(View.VISIBLE);
|
||||
});
|
||||
clearCardView();
|
||||
ConfigBuilderPlugin.getCommandQueue().loadHistory(selected.type, new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadHistory(selected.type, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadDataFromDB(selected.type);
|
||||
|
|
|
@ -20,6 +20,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
|
@ -204,7 +205,7 @@ public class DanaRUserOptionsActivity extends Activity {
|
|||
} else
|
||||
pump.lowReservoirRate = 10;
|
||||
|
||||
MainApp.getConfigBuilder().getCommandQueue().setUserOptions(null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().setUserOptions(null);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ public class MsgInitConnStatusTime extends MessageBase {
|
|||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingDanaDriver");
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaDriver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
failed = false;
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStart;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStop;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
|
@ -55,7 +56,6 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
|||
protected BluetoothSocket mRfcommSocket;
|
||||
protected BluetoothDevice mBTDevice;
|
||||
|
||||
protected DanaRPump mDanaRPump = DanaRPump.getInstance();
|
||||
protected Treatment mBolusingTreatment = null;
|
||||
|
||||
protected boolean mConnectionInProgress = false;
|
||||
|
@ -237,4 +237,15 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
|||
result.comment = "OK";
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void waitForWholeMinute() {
|
||||
while (true) {
|
||||
long time = DateUtil.now();
|
||||
long timeToWholeMinute = (60000 - time % 60000);
|
||||
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
||||
break;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
||||
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public void getPumpStatus() {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
try {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||
MsgStatus statusMsg = new MsgStatus();
|
||||
|
@ -141,7 +142,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended();
|
||||
MsgCheckValue checkValue = new MsgCheckValue();
|
||||
|
||||
if (mDanaRPump.isNewPump) {
|
||||
if (danaRPump.isNewPump) {
|
||||
mSerialIOThread.sendMessage(checkValue);
|
||||
if (!checkValue.received) {
|
||||
return;
|
||||
|
@ -157,19 +158,19 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
mDanaRPump.lastConnection = now;
|
||||
danaRPump.lastConnection = now;
|
||||
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
MainApp.bus().post(new EventProfileSwitchChange());
|
||||
}
|
||||
}
|
||||
|
||||
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||
|
@ -184,29 +185,29 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 10) {
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
mDanaRPump.lastSettingsRead = now;
|
||||
danaRPump.lastSettingsRead = now;
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
||||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
@ -216,8 +217,9 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean tempBasal(int percent, int durationInHours) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
if (mDanaRPump.isTempBasalInProgress) {
|
||||
if (danaRPump.isTempBasalInProgress) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
SystemClock.sleep(500);
|
||||
|
@ -262,6 +264,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean bolus(double amount, int carbs, long carbtime, final Treatment t) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
if (BolusProgressDialog.stopPressed) return false;
|
||||
|
||||
|
@ -332,16 +335,16 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
final Object o = new Object();
|
||||
synchronized (o) {
|
||||
ConfigBuilderPlugin.getCommandQueue().independentConnect("bolusingInterrupted", new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().independentConnect("bolusingInterrupted", new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mDanaRPump.lastBolusTime > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
|
||||
t.insulin = mDanaRPump.lastBolusAmount;
|
||||
if (danaRPump.lastBolusTime > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
|
||||
t.insulin = danaRPump.lastBolusAmount;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
|
||||
log.debug("Used bolus amount from history: " + danaRPump.lastBolusAmount);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Bolus amount in history too old: " + DateUtil.dateAndTimeFullString(mDanaRPump.lastBolusTime));
|
||||
log.debug("Bolus amount in history too old: " + DateUtil.dateAndTimeFullString(danaRPump.lastBolusTime));
|
||||
}
|
||||
synchronized (o) {
|
||||
o.notify();
|
||||
|
@ -355,7 +358,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("bolusOK", null);
|
||||
}
|
||||
}
|
||||
return !start.failed;
|
||||
|
@ -379,6 +382,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean updateBasalsInPump(final Profile profile) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||
|
@ -386,7 +390,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(msgSet);
|
||||
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
|
||||
mSerialIOThread.sendMessage(msgActivate);
|
||||
mDanaRPump.lastSettingsRead = 0; // force read full settings
|
||||
danaRPump.lastSettingsRead = 0; // force read full settings
|
||||
getPumpStatus();
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
return true;
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
@ -51,5 +52,9 @@ public class MsgInitConnStatusBolus_k extends MessageBase {
|
|||
} else {
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
|
||||
}
|
||||
|
||||
// This is last message of initial sequence
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump() != null)
|
||||
ConfigBuilderPlugin.getPlugin().getActivePump().finishHandshaking();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ public class MsgInitConnStatusTime_k extends MessageBase {
|
|||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingKoreanDanaDriver");
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingKoreanDanaDriver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
@ -55,8 +56,8 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgSettingBasal_k
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.comm.MsgStatusBasic_k;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.queue.commands.Command;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.T;
|
||||
|
||||
public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||
|
||||
|
@ -137,6 +138,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public void getPumpStatus() {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
try {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||
//MsgStatus_k statusMsg = new MsgStatus_k();
|
||||
|
@ -145,7 +147,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended();
|
||||
MsgCheckValue_k checkValue = new MsgCheckValue_k();
|
||||
|
||||
if (mDanaRPump.isNewPump) {
|
||||
if (danaRPump.isNewPump) {
|
||||
mSerialIOThread.sendMessage(checkValue);
|
||||
if (!checkValue.received) {
|
||||
return;
|
||||
|
@ -161,19 +163,19 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
mDanaRPump.lastConnection = now;
|
||||
danaRPump.lastConnection = now;
|
||||
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
MainApp.bus().post(new EventProfileSwitchChange());
|
||||
}
|
||||
}
|
||||
|
||||
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||
|
@ -184,29 +186,31 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 10) {
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||
waitForWholeMinute(); // Dana can set only whole minute
|
||||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
mDanaRPump.lastSettingsRead = now;
|
||||
danaRPump.lastSettingsRead = now;
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
||||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
@ -216,8 +220,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean tempBasal(int percent, int durationInHours) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
if (mDanaRPump.isTempBasalInProgress) {
|
||||
if (danaRPump.isTempBasalInProgress) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
SystemClock.sleep(500);
|
||||
|
@ -294,7 +299,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
SystemClock.sleep(300);
|
||||
|
||||
mBolusingTreatment = null;
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("bolusOK", null);
|
||||
}
|
||||
|
||||
return !start.failed;
|
||||
|
@ -318,12 +323,13 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean updateBasalsInPump(final Profile profile) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
||||
mSerialIOThread.sendMessage(msgSet);
|
||||
mDanaRPump.lastSettingsRead = 0; // force read full settings
|
||||
danaRPump.lastSettingsRead = 0; // force read full settings
|
||||
getPumpStatus();
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
return true;
|
||||
|
|
|
@ -377,6 +377,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
return DanaRPump.getInstance().currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return DanaRPump.getInstance().reservoirRemainingUnits; }
|
||||
|
||||
@Override
|
||||
public int getBatteryLevel() { return DanaRPump.getInstance().batteryRemaining; }
|
||||
|
||||
@Override
|
||||
public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
detailedBolusInfo.insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value();
|
||||
|
@ -419,6 +425,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
if (!result.success) {
|
||||
String error = "" + DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode;
|
||||
switch (DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode) {
|
||||
// 4 reported as max bolus violation. Check later
|
||||
case 0x10:
|
||||
error = MainApp.gs(R.string.maxbolusviolation);
|
||||
break;
|
||||
|
|
|
@ -51,8 +51,8 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
|
|||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.danars_pairingprogressdialog, container, false);
|
||||
getDialog().setTitle(MainApp.gs(R.string.pairing));
|
||||
statusView = (TextView) view.findViewById(R.id.danars_paringprogress_status);
|
||||
progressBar = (ProgressBar) view.findViewById(R.id.danars_paringprogress_progressbar);
|
||||
statusView = (TextView) view.findViewById(R.id.danars_pairingprogress_status);
|
||||
progressBar = (ProgressBar) view.findViewById(R.id.danars_pairingprogress_progressbar);
|
||||
button = (Button) view.findViewById(R.id.ok);
|
||||
|
||||
progressBar.setMax(100);
|
||||
|
|
|
@ -45,6 +45,12 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
|||
public DanaRS_Packet_APS_History_Events(long from) {
|
||||
this();
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
|
||||
if (from > DateUtil.now()) {
|
||||
log.debug("Asked to load from the future");
|
||||
from = 0;
|
||||
}
|
||||
|
||||
if (from != 0)
|
||||
cal.setTimeInMillis(from);
|
||||
else
|
||||
|
|
|
@ -144,9 +144,9 @@ public class BLEComm {
|
|||
|
||||
if (L.isEnabled(L.PUMPBTCOMM))
|
||||
log.debug("Trying to create a new connection from: " + from);
|
||||
mBluetoothDeviceName = device.getName();
|
||||
mBluetoothGatt = device.connectGatt(service.getApplicationContext(), false, mGattCallback);
|
||||
setCharacteristicNotification(getUARTReadBTGattChar(), true);
|
||||
mBluetoothDeviceName = device.getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,13 @@ public class BLEComm {
|
|||
|
||||
private void SendPumpCheck() {
|
||||
// 1st message sent to pump after connect
|
||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, getConnectDeviceName());
|
||||
String devicename = getConnectDeviceName();
|
||||
if(devicename == null || devicename.equals("")){
|
||||
Notification n = new Notification(Notification.DEVICENOTPAIRED, MainApp.gs(R.string.pairfirst), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
return;
|
||||
}
|
||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, devicename);
|
||||
if (L.isEnabled(L.PUMPBTCOMM))
|
||||
log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes));
|
||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
||||
|
|
|
@ -144,11 +144,11 @@ public class DanaRSService extends Service {
|
|||
danaRPump.lastConnection = System.currentTimeMillis();
|
||||
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
MainApp.bus().post(new EventProfileSwitchChange());
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ public class DanaRSService extends Service {
|
|||
SystemClock.sleep(1000);
|
||||
}
|
||||
// do not call loadEvents() directly, reconnection may be needed
|
||||
ConfigBuilderPlugin.getCommandQueue().loadEvents(new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadEvents(new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
// reread bolus status
|
||||
|
|
|
@ -59,9 +59,9 @@ public class MsgCheckValue_v2 extends MessageBase {
|
|||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingDanaRv2Driver");
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,9 @@ public class MsgCheckValue_v2 extends MessageBase {
|
|||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingDanaRv2Driver");
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
}
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
|
|
|
@ -26,23 +26,30 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
|
||||
public static long lastEventTimeLoaded = 0;
|
||||
|
||||
public MsgHistoryEvents_v2(long from) {
|
||||
SetCommand(0xE003);
|
||||
GregorianCalendar gfrom = new GregorianCalendar();
|
||||
gfrom.setTimeInMillis(from);
|
||||
AddParamDate(gfrom);
|
||||
done = false;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("New message");
|
||||
public MsgHistoryEvents_v2() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public MsgHistoryEvents_v2() {
|
||||
public MsgHistoryEvents_v2(long from) {
|
||||
SetCommand(0xE003);
|
||||
AddParamByte((byte) 0);
|
||||
AddParamByte((byte) 1);
|
||||
AddParamByte((byte) 1);
|
||||
AddParamByte((byte) 0);
|
||||
AddParamByte((byte) 0);
|
||||
|
||||
if (from > DateUtil.now()) {
|
||||
log.debug("Asked to load from the future");
|
||||
from = 0;
|
||||
}
|
||||
|
||||
if (from == 0) {
|
||||
AddParamByte((byte) 0);
|
||||
AddParamByte((byte) 1);
|
||||
AddParamByte((byte) 1);
|
||||
AddParamByte((byte) 0);
|
||||
AddParamByte((byte) 0);
|
||||
} else {
|
||||
GregorianCalendar gfrom = new GregorianCalendar();
|
||||
gfrom.setTimeInMillis(from);
|
||||
AddParamDate(gfrom);
|
||||
}
|
||||
|
||||
done = false;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("New message");
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
|
@ -71,7 +72,6 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
|||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.commands.Command;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.T;
|
||||
|
||||
|
@ -156,6 +156,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public void getPumpStatus() {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
try {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||
MsgStatus statusMsg = new MsgStatus();
|
||||
|
@ -164,7 +165,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
MsgStatusBolusExtended_v2 exStatusMsg = new MsgStatusBolusExtended_v2();
|
||||
MsgCheckValue_v2 checkValue = new MsgCheckValue_v2();
|
||||
|
||||
if (mDanaRPump.isNewPump) {
|
||||
if (danaRPump.isNewPump) {
|
||||
mSerialIOThread.sendMessage(checkValue);
|
||||
if (!checkValue.received) {
|
||||
return;
|
||||
|
@ -179,21 +180,21 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||
mSerialIOThread.sendMessage(exStatusMsg);
|
||||
|
||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
||||
danaRPump.lastConnection = System.currentTimeMillis();
|
||||
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||
MainApp.bus().post(new EventProfileSwitchChange());
|
||||
}
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
long timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
if (Math.abs(timeDiff) > 3) {
|
||||
|
@ -209,7 +210,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
MainApp.instance().startActivity(i);
|
||||
|
||||
//deinitialize pump
|
||||
mDanaRPump.lastConnection = 0;
|
||||
danaRPump.lastConnection = 0;
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
return;
|
||||
|
@ -218,14 +219,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||
timeDiff = (mDanaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||
}
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||
|
@ -238,7 +239,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||
mDanaRPump.lastSettingsRead = now;
|
||||
danaRPump.lastSettingsRead = now;
|
||||
}
|
||||
|
||||
loadEvents();
|
||||
|
@ -246,13 +247,13 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
||||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
@ -262,8 +263,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean tempBasal(int percent, int durationInHours) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
if (mDanaRPump.isTempBasalInProgress) {
|
||||
if (danaRPump.isTempBasalInProgress) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
SystemClock.sleep(500);
|
||||
|
@ -277,8 +279,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean highTempBasal(int percent) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
if (mDanaRPump.isTempBasalInProgress) {
|
||||
if (danaRPump.isTempBasalInProgress) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
SystemClock.sleep(500);
|
||||
|
@ -292,13 +295,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public boolean tempBasalShortDuration(int percent, int durationInMinutes) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (durationInMinutes != 15 && durationInMinutes != 30) {
|
||||
log.error("Wrong duration param");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isConnected()) return false;
|
||||
if (mDanaRPump.isTempBasalInProgress) {
|
||||
if (danaRPump.isTempBasalInProgress) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||
SystemClock.sleep(500);
|
||||
|
@ -409,7 +413,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
SystemClock.sleep(1000);
|
||||
}
|
||||
// do not call loadEvents() directly, reconnection may be needed
|
||||
ConfigBuilderPlugin.getCommandQueue().loadEvents(new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().loadEvents(new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
// load last bolus status
|
||||
|
@ -449,6 +453,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
public PumpEnactResult loadEvents() {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
|
||||
if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
|
||||
PumpEnactResult result = new PumpEnactResult().success(false);
|
||||
|
@ -460,16 +465,10 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
if (!isConnected())
|
||||
return new PumpEnactResult().success(false);
|
||||
SystemClock.sleep(300);
|
||||
MsgHistoryEvents_v2 msg;
|
||||
if (lastHistoryFetched == 0) {
|
||||
msg = new MsgHistoryEvents_v2();
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Loading complete event history");
|
||||
} else {
|
||||
msg = new MsgHistoryEvents_v2(lastHistoryFetched);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
||||
}
|
||||
MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(lastHistoryFetched);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
||||
|
||||
mSerialIOThread.sendMessage(msg);
|
||||
while (!msg.done && mRfcommSocket.isConnected()) {
|
||||
SystemClock.sleep(100);
|
||||
|
@ -479,11 +478,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - T.mins(1).msecs();
|
||||
else
|
||||
lastHistoryFetched = 0;
|
||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
||||
danaRPump.lastConnection = System.currentTimeMillis();
|
||||
return new PumpEnactResult().success(true);
|
||||
}
|
||||
|
||||
public boolean updateBasalsInPump(final Profile profile) {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
if (!isConnected()) return false;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||
|
@ -491,23 +491,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
mSerialIOThread.sendMessage(msgSet);
|
||||
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
|
||||
mSerialIOThread.sendMessage(msgActivate);
|
||||
mDanaRPump.lastSettingsRead = 0; // force read full settings
|
||||
danaRPump.lastSettingsRead = 0; // force read full settings
|
||||
getPumpStatus();
|
||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||
return true;
|
||||
}
|
||||
|
||||
void waitForWholeMinute() {
|
||||
while (true) {
|
||||
long time = DateUtil.now();
|
||||
long timeToWholeMinute = (60000 - time % 60000);
|
||||
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
||||
break;
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
||||
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||
}
|
||||
}
|
||||
|
||||
public PumpEnactResult setUserOptions() {
|
||||
if (!isConnected())
|
||||
return new PumpEnactResult().success(false);
|
||||
|
|
|
@ -410,6 +410,12 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
return basalRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return reservoirInUnits; }
|
||||
|
||||
@Override
|
||||
public int getBatteryLevel() { return batteryPercent; }
|
||||
|
||||
public String getBaseBasalRateString() {
|
||||
final DecimalFormat df = new DecimalFormat("#.##");
|
||||
return df.format(basalRate);
|
||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventFeatureRunning;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
|
||||
|
@ -459,7 +460,7 @@ public class Connector {
|
|||
public void tryToGetPumpStatusAgain() {
|
||||
if (Helpers.ratelimit("insight-retry-status-request", 5)) {
|
||||
try {
|
||||
MainApp.getConfigBuilder().getCommandQueue().readStatus("Insight. Status missing", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Insight. Status missing", null);
|
||||
} catch (NullPointerException e) {
|
||||
//
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
public class EventLocalInsightUpdateGUI extends EventUpdateGui {
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioManager;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.activities.InsightAlertActivity;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.remote_control.ConfirmAlertMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.remote_control.SnoozeAlertMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.status.GetActiveAlertMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.connection_service.InsightConnectionService;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.Alert;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertType;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.InsightState;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.InsightException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.AppLayerErrorException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ExceptionTranslator;
|
||||
|
||||
public class InsightAlertService extends Service implements InsightConnectionService.StateCallback {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
private LocalBinder localBinder = new LocalBinder();
|
||||
private boolean connectionRequested;
|
||||
private final Object $alertLock = new Object[0];
|
||||
private Alert alert;
|
||||
private Thread thread;
|
||||
private InsightAlertActivity alertActivity;
|
||||
private Ringtone ringtone;
|
||||
private Vibrator vibrator;
|
||||
private boolean vibrating;
|
||||
private InsightConnectionService connectionService;
|
||||
private long ignoreTimestamp;
|
||||
private AlertType ignoreType;
|
||||
|
||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||
connectionService.registerStateCallback(InsightAlertService.this);
|
||||
onStateChanged(connectionService.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
connectionService = null;
|
||||
}
|
||||
};
|
||||
|
||||
private void retrieveRingtone() {
|
||||
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||
ringtone = RingtoneManager.getRingtone(this, uri);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
ringtone.setAudioAttributes(new AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
|
||||
.setLegacyStreamType(AudioManager.STREAM_RING).build());
|
||||
} else ringtone.setStreamType(AudioManager.STREAM_RING);
|
||||
}
|
||||
|
||||
public Alert getAlert() {
|
||||
synchronized ($alertLock) {
|
||||
return alert;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAlertActivity(InsightAlertActivity alertActivity) {
|
||||
this.alertActivity = alertActivity;
|
||||
}
|
||||
|
||||
public void ignore(AlertType alertType) {
|
||||
synchronized ($alertLock) {
|
||||
if (alertType == null) {
|
||||
ignoreTimestamp = 0;
|
||||
ignoreType = null;
|
||||
} else {
|
||||
ignoreTimestamp = System.currentTimeMillis();
|
||||
ignoreType = alertType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return localBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
||||
bindService(new Intent(this, InsightConnectionService.class), serviceConnection, BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (thread != null) thread.interrupt();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(InsightState state) {
|
||||
if (state == InsightState.CONNECTED) {
|
||||
thread = new Thread(this::queryActiveAlert);
|
||||
thread.start();
|
||||
|
||||
} else if (thread != null) thread.interrupt();
|
||||
}
|
||||
|
||||
private void queryActiveAlert() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
Alert alert = connectionService.requestMessage(new GetActiveAlertMessage()).await().getAlert();
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
connectionService.withdrawConnectionRequest(thread);
|
||||
break;
|
||||
}
|
||||
synchronized ($alertLock) {
|
||||
if ((this.alert == null && alert != null)
|
||||
|| (this.alert != null && alert == null)
|
||||
|| (this.alert != null && alert != null && !this.alert.equals(alert))) {
|
||||
if (this.alert != null && (alert == null || this.alert.getAlertId() != alert.getAlertId())) stopAlerting();
|
||||
this.alert = alert;
|
||||
if (alertActivity != null && alert != null)
|
||||
new Handler(Looper.getMainLooper()).post(() -> alertActivity.update(alert));
|
||||
}
|
||||
if (alert == null) {
|
||||
stopAlerting();
|
||||
if (connectionRequested) {
|
||||
connectionService.withdrawConnectionRequest(this);
|
||||
connectionRequested = false;
|
||||
}
|
||||
if (alertActivity != null)
|
||||
new Handler(Looper.getMainLooper()).post(() -> alertActivity.finish());
|
||||
} else if (!(alert.getAlertType() == ignoreType && System.currentTimeMillis() - ignoreTimestamp < 10000)) {
|
||||
if (alert.getAlertStatus() == AlertStatus.ACTIVE) alert();
|
||||
else stopAlerting();
|
||||
if (!connectionRequested) {
|
||||
connectionService.requestConnection(this);
|
||||
connectionRequested = true;
|
||||
}
|
||||
if (alertActivity == null) {
|
||||
Intent intent = new Intent(InsightAlertService.this, InsightAlertActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
new Handler(Looper.getMainLooper()).post(() -> startActivity(intent));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
connectionService.withdrawConnectionRequest(thread);
|
||||
break;
|
||||
} catch (AppLayerErrorException e) {
|
||||
log.info("Exception while fetching alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||
} catch (InsightException e) {
|
||||
log.info("Exception while fetching alert: " + e.getClass().getSimpleName());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception while fetching alert", e);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (connectionRequested) {
|
||||
connectionService.withdrawConnectionRequest(thread);
|
||||
connectionRequested = false;
|
||||
}
|
||||
if (alertActivity != null)
|
||||
new Handler(Looper.getMainLooper()).post(() -> alertActivity.finish());
|
||||
stopAlerting();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
private void alert() {
|
||||
if (!vibrating) {
|
||||
vibrator.vibrate(new long[] {0, 1000, 1000}, 0);
|
||||
vibrating = true;
|
||||
}
|
||||
if (ringtone == null || !ringtone.isPlaying()) {
|
||||
retrieveRingtone();
|
||||
ringtone.play();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAlerting() {
|
||||
if (vibrating) {
|
||||
vibrator.cancel();
|
||||
vibrating = false;
|
||||
}
|
||||
if (ringtone != null && ringtone.isPlaying()) ringtone.stop();
|
||||
}
|
||||
|
||||
public void mute() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
SnoozeAlertMessage snoozeAlertMessage = new SnoozeAlertMessage();
|
||||
snoozeAlertMessage.setAlertID(alert.getAlertId());
|
||||
connectionService.requestMessage(snoozeAlertMessage).await();
|
||||
} catch (AppLayerErrorException e) {
|
||||
log.info("Exception while muting alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||
} catch (InsightException e) {
|
||||
log.info("Exception while muting alert: " + e.getClass().getSimpleName());
|
||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception while muting alert", e);
|
||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void confirm() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
ConfirmAlertMessage confirmAlertMessage = new ConfirmAlertMessage();
|
||||
confirmAlertMessage.setAlertID(alert.getAlertId());
|
||||
connectionService.requestMessage(confirmAlertMessage).await();
|
||||
} catch (AppLayerErrorException e) {
|
||||
log.info("Exception while confirming alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||
} catch (InsightException e) {
|
||||
log.info("Exception while confirming alert: " + e.getClass().getSimpleName());
|
||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception while confirming alert", e);
|
||||
ExceptionTranslator.makeToast(InsightAlertService.this, e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
public InsightAlertService getService() {
|
||||
return InsightAlertService.this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.parameter_blocks.TBROverNotificationBlock;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.ActiveBasalRate;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.ActiveBolus;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.ActiveTBR;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.CartridgeStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.InsightState;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.TotalDailyDose;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
public class LocalInsightFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
|
||||
private static final boolean ENABLE_OPERATING_MODE_BUTTON = false;
|
||||
|
||||
private boolean viewsCreated;
|
||||
private Button operatingMode;
|
||||
private Button tbrOverNotification;
|
||||
private Button refresh;
|
||||
private LinearLayout statusItemContainer = null;
|
||||
|
||||
private Callback operatingModeCallback;
|
||||
private Callback tbrOverNotificationCallback;
|
||||
private Callback refreshCallback;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.local_insight_fragment, container, false);
|
||||
statusItemContainer = view.findViewById(R.id.status_item_container);
|
||||
tbrOverNotification = view.findViewById(R.id.tbr_over_notification);
|
||||
tbrOverNotification.setOnClickListener(this);
|
||||
operatingMode = view.findViewById(R.id.operating_mode);
|
||||
operatingMode.setOnClickListener(this);
|
||||
refresh = view.findViewById(R.id.refresh);
|
||||
refresh.setOnClickListener(this);
|
||||
viewsCreated = true;
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
viewsCreated = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == operatingMode) {
|
||||
if (LocalInsightPlugin.getInstance().getOperatingMode() != null) {
|
||||
operatingMode.setEnabled(false);
|
||||
operatingModeCallback = new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
operatingModeCallback = null;
|
||||
updateGUI();
|
||||
});
|
||||
}
|
||||
};
|
||||
switch (LocalInsightPlugin.getInstance().getOperatingMode()) {
|
||||
case PAUSED:
|
||||
case STOPPED:
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().startPump(operatingModeCallback);
|
||||
break;
|
||||
case STARTED:
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().stopPump(operatingModeCallback);
|
||||
}
|
||||
}
|
||||
} else if (v == tbrOverNotification) {
|
||||
TBROverNotificationBlock notificationBlock = LocalInsightPlugin.getInstance().getTBROverNotificationBlock();
|
||||
if (notificationBlock != null) {
|
||||
tbrOverNotification.setEnabled(false);
|
||||
tbrOverNotificationCallback = new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
tbrOverNotificationCallback = null;
|
||||
updateGUI();
|
||||
});
|
||||
}
|
||||
};
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue()
|
||||
.setTBROverNotification(tbrOverNotificationCallback, !notificationBlock.isEnabled());
|
||||
}
|
||||
} else if (v == refresh) {
|
||||
refresh.setEnabled(false);
|
||||
refreshCallback = new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
refreshCallback = null;
|
||||
updateGUI();
|
||||
});
|
||||
}
|
||||
};
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("InsightRefreshButton", refreshCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onUpdateGUIEvent(EventLocalInsightUpdateGUI event) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
if (!viewsCreated) return;
|
||||
statusItemContainer.removeAllViews();
|
||||
if (!LocalInsightPlugin.getInstance().isInitialized()) {
|
||||
operatingMode.setVisibility(View.GONE);
|
||||
tbrOverNotification.setVisibility(View.GONE);
|
||||
refresh.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
refresh.setVisibility(View.VISIBLE);
|
||||
refresh.setEnabled(refreshCallback == null);
|
||||
TBROverNotificationBlock notificationBlock = LocalInsightPlugin.getInstance().getTBROverNotificationBlock();
|
||||
tbrOverNotification.setVisibility(notificationBlock == null ? View.GONE : View.VISIBLE);
|
||||
if (notificationBlock != null)
|
||||
tbrOverNotification.setText(notificationBlock.isEnabled() ? R.string.disable_tbr_over_notification : R.string.enable_tbr_over_notification);
|
||||
tbrOverNotification.setEnabled(tbrOverNotificationCallback == null);
|
||||
List<View> statusItems = new ArrayList<>();
|
||||
getConnectionStatusItem(statusItems);
|
||||
getLastConnectedItem(statusItems);
|
||||
getOperatingModeItem(statusItems);
|
||||
getBatteryStatusItem(statusItems);
|
||||
getCartridgeStatusItem(statusItems);
|
||||
getTDDItems(statusItems);
|
||||
getBaseBasalRateItem(statusItems);
|
||||
getTBRItem(statusItems);
|
||||
getBolusItems(statusItems);
|
||||
for (int i = 0; i < statusItems.size(); i++) {
|
||||
statusItemContainer.addView(statusItems.get(i));
|
||||
if (i != statusItems.size() - 1)
|
||||
getLayoutInflater().inflate(R.layout.local_insight_status_delimitter, statusItemContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private View getStatusItem(String label, String value) {
|
||||
View statusItem = getLayoutInflater().inflate(R.layout.local_insight_status_item, null);
|
||||
((TextView) statusItem.findViewById(R.id.label)).setText(label);
|
||||
((TextView) statusItem.findViewById(R.id.value)).setText(value);
|
||||
return statusItem;
|
||||
}
|
||||
|
||||
private void getConnectionStatusItem(List<View> statusItems) {
|
||||
int string = 0;
|
||||
InsightState state = LocalInsightPlugin.getInstance().getConnectionService().getState();
|
||||
switch (state) {
|
||||
case NOT_PAIRED:
|
||||
string = R.string.not_paired;
|
||||
break;
|
||||
case DISCONNECTED:
|
||||
string = R.string.disconnected;
|
||||
break;
|
||||
case CONNECTING:
|
||||
case SATL_CONNECTION_REQUEST:
|
||||
case SATL_KEY_REQUEST:
|
||||
case SATL_SYN_REQUEST:
|
||||
case SATL_VERIFY_CONFIRM_REQUEST:
|
||||
case SATL_VERIFY_DISPLAY_REQUEST:
|
||||
case APP_ACTIVATE_PARAMETER_SERVICE:
|
||||
case APP_ACTIVATE_STATUS_SERVICE:
|
||||
case APP_BIND_MESSAGE:
|
||||
case APP_CONNECT_MESSAGE:
|
||||
case APP_FIRMWARE_VERSIONS:
|
||||
case APP_SYSTEM_IDENTIFICATION:
|
||||
case AWAITING_CODE_CONFIRMATION:
|
||||
string = R.string.connecting;
|
||||
break;
|
||||
case CONNECTED:
|
||||
string = R.string.connected;
|
||||
break;
|
||||
case RECOVERING:
|
||||
string = R.string.recovering;
|
||||
break;
|
||||
}
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.insight_status), MainApp.gs(string)));
|
||||
if (state == InsightState.RECOVERING) {
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.recovery_duration), LocalInsightPlugin.getInstance().getConnectionService().getRecoveryDuration() / 1000 + "s"));
|
||||
}
|
||||
}
|
||||
|
||||
private void getLastConnectedItem(List<View> statusItems) {
|
||||
switch (LocalInsightPlugin.getInstance().getConnectionService().getState()) {
|
||||
case CONNECTED:
|
||||
case NOT_PAIRED:
|
||||
return;
|
||||
default:
|
||||
long lastConnection = LocalInsightPlugin.getInstance().getConnectionService().getLastConnected();
|
||||
if (lastConnection == 0) return;
|
||||
int min = (int) ((System.currentTimeMillis() - lastConnection) / 60000);
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.last_connected), DateUtil.timeString(lastConnection)));
|
||||
}
|
||||
}
|
||||
|
||||
private void getOperatingModeItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getOperatingMode() == null) {
|
||||
operatingMode.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
int string = 0;
|
||||
if (ENABLE_OPERATING_MODE_BUTTON) operatingMode.setVisibility(View.VISIBLE);
|
||||
operatingMode.setEnabled(operatingModeCallback == null);
|
||||
switch (LocalInsightPlugin.getInstance().getOperatingMode()) {
|
||||
case STARTED:
|
||||
operatingMode.setText(R.string.stop_pump);
|
||||
string = R.string.started;
|
||||
break;
|
||||
case STOPPED:
|
||||
operatingMode.setText(R.string.start_pump);
|
||||
string = R.string.stopped;
|
||||
break;
|
||||
case PAUSED:
|
||||
operatingMode.setText(R.string.start_pump);
|
||||
string = R.string.paused;
|
||||
break;
|
||||
}
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.operating_mode), MainApp.gs(string)));
|
||||
}
|
||||
|
||||
private void getBatteryStatusItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getBatteryStatus() == null) return;
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_battery_label),
|
||||
LocalInsightPlugin.getInstance().getBatteryStatus().getBatteryAmount() + "%"));
|
||||
}
|
||||
|
||||
private void getCartridgeStatusItem(List<View> statusItems) {
|
||||
CartridgeStatus cartridgeStatus = LocalInsightPlugin.getInstance().getCartridgeStatus();
|
||||
if (cartridgeStatus == null) return;
|
||||
String status;
|
||||
if (cartridgeStatus.isInserted())
|
||||
status = DecimalFormatter.to2Decimal(LocalInsightPlugin.getInstance().getCartridgeStatus().getRemainingAmount()) + "U";
|
||||
else status = MainApp.gs(R.string.not_inserted);
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_reservoir_label), status));
|
||||
}
|
||||
|
||||
private void getTDDItems(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getTotalDailyDose() == null) return;
|
||||
TotalDailyDose tdd = LocalInsightPlugin.getInstance().getTotalDailyDose();
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.tdd_bolus), DecimalFormatter.to2Decimal(tdd.getBolus())));
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.tdd_basal), DecimalFormatter.to2Decimal(tdd.getBasal())));
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.tdd_total), DecimalFormatter.to2Decimal(tdd.getBolusAndBasal())));
|
||||
}
|
||||
|
||||
private void getBaseBasalRateItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getActiveBasalRate() == null) return;
|
||||
ActiveBasalRate activeBasalRate = LocalInsightPlugin.getInstance().getActiveBasalRate();
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_basebasalrate_label),
|
||||
DecimalFormatter.to2Decimal(activeBasalRate.getActiveBasalRate()) + " U/h (" + activeBasalRate.getActiveBasalProfileName() + ")"));
|
||||
}
|
||||
|
||||
private void getTBRItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getActiveTBR() == null) return;
|
||||
ActiveTBR activeTBR = LocalInsightPlugin.getInstance().getActiveTBR();
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_tempbasal_label),
|
||||
MainApp.gs(R.string.tbr_formatter, activeTBR.getPercentage(), activeTBR.getInitialDuration() - activeTBR.getRemainingDuration(), activeTBR.getInitialDuration())));
|
||||
}
|
||||
|
||||
private void getBolusItems(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getActiveBoluses() == null) return;
|
||||
for (ActiveBolus activeBolus : LocalInsightPlugin.getInstance().getActiveBoluses()) {
|
||||
String label;
|
||||
switch (activeBolus.getBolusType()) {
|
||||
case MULTIWAVE:
|
||||
label = MainApp.gs(R.string.multiwave_bolus);
|
||||
break;
|
||||
case EXTENDED:
|
||||
label = MainApp.gs(R.string.extended_bolus);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
statusItems.add(getStatusItem(label, MainApp.gs(R.string.eb_formatter, activeBolus.getRemainingAmount(), activeBolus.getInitialAmount(), activeBolus.getRemainingDuration())));
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,257 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.activities;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.InsightAlertService;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.Alert;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.AlertStatus;
|
||||
|
||||
public class InsightAlertActivity extends AppCompatActivity {
|
||||
|
||||
private Alert alert;
|
||||
private InsightAlertService alertService;
|
||||
|
||||
private ImageView icon;
|
||||
private TextView errorCode;
|
||||
private TextView errorTitle;
|
||||
private TextView errorDescription;
|
||||
private Button mute;
|
||||
private Button confirm;
|
||||
|
||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||
alertService = ((InsightAlertService.LocalBinder) binder).getService();
|
||||
alertService.setAlertActivity(InsightAlertActivity.this);
|
||||
alert = alertService.getAlert();
|
||||
if (alert == null) finish();
|
||||
update(alert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
alertService = null;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_insight_alert);
|
||||
|
||||
bindService(new Intent(this, InsightAlertService.class), serviceConnection, BIND_AUTO_CREATE);
|
||||
|
||||
icon = findViewById(R.id.icon);
|
||||
errorCode = findViewById(R.id.error_code);
|
||||
errorTitle = findViewById(R.id.error_title);
|
||||
errorDescription = findViewById(R.id.error_description);
|
||||
mute = findViewById(R.id.mute);
|
||||
confirm = findViewById(R.id.confirm);
|
||||
|
||||
setFinishOnTouchOutside(false);
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
|
||||
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
|
||||
layoutParams.screenBrightness = 1.0F;
|
||||
getWindow().setAttributes(layoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
alertService.setAlertActivity(null);
|
||||
unbindService(serviceConnection);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void update(Alert alert) {
|
||||
this.alert = alert;
|
||||
mute.setEnabled(true);
|
||||
mute.setVisibility(alert.getAlertStatus() == AlertStatus.SNOOZED ? View.GONE : View.VISIBLE);
|
||||
confirm.setEnabled(true);
|
||||
int icon = 0;
|
||||
int code = 0;
|
||||
int title = 0;
|
||||
String description = null;
|
||||
switch (alert.getAlertCategory()) {
|
||||
case ERROR:
|
||||
icon = R.drawable.ic_error;
|
||||
break;
|
||||
case MAINTENANCE:
|
||||
icon = R.drawable.ic_maintenance;
|
||||
break;
|
||||
case WARNING:
|
||||
icon = R.drawable.ic_warning;
|
||||
break;
|
||||
case REMINDER:
|
||||
icon = R.drawable.ic_reminder;
|
||||
break;
|
||||
}
|
||||
DecimalFormat decimalFormat = new DecimalFormat("##0.00");
|
||||
int hours = alert.getTBRDuration() / 60;
|
||||
int minutes = alert.getTBRDuration() - hours * 60;
|
||||
switch (alert.getAlertType()) {
|
||||
case REMINDER_01:
|
||||
code = R.string.alert_r1_code;
|
||||
title = R.string.alert_r1_title;
|
||||
break;
|
||||
case REMINDER_02:
|
||||
code = R.string.alert_r2_code;
|
||||
title = R.string.alert_r2_title;
|
||||
break;
|
||||
case REMINDER_03:
|
||||
code = R.string.alert_r3_code;
|
||||
title = R.string.alert_r3_title;
|
||||
break;
|
||||
case REMINDER_04:
|
||||
code = R.string.alert_r4_code;
|
||||
title = R.string.alert_r4_title;
|
||||
break;
|
||||
case REMINDER_07:
|
||||
code = R.string.alert_r7_code;
|
||||
title = R.string.alert_r7_title;
|
||||
description = getString(R.string.alert_r7_description, alert.getTBRAmount(), new DecimalFormat("#0").format(hours) + ":" + new DecimalFormat("00").format(minutes));
|
||||
break;
|
||||
case WARNING_31:
|
||||
code = R.string.alert_w31_code;
|
||||
title = R.string.alert_w31_title;
|
||||
description = getString(R.string.alert_w31_description, decimalFormat.format(alert.getCartridgeAmount()));
|
||||
break;
|
||||
case WARNING_32:
|
||||
code = R.string.alert_w32_code;
|
||||
title = R.string.alert_w32_title;
|
||||
description = getString(R.string.alert_w32_description);
|
||||
break;
|
||||
case WARNING_33:
|
||||
code = R.string.alert_w33_code;
|
||||
title = R.string.alert_w33_title;
|
||||
description = getString(R.string.alert_w33_description);
|
||||
break;
|
||||
case WARNING_34:
|
||||
code = R.string.alert_w34_code;
|
||||
title = R.string.alert_w34_title;
|
||||
description = getString(R.string.alert_w34_description);
|
||||
break;
|
||||
case WARNING_36:
|
||||
code = R.string.alert_w36_code;
|
||||
title = R.string.alert_w36_title;
|
||||
description = getString(R.string.alert_w36_description, alert.getTBRAmount(), new DecimalFormat("#0").format(hours) + ":" + new DecimalFormat("00").format(minutes));
|
||||
break;
|
||||
case WARNING_38:
|
||||
code = R.string.alert_w38_code;
|
||||
title = R.string.alert_w38_title;
|
||||
description = getString(R.string.alert_w38_description, decimalFormat.format(alert.getProgrammedBolusAmount()), decimalFormat.format(alert.getDeliveredBolusAmount()));
|
||||
break;
|
||||
case WARNING_39:
|
||||
code = R.string.alert_w39_code;
|
||||
title = R.string.alert_w39_title;
|
||||
break;
|
||||
case MAINTENANCE_20:
|
||||
code = R.string.alert_m20_code;
|
||||
title = R.string.alert_m20_title;
|
||||
description = getString(R.string.alert_m20_description);
|
||||
break;
|
||||
case MAINTENANCE_21:
|
||||
code = R.string.alert_m21_code;
|
||||
title = R.string.alert_m21_title;
|
||||
description = getString(R.string.alert_m21_description);
|
||||
break;
|
||||
case MAINTENANCE_22:
|
||||
code = R.string.alert_m22_code;
|
||||
title = R.string.alert_m22_title;
|
||||
description = getString(R.string.alert_m22_description);
|
||||
break;
|
||||
case MAINTENANCE_23:
|
||||
code = R.string.alert_m23_code;
|
||||
title = R.string.alert_m23_title;
|
||||
description = getString(R.string.alert_m23_description);
|
||||
break;
|
||||
case MAINTENANCE_24:
|
||||
code = R.string.alert_m24_code;
|
||||
title = R.string.alert_m24_title;
|
||||
description = getString(R.string.alert_m24_description);
|
||||
break;
|
||||
case MAINTENANCE_25:
|
||||
code = R.string.alert_m25_code;
|
||||
title = R.string.alert_m25_title;
|
||||
description = getString(R.string.alert_m25_description);
|
||||
break;
|
||||
case MAINTENANCE_26:
|
||||
code = R.string.alert_m26_code;
|
||||
title = R.string.alert_m26_title;
|
||||
description = getString(R.string.alert_m26_description);
|
||||
break;
|
||||
case MAINTENANCE_27:
|
||||
code = R.string.alert_m27_code;
|
||||
title = R.string.alert_m27_title;
|
||||
description = getString(R.string.alert_m27_description);
|
||||
break;
|
||||
case MAINTENANCE_28:
|
||||
code = R.string.alert_m28_code;
|
||||
title = R.string.alert_m28_title;
|
||||
description = getString(R.string.alert_m28_description);
|
||||
break;
|
||||
case MAINTENANCE_29:
|
||||
code = R.string.alert_m29_code;
|
||||
title = R.string.alert_m29_title;
|
||||
description = getString(R.string.alert_m29_description);
|
||||
break;
|
||||
case MAINTENANCE_30:
|
||||
code = R.string.alert_m30_code;
|
||||
title = R.string.alert_m30_title;
|
||||
description = getString(R.string.alert_m30_description);
|
||||
break;
|
||||
case ERROR_6:
|
||||
code = R.string.alert_e6_code;
|
||||
title = R.string.alert_e6_title;
|
||||
description = getString(R.string.alert_e6_description);
|
||||
break;
|
||||
case ERROR_10:
|
||||
code = R.string.alert_e10_code;
|
||||
title = R.string.alert_e10_title;
|
||||
description = getString(R.string.alert_e10_description);
|
||||
break;
|
||||
case ERROR_13:
|
||||
code = R.string.alert_e13_code;
|
||||
title = R.string.alert_e13_title;
|
||||
description = getString(R.string.alert_e13_description);
|
||||
break;
|
||||
}
|
||||
this.icon.setImageDrawable(ContextCompat.getDrawable(this, icon));
|
||||
this.errorCode.setText(code);
|
||||
this.errorTitle.setText(title);
|
||||
if (description == null) this.errorDescription.setVisibility(View.GONE);
|
||||
else {
|
||||
this.errorDescription.setVisibility(View.VISIBLE);
|
||||
this.errorDescription.setText(Html.fromHtml(description));
|
||||
}
|
||||
}
|
||||
|
||||
public void muteClicked(View view) {
|
||||
mute.setEnabled(false);
|
||||
alertService.mute();
|
||||
}
|
||||
|
||||
public void confirmClicked(View view) {
|
||||
mute.setEnabled(false);
|
||||
confirm.setEnabled(false);
|
||||
alertService.confirm();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.activities;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.connection_service.InsightConnectionService;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.InsightState;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ExceptionTranslator;
|
||||
|
||||
public class InsightPairingActivity extends AppCompatActivity implements InsightConnectionService.StateCallback, View.OnClickListener, InsightConnectionService.ExceptionCallback {
|
||||
|
||||
private boolean scanning;
|
||||
private LinearLayout deviceSearchSection;
|
||||
private TextView pleaseWaitSection;
|
||||
private LinearLayout codeCompareSection;
|
||||
private LinearLayout pairingCompletedSection;
|
||||
private Button yes;
|
||||
private Button no;
|
||||
private TextView code;
|
||||
private Button exit;
|
||||
private RecyclerView deviceList;
|
||||
private DeviceAdapter deviceAdapter = new DeviceAdapter();
|
||||
|
||||
private InsightConnectionService service;
|
||||
|
||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||
service = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||
if (service.isPaired()) return;
|
||||
else {
|
||||
service.requestConnection(InsightPairingActivity.this);
|
||||
service.registerStateCallback(InsightPairingActivity.this);
|
||||
service.registerExceptionCallback(InsightPairingActivity.this);
|
||||
onStateChanged(service.getState());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_insight_pairing);
|
||||
|
||||
deviceSearchSection = findViewById(R.id.device_search_section);
|
||||
pleaseWaitSection = findViewById(R.id.please_wait_section);
|
||||
codeCompareSection = findViewById(R.id.code_compare_section);
|
||||
pairingCompletedSection = findViewById(R.id.pairing_completed_section);
|
||||
yes = findViewById(R.id.yes);
|
||||
no = findViewById(R.id.no);
|
||||
code = findViewById(R.id.code);
|
||||
exit = findViewById(R.id.exit);
|
||||
deviceList = findViewById(R.id.device_list);
|
||||
|
||||
yes.setOnClickListener(this);
|
||||
no.setOnClickListener(this);
|
||||
exit.setOnClickListener(this);
|
||||
|
||||
deviceList.setLayoutManager(new LinearLayoutManager(this));
|
||||
deviceList.setAdapter(deviceAdapter);
|
||||
|
||||
|
||||
bindService(new Intent(this, InsightConnectionService.class), serviceConnection, BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (service != null) {
|
||||
service.withdrawConnectionRequest(InsightPairingActivity.this);
|
||||
service.unregisterStateCallback(InsightPairingActivity.this);
|
||||
service.unregisterExceptionCallback(InsightPairingActivity.this);
|
||||
}
|
||||
unbindService(serviceConnection);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (service != null && service.getState() == InsightState.NOT_PAIRED) startBLScan();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
stopBLScan();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(InsightState state) {
|
||||
runOnUiThread(() -> {
|
||||
switch (state) {
|
||||
case NOT_PAIRED:
|
||||
startBLScan();
|
||||
deviceSearchSection.setVisibility(View.VISIBLE);
|
||||
pleaseWaitSection.setVisibility(View.GONE);
|
||||
codeCompareSection.setVisibility(View.GONE);
|
||||
pairingCompletedSection.setVisibility(View.GONE);
|
||||
break;
|
||||
case CONNECTING:
|
||||
case SATL_CONNECTION_REQUEST:
|
||||
case SATL_KEY_REQUEST:
|
||||
case SATL_VERIFY_DISPLAY_REQUEST:
|
||||
case SATL_VERIFY_CONFIRM_REQUEST:
|
||||
case APP_BIND_MESSAGE:
|
||||
stopBLScan();
|
||||
deviceSearchSection.setVisibility(View.GONE);
|
||||
pleaseWaitSection.setVisibility(View.VISIBLE);
|
||||
codeCompareSection.setVisibility(View.GONE);
|
||||
pairingCompletedSection.setVisibility(View.GONE);
|
||||
break;
|
||||
case AWAITING_CODE_CONFIRMATION:
|
||||
stopBLScan();
|
||||
deviceSearchSection.setVisibility(View.GONE);
|
||||
pleaseWaitSection.setVisibility(View.GONE);
|
||||
codeCompareSection.setVisibility(View.VISIBLE);
|
||||
pairingCompletedSection.setVisibility(View.GONE);
|
||||
code.setText(service.getVerificationString());
|
||||
break;
|
||||
case DISCONNECTED:
|
||||
case CONNECTED:
|
||||
stopBLScan();
|
||||
deviceSearchSection.setVisibility(View.GONE);
|
||||
pleaseWaitSection.setVisibility(View.GONE);
|
||||
codeCompareSection.setVisibility(View.GONE);
|
||||
pairingCompletedSection.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startBLScan() {
|
||||
if (!scanning) {
|
||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (!bluetoothAdapter.isEnabled()) bluetoothAdapter.enable();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
|
||||
registerReceiver(broadcastReceiver, intentFilter);
|
||||
bluetoothAdapter.startDiscovery();
|
||||
scanning = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void stopBLScan() {
|
||||
if (scanning) {
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
|
||||
scanning = false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == exit) finish();
|
||||
else if (v == yes) service.confirmVerificationString();
|
||||
else if (v == no) service.rejectVerificationString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExceptionOccur(Exception e) {
|
||||
ExceptionTranslator.makeToast(this, e);
|
||||
}
|
||||
|
||||
private void deviceSelected(BluetoothDevice device) {
|
||||
service.pair(device.getAddress());
|
||||
}
|
||||
|
||||
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED))
|
||||
BluetoothAdapter.getDefaultAdapter().startDiscovery();
|
||||
else if (action.equals(BluetoothDevice.ACTION_FOUND)) {
|
||||
BluetoothDevice bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
deviceAdapter.addDevice(bluetoothDevice);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private class DeviceAdapter extends RecyclerView.Adapter<DeviceAdapter.ViewHolder> {
|
||||
|
||||
private List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
|
||||
|
||||
public void addDevice(BluetoothDevice bluetoothDevice) {
|
||||
if (!bluetoothDevices.contains(bluetoothDevice)) {
|
||||
bluetoothDevices.add(bluetoothDevice);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
bluetoothDevices.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.bluetooth_device, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
BluetoothDevice bluetoothDevice = bluetoothDevices.get(position);
|
||||
holder.deviceName.setText(bluetoothDevice.getName() == null ? bluetoothDevice.getAddress() : bluetoothDevice.getName());
|
||||
holder.deviceName.setOnClickListener((v) -> deviceSelected(bluetoothDevice));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return bluetoothDevices.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView deviceName;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
deviceName = (TextView) itemView;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.activities;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.connection_service.InsightConnectionService;
|
||||
|
||||
public class InsightPairingInformationActivity extends AppCompatActivity {
|
||||
|
||||
private InsightConnectionService connectionService;
|
||||
|
||||
private TextView serialNumber;
|
||||
private TextView releaseSWVersion;
|
||||
private TextView uiProcSWVersion;
|
||||
private TextView pcProcSWVersion;
|
||||
private TextView mdTelSWVersion;
|
||||
private TextView safetyProcSWVersion;
|
||||
private TextView btInfoPageVersion;
|
||||
private TextView bluetoothAddress;
|
||||
private TextView systemIdAppendix;
|
||||
private TextView manufacturingDate;
|
||||
|
||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||
if (!connectionService.isPaired()) {
|
||||
overridePendingTransition(0, 0);
|
||||
finish();
|
||||
startActivity(new Intent(InsightPairingInformationActivity.this, InsightPairingActivity.class));
|
||||
} else {
|
||||
serialNumber.setText(connectionService.getPumpSystemIdentification().getSerialNumber());
|
||||
manufacturingDate.setText(connectionService.getPumpSystemIdentification().getManufacturingDate());
|
||||
systemIdAppendix.setText(connectionService.getPumpSystemIdentification().getSystemIdAppendix() + "");
|
||||
releaseSWVersion.setText(connectionService.getPumpFirmwareVersions().getReleaseSWVersion());
|
||||
uiProcSWVersion.setText(connectionService.getPumpFirmwareVersions().getUiProcSWVersion());
|
||||
pcProcSWVersion.setText(connectionService.getPumpFirmwareVersions().getPcProcSWVersion());
|
||||
mdTelSWVersion.setText(connectionService.getPumpFirmwareVersions().getMdTelProcSWVersion());
|
||||
safetyProcSWVersion.setText(connectionService.getPumpFirmwareVersions().getSafetyProcSWVersion());
|
||||
btInfoPageVersion.setText(connectionService.getPumpFirmwareVersions().getBtInfoPageVersion());
|
||||
bluetoothAddress.setText(connectionService.getBluetoothAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
connectionService = null;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_insight_pairing_information);
|
||||
serialNumber = findViewById(R.id.serial_number);
|
||||
releaseSWVersion = findViewById(R.id.release_sw_version);
|
||||
uiProcSWVersion = findViewById(R.id.ui_proc_sw_version);
|
||||
pcProcSWVersion = findViewById(R.id.pc_proc_sw_version);
|
||||
mdTelSWVersion = findViewById(R.id.md_tel_sw_version);
|
||||
safetyProcSWVersion = findViewById(R.id.safety_proc_sw_version);
|
||||
btInfoPageVersion = findViewById(R.id.bt_info_page_version);
|
||||
bluetoothAddress = findViewById(R.id.bluetooth_address);
|
||||
systemIdAppendix = findViewById(R.id.system_id_appendix);
|
||||
manufacturingDate = findViewById(R.id.manufacturing_date);
|
||||
bindService(new Intent(this, InsightConnectionService.class), serviceConnection, BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
unbindService(serviceConnection);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void deletePairing(View view) {
|
||||
if (connectionService != null) {
|
||||
connectionService.reset();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.IncompatibleAppVersionException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.InvalidAppCRCException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.UnknownAppCommandException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.UnknownServiceException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.AppLayerErrorException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.exceptions.app_layer_errors.UnknownAppLayerErrorCodeException;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.ids.AppCommandIDs;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.ids.AppErrorIDs;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.ids.ServiceIDs;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.satl.DataMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.crypto.Cryptograph;
|
||||
|
||||
public class AppLayerMessage implements Comparable<AppLayerMessage> {
|
||||
|
||||
private static final byte VERSION = 0x20;
|
||||
|
||||
private final MessagePriority messagePriority;
|
||||
private final boolean inCRC;
|
||||
private final boolean outCRC;
|
||||
private final Service service;
|
||||
|
||||
public AppLayerMessage(MessagePriority messagePriority, boolean inCRC, boolean outCRC, Service service) {
|
||||
this.messagePriority = messagePriority;
|
||||
this.inCRC = inCRC;
|
||||
this.outCRC = outCRC;
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
protected ByteBuf getData() {
|
||||
return new ByteBuf(0);
|
||||
}
|
||||
|
||||
protected void parse(ByteBuf byteBuf) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
public ByteBuf serialize(Class<? extends AppLayerMessage> clazz) {
|
||||
byte[] data = getData().getBytes();
|
||||
ByteBuf byteBuf = new ByteBuf(4 + data.length + (outCRC ? 2 : 0));
|
||||
byteBuf.putByte(VERSION);
|
||||
byteBuf.putByte(ServiceIDs.IDS.getID(getService()));
|
||||
byteBuf.putUInt16LE(AppCommandIDs.IDS.getID(clazz));
|
||||
byteBuf.putBytes(data);
|
||||
if (outCRC) byteBuf.putUInt16LE(Cryptograph.calculateCRC(data));
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public static AppLayerMessage deserialize(ByteBuf byteBuf) throws Exception {
|
||||
byte version = byteBuf.readByte();
|
||||
byte service = byteBuf.readByte();
|
||||
int command = byteBuf.readUInt16LE();
|
||||
int error = byteBuf.readUInt16LE();
|
||||
Class<? extends AppLayerMessage> clazz = AppCommandIDs.IDS.getType(command);
|
||||
if (clazz == null) throw new UnknownAppCommandException();
|
||||
if (version != VERSION) throw new IncompatibleAppVersionException();
|
||||
AppLayerMessage message = clazz.newInstance();
|
||||
if (ServiceIDs.IDS.getType(service) == null) throw new UnknownServiceException();
|
||||
if (error != 0) {
|
||||
Class<? extends AppLayerErrorException> exceptionClass = AppErrorIDs.IDS.getType(error);
|
||||
if (exceptionClass == null) throw new UnknownAppLayerErrorCodeException(error);
|
||||
else throw exceptionClass.getConstructor(int.class).newInstance(error);
|
||||
}
|
||||
byte[] data = byteBuf.readBytes(byteBuf.getSize() - (message.inCRC ? 2 : 0));
|
||||
if (message.inCRC && Cryptograph.calculateCRC(data) != byteBuf.readUInt16LE()) throw new InvalidAppCRCException();
|
||||
message.parse(ByteBuf.from(data));
|
||||
return message;
|
||||
}
|
||||
|
||||
public static DataMessage wrap(AppLayerMessage message) {
|
||||
DataMessage dataMessage = new DataMessage();
|
||||
dataMessage.setData(message.serialize(message.getClass()));
|
||||
return dataMessage;
|
||||
}
|
||||
|
||||
public static AppLayerMessage unwrap(DataMessage dataMessage) throws Exception {
|
||||
return deserialize(dataMessage.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(AppLayerMessage o) {
|
||||
return messagePriority.compareTo(o.messagePriority);
|
||||
}
|
||||
|
||||
public Service getService() {
|
||||
return this.service;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.parameter_blocks.ParameterBlock;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.ids.ParameterBlockIDs;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
|
||||
public class ReadParameterBlockMessage extends AppLayerMessage {
|
||||
|
||||
private Class<? extends ParameterBlock> parameterBlockId;
|
||||
private ParameterBlock parameterBlock;
|
||||
private Service service;
|
||||
|
||||
public ReadParameterBlockMessage() {
|
||||
super(MessagePriority.NORMAL, true, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(Service service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuf getData() {
|
||||
ByteBuf byteBuf = new ByteBuf(2);
|
||||
byteBuf.putUInt16LE(ParameterBlockIDs.IDS.getID(parameterBlockId));
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parse(ByteBuf byteBuf) throws Exception {
|
||||
parameterBlock = ParameterBlockIDs.IDS.getType(byteBuf.readUInt16LE()).newInstance();
|
||||
byteBuf.shift(2); //Restriction level
|
||||
parameterBlock.parse(byteBuf);
|
||||
}
|
||||
|
||||
public ParameterBlock getParameterBlock() {
|
||||
return this.parameterBlock;
|
||||
}
|
||||
|
||||
public void setParameterBlockId(Class<? extends ParameterBlock> configurationBlockId) {
|
||||
this.parameterBlockId = configurationBlockId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer;
|
||||
|
||||
public enum Service {
|
||||
|
||||
CONNECTION((short) 0x0000, null),
|
||||
STATUS((short) 0x0100, null),
|
||||
HISTORY((short) 0x0200, null),
|
||||
CONFIGURATION((short) 0x0200, "u+5Fhz6Gw4j1Kkas"),
|
||||
PARAMETER((short) 0x0200, null),
|
||||
REMOTE_CONTROL((short) 0x0100, "MAbcV2X6PVjxuz+R");
|
||||
|
||||
private short version;
|
||||
private String servicePassword;
|
||||
|
||||
Service(short version, String servicePassword) {
|
||||
this.version = version;
|
||||
this.servicePassword = servicePassword;
|
||||
}
|
||||
|
||||
public short getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getServicePassword() {
|
||||
return this.servicePassword;
|
||||
}
|
||||
|
||||
public void setServicePassword(String servicePassword) {
|
||||
this.servicePassword = servicePassword;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
|
||||
public class CloseConfigurationWriteSessionMessage extends AppLayerMessage {
|
||||
|
||||
public CloseConfigurationWriteSessionMessage() {
|
||||
super(MessagePriority.NORMAL, false, false, Service.CONFIGURATION);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
|
||||
public class OpenConfigurationWriteSessionMessage extends AppLayerMessage {
|
||||
|
||||
public OpenConfigurationWriteSessionMessage() {
|
||||
super(MessagePriority.NORMAL, false, false, Service.CONFIGURATION);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.configuration;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.parameter_blocks.ParameterBlock;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.ids.ParameterBlockIDs;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
|
||||
public class WriteConfigurationBlockMessage extends AppLayerMessage {
|
||||
|
||||
private ParameterBlock parameterBlock;
|
||||
private Class<? extends ParameterBlock> configurationBlockId;
|
||||
|
||||
public WriteConfigurationBlockMessage() {
|
||||
super(MessagePriority.NORMAL, false, true, Service.CONFIGURATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuf getData() {
|
||||
ByteBuf configBlockData = parameterBlock.getData();
|
||||
ByteBuf data = new ByteBuf(4 + configBlockData.getSize());
|
||||
data.putUInt16LE(ParameterBlockIDs.IDS.getID(parameterBlock.getClass()));
|
||||
data.putUInt16LE(31);
|
||||
data.putByteBuf(configBlockData);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parse(ByteBuf byteBuf) throws Exception {
|
||||
configurationBlockId = ParameterBlockIDs.IDS.getType(byteBuf.readUInt16LE());
|
||||
}
|
||||
|
||||
public Class<? extends ParameterBlock> getConfigurationBlockId() {
|
||||
return this.configurationBlockId;
|
||||
}
|
||||
|
||||
public void setParameterBlock(ParameterBlock parameterBlock) {
|
||||
this.parameterBlock = parameterBlock;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.connection;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
|
||||
public class ActivateServiceMessage extends AppLayerMessage {
|
||||
|
||||
private byte serviceID;
|
||||
private short version;
|
||||
private byte[] servicePassword;
|
||||
|
||||
public ActivateServiceMessage() {
|
||||
super(MessagePriority.NORMAL, false, false, Service.CONNECTION);
|
||||
}
|
||||
|
||||
protected void parse(ByteBuf byteBuf) {
|
||||
serviceID = byteBuf.readByte();
|
||||
version = byteBuf.readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuf getData() {
|
||||
ByteBuf byteBuf = new ByteBuf(19);
|
||||
byteBuf.putByte(serviceID);
|
||||
byteBuf.putShort(version);
|
||||
byteBuf.putBytes(servicePassword);
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public byte getServiceID() {
|
||||
return this.serviceID;
|
||||
}
|
||||
|
||||
public short getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void setServiceID(byte serviceID) {
|
||||
this.serviceID = serviceID;
|
||||
}
|
||||
|
||||
public void setVersion(short version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setServicePassword(byte[] servicePassword) {
|
||||
this.servicePassword = servicePassword;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.connection;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
|
||||
public class BindMessage extends AppLayerMessage {
|
||||
|
||||
public BindMessage() {
|
||||
super(MessagePriority.NORMAL, false, false, Service.CONNECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuf getData() {
|
||||
return ByteBuf.from(Hex.decode("3438310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.connection;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
|
||||
public class ConnectMessage extends AppLayerMessage {
|
||||
|
||||
public ConnectMessage() {
|
||||
super(MessagePriority.NORMAL, false, false, Service.CONNECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuf getData() {
|
||||
return ByteBuf.from(Hex.decode("0000080100196000"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.connection;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.AppLayerMessage;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.app_layer.Service;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.descriptors.MessagePriority;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.utils.ByteBuf;
|
||||
|
||||
public class DisconnectMessage extends AppLayerMessage {
|
||||
|
||||
public DisconnectMessage() {
|
||||
super(MessagePriority.NORMAL, false, false, Service.CONNECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuf getData() {
|
||||
return ByteBuf.from(Hex.decode("0360"));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue