Release 0.7

- finished decoding DailyTotals records
- fixed some of most common bugs from Crashalytics
This commit is contained in:
Andy Rozman 2019-02-20 15:28:14 +00:00
parent 5aa5d9f749
commit a441a7e35e
17 changed files with 781 additions and 253 deletions

View file

@ -63,8 +63,8 @@ android {
targetSdkVersion 25 targetSdkVersion 25
multiDexEnabled true multiDexEnabled true
versionCode 1500 versionCode 1500
// dev_version: 2.0 // dev_version: 2.0i
version "medtronic-0.7.1-SNAPSHOT" version "medtronic-0.7"
buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
@ -170,10 +170,10 @@ dependencies {
wearApp project(':wear') wearApp project(':wear')
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation("com.crashlytics.sdk.android:crashlytics:2.6.7@aar") { implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
transitive = true; transitive = true;
} }
implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") { implementation("com.crashlytics.sdk.android:answers:1.4.7@aar") {
transitive = true; transitive = true;
} }
libs "MilosKozak:danars-support-lib:master@zip" libs "MilosKozak:danars-support-lib:master@zip"

View file

@ -51,6 +51,10 @@
<activity <activity
android:name=".plugins.Overview.Dialogs.ErrorHelperActivity" android:name=".plugins.Overview.Dialogs.ErrorHelperActivity"
android:theme="@style/Theme.AppCompat.Translucent" /> android:theme="@style/Theme.AppCompat.Translucent" />
<activity
android:name=".plugins.Overview.Dialogs.MessageHelperActivity"
android:theme="@style/Theme.AppCompat.Translucent" />
<activity android:name=".activities.AgreementActivity" /> <activity android:name=".activities.AgreementActivity" />
<activity android:name=".plugins.PumpDanaR.activities.DanaRHistoryActivity" /> <activity android:name=".plugins.PumpDanaR.activities.DanaRHistoryActivity" />
<activity android:name=".plugins.PumpDanaR.activities.DanaRUserOptionsActivity" /> <activity android:name=".plugins.PumpDanaR.activities.DanaRUserOptionsActivity" />

View file

@ -44,6 +44,8 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin; import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin; import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
import info.nightscout.androidaps.plugins.Maintenance.MaintenancePlugin; import info.nightscout.androidaps.plugins.Maintenance.MaintenancePlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
@ -68,6 +70,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin; import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
import info.nightscout.androidaps.plugins.PumpInsightLocal.LocalInsightPlugin; import info.nightscout.androidaps.plugins.PumpInsightLocal.LocalInsightPlugin;
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin; import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicConst;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
@ -119,6 +122,7 @@ public class MainApp extends Application {
public static boolean devBranch; public static boolean devBranch;
public static boolean engineeringMode; public static boolean engineeringMode;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -160,7 +164,8 @@ public class MainApp extends Application {
// Register all tabs in app here // Register all tabs in app here
pluginsList.add(OverviewPlugin.getPlugin()); pluginsList.add(OverviewPlugin.getPlugin());
pluginsList.add(IobCobCalculatorPlugin.getPlugin()); pluginsList.add(IobCobCalculatorPlugin.getPlugin());
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin()); if (Config.ACTION)
pluginsList.add(ActionsFragment.getPlugin());
pluginsList.add(InsulinOrefRapidActingPlugin.getPlugin()); pluginsList.add(InsulinOrefRapidActingPlugin.getPlugin());
pluginsList.add(InsulinOrefUltraRapidActingPlugin.getPlugin()); pluginsList.add(InsulinOrefUltraRapidActingPlugin.getPlugin());
pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin()); pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin());
@ -174,21 +179,32 @@ public class MainApp extends Application {
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin()); if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
if (Config.PUMPDRIVERS && engineeringMode) pluginsList.add(LocalInsightPlugin.getInstance()); if (Config.PUMPDRIVERS && engineeringMode) pluginsList.add(LocalInsightPlugin.getInstance());
pluginsList.add(CareportalPlugin.getPlugin()); pluginsList.add(CareportalPlugin.getPlugin());
/*if (Config.PUMPDRIVERS && engineeringMode) if (Config.PUMPDRIVERS && engineeringMode) {
pluginsList.add(InsightPlugin.getPlugin());*/ pluginsList.add(MedtronicPumpPlugin.getPlugin());
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin()); }
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin()); if (Config.PUMPDRIVERS)
pluginsList.add(ComboPlugin.getPlugin());
if (Config.MDI)
pluginsList.add(MDIPlugin.getPlugin());
pluginsList.add(VirtualPumpPlugin.getPlugin()); pluginsList.add(VirtualPumpPlugin.getPlugin());
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin()); if (Config.APS)
if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin()); pluginsList.add(LoopPlugin.getPlugin());
if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin()); if (Config.APS)
if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin()); pluginsList.add(OpenAPSMAPlugin.getPlugin());
if (Config.APS)
pluginsList.add(OpenAPSAMAPlugin.getPlugin());
if (Config.APS)
pluginsList.add(OpenAPSSMBPlugin.getPlugin());
pluginsList.add(NSProfilePlugin.getPlugin()); pluginsList.add(NSProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin()); if (Config.OTHERPROFILES)
if (Config.OTHERPROFILES) pluginsList.add(LocalProfilePlugin.getPlugin()); pluginsList.add(SimpleProfilePlugin.getPlugin());
if (Config.OTHERPROFILES)
pluginsList.add(LocalProfilePlugin.getPlugin());
pluginsList.add(TreatmentsPlugin.getPlugin()); pluginsList.add(TreatmentsPlugin.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin()); if (Config.SAFETY)
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin()); pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS)
pluginsList.add(ObjectivesPlugin.getPlugin());
pluginsList.add(SourceXdripPlugin.getPlugin()); pluginsList.add(SourceXdripPlugin.getPlugin());
pluginsList.add(SourceNSClientPlugin.getPlugin()); pluginsList.add(SourceNSClientPlugin.getPlugin());
pluginsList.add(SourceMM640gPlugin.getPlugin()); pluginsList.add(SourceMM640gPlugin.getPlugin());
@ -298,11 +314,13 @@ public class MainApp extends Application {
} }
} }
public void stopKeepAliveService() { public void stopKeepAliveService() {
if (keepAliveReceiver != null) if (keepAliveReceiver != null)
KeepAliveReceiver.cancelAlarm(this); KeepAliveReceiver.cancelAlarm(this);
} }
public static void subscribe(Object subscriber) { public static void subscribe(Object subscriber) {
try { try {
bus().register(subscriber); bus().register(subscriber);
@ -311,6 +329,7 @@ public class MainApp extends Application {
} }
} }
public static void unsubscribe(Object subscriber) { public static void unsubscribe(Object subscriber) {
try { try {
bus().unregister(subscriber); bus().unregister(subscriber);
@ -319,34 +338,42 @@ public class MainApp extends Application {
} }
} }
public static Bus bus() { public static Bus bus() {
return sBus; return sBus;
} }
public static String gs(int id) { public static String gs(int id) {
return sResources.getString(id); return sResources.getString(id);
} }
public static String gs(int id, Object... args) { public static String gs(int id, Object... args) {
return sResources.getString(id, args); return sResources.getString(id, args);
} }
public static String gq(@PluralsRes int id, int quantity, Object... args) { public static String gq(@PluralsRes int id, int quantity, Object... args) {
return sResources.getQuantityString(id, quantity, args); return sResources.getQuantityString(id, quantity, args);
} }
public static int gc(int id) { public static int gc(int id) {
return sResources.getColor(id); return sResources.getColor(id);
} }
public static MainApp instance() { public static MainApp instance() {
return sInstance; return sInstance;
} }
public static DatabaseHelper getDbHelper() { public static DatabaseHelper getDbHelper() {
return sDatabaseHelper; return sDatabaseHelper;
} }
public static void closeDbHelper() { public static void closeDbHelper() {
if (sDatabaseHelper != null) { if (sDatabaseHelper != null) {
sDatabaseHelper.close(); sDatabaseHelper.close();
@ -354,14 +381,17 @@ public class MainApp extends Application {
} }
} }
public static ConstraintChecker getConstraintChecker() { public static ConstraintChecker getConstraintChecker() {
return sConstraintsChecker; return sConstraintsChecker;
} }
public static ArrayList<PluginBase> getPluginsList() { public static ArrayList<PluginBase> getPluginsList() {
return pluginsList; return pluginsList;
} }
public static ArrayList<PluginBase> getSpecificPluginsList(PluginType type) { public static ArrayList<PluginBase> getSpecificPluginsList(PluginType type) {
ArrayList<PluginBase> newList = new ArrayList<>(); ArrayList<PluginBase> newList = new ArrayList<>();
@ -376,6 +406,7 @@ public class MainApp extends Application {
return newList; return newList;
} }
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type) { public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type) {
ArrayList<PluginBase> newList = new ArrayList<>(); ArrayList<PluginBase> newList = new ArrayList<>();
@ -391,6 +422,7 @@ public class MainApp extends Application {
return newList; return newList;
} }
public static ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass) { public static ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass) {
ArrayList<PluginBase> newList = new ArrayList<>(); ArrayList<PluginBase> newList = new ArrayList<>();
@ -405,6 +437,7 @@ public class MainApp extends Application {
return newList; return newList;
} }
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type) { public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type) {
ArrayList<PluginBase> newList = new ArrayList<>(); ArrayList<PluginBase> newList = new ArrayList<>();
@ -420,12 +453,13 @@ public class MainApp extends Application {
return newList; return newList;
} }
@Nullable @Nullable
public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) { public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) {
if (pluginsList != null) { if (pluginsList != null) {
for (PluginBase p : pluginsList) { for (PluginBase p : pluginsList) {
if (pluginClass.isAssignableFrom(p.getClass())) if (pluginClass.isAssignableFrom(p.getClass()))
return (T) p; return (T)p;
} }
} else { } else {
log.error("pluginsList=null"); log.error("pluginsList=null");
@ -433,6 +467,7 @@ public class MainApp extends Application {
return null; return null;
} }
public static boolean isEngineeringModeOrRelease() { public static boolean isEngineeringModeOrRelease() {
if (!Config.APS) if (!Config.APS)
return true; return true;
@ -449,6 +484,7 @@ public class MainApp extends Application {
return devBranch; return devBranch;
} }
@Override @Override
public void onTerminate() { public void onTerminate() {
if (L.isEnabled(L.CORE)) if (L.isEnabled(L.CORE))

View file

@ -70,6 +70,7 @@ import info.nightscout.utils.ToastUtils;
* direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service. * direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service.
*/ */
public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static Logger log = LoggerFactory.getLogger(L.DATABASE); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
public static final String DATABASE_NAME = "AndroidAPSDb"; public static final String DATABASE_NAME = "AndroidAPSDb";
@ -111,12 +112,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private int oldVersion = 0; private int oldVersion = 0;
private int newVersion = 0; private int newVersion = 0;
public DatabaseHelper(Context context) { public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); super(context, DATABASE_NAME, null, DATABASE_VERSION);
onCreate(getWritableDatabase(), getConnectionSource()); onCreate(getWritableDatabase(), getConnectionSource());
//onUpgrade(getWritableDatabase(), getConnectionSource(), 1,1); //onUpgrade(getWritableDatabase(), getConnectionSource(), 1,1);
} }
@Override @Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try { try {
@ -140,6 +143,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
@Override @Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
try { try {
@ -172,20 +176,24 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
@Override @Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
log.info("Do nothing for downgrading..."); log.info("Do nothing for downgrading...");
log.debug("oldVersion: {}, newVersion: {}", oldVersion, newVersion); log.debug("oldVersion: {}, newVersion: {}", oldVersion, newVersion);
} }
public int getOldVersion() { public int getOldVersion() {
return oldVersion; return oldVersion;
} }
public int getNewVersion() { public int getNewVersion() {
return newVersion; return newVersion;
} }
/** /**
* Close the database connections and clear any cached DAOs. * Close the database connections and clear any cached DAOs.
*/ */
@ -199,6 +207,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return DatabaseUtils.queryNumEntries(getReadableDatabase(), database); return DatabaseUtils.queryNumEntries(getReadableDatabase(), database);
} }
// --------------------- DB resets --------------------- // --------------------- DB resets ---------------------
public void resetDatabases() { public void resetDatabases() {
@ -243,6 +252,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
); );
} }
public void resetTempTargets() { public void resetTempTargets() {
try { try {
TableUtils.dropTable(connectionSource, TempTarget.class, true); TableUtils.dropTable(connectionSource, TempTarget.class, true);
@ -253,6 +263,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryTargetChange(); scheduleTemporaryTargetChange();
} }
public void resetTemporaryBasals() { public void resetTemporaryBasals() {
try { try {
TableUtils.dropTable(connectionSource, TemporaryBasal.class, true); TableUtils.dropTable(connectionSource, TemporaryBasal.class, true);
@ -265,6 +276,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
} }
public void resetExtededBoluses() { public void resetExtededBoluses() {
try { try {
TableUtils.dropTable(connectionSource, ExtendedBolus.class, true); TableUtils.dropTable(connectionSource, ExtendedBolus.class, true);
@ -276,6 +288,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
} }
public void resetCareportalEvents() { public void resetCareportalEvents() {
try { try {
TableUtils.dropTable(connectionSource, CareportalEvent.class, true); TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
@ -286,6 +299,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleCareportalEventChange(); scheduleCareportalEventChange();
} }
public void resetProfileSwitch() { public void resetProfileSwitch() {
try { try {
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true); TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
@ -296,6 +310,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleProfileSwitchChange(); scheduleProfileSwitchChange();
} }
public void resetTDDs() { public void resetTDDs() {
try { try {
TableUtils.dropTable(connectionSource, TDD.class, true); TableUtils.dropTable(connectionSource, TDD.class, true);
@ -305,40 +320,49 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
// ------------------ getDao ------------------------------------------- // ------------------ getDao -------------------------------------------
private Dao<TempTarget, Long> getDaoTempTargets() throws SQLException { private Dao<TempTarget, Long> getDaoTempTargets() throws SQLException {
return getDao(TempTarget.class); return getDao(TempTarget.class);
} }
private Dao<BgReading, Long> getDaoBgReadings() throws SQLException { private Dao<BgReading, Long> getDaoBgReadings() throws SQLException {
return getDao(BgReading.class); return getDao(BgReading.class);
} }
private Dao<DanaRHistoryRecord, String> getDaoDanaRHistory() throws SQLException { private Dao<DanaRHistoryRecord, String> getDaoDanaRHistory() throws SQLException {
return getDao(DanaRHistoryRecord.class); return getDao(DanaRHistoryRecord.class);
} }
private Dao<TDD, String> getDaoTDD() throws SQLException { private Dao<TDD, String> getDaoTDD() throws SQLException {
return getDao(TDD.class); return getDao(TDD.class);
} }
private Dao<DbRequest, String> getDaoDbRequest() throws SQLException { private Dao<DbRequest, String> getDaoDbRequest() throws SQLException {
return getDao(DbRequest.class); return getDao(DbRequest.class);
} }
private Dao<TemporaryBasal, Long> getDaoTemporaryBasal() throws SQLException { private Dao<TemporaryBasal, Long> getDaoTemporaryBasal() throws SQLException {
return getDao(TemporaryBasal.class); return getDao(TemporaryBasal.class);
} }
private Dao<ExtendedBolus, Long> getDaoExtendedBolus() throws SQLException { private Dao<ExtendedBolus, Long> getDaoExtendedBolus() throws SQLException {
return getDao(ExtendedBolus.class); return getDao(ExtendedBolus.class);
} }
private Dao<CareportalEvent, Long> getDaoCareportalEvents() throws SQLException { private Dao<CareportalEvent, Long> getDaoCareportalEvents() throws SQLException {
return getDao(CareportalEvent.class); return getDao(CareportalEvent.class);
} }
private Dao<ProfileSwitch, Long> getDaoProfileSwitch() throws SQLException { private Dao<ProfileSwitch, Long> getDaoProfileSwitch() throws SQLException {
return getDao(ProfileSwitch.class); return getDao(ProfileSwitch.class);
} }
@ -362,7 +386,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
log.debug("Rounding " + date + " to " + rounded); log.debug("Rounding " + date + " to " + rounded);
return rounded; return rounded;
} }
// ------------------- BgReading handling -----------------------
// ------------------- BgReading handling -----------------------
public boolean createIfNotExists(BgReading bgReading, String from) { public boolean createIfNotExists(BgReading bgReading, String from) {
try { try {
@ -391,6 +417,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false; return false;
} }
public void update(BgReading bgReading) { public void update(BgReading bgReading) {
bgReading.date = roundDateToSec(bgReading.date); bgReading.date = roundDateToSec(bgReading.date);
try { try {
@ -400,8 +427,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
private static void scheduleBgChange(@Nullable final BgReading bgReading) { private static void scheduleBgChange(@Nullable final BgReading bgReading) {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(L.DATABASE))
log.debug("Firing EventNewBg"); log.debug("Firing EventNewBg");
@ -419,6 +448,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
/* /*
* Return last BgReading from database or null if db is empty * Return last BgReading from database or null if db is empty
*/ */
@ -444,6 +474,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null; return null;
} }
/* /*
* Return bg reading if not old ( <9 min ) * Return bg reading if not old ( <9 min )
* or null if older * or null if older
@ -479,6 +510,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<BgReading>(); return new ArrayList<BgReading>();
} }
public List<BgReading> getBgreadingsDataFromTime(long start, long end, boolean ascending) { public List<BgReading> getBgreadingsDataFromTime(long start, long end, boolean ascending) {
try { try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings(); Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
@ -496,6 +528,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<BgReading>(); return new ArrayList<BgReading>();
} }
public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) { public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
try { try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings(); Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
@ -513,7 +546,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<BgReading>(); return new ArrayList<BgReading>();
} }
// ------------------- TDD handling -----------------------
// ------------------- TDD handling -----------------------
public void createOrUpdateTDD(TDD tdd) { public void createOrUpdateTDD(TDD tdd) {
try { try {
Dao<TDD, String> dao = getDaoTDD(); Dao<TDD, String> dao = getDaoTDD();
@ -524,6 +558,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public List<TDD> getTDDs() { public List<TDD> getTDDs() {
List<TDD> tddList; List<TDD> tddList;
try { try {
@ -574,6 +609,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public int delete(DbRequest dbr) { public int delete(DbRequest dbr) {
try { try {
return getDaoDbRequest().delete(dbr); return getDaoDbRequest().delete(dbr);
@ -583,6 +619,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return 0; return 0;
} }
public int deleteDbRequest(String nsClientId) { public int deleteDbRequest(String nsClientId) {
try { try {
return getDaoDbRequest().deleteById(nsClientId); return getDaoDbRequest().deleteById(nsClientId);
@ -592,6 +629,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return 0; return 0;
} }
public void deleteDbRequestbyMongoId(String action, String id) { public void deleteDbRequestbyMongoId(String action, String id) {
try { try {
QueryBuilder<DbRequest, String> queryBuilder = getDaoDbRequest().queryBuilder(); QueryBuilder<DbRequest, String> queryBuilder = getDaoDbRequest().queryBuilder();
@ -608,6 +646,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public void deleteAllDbRequests() { public void deleteAllDbRequests() {
try { try {
TableUtils.clearTable(connectionSource, DbRequest.class); TableUtils.clearTable(connectionSource, DbRequest.class);
@ -616,6 +655,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public CloseableIterator getDbRequestInterator() { public CloseableIterator getDbRequestInterator() {
try { try {
return getDaoDbRequest().closeableIterator(); return getDaoDbRequest().closeableIterator();
@ -625,7 +665,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
// -------------------- TREATMENT HANDLING -------------------
// -------------------- TREATMENT HANDLING -------------------
public static void updateEarliestDataChange(long newDate) { public static void updateEarliestDataChange(long newDate) {
if (earliestDataChange == null) { if (earliestDataChange == null) {
@ -637,6 +678,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
// ---------------- TempTargets handling --------------- // ---------------- TempTargets handling ---------------
public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) { public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) {
@ -656,6 +698,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<TempTarget>(); return new ArrayList<TempTarget>();
} }
public boolean createOrUpdate(TempTarget tempTarget) { public boolean createOrUpdate(TempTarget tempTarget) {
try { try {
TempTarget old; TempTarget old;
@ -714,6 +757,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false; return false;
} }
public void delete(TempTarget tempTarget) { public void delete(TempTarget tempTarget) {
try { try {
getDaoTempTargets().delete(tempTarget); getDaoTempTargets().delete(tempTarget);
@ -723,8 +767,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
private static void scheduleTemporaryTargetChange() { private static void scheduleTemporaryTargetChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(L.DATABASE))
log.debug("Firing EventTempTargetChange"); log.debug("Firing EventTempTargetChange");
@ -742,20 +788,21 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
/*
{ /*
"_id": "58795998aa86647ba4d68ce7", * {
"enteredBy": "", * "_id": "58795998aa86647ba4d68ce7",
"eventType": "Temporary Target", * "enteredBy": "",
"reason": "Eating Soon", * "eventType": "Temporary Target",
"targetTop": 80, * "reason": "Eating Soon",
"targetBottom": 80, * "targetTop": 80,
"duration": 120, * "targetBottom": 80,
"created_at": "2017-01-13T22:50:00.782Z", * "duration": 120,
"carbs": null, * "created_at": "2017-01-13T22:50:00.782Z",
"insulin": null * "carbs": null,
} * "insulin": null
*/ * }
*/
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) { public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
try { try {
@ -774,6 +821,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public void deleteTempTargetById(String _id) { public void deleteTempTargetById(String _id) {
TempTarget stored = findTempTargetById(_id); TempTarget stored = findTempTargetById(_id);
if (stored != null) { if (stored != null) {
@ -783,6 +831,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public TempTarget findTempTargetById(String _id) { public TempTarget findTempTargetById(String _id) {
try { try {
QueryBuilder<TempTarget, Long> queryBuilder = getDaoTempTargets().queryBuilder(); QueryBuilder<TempTarget, Long> queryBuilder = getDaoTempTargets().queryBuilder();
@ -802,6 +851,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null; return null;
} }
// ----------------- DanaRHistory handling -------------------- // ----------------- DanaRHistory handling --------------------
public void createOrUpdate(DanaRHistoryRecord record) { public void createOrUpdate(DanaRHistoryRecord record) {
@ -818,6 +868,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) { public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) {
List<DanaRHistoryRecord> historyList; List<DanaRHistoryRecord> historyList;
try { try {
@ -835,6 +886,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return historyList; return historyList;
} }
public void updateDanaRHistoryRecordId(JSONObject trJson) { public void updateDanaRHistoryRecordId(JSONObject trJson) {
try { try {
QueryBuilder<DanaRHistoryRecord, String> queryBuilder = getDaoDanaRHistory().queryBuilder(); QueryBuilder<DanaRHistoryRecord, String> queryBuilder = getDaoDanaRHistory().queryBuilder();
@ -860,6 +912,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
// ------------ TemporaryBasal handling --------------- // ------------ TemporaryBasal handling ---------------
//return true if new record was created //return true if new record was created
@ -953,6 +1006,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false; return false;
} }
public void delete(TemporaryBasal tempBasal) { public void delete(TemporaryBasal tempBasal) {
try { try {
getDaoTemporaryBasal().delete(tempBasal); getDaoTemporaryBasal().delete(tempBasal);
@ -963,6 +1017,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryBasalChange(); scheduleTemporaryBasalChange();
} }
public List<TemporaryBasal> getTemporaryBasalsDataFromTime(long mills, boolean ascending) { public List<TemporaryBasal> getTemporaryBasalsDataFromTime(long mills, boolean ascending) {
try { try {
List<TemporaryBasal> tempbasals; List<TemporaryBasal> tempbasals;
@ -979,8 +1034,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<TemporaryBasal>(); return new ArrayList<TemporaryBasal>();
} }
private static void scheduleTemporaryBasalChange() { private static void scheduleTemporaryBasalChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(L.DATABASE))
log.debug("Firing EventTempBasalChange"); log.debug("Firing EventTempBasalChange");
@ -1002,6 +1059,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
/* /*
{ {
"_id": "59232e1ddd032d04218dab00", "_id": "59232e1ddd032d04218dab00",
@ -1074,6 +1132,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public void deleteTempBasalById(String _id) { public void deleteTempBasalById(String _id) {
TemporaryBasal stored = findTempBasalById(_id); TemporaryBasal stored = findTempBasalById(_id);
if (stored != null) { if (stored != null) {
@ -1085,6 +1144,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public TemporaryBasal findTempBasalById(String _id) { public TemporaryBasal findTempBasalById(String _id) {
try { try {
QueryBuilder<TemporaryBasal, Long> queryBuilder = null; QueryBuilder<TemporaryBasal, Long> queryBuilder = null;
@ -1105,6 +1165,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null; return null;
} }
// ------------ ExtendedBolus handling --------------- // ------------ ExtendedBolus handling ---------------
public boolean createOrUpdate(ExtendedBolus extendedBolus) { public boolean createOrUpdate(ExtendedBolus extendedBolus) {
@ -1222,6 +1283,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleExtendedBolusChange(); scheduleExtendedBolusChange();
} }
public List<ExtendedBolus> getExtendedBolusDataFromTime(long mills, boolean ascending) { public List<ExtendedBolus> getExtendedBolusDataFromTime(long mills, boolean ascending) {
try { try {
List<ExtendedBolus> extendedBoluses; List<ExtendedBolus> extendedBoluses;
@ -1238,6 +1300,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<ExtendedBolus>(); return new ArrayList<ExtendedBolus>();
} }
public void deleteExtendedBolusById(String _id) { public void deleteExtendedBolusById(String _id) {
ExtendedBolus stored = findExtendedBolusById(_id); ExtendedBolus stored = findExtendedBolusById(_id);
if (stored != null) { if (stored != null) {
@ -1249,6 +1312,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public ExtendedBolus findExtendedBolusById(String _id) { public ExtendedBolus findExtendedBolusById(String _id) {
try { try {
QueryBuilder<ExtendedBolus, Long> queryBuilder = null; QueryBuilder<ExtendedBolus, Long> queryBuilder = null;
@ -1269,6 +1333,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null; return null;
} }
/* /*
{ {
"_id": "5924898d577eb0880e355337", "_id": "5924898d577eb0880e355337",
@ -1292,8 +1357,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
createOrUpdate(extendedBolus); createOrUpdate(extendedBolus);
} }
private static void scheduleExtendedBolusChange() { private static void scheduleExtendedBolusChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(L.DATABASE))
log.debug("Firing EventExtendedBolusChange"); log.debug("Firing EventExtendedBolusChange");
@ -1327,6 +1394,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleCareportalEventChange(); scheduleCareportalEventChange();
} }
public void delete(CareportalEvent careportalEvent) { public void delete(CareportalEvent careportalEvent) {
try { try {
getDaoCareportalEvents().delete(careportalEvent); getDaoCareportalEvents().delete(careportalEvent);
@ -1336,6 +1404,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleCareportalEventChange(); scheduleCareportalEventChange();
} }
public CareportalEvent getCareportalEventFromTimestamp(long timestamp) { public CareportalEvent getCareportalEventFromTimestamp(long timestamp) {
try { try {
return getDaoCareportalEvents().queryForId(timestamp); return getDaoCareportalEvents().queryForId(timestamp);
@ -1345,6 +1414,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null; return null;
} }
@Nullable @Nullable
public CareportalEvent getLastCareportalEvent(String event) { public CareportalEvent getLastCareportalEvent(String event) {
try { try {
@ -1366,6 +1436,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null; return null;
} }
public List<CareportalEvent> getCareportalEventsFromTime(long mills, boolean ascending) { public List<CareportalEvent> getCareportalEventsFromTime(long mills, boolean ascending) {
try { try {
List<CareportalEvent> careportalEvents; List<CareportalEvent> careportalEvents;
@ -1383,6 +1454,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>(); return new ArrayList<>();
} }
public void preprocessOpenAPSOfflineEvents(List<CareportalEvent> list) { public void preprocessOpenAPSOfflineEvents(List<CareportalEvent> list) {
OverlappingIntervals offlineEvents = new OverlappingIntervals(); OverlappingIntervals offlineEvents = new OverlappingIntervals();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
@ -1393,6 +1465,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
public List<CareportalEvent> getCareportalEventsFromTime(long mills, String type, boolean ascending) { public List<CareportalEvent> getCareportalEventsFromTime(long mills, String type, boolean ascending) {
try { try {
List<CareportalEvent> careportalEvents; List<CareportalEvent> careportalEvents;
@ -1410,6 +1483,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>(); return new ArrayList<>();
} }
public List<CareportalEvent> getCareportalEvents(boolean ascending) { public List<CareportalEvent> getCareportalEvents(boolean ascending) {
try { try {
List<CareportalEvent> careportalEvents; List<CareportalEvent> careportalEvents;
@ -1425,6 +1499,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>(); return new ArrayList<>();
} }
public void deleteCareportalEventById(String _id) { public void deleteCareportalEventById(String _id) {
try { try {
QueryBuilder<CareportalEvent, Long> queryBuilder; QueryBuilder<CareportalEvent, Long> queryBuilder;
@ -1448,6 +1523,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public void createCareportalEventFromJsonIfNotExists(JSONObject trJson) { public void createCareportalEventFromJsonIfNotExists(JSONObject trJson) {
try { try {
QueryBuilder<CareportalEvent, Long> queryBuilder; QueryBuilder<CareportalEvent, Long> queryBuilder;
@ -1481,8 +1557,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
private static void scheduleCareportalEventChange() { private static void scheduleCareportalEventChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(L.DATABASE))
log.debug("Firing scheduleCareportalEventChange"); log.debug("Firing scheduleCareportalEventChange");
@ -1500,6 +1578,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
// ---------------- ProfileSwitch handling --------------- // ---------------- ProfileSwitch handling ---------------
public List<ProfileSwitch> getProfileSwitchData(boolean ascending) { public List<ProfileSwitch> getProfileSwitchData(boolean ascending) {
@ -1518,6 +1597,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>(); return new ArrayList<>();
} }
public List<ProfileSwitch> getProfileSwitchEventsFromTime(long mills, boolean ascending) { public List<ProfileSwitch> getProfileSwitchEventsFromTime(long mills, boolean ascending) {
try { try {
Dao<ProfileSwitch, Long> daoProfileSwitch = getDaoProfileSwitch(); Dao<ProfileSwitch, Long> daoProfileSwitch = getDaoProfileSwitch();
@ -1536,6 +1616,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>(); return new ArrayList<>();
} }
public boolean createOrUpdate(ProfileSwitch profileSwitch) { public boolean createOrUpdate(ProfileSwitch profileSwitch) {
try { try {
ProfileSwitch old; ProfileSwitch old;
@ -1597,6 +1678,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false; return false;
} }
public void delete(ProfileSwitch profileSwitch) { public void delete(ProfileSwitch profileSwitch) {
try { try {
getDaoProfileSwitch().delete(profileSwitch); getDaoProfileSwitch().delete(profileSwitch);
@ -1606,8 +1688,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
private static void scheduleProfileSwitchChange() { private static void scheduleProfileSwitchChange() {
class PostRunnable implements Runnable { class PostRunnable implements Runnable {
public void run() { public void run() {
if (L.isEnabled(L.DATABASE)) if (L.isEnabled(L.DATABASE))
log.debug("Firing EventProfileSwitchChange"); log.debug("Firing EventProfileSwitchChange");
@ -1690,6 +1774,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public void deleteProfileSwitchById(String _id) { public void deleteProfileSwitchById(String _id) {
ProfileSwitch stored = findProfileSwitchById(_id); ProfileSwitch stored = findProfileSwitchById(_id);
if (stored != null) { if (stored != null) {
@ -1700,6 +1785,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
public ProfileSwitch findProfileSwitchById(String _id) { public ProfileSwitch findProfileSwitchById(String _id) {
try { try {
QueryBuilder<ProfileSwitch, Long> queryBuilder = getDaoProfileSwitch().queryBuilder(); QueryBuilder<ProfileSwitch, Long> queryBuilder = getDaoProfileSwitch().queryBuilder();

View file

@ -131,7 +131,8 @@ public class RileyLinkUtil {
} else { } else {
return RileyLinkUtil.rileyLinkServiceData.serviceState; return RileyLinkUtil.rileyLinkServiceData.serviceState == null ? RileyLinkServiceState.NotStarted
: RileyLinkUtil.rileyLinkServiceData.serviceState;
} }

View file

@ -55,8 +55,10 @@ public class SendAndListen extends RileyLinkCommand {
@Override @Override
public byte[] getRaw() { public byte[] getRaw() {
boolean isPacketV2 = RileyLinkUtil.getFirmwareVersion().isSameVersion( // If firmware version is not set (error reading version from device, shouldn't happen),
RileyLinkFirmwareVersion.Version2AndHigher); // we will default to version 2
boolean isPacketV2 = RileyLinkUtil.getFirmwareVersion() != null ? RileyLinkUtil.getFirmwareVersion()
.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher) : true;
ArrayList<Byte> bytes = new ArrayList<Byte>(); ArrayList<Byte> bytes = new ArrayList<Byte>();
bytes.add(this.getCommandType().code); bytes.add(this.getCommandType().code);

View file

@ -91,7 +91,7 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
RileyLinkTargetDevice targetDevice = RileyLinkUtil.getTargetDevice(); RileyLinkTargetDevice targetDevice = RileyLinkUtil.getTargetDevice();
this.connectionStatus.setText(MainApp.gs(rileyLinkServiceData.serviceState.getResourceId(targetDevice))); this.connectionStatus.setText(MainApp.gs(RileyLinkUtil.getServiceState().getResourceId(targetDevice)));
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress); this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
this.connectionError.setText(rileyLinkServiceData.errorCode == null ? // this.connectionError.setText(rileyLinkServiceData.errorCode == null ? //
"-" "-"

View file

@ -395,6 +395,15 @@ public class ByteUtil {
} }
public static byte[] createByteArrayFromHexString(String dataFull) {
String data = dataFull.replace(" 0x", "");
data = data.replace("0x", "");
return createByteArrayFromCompactString(data, 0, data.length());
}
public static byte[] createByteArrayFromCompactString(String dataFull, int startIndex) { public static byte[] createByteArrayFromCompactString(String dataFull, int startIndex) {
return createByteArrayFromCompactString(dataFull, startIndex, dataFull.length()); return createByteArrayFromCompactString(dataFull, startIndex, dataFull.length());
} }

View file

@ -36,6 +36,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Actions.defs.CustomAction; import info.nightscout.androidaps.plugins.Actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.Actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.Actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@ -76,7 +77,7 @@ import info.nightscout.utils.SP;
*/ */
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface { public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpPlugin.class); private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
protected static MedtronicPumpPlugin plugin = null; protected static MedtronicPumpPlugin plugin = null;
private RileyLinkMedtronicService medtronicService; private RileyLinkMedtronicService medtronicService;
@ -96,18 +97,18 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation() public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
.setPrettyPrinting().create(); .setPrettyPrinting().create();
private MedtronicPumpPlugin() { private MedtronicPumpPlugin() {
super(new PluginDescription() // super(new PluginDescription() //
.mainType(PluginType.PUMP) // .mainType(PluginType.PUMP) //
.fragmentClass(MedtronicFragment.class.getName()) // .fragmentClass(MedtronicFragment.class.getName()) //
.pluginName(R.string.medtronic_name) // .pluginName(R.string.medtronic_name) //
.shortName(R.string.medtronic_name_short) // .shortName(R.string.medtronic_name_short) //
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), // .preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
); );
// TODO remove this later // TODO remove this later
@ -129,7 +130,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.debug("RileyLinkMedtronicService is connected"); LOG.debug("RileyLinkMedtronicService is connected");
RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder)service; RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder) service;
medtronicService = mLocalBinder.getServiceInstance(); medtronicService = mLocalBinder.getServiceInstance();
new Thread(() -> { new Thread(() -> {
@ -218,7 +219,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (this.isInitialized) { if (this.isInitialized) {
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh( Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(
StatusRefreshAction.GetData, null, null); StatusRefreshAction.GetData, null, null);
if (doWeHaveAnyStatusNeededRefereshing(statusRefresh)) { if (doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Scheduled Status Refresh", null); ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Scheduled Status Refresh", null);
@ -324,8 +325,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
RileyLinkServiceState rileyLinkServiceState = MedtronicUtil.getServiceState(); RileyLinkServiceState rileyLinkServiceState = MedtronicUtil.getServiceState();
if (rileyLinkServiceState != RileyLinkServiceState.PumpConnectorReady // if (rileyLinkServiceState != RileyLinkServiceState.PumpConnectorReady //
&& rileyLinkServiceState != RileyLinkServiceState.RileyLinkReady // && rileyLinkServiceState != RileyLinkServiceState.RileyLinkReady //
&& rileyLinkServiceState != RileyLinkServiceState.TuneUpDevice) { && rileyLinkServiceState != RileyLinkServiceState.TuneUpDevice) {
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.error("RileyLink unreachable."); LOG.error("RileyLink unreachable.");
return false; return false;
@ -338,7 +339,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private void refreshAnyStatusThatNeedsToBeRefreshed() { private void refreshAnyStatusThatNeedsToBeRefreshed() {
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(StatusRefreshAction.GetData, null, Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(StatusRefreshAction.GetData, null,
null); null);
if (!doWeHaveAnyStatusNeededRefereshing(statusRefresh)) { if (!doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
return; return;
@ -367,7 +368,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
case PumpHistory: { case PumpHistory: {
readPumpHistory(); readPumpHistory();
} }
break; break;
case PumpTime: case PumpTime:
case BatteryStatus: case BatteryStatus:
@ -376,13 +377,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
refreshTypesNeededToReschedule.add(refreshType.getKey()); refreshTypesNeededToReschedule.add(refreshType.getKey());
resetTime = true; resetTime = true;
} }
break; break;
case Configuration: { case Configuration: {
medtronicUIComm.executeCommand(refreshType.getKey().getCommandType()); medtronicUIComm.executeCommand(refreshType.getKey().getCommandType());
resetTime = true; resetTime = true;
} }
break; break;
} }
} }
} }
@ -498,9 +499,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} }
FabricPrivacy.getInstance().logCustom( // FabricPrivacy.getInstance().logCustom( //
new CustomEvent("MedtronicInitializePump") // new CustomEvent("MedtronicInitializePump") //
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) // .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) //
.putCustomAttribute("version", BuildConfig.VERSION)); .putCustomAttribute("version", BuildConfig.VERSION));
isInitialized = true; isInitialized = true;
// this.pumpState = PumpDriverState.Initialized; // this.pumpState = PumpDriverState.Initialized;
@ -525,7 +526,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// LOG.info("isThisProfileSet: check"); // LOG.info("isThisProfileSet: check");
LOG.info("isThisProfileSet: check [basalProfileChanged={}, basalByHourSet={}, isBasalProfileInvalid={}", LOG.info("isThisProfileSet: check [basalProfileChanged={}, basalByHourSet={}, isBasalProfileInvalid={}",
basalProfileChanged, getMDTPumpStatus().basalsByHour != null, isBasalProfileInvalid); basalProfileChanged, getMDTPumpStatus().basalsByHour != null, isBasalProfileInvalid);
if (!basalProfileChanged && getMDTPumpStatus().basalsByHour != null && !isBasalProfileInvalid) { if (!basalProfileChanged && getMDTPumpStatus().basalsByHour != null && !isBasalProfileInvalid) {
if (isLoggingEnabled()) if (isLoggingEnabled())
@ -601,7 +602,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.debug("Current Basals (h): " LOG.debug("Current Basals (h): "
+ (basalsByHour == null ? "null" : BasalProfile.getProfilesByHourToString(basalsByHour))); + (basalsByHour == null ? "null" : BasalProfile.getProfilesByHourToString(basalsByHour)));
int index = 0; int index = 0;
@ -733,9 +734,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery"); // LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery");
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus, MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
detailedBolusInfo.insulin); detailedBolusInfo.insulin);
Boolean response = (Boolean)responseTask.returnData; Boolean response = (Boolean) responseTask.returnData;
setRefreshButtonEnabled(true); setRefreshButtonEnabled(true);
@ -769,18 +770,18 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin; getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin;
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
: MedtronicConst.Statistics.StandardBoluses); : MedtronicConst.Statistics.StandardBoluses);
return new PumpEnactResult().success(response) // return new PumpEnactResult().success(response) //
.enacted(response) // .enacted(response) //
.bolusDelivered(detailedBolusInfo.insulin) // .bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs); .carbsDelivered(detailedBolusInfo.carbs);
} else { } else {
return new PumpEnactResult() // return new PumpEnactResult() //
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) // .success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered)); .comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
} }
} finally { } finally {
@ -800,13 +801,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (success) { if (success) {
return new PumpEnactResult() // return new PumpEnactResult() //
.success(true) // .success(true) //
.enacted(false); .enacted(false);
} else { } else {
return new PumpEnactResult() // return new PumpEnactResult() //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable)); .comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
} }
} }
@ -831,7 +832,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed // if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
@Override @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
boolean enforceNew) { boolean enforceNew) {
setRefreshButtonEnabled(false); setRefreshButtonEnabled(false);
@ -840,9 +841,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true); setRefreshButtonEnabled(true);
return new PumpEnactResult() // return new PumpEnactResult() //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable)); .comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
} }
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable); MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
@ -860,11 +861,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.warn(getLogPrefix() + "setTempBasalAbsolute - Could not read current TBR, canceling operation."); LOG.warn(getLogPrefix() + "setTempBasalAbsolute - Could not read current TBR, canceling operation.");
finishAction("TBR"); finishAction("TBR");
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr)); .comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr));
} else { } else {
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.info(getLogPrefix() + "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}", LOG.info(getLogPrefix() + "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate()); tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
} }
if (!enforceNew) { if (!enforceNew) {
@ -896,7 +897,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR); MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
Boolean response = (Boolean)responseTask2.returnData; Boolean response = (Boolean) responseTask2.returnData;
if (response) { if (response) {
if (isLoggingEnabled()) if (isLoggingEnabled())
@ -908,15 +909,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
finishAction("TBR"); finishAction("TBR");
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr_stop_op)); .comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr_stop_op));
} }
} }
// now start new TBR // now start new TBR
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal, MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal,
absoluteRate, durationInMinutes); absoluteRate, durationInMinutes);
Boolean response = (Boolean)responseTask.returnData; Boolean response = (Boolean) responseTask.returnData;
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response); LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response);
@ -928,10 +929,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
pumpStatusLocal.tempBasalLength = durationInMinutes; pumpStatusLocal.tempBasalLength = durationInMinutes;
TemporaryBasal tempStart = new TemporaryBasal() // TemporaryBasal tempStart = new TemporaryBasal() //
.date(System.currentTimeMillis()) // .date(System.currentTimeMillis()) //
.duration(durationInMinutes) // .duration(durationInMinutes) //
.absolute(absoluteRate) // .absolute(absoluteRate) //
.source(Source.USER); .source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
@ -940,13 +941,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
finishAction("TBR"); finishAction("TBR");
return new PumpEnactResult().success(response).enacted(response) // return new PumpEnactResult().success(response).enacted(response) //
.absolute(absoluteRate).duration(durationInMinutes); .absolute(absoluteRate).duration(durationInMinutes);
} else { } else {
finishAction("TBR"); finishAction("TBR");
return new PumpEnactResult().success(response).enacted(response) // return new PumpEnactResult().success(response).enacted(response) //
.comment(MainApp.gs(R.string.medtronic_cmd_tbr_could_not_be_delivered)); .comment(MainApp.gs(R.string.medtronic_cmd_tbr_could_not_be_delivered));
} }
} }
@ -981,7 +982,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} }
if (this.getMDTPumpStatus().basalProfileStatus != BasalProfileStatus.NotInitialized if (this.getMDTPumpStatus().basalProfileStatus != BasalProfileStatus.NotInitialized
&& medtronicHistoryData.hasBasalProfileChanged()) { && medtronicHistoryData.hasBasalProfileChanged()) {
medtronicHistoryData.processLastBasalProfileChange(getMDTPumpStatus()); medtronicHistoryData.processLastBasalProfileChange(getMDTPumpStatus());
// this.basalProfileChanged = true; // this.basalProfileChanged = true;
} }
@ -1007,10 +1008,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
processTDDs(tdds); processTDDs(tdds);
} }
List<PumpHistoryEntry> tdds2 = medtronicHistoryData.getTDDs2(); // List<PumpHistoryEntry> tdds2 = medtronicHistoryData.getTDDs2();
//
// FIXME // // FIXME
LOG.debug("TDDs2: {}", gsonInstancePretty.toJson(tdds2)); // LOG.debug("TDDs2: {}", gsonInstancePretty.toJson(tdds2));
List<PumpHistoryEntry> treatments = medtronicHistoryData.getTreatments(); List<PumpHistoryEntry> treatments = medtronicHistoryData.getTreatments();
@ -1066,21 +1067,21 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (lastPumpHistoryEntryTime == 0L) { if (lastPumpHistoryEntryTime == 0L) {
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: 0L - targetDate: " LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: 0L - targetDate: "
+ targetDate); + targetDate);
targetDate = timeMinus36h; targetDate = timeMinus36h;
} else { } else {
// LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime); // LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime);
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: {} - targetDate: {}", LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: {} - targetDate: {}",
lastPumpHistoryEntryTime, targetDate); lastPumpHistoryEntryTime, targetDate);
medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntryTime); medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntryTime);
LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime); LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime);
lastHistoryRecordTime = lastHistoryRecordTime.minusHours(12); // we get last 12 hours of history to lastHistoryRecordTime = lastHistoryRecordTime.minusHours(12); // we get last 12 hours of history to
// determine pump state // determine pump state
// (we don't process that data), we process only // (we don't process that data), we process only
if (timeMinus36h.isAfter(lastHistoryRecordTime)) { if (timeMinus36h.isAfter(lastHistoryRecordTime)) {
@ -1095,7 +1096,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} else { } else {
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntry: not null - {}", LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntry: not null - {}",
gsonInstancePretty.toJson(lastPumpHistoryEntry)); gsonInstancePretty.toJson(lastPumpHistoryEntry));
medtronicHistoryData.setIsInInit(false); medtronicHistoryData.setIsInInit(false);
medtronicHistoryData.setLastHistoryRecordTime(null); medtronicHistoryData.setLastHistoryRecordTime(null);
@ -1105,11 +1106,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.debug("HST: Target Date: {}", targetDate); LOG.debug("HST: Target Date: {}", targetDate);
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData, MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,
lastPumpHistoryEntry, targetDate); lastPumpHistoryEntry, targetDate);
LOG.debug("HST: After task"); LOG.debug("HST: After task");
PumpHistoryResult historyResult = (PumpHistoryResult)responseTask2.returnData; PumpHistoryResult historyResult = (PumpHistoryResult) responseTask2.returnData;
LOG.debug("HST: History Result: {}", historyResult.toString()); LOG.debug("HST: History Result: {}", historyResult.toString());
@ -1125,7 +1126,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
SP.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime); SP.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime);
LOG.debug("HST: History: valid={}, unprocessed={}", historyResult.validEntries.size(), LOG.debug("HST: History: valid={}, unprocessed={}", historyResult.validEntries.size(),
historyResult.unprocessedEntries.size()); historyResult.unprocessedEntries.size());
this.medtronicHistoryData.addNewHistory(historyResult); this.medtronicHistoryData.addNewHistory(historyResult);
this.medtronicHistoryData.filterNewEntries(); this.medtronicHistoryData.filterNewEntries();
@ -1173,15 +1174,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
workWithStatusRefresh(StatusRefreshAction.Add, refreshType, getTimeInFutureFromMinutes(min)); workWithStatusRefresh(StatusRefreshAction.Add, refreshType, getTimeInFutureFromMinutes(min));
} }
break; break;
case PumpTime: case PumpTime:
case Configuration: case Configuration:
case PumpHistory: { case PumpHistory: {
workWithStatusRefresh(StatusRefreshAction.Add, refreshType, workWithStatusRefresh(StatusRefreshAction.Add, refreshType,
getTimeInFutureFromMinutes(refreshType.getRefreshTime() + additionalTimeInMinutes)); getTimeInFutureFromMinutes(refreshType.getRefreshTime() + additionalTimeInMinutes));
} }
break; break;
} }
} }
@ -1192,7 +1193,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private synchronized Map<MedtronicStatusRefreshType, Long> workWithStatusRefresh(StatusRefreshAction action, private synchronized Map<MedtronicStatusRefreshType, Long> workWithStatusRefresh(StatusRefreshAction action,
MedtronicStatusRefreshType statusRefreshType, Long time) { MedtronicStatusRefreshType statusRefreshType, Long time) {
switch (action) { switch (action) {
@ -1230,7 +1231,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal); MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal);
if (responseTask.hasData()) { if (responseTask.hasData()) {
TempBasalPair tbr = (TempBasalPair)responseTask.returnData; TempBasalPair tbr = (TempBasalPair) responseTask.returnData;
// we sometimes get rate returned even if TBR is no longer running // we sometimes get rate returned even if TBR is no longer running
if (tbr.getDurationMinutes() == 0) { if (tbr.getDurationMinutes() == 0) {
@ -1255,9 +1256,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true); setRefreshButtonEnabled(true);
return new PumpEnactResult() // return new PumpEnactResult() //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable)); .comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
} }
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable); MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
@ -1277,12 +1278,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.warn(getLogPrefix() + "cancelTempBasal - Could not read currect TBR, canceling operation."); LOG.warn(getLogPrefix() + "cancelTempBasal - Could not read currect TBR, canceling operation.");
finishAction("TBR"); finishAction("TBR");
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr)); .comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr));
} }
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR); MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
Boolean response = (Boolean)responseTask2.returnData; Boolean response = (Boolean) responseTask2.returnData;
finishAction("TBR"); finishAction("TBR");
@ -1291,20 +1292,20 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful."); LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
TemporaryBasal tempBasal = new TemporaryBasal() // TemporaryBasal tempBasal = new TemporaryBasal() //
.date(System.currentTimeMillis()) // .date(System.currentTimeMillis()) //
.duration(0) // .duration(0) //
.source(Source.USER); .source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
return new PumpEnactResult().success(response).enacted(response) // return new PumpEnactResult().success(response).enacted(response) //
.isTempCancel(true); .isTempCancel(true);
} else { } else {
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed."); LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
return new PumpEnactResult().success(response).enacted(response) // return new PumpEnactResult().success(response).enacted(response) //
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr)); .comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr));
} }
} }
@ -1317,9 +1318,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// this shouldn't be needed, but let's do check if profile setting we are setting is same as current one // this shouldn't be needed, but let's do check if profile setting we are setting is same as current one
if (isProfileSame(profile)) { if (isProfileSame(profile)) {
return new PumpEnactResult() // return new PumpEnactResult() //
.success(true) // .success(true) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same)); .comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
} }
setRefreshButtonEnabled(false); setRefreshButtonEnabled(false);
@ -1329,9 +1330,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true); setRefreshButtonEnabled(true);
return new PumpEnactResult() // return new PumpEnactResult() //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable)); .comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
} }
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable); MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
@ -1342,15 +1343,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (profileInvalid != null) { if (profileInvalid != null) {
return new PumpEnactResult() // return new PumpEnactResult() //
.success(false) // .success(false) //
.enacted(false) // .enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid)); .comment(MainApp.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid));
} }
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBasalProfileSTD, MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBasalProfileSTD,
basalProfile); basalProfile);
Boolean response = (Boolean)responseTask.returnData; Boolean response = (Boolean) responseTask.returnData;
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.info(getLogPrefix() + "Basal Profile was set: " + response); LOG.info(getLogPrefix() + "Basal Profile was set: " + response);
@ -1360,7 +1361,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return new PumpEnactResult().success(response).enacted(response); return new PumpEnactResult().success(response).enacted(response);
} else { } else {
return new PumpEnactResult().success(response).enacted(response) // return new PumpEnactResult().success(response).enacted(response) //
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_could_not_be_set)); .comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_could_not_be_set));
} }
} }
@ -1445,7 +1446,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
this.customActions = new ArrayList<>(); this.customActions = new ArrayList<>();
CustomAction ca = new CustomAction(R.string.medtronic_custom_action_wake_and_tune, CustomAction ca = new CustomAction(R.string.medtronic_custom_action_wake_and_tune,
MedtronicCustomActionType.WakeUpAndTune); MedtronicCustomActionType.WakeUpAndTune);
this.customActions.add(ca); this.customActions.add(ca);
} }
@ -1456,7 +1457,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override @Override
public PumpEnactResult executeCustomAction(CustomActionType customActionType) { public PumpEnactResult executeCustomAction(CustomActionType customActionType) {
MedtronicCustomActionType mcat = (MedtronicCustomActionType)customActionType; MedtronicCustomActionType mcat = (MedtronicCustomActionType) customActionType;
switch (mcat) { switch (mcat) {

View file

@ -465,7 +465,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// Bolus=1.7, Fodd, Corr, Manual=1.7, // Bolus=1.7, Fodd, Corr, Manual=1.7,
// Num bOlus=1, food/corr, Food+corr, manual bolus=1 // Num bOlus=1, food/corr, Food+corr, manual bolus=1
DailyTotalsDTO totals = new DailyTotalsDTO(entry.getEntryType(), entry.getBody()); DailyTotalsDTO totals = new DailyTotalsDTO(entry);
// System.out.println("Totals:" + totals); // System.out.println("Totals:" + totals);
@ -487,6 +487,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// } // }
// //
// } // }
entry.addDecodedData("Object", totals);
System.out.println("" + totals.toString()); System.out.println("" + totals.toString());
@ -563,7 +564,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
} }
private String getFormattedValue(float value, int decimals) { public static String getFormattedValue(float value, int decimals) {
return String.format(Locale.ENGLISH, "%." + decimals + "f", value); return String.format(Locale.ENGLISH, "%." + decimals + "f", value);
} }

View file

@ -144,17 +144,15 @@ public enum PumpHistoryEntryType // implements CodeEnum
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69 BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14 DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 0, 0, 36), // DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 33), // v4: 0,0,36. v5: 1,2,33
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), // // hack1(0x6d, "hack1", DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
// 46,
// 5, 0), // 1,2,41
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00 DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
ChangeCarbUnits((byte)0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), // ChangeCarbUnits((byte) 0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
/**/EventUnknown_MM522_0x70((byte)0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), // /**/EventUnknown_MM522_0x70((byte) 0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722 BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
ChangeWatchdogEnable((byte)0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), // ChangeWatchdogEnable((byte) 0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), //
ChangeOtherDeviceID((byte)0x7d, "Change Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // ChangeOtherDeviceID((byte) 0x7d, "Change Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 30), //
ChangeWatchdogMarriageProfile(0x81, "Change Watchdog Marriage Profile", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12 ChangeWatchdogMarriageProfile(0x81, "Change Watchdog Marriage Profile", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
DeleteOtherDeviceID(0x82, "Delete Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // DeleteOtherDeviceID(0x82, "Delete Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 5), //
@ -184,6 +182,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
UnknownBasePacket(0xff, "Unknown Base Packet", PumpHistoryEntryGroup.Unknown); UnknownBasePacket(0xff, "Unknown Base Packet", PumpHistoryEntryGroup.Unknown);
private static Map<Integer, PumpHistoryEntryType> opCodeMap = new HashMap<Integer, PumpHistoryEntryType>(); private static Map<Integer, PumpHistoryEntryType> opCodeMap = new HashMap<Integer, PumpHistoryEntryType>();
private static PumpHistoryEntryType tddType;
static { static {
for (PumpHistoryEntryType type : values()) { for (PumpHistoryEntryType type : values()) {
@ -206,6 +205,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
private List<SpecialRule> specialRulesBody; private List<SpecialRule> specialRulesBody;
private boolean hasSpecialRules = false; private boolean hasSpecialRules = false;
private PumpHistoryEntryGroup group = PumpHistoryEntryGroup.Unknown; private PumpHistoryEntryGroup group = PumpHistoryEntryGroup.Unknown;
private static Object TDDType;
PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group) { PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group) {
@ -239,10 +239,10 @@ public enum PumpHistoryEntryType // implements CodeEnum
Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8)); Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8));
// BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_522andHigher, 143)); // BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_522andHigher, 143));
BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 143)); // V5: BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 143)); // V5:
// 522 // 522
// has // has
// old // old
// form // form
BolusWizardBolusEstimate.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 15)); BolusWizardBolusEstimate.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 15));
BolusReminder.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 2)); BolusReminder.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 2));
} }
@ -272,32 +272,32 @@ public enum PumpHistoryEntryType // implements CodeEnum
public static boolean isAAPSRelevantEntry(PumpHistoryEntryType entryType) { public static boolean isAAPSRelevantEntry(PumpHistoryEntryType entryType) {
return (entryType == PumpHistoryEntryType.Bolus || // Treatments return (entryType == PumpHistoryEntryType.Bolus || // Treatments
entryType == PumpHistoryEntryType.TempBasalRate || // entryType == PumpHistoryEntryType.TempBasalRate || //
entryType == PumpHistoryEntryType.TempBasalDuration || // entryType == PumpHistoryEntryType.TempBasalDuration || //
entryType == PumpHistoryEntryType.Prime || // Pump Status Change entryType == PumpHistoryEntryType.Prime || // Pump Status Change
entryType == PumpHistoryEntryType.PumpSuspend || // entryType == PumpHistoryEntryType.PumpSuspend || //
entryType == PumpHistoryEntryType.PumpResume || // entryType == PumpHistoryEntryType.PumpResume || //
entryType == PumpHistoryEntryType.Rewind || // entryType == PumpHistoryEntryType.Rewind || //
entryType == PumpHistoryEntryType.NoDeliveryAlarm || // no delivery entryType == PumpHistoryEntryType.NoDeliveryAlarm || // no delivery
entryType == PumpHistoryEntryType.BasalProfileStart || // entryType == PumpHistoryEntryType.BasalProfileStart || //
entryType == PumpHistoryEntryType.ChangeTime || // Time Change entryType == PumpHistoryEntryType.ChangeTime || // Time Change
entryType == PumpHistoryEntryType.NewTimeSet || // entryType == PumpHistoryEntryType.NewTimeSet || //
entryType == PumpHistoryEntryType.ChangeBasalPattern || // Configuration entryType == PumpHistoryEntryType.ChangeBasalPattern || // Configuration
entryType == PumpHistoryEntryType.ClearSettings || // entryType == PumpHistoryEntryType.ClearSettings || //
entryType == PumpHistoryEntryType.SaveSettings || // entryType == PumpHistoryEntryType.SaveSettings || //
entryType == PumpHistoryEntryType.ChangeMaxBolus || // entryType == PumpHistoryEntryType.ChangeMaxBolus || //
entryType == PumpHistoryEntryType.ChangeMaxBasal || // entryType == PumpHistoryEntryType.ChangeMaxBasal || //
entryType == PumpHistoryEntryType.ChangeTempBasalType || // entryType == PumpHistoryEntryType.ChangeTempBasalType || //
entryType == PumpHistoryEntryType.ChangeBasalProfile_NewProfile || // Basal profile entryType == PumpHistoryEntryType.ChangeBasalProfile_NewProfile || // Basal profile
entryType == PumpHistoryEntryType.DailyTotals515 || // Daily Totals entryType == PumpHistoryEntryType.DailyTotals515 || // Daily Totals
entryType == PumpHistoryEntryType.DailyTotals522 || // entryType == PumpHistoryEntryType.DailyTotals522 || //
entryType == PumpHistoryEntryType.DailyTotals523 || // entryType == PumpHistoryEntryType.DailyTotals523 || //
entryType == PumpHistoryEntryType.EndResultTotals); entryType == PumpHistoryEntryType.EndResultTotals);
} }

View file

@ -128,8 +128,8 @@ public class PumpHistoryResult {
public String toString() { public String toString() {
return "PumpHistoryResult [unprocessed=" + unprocessedEntries.size() + // return "PumpHistoryResult [unprocessed=" + (unprocessedEntries != null ? "" + unprocessedEntries.size() : "0") + //
", valid=" + validEntries.size() + // ", valid=" + (validEntries != null ? "" + validEntries.size() : "0") + //
", searchEntry=" + searchEntry + // ", searchEntry=" + searchEntry + //
", searchDate=" + searchDate + // ", searchDate=" + searchDate + //
", searchType=" + searchType + // ", searchType=" + searchType + //

View file

@ -1,5 +1,10 @@
package info.nightscout.androidaps.plugins.PumpMedtronic.data; package info.nightscout.androidaps.plugins.PumpMedtronic.data;
import com.google.common.base.Splitter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
@ -7,11 +12,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Splitter;
import info.nightscout.androidaps.plugins.PumpCommon.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.PumpCommon.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin; import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.MedtronicPumpHistoryDecoder; import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
@ -20,6 +20,7 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHi
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryResult; import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryResult;
import info.nightscout.androidaps.plugins.PumpMedtronic.data.dto.BasalProfile; import info.nightscout.androidaps.plugins.PumpMedtronic.data.dto.BasalProfile;
import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
//import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin; //import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
@ -128,7 +129,7 @@ public class MedtronicHistoryData {
// FIXME not just 50 records, last 24 hours // FIXME not just 50 records, last 24 hours
public void finalizeNewHistoryRecords() { public void finalizeNewHistoryRecords() {
List<PumpHistoryEntry> filteredListByLastRecord = getFilteredListByLastRecord((PumpHistoryEntryType)null); List<PumpHistoryEntry> filteredListByLastRecord = getFilteredListByLastRecord((PumpHistoryEntryType) null);
LOG.debug("New records: " + filteredListByLastRecord.size()); LOG.debug("New records: " + filteredListByLastRecord.size());
@ -173,12 +174,12 @@ public class MedtronicHistoryData {
public boolean hasRelevantConfigurationChanged() { public boolean hasRelevantConfigurationChanged() {
return getStateFromFilteredList( // return getStateFromFilteredList( //
PumpHistoryEntryType.ChangeBasalPattern, // PumpHistoryEntryType.ChangeBasalPattern, //
PumpHistoryEntryType.ClearSettings, // PumpHistoryEntryType.ClearSettings, //
PumpHistoryEntryType.SaveSettings, // PumpHistoryEntryType.SaveSettings, //
PumpHistoryEntryType.ChangeMaxBolus, // PumpHistoryEntryType.ChangeMaxBolus, //
PumpHistoryEntryType.ChangeMaxBasal, // PumpHistoryEntryType.ChangeMaxBasal, //
PumpHistoryEntryType.ChangeTempBasalType); PumpHistoryEntryType.ChangeTempBasalType);
} }
@ -198,13 +199,13 @@ public class MedtronicHistoryData {
if (wasPumpSuspended == null) { // suspension status not known if (wasPumpSuspended == null) { // suspension status not known
List<PumpHistoryEntry> items = getFilteredItems(PumpHistoryEntryType.Bolus, // List<PumpHistoryEntry> items = getFilteredItems(PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined, // PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, // PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.PumpSuspend, // PumpHistoryEntryType.PumpSuspend, //
PumpHistoryEntryType.PumpResume, // PumpHistoryEntryType.PumpResume, //
PumpHistoryEntryType.Rewind, // PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, // PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BasalProfileStart); PumpHistoryEntryType.BasalProfileStart);
if (items.size() == 0) if (items.size() == 0)
return wasPumpSuspended == null ? false : wasPumpSuspended; return wasPumpSuspended == null ? false : wasPumpSuspended;
@ -212,20 +213,20 @@ public class MedtronicHistoryData {
PumpHistoryEntry pumpHistoryEntry = items.get(0); PumpHistoryEntry pumpHistoryEntry = items.get(0);
return !(pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.TempBasalCombined || // return !(pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.TempBasalCombined || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || // pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || // pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume); pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume);
} else { } else {
List<PumpHistoryEntry> items = getFilteredItems(PumpHistoryEntryType.Bolus, // List<PumpHistoryEntry> items = getFilteredItems(PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined, // PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, // PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.PumpSuspend, // PumpHistoryEntryType.PumpSuspend, //
PumpHistoryEntryType.PumpResume, // PumpHistoryEntryType.PumpResume, //
PumpHistoryEntryType.Rewind, // PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, // PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BasalProfileStart); PumpHistoryEntryType.BasalProfileStart);
if (wasPumpSuspended) { if (wasPumpSuspended) {
@ -235,9 +236,9 @@ public class MedtronicHistoryData {
PumpHistoryEntry pumpHistoryEntry = items.get(0); PumpHistoryEntry pumpHistoryEntry = items.get(0);
if (pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.TempBasalCombined || // if (pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.TempBasalCombined || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || // pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || // pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume) pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume)
return false; return false;
else else
return true; return true;
@ -250,8 +251,8 @@ public class MedtronicHistoryData {
PumpHistoryEntry pumpHistoryEntry = items.get(0); PumpHistoryEntry pumpHistoryEntry = items.get(0);
if (pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.NoDeliveryAlarm || // if (pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.NoDeliveryAlarm || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpSuspend || // pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpSuspend || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Prime) pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Prime)
return true; return true;
} }
@ -266,16 +267,35 @@ public class MedtronicHistoryData {
public List<PumpHistoryEntry> getTDDs() { public List<PumpHistoryEntry> getTDDs() {
return getFilteredListByLastRecord(PumpHistoryEntryType.EndResultTotals); return getFilteredListByLastRecord(getTDDType());
} }
// FIXME remove private PumpHistoryEntryType getTDDType() {
public List<PumpHistoryEntry> getTDDs2() {
return getFilteredListByLastRecord(PumpHistoryEntryType.DailyTotals515, PumpHistoryEntryType.DailyTotals522,
PumpHistoryEntryType.DailyTotals523); switch (MedtronicUtil.getMedtronicPumpModel()) {
case Medtronic_515:
case Medtronic_715:
return PumpHistoryEntryType.DailyTotals515;
case Medtronic_522:
case Medtronic_722:
return PumpHistoryEntryType.DailyTotals522;
case Medtronic_523_Revel:
case Medtronic_723_Revel:
case Medtronic_554_Veo:
case Medtronic_754_Veo:
return PumpHistoryEntryType.DailyTotals523;
default: {
return PumpHistoryEntryType.EndResultTotals;
}
}
} }
@ -283,8 +303,8 @@ public class MedtronicHistoryData {
public List<PumpHistoryEntry> getTreatments() { public List<PumpHistoryEntry> getTreatments() {
return getFilteredListByLastRecord( // return getFilteredListByLastRecord( //
PumpHistoryEntryType.Bolus, // PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined); PumpHistoryEntryType.TempBasalCombined);
} }
@ -373,7 +393,7 @@ public class MedtronicHistoryData {
if (newProfile != null) { if (newProfile != null) {
LOG.debug("processLastBasalProfileChange. item found, setting new basalProfileLocally: " + newProfile); LOG.debug("processLastBasalProfileChange. item found, setting new basalProfileLocally: " + newProfile);
BasalProfile basalProfile = (BasalProfile)newProfile.getDecodedData().get("Object"); BasalProfile basalProfile = (BasalProfile) newProfile.getDecodedData().get("Object");
mdtPumpStatus.basalsByHour = basalProfile.getProfilesByHour(); mdtPumpStatus.basalsByHour = basalProfile.getProfilesByHour();
} }
@ -391,7 +411,7 @@ public class MedtronicHistoryData {
public boolean hasPumpTimeChanged() { public boolean hasPumpTimeChanged() {
return getStateFromFilteredList(PumpHistoryEntryType.NewTimeSet, // return getStateFromFilteredList(PumpHistoryEntryType.NewTimeSet, //
PumpHistoryEntryType.ChangeTime); PumpHistoryEntryType.ChangeTime);
} }

View file

@ -6,12 +6,17 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil; import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryEntryType; import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryEntry;
/** /**
* Created by andy on 11/3/18. * Created by andy on 11/3/18.
*/ */
/**
* NOTE: Decoding is only done for insulin part, everything else is pretty must left undecoded.
*/
public class DailyTotalsDTO { public class DailyTotalsDTO {
private static final Logger LOG = LoggerFactory.getLogger(DailyTotalsDTO.class); private static final Logger LOG = LoggerFactory.getLogger(DailyTotalsDTO.class);
@ -21,54 +26,87 @@ public class DailyTotalsDTO {
// Insulin=19.8[8,9], Basal[10,11], Bolus[13,14], Carbs, // Insulin=19.8[8,9], Basal[10,11], Bolus[13,14], Carbs,
// Bolus=1.7, Fodd, Corr, Manual=1.7, // Bolus=1.7, Fodd, Corr, Manual=1.7,
// Num bOlus=1, food/corr, Food+corr, manual bolus=1 // Num bOlus=1, food/corr, Food+corr, manual bolus=1
Double bgAvg; private Double bgAvg;
Double bgLow; private Double bgLow;
Double bgHigh; private Double bgHigh;
Integer bgCount; private Integer bgCount;
Double sensorAvg; private Double sensorAvg;
Double sensorMin; private Double sensorMin;
Double sensorMax; private Double sensorMax;
Integer sensorCalcCount; private Integer sensorCalcCount;
Integer sensorDataCount; private Integer sensorDataCount;
Double insulinTotal; private Double insulinTotal;
Double insulinBasal; private Double insulinBasal;
Double insulinBolus; private Double insulinBolus;
Double insulinCarbs; private Double insulinCarbs;
Double bolusTotal; private Double bolusTotal;
Double bolusFood; private Double bolusFood;
Double bolusFoodAndCorr; private Double bolusFoodAndCorr;
Double bolusCorrection; private Double bolusCorrection;
Double bolusManual; private Double bolusManual;
Integer bolusCount; private Integer bolusCount;
Integer bolusCountFoodOrCorr; private Integer bolusCountFoodOrCorr;
// Integer bolusCountCorr; // Integer bolusCountCorr;
Integer bolusCountFoodAndCorr; Integer bolusCountFoodAndCorr;
Integer bolusCountManual; Integer bolusCountManual;
private Integer bolusCountFood; private Integer bolusCountFood;
private Integer bolusCountCorr; private Integer bolusCountCorr;
PumpHistoryEntry entry;
public DailyTotalsDTO(PumpHistoryEntryType entryType, byte[] data) {
switch (entryType) { public DailyTotalsDTO(PumpHistoryEntry entry) {
this.entry = entry;
switch (entry.getEntryType()) {
case EndResultTotals:
decodeEndResultsTotals(entry);
break;
case DailyTotals515: case DailyTotals515:
decodeDailyTotals515(data); decodeDailyTotals515(entry.getBody());
break; break;
case DailyTotals522: case DailyTotals522:
decodeDailyTotals522(data); decodeDailyTotals522(entry.getBody());
break; break;
case DailyTotals523: case DailyTotals523:
decodeDailyTotals523(data); decodeDailyTotals523(entry.getBody());
break; break;
default: default:
break; break;
} }
// setDisplayable();
}
private void setDisplayable() {
if (this.insulinBasal == null) {
this.entry.setDisplayableValue("Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2));
} else {
this.entry.setDisplayableValue("Basal Insulin: " + StringUtil.getFormatedValueUS(this.insulinBasal, 2)
+ ", Total Insulin: " + StringUtil.getFormatedValueUS(this.insulinTotal, 2));
}
}
private void decodeEndResultsTotals(PumpHistoryEntry entry) {
double totals = ByteUtil.toInt((int)entry.getHead()[0], (int)entry.getHead()[1], (int)entry.getHead()[2],
(int)entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025d;
this.insulinTotal = totals;
entry.addDecodedData("Totals", totals);
// entry.setDisplayableValue(getFormattedValue(totals, 3));
} }
@ -100,9 +138,18 @@ public class DailyTotalsDTO {
private void decodeDailyTotals515(byte[] data) { private void decodeDailyTotals515(byte[] data) {
LOG.debug("Can't decode DailyTotals515: Body={}", ByteUtil.getHex(data)); // LOG.debug("Can't decode DailyTotals515: Body={}", ByteUtil.getHex(data));
testDecode(data); this.insulinTotal = ByteUtil.toInt(data[8], data[9]) / 40.0d;
this.insulinBasal = ByteUtil.toInt(data[10], data[11]) / 40.0d;
this.insulinBolus = ByteUtil.toInt(data[13], data[14]) / 40.0d;
// Delivery Stats: BG AVG: Bg Low/Hi=none,Number BGs=0
// Delivery Stats: INSULIN: Basal 22.30, Bolus=4.20, Catbs = 0g (26.5)
// Delivery Stats: BOLUS: Food=0.00, Corr=0.00, Manual=4.20
// Delivery Stats: NUM BOLUS: Food/Corr=0,Food+Corr=0, Manual=3
LOG.debug("515: {}", toString());
} }

View file

@ -1,3 +1,323 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com--> <resources>
<resources></resources> <string name="openaps_short">OAPS</string>
<string name="MM640g">MM640g</string>
<string name="mmol">mmol/l</string>
<string name="mgdl">mg/dl</string>
<string name="yes"></string>
<string name="no">Níl</string>
<string name="combo_pump_connected_now">Anois</string>
<string name="ga_lang">Gaeilge</string>
<string name="food">Bia</string>
<string name="danarspump_shortname">Dana</string>
<string name="danarspump">DanaRS</string>
<string name="oaps_shortname">OAPS</string>
<string name="nsalarm_high">Ard</string>
<string name="nsalarm_low">Íseal</string>
<string name="danar_stats_amount_days"># Lá</string>
<string name="xdrip">xDrip</string>
<string name="danar_alarm">aláraim</string>
<string name="pump_battery_label">Ceallraí</string>
<string name="bluetooth">Bluetooth</string>
<string name="button1">Cnaipe 1</string>
<string name="button2">Cnaipe 2</string>
<string name="button3">Cnaipe 3</string>
<string name="cancel">Cuir ar ceal</string>
<string name="mdtp_cancel">Cuir ar ceal</string>
<string name="connected">Nasctha</string>
<string name="connecting">Ag nascadh</string>
<string name="danarpump_shortname">DANA</string>
<string name="danarpump">DanaR</string>
<string name="days"></string>
<string name="date">Dáta</string>
<string name="device">Gléas</string>
<string name="disconnected">Dínasctha</string>
<string name="combo_pump_state_disconnected">Dínasctha</string>
<string name="overview_quickwizard_item_edit_button">In eagar</string>
<string name="en_lang">Bearla (English)</string>
<string name="danar_error">earráid</string>
<string name="nav_exit">Scoir</string>
<string name="overview_shortname">BAILE</string>
<string name="combo_reservoir_low">Íseal</string>
<string name="mute">Balbh</string>
<string name="nsclient">NSClient</string>
<string name="nsclientinternal">NSClient</string>
<string name="nsclientinternal_title">NSClient</string>
<string name="virtualpump_resultok">OK</string>
<string name="ok">OK</string>
<string name="mdtp_ok">OK</string>
<string name="openaps">OpenAPS</string>
<string name="openapsama">OpenAPS AMA</string>
<string name="openapsma">OpenAPS MA</string>
<string name="careportal_newnstreatment_other">Eile</string>
<string name="othersettings_title">Eile</string>
<string name="combo_refresh">Athnuachan</string>
<string name="restart">Atosaigh</string>
<string name="careportal_sensorage_label_short">SAGE</string>
<string name="save">Sábháil</string>
<string name="objectives_button_start">Tosaigh</string>
<string name="overview_bolusprogress_stop">Stad</string>
<string name="nsclientinternal_url">URL:</string>
<string name="up">Suas</string>
<string name="result">Toradh</string>
<string name="el_lang">Gréigis</string>
<string name="configbuilder_general">Ginearálta</string>
<string name="danar_glucose">glúcóis</string>
<string name="glucose">Glúcóis</string>
<string name="danar_history_glucose">Glúcóis</string>
<string name="shortgramm">g</string>
<string name="ultrafastactinginsulincomment">Fiasp</string>
<string name="shortfat">Saill</string>
<string name="careportal_exercise">Cleachtadh</string>
<string name="combo_reservoir_empty">Folamh</string>
<string name="tempbasals_realduration_label_string">Fad:</string>
<string name="duration">Fad</string>
<string name="careportal_newnstreatment_duration_label">Fad</string>
<string name="careportal_newnstreatment_duration_min_label">Fad [nóim.]</string>
<string name="danarv2pump">DanaRv2</string>
<string name="danar_stats_date">Dáta</string>
<string name="openapsma_profile_label">Próifíl</string>
<string name="configbuilder_profile">Próifíl</string>
<string name="careportal_newnstreatment_profile_label">Próifíl</string>
<string name="profile">Próifíl</string>
<string name="careportal_pbage_label_short">PBAGE</string>
<string name="configbuilder_pump">Caidéil</string>
<string name="pump">Caidéil</string>
<string name="careportal_pump_label">CAIDÉIL</string>
<string name="rate">Ráta</string>
<string name="danar_stats_ratio">Cóimheas</string>
<string name="tempbasals_netratio_label_string">Cóimheas:</string>
<string name="reason">Cúis</string>
<string name="pump_reservoir_label">Taiscumar</string>
<string name="resume">Atosú</string>
<string name="openapsma_run">Reáchtáil anois</string>
<string name="combo_pump_state_running">Ag reáchtáil</string>
<string name="careportal_newnstreatment_sensor">Braiteoir</string>
<string name="glucosetype_sensor">Braiteoir</string>
<string name="careportal_sensorage_label">Braiteoir aois</string>
<string name="success">Rathúlacht</string>
<string name="nsprofileview_units_label">Aonaid</string>
<string name="units">Aonaid:</string>
<string name="treatments_wizard_unit_label">A</string>
<string name="suspendloopfor10h">Fionraí lúb do 10 u</string>
<string name="suspendloopfor1h">Fionraí lúb do 1 u</string>
<string name="suspendloopfor2h">Fionraí lúb do 2 u</string>
<string name="suspendloopfor3h">Fionraí lúb do 3 u</string>
<string name="danar_history_syspend">Fionraí</string>
<string name="careportal_question">Ceist</string>
<string name="language">Teanga</string>
<string name="treatments_newtreatment_insulinamount_label">Inslin</string>
<string name="tempbasals_netinsulin_label_string">Ins:</string>
<string name="insulin_shortname">INS</string>
<string name="careportal_newnstreatment_insulin_label">Inslin</string>
<string name="configbuilder_insulin">Inslin</string>
<string name="treatments_insulin_label_string">Inslin:</string>
<string name="careportal_insulinage_label">Inslin aois</string>
<string name="careportal_insulinage_label_short">IAGE</string>
<string name="nsclientinternal_devicename_title">Gléas ainm</string>
<string name="child">Páiste</string>
<string name="overview_calculator_label">Áireamhán</string>
<string name="careportal_canulaage_label_short">CAGE</string>
<string name="danar_bluetooth_status">Bluetooth stádas</string>
<string name="configbuilder_aps">APS</string>
<string name="loop_aps_label">APS</string>
<string name="androidaps_start">AndroidAPS thosaigh</string>
<string name="sms_minago">%dnóim ó shin</string>
<string name="minago">%d nóim ó shin</string>
<string name="hoursago">%.1fu ó shin</string>
<string name="pump_basebasalrate">%.2f A/u</string>
<string name="combo_tbr_remaining">%1$d%% (%2$d nóim fágtha)</string>
<string name="actions">Gníomhartha</string>
<string name="actions_shortname">GNÍ</string>
<string name="overview_editquickwizardlistactivity_add">Cuir</string>
<string name="adult">Duine fásta</string>
<string name="overview_calibration">Calabrú</string>
<string name="overview_calibration_bg_label">Calabrú</string>
<string name="danar_carbohydrate">carbaihiodráit</string>
<string name="danar_history_carbohydrates">Carbaihiodráití</string>
<string name="closedloop">Lúb dúnta</string>
<string name="treatments_wizard_correction_label">Cear</string>
<string name="correctionbous">Cear</string>
<string name="overview_bolusprogress_delivered">Seachadta</string>
<string name="bolusdelivering">Seachadadh %.2fA</string>
<string name="deliver_now">Seachadadh anois</string>
<string name="disconnectpumpfor10h">Dhícheangal Caidéil do 10 u</string>
<string name="disconnectpumpfor1h">Dhícheangal Caidéil do 1 u</string>
<string name="disconnectpumpfor2h">Dhícheangal Caidéil do 2 u</string>
<string name="disconnectpumpfor3h">Dhícheangal Caidéil do 3 u</string>
<string name="disconnectpumpfor30m">Dhícheangal Caidéil do 30 nóim</string>
<string name="disconnecting">Dícheangal</string>
<string name="nl_lang">Ollainnis</string>
<string name="free_peak_oref">Free-Peak Oref</string>
<string name="about_link_urls">" http://www.androidaps.org http://www.androidaps.de (de) facebook: http://facebook.androidaps.org http://facebook.androidaps.de (de)"</string>
<string name="it_lang">Iodáilis</string>
<string name="ko_lang">Cóiréis</string>
<string name="loop">Lúb</string>
<string name="configbuilder_loop">Lúb</string>
<string name="loop_shortname">LÚB</string>
<string name="emptyreservoir">Taiscumar folamh</string>
<string name="openapsma_glucosestatus_label">Glúcóis stádas</string>
<string name="de_lang">Gearmáinis</string>
<string name="Glimp">Glimp</string>
<string name="combo_history">Stair</string>
<string name="loopenabled">Lúb cumasaithe</string>
<string name="key_ns_create_announcements_from_errors">ns_create_announcements_from_errors</string>
<string name="nsclientinternal_shortname">NSCI</string>
<string name="nsclientinternal_secret_dialogtitle">NS API secret</string>
<string name="nsclientinternal_secret_title">NS API secret</string>
<string name="openloop">Lúb oscailte</string>
<string name="careportal_newnstreatment_percent_label">Faoin gcéad</string>
<string name="percent">Faoin gcéad</string>
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
<string name="danar_refill">athlán</string>
<string name="danar_history_refill">Athlán</string>
<string name="danar_historyreload">Athlódáil</string>
<string name="reloadprofile">Athlódáil próifíl</string>
<string name="ro_lang">Rómáinis</string>
<string name="ru_lang">Rúisis</string>
<string name="sensitivityoref0">Sensitivity Oref0</string>
<string name="es_lang">Spainnis</string>
<string name="sv_lang">Sualainnis</string>
<string name="teenage">Déagóirí</string>
<string name="treatments">Cóireálacha</string>
<string name="configbuilder_treatments">Cóireálacha</string>
<string name="visible">Infheicthe</string>
<string name="overview_editquickwizard_valid">Bailí:</string>
<string name="objectives_button_verify">Fhíorú</string>
<string name="loopsuspendedfor">Ar fionraí (%d n)</string>
<string name="combo_pump_state_suspended_by_user">Ar fionraí ag úsáideoir</string>
<string name="objectives_1_objective">Tosaigh ag lúb oscailte</string>
<string name="status">Stádas:</string>
<string name="combo_pump_state_label">Stáit</string>
<string name="overview_bolusprogress_stoped">Stopadh</string>
<string name="serialnumber">Sraithuimhir</string>
<string name="combo_pump_action_refreshing">Athnuaigh</string>
<string name="combo_activity_checking_pump_state">Athnuaigh caidéil stáit</string>
<string name="combo_pump_never_connected">Riamh</string>
<string name="combo_pump_state_initializing">Tosaithe</string>
<string name="combo_reservoir_normal">Gnáth</string>
<string name="combo_tdd_average">Meán: %3.1f A</string>
<string name="combo_tdd_maximum">Uasmhéid: %3.1f A</string>
<string name="combo_tdd_minimum">Íosmhéid: %3.1f A</string>
<string name="combo_pump_state_suspended_due_to_error">Ar fionraí ag earráid</string>
<string name="initializing">Tosaithe ...</string>
<string name="combo_actvity_reading_basal_profile">Léigh próifíl bunaidh</string>
<string name="combo_activity_reading_pump_history">Léigh stair caidéil</string>
<string name="enabled">Cumasaithe</string>
<string name="combo_pump_action_setting_tbr">Socrú BRS (%1$d%% / %2$d nóim)</string>
<string name="combo_pump_action_initializing">Tosaithe</string>
<string name="combo_pump_action_cancelling_tbr">Cealú BRS</string>
<string name="combo_pump_battery_low_warrning">Is ceallraí Caidéil íseal</string>
<string name="combo_pump_cartridge_low_warrning">Is leibhéal cartús íseal</string>
<string name="combo_pump_action_bolusing">Ag bólas (%.1f A)</string>
<string name="carbs">Carbí</string>
<string name="careportal_newnstreatment_carbs_label">Carbí</string>
<string name="treatments_newtreatment_carbsamount_label">Carbí</string>
<string name="treatments_wizard_carbs_label">Carbí</string>
<string name="overview_editquickwizard_carbs">Carbí:</string>
<string name="treatments_carbs_label_string">Carbí:</string>
<string name="careportal_carbsandbolus_label">CARBÍ &amp; BÓLAS</string>
<string name="danar_history_connectingfor">Ag nascadh le %d s</string>
<string name="circadian_percentage_profile_shortname">CPP</string>
<string name="comment">Tuairim</string>
<string name="danar_bt_name_title">DanaR Bluetooth gléas</string>
<string name="cs_lang">Seice</string>
<string name="danarkoreanpump">DanaR Cóiréis</string>
<string name="danar_stats">DanaR staiti</string>
<string name="smscommunicator_loopresumed">Lúb atógáil</string>
<string name="smscommunicator_loophasbeenenabled">Is lúb cumasaithe</string>
<string name="smscommunicator_loopisenabled">Is lúb cumasaithe</string>
<string name="smscommunicator_loopisdisabled">Is lúb díchumasaithe</string>
<string name="smscommunicator_loophasbeendisabled">Is lúb díchumasaithe</string>
<string name="loopsuspended">Lúb ar fionraí</string>
<string name="smscommunicator_loopsuspended">Lúb ar fionraí</string>
<string name="disabledloop">Lúb díchumasaithe</string>
<string name="loopdisabled">LÚB DÍCHUMASAITHE LE SRIANTA</string>
<string name="lowbattery">Ceallraí Íseal</string>
<string name="nsclientinternal_url_title">Nightscout URL</string>
<string name="nightscout">Nightscout</string>
<string name="fastactinginsulincomment">Novorapid, Novolog, Humalog</string>
<string name="careportal_note">Nóta</string>
<string name="careportal_newnstreatment_notes_label">Nótaí</string>
<string name="fastactinginsulinprolonged">Fast Acting Insulin Prolonged</string>
<string name="DexcomG5">DexcomG5 App (patched)</string>
<string name="disableloop">Díchumasaigh lúb</string>
<string name="enableloop">Cumasaigh lúb</string>
<string name="objectives_gate_label_string">Geata:</string>
<string name="careportal_newnstreatment_glucosetype">Glúcóis cineál</string>
<string name="careportal_insulincartridgechange">Athrú Cartús Inslin</string>
<string name="invalidprofile">Próifíl neamhbhailí !!!</string>
<string name="zerovalueinprofile">Próifíl neamhbhailí: %s</string>
<string name="pump_lastbolus_label">Bólas deiridh</string>
<string name="openapsma_lastrun_label">Reáchtáil deiridh</string>
<string name="openapsma_lastenact_label">Achtaíodh deiridh</string>
<string name="pump_lastconnection_label">Nasc deiridh</string>
<string name="sms_lastbg">GF deiridh:</string>
<string name="glucosetype_finger">Méar</string>
<string name="fastactinginsulin">Fast Acting Insulin</string>
<string name="danar_history_errors">Earráidí</string>
<string name="danar_history_dailyinsulin">Inslin lá</string>
<string name="danar_dailyunits">Aonaid lá</string>
<string name="delta">Deilte</string>
<string name="sms_delta">Deilte:</string>
<string name="prefs_delta_title">Socruithe Deilte</string>
<string name="app_name">AndroidAPS</string>
<string name="bolus">Bólas</string>
<string name="bolusstopped">Bólas stopadh</string>
<string name="bolusstopping">Ag stopadh bólas</string>
<string name="bolusrequested">Ag dul a sheachadadh %.2fA</string>
<string name="combo_activity_setting_basal_profile">Socrú próifíl bunaidh</string>
<string name="combo_activity_checking_for_history_changes">Ag féachaint d\'athruithe stair</string>
<string name="combo_no_pump_connection">Níl nasc le haghaidh %d nóim</string>
<string name="combo_notification_check_time_date">Is nuashonrú gá clog Caidéil</string>
<string name="combo_programming_bolus">Cláir Caidéil bólas</string>
<string name="combo_pump_alerts">Foláirimh</string>
<string name="combo_pump_activity_label">Gníomhaíocht</string>
<string name="treatments_activity_string">Gníom.:</string>
<string name="activity">Gníomhaíocht</string>
<string name="activity_duration">Gníomhaíocht fad</string>
<string name="activity_target">Gníomhaíocht sprioc</string>
<string name="combo_warning">Rabhadh</string>
<string name="danar_history">Stair le Caidéil</string>
<string name="dev">GLÉ</string>
<string name="executing">Feidhmiú</string>
<string name="virtualpump_firmware_label">Firmware</string>
<string name="mdi">MDI</string>
<string name="nav_about">Faoi</string>
<string name="careportal_newnstreatment_absolute_label">Iomlán</string>
<string name="absolute">Iomlán</string>
<string name="nsprofileview_activeprofile_label">Próifíl gníomhach</string>
<string name="danar_history_alarm">Aláraim</string>
<string name="apsmode_title">APS mód</string>
<string name="apsselected">APS roghnaithe</string>
<string name="nsprofileview_basal_label">Bunaidh</string>
<string name="basal">Bunaidh</string>
<string name="danar_stats_basalrate">Bunaidh</string>
<string name="sms_basal">Bunaidh:</string>
<string name="basalshortlabel">BUN</string>
<string name="basal_short">BUN</string>
<string name="xdripstatus_shortname">xds</string>
<string name="sms_bolus">Bólas:</string>
<string name="danar_stats_bolus">Bólas</string>
<string name="overview_bolus_label">Bólas</string>
<string name="danar_ebolus">Bólas E</string>
<string name="overview_bolusprogress_goingtodeliver">Ag dul a sheachadadh %.2fA</string>
<string name="danar_dsbolus">Bólas DS</string>
<string name="danar_debolus">Bólas DE</string>
<string name="danar_sbolus">Bólas S</string>
<string name="smscommunicator_shortname">SMS</string>
<string name="nav_backup">Cúltaca</string>
<string name="basal_rate">Bunaidh ráta</string>
<string name="basal_step">Bunaidh Céim</string>
<string name="overview_newtempbasal_basaltype_label">Bunaidh cineál</string>
<string name="overview_newtempbasal_basalpercent">Bunaidh luach [%]</string>
<string name="overview_newtempbasal_basalabsolute">Bunaidh luach [A/u]</string>
<string name="pump_basebasalrate_label">Bunaidh ráta bonn</string>
<string name="base_profile_label">Próifíl bonn</string>
<string name="bolusdelivered">Seachadta %.2fA Bólas go rathúil</string>
<string name="smscommunicator_bolusdelivered">Seachadta %.2fA Bólas go rathúil</string>
<string name="bolus_step">Bólas Céim</string>
<string name="danar_history_bolus">Bólasi</string>
<string name="canceltemp">Cealú BRS</string>
<string name="smscommunicator_tempbasalcancelfailed">Cealú BRS teip</string>
</resources>

View file

@ -1458,6 +1458,7 @@
<string name="pump_no_connection_h">No connection for %1$d hour(s) %2$d min</string> <string name="pump_no_connection_h">No connection for %1$d hour(s) %2$d min</string>
<string name="pump_no_connection_d">No connection for %1$d day(s) %2$d hours</string> <string name="pump_no_connection_d">No connection for %1$d day(s) %2$d hours</string>
<plurals name="objective_days"> <plurals name="objective_days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item> <item quantity="other">%1$d days</item>

View file

@ -93,20 +93,18 @@ public class MedtronicPumpHistoryDecoderUTest {
@Test @Test
public void decodeDailyTotals515() { public void decodeDailyTotals515() {
byte[] data = new byte[] { byte[] data = ByteUtil
0x6E, (byte)0xB1, (byte)0x92, 0x05, 0x00, (byte)0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, (byte)0x9A, 0x00, .createByteArrayFromHexString("0x6C 0x17 0x93 0x06 0x08 0x00 0x2B 0x00 0x00 0x00 0x00 0x04 0x24 0x03 0x7C 0x54 0x00 0xA8 0x10 0x00 0x00 0x00 0xA8 0x10"
0x50, 0x34, 0x00, 0x4A, 0x30, 0x00, 0x0B, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x01, 0x00, 0x00, + " 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xA8 0x64 0x03 0x00 0x00");
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0x80, (byte)0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
// Carbs=11, total=3.850,basal=2.000, bolus=1.850, basal 52%, blus=48%, Manual=0.95, #manual=5, // 0x6C 0x17 0x93 0x06 0x08 0x00 0x2B 0x00 0x00 0x00 0x00 0x04 0x24 0x03 0x7C 0x54 0x00 0xA8 0x10 0x00 0x00 0x00
// Food only=0.9, #Food Only=1,Corr Only =0, #Corr only=0,Food+Corr=0 // 0xA8 0x10
// 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xA8 0x64 0x03 0x00 0x00
// Delivery Stats: Carbs=11, Total Insulin=3.850, Basal=2.000 // Delivery Stats: BG AVG: Bg Low/Hi=none,Number BGs=0
// Delivery Stats: Basal 52,Bolus 1.850, Bolus=48%o // Delivery Stats: INSULIN: Basal 22.30, Bolus=4.20, Catbs = 0g
// Delivery Stats: Food only=0.9, Food only#=1, Corr only = 0.0 // Delivery Stats: BOLUS: Food=0.00, Corr=0.00, Manual=4.20
// Delivery Stats: #Corr_only=0,Food+Corr=0.000, #Food+Corr=0 // Delivery Stats: NUM BOLUS: Food/Corr=0,Food+Corr=0, Manual=3
// Delivery Stats: Manual = 0.95, #Manual=5
testRecord(data); testRecord(data);
@ -145,6 +143,8 @@ public class MedtronicPumpHistoryDecoderUTest {
phe.setEntryType(entryType); phe.setEntryType(entryType);
phe.setData(ByteUtil.getListFromByteArray(data), false); phe.setData(ByteUtil.getListFromByteArray(data), false);
System.out.println("EntryType: " + entryType);
decoder.decodeRecord(phe); decoder.decodeRecord(phe);
System.out.println("Record: " + phe); System.out.println("Record: " + phe);