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
multiDexEnabled true
versionCode 1500
// dev_version: 2.0
version "medtronic-0.7.1-SNAPSHOT"
// dev_version: 2.0i
version "medtronic-0.7"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
@ -170,10 +170,10 @@ dependencies {
wearApp project(':wear')
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;
}
implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") {
implementation("com.crashlytics.sdk.android:answers:1.4.7@aar") {
transitive = true;
}
libs "MilosKozak:danars-support-lib:master@zip"

View file

@ -51,6 +51,10 @@
<activity
android:name=".plugins.Overview.Dialogs.ErrorHelperActivity"
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=".plugins.PumpDanaR.activities.DanaRHistoryActivity" />
<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.InsulinOrefUltraRapidActingPlugin;
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.Loop.LoopPlugin;
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.PumpInsightLocal.LocalInsightPlugin;
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.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
@ -119,6 +122,7 @@ public class MainApp extends Application {
public static boolean devBranch;
public static boolean engineeringMode;
@Override
public void onCreate() {
super.onCreate();
@ -160,7 +164,8 @@ public class MainApp extends Application {
// Register all tabs in app here
pluginsList.add(OverviewPlugin.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(InsulinOrefUltraRapidActingPlugin.getPlugin());
pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin());
@ -174,21 +179,32 @@ public class MainApp extends Application {
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
if (Config.PUMPDRIVERS && engineeringMode) pluginsList.add(LocalInsightPlugin.getInstance());
pluginsList.add(CareportalPlugin.getPlugin());
/*if (Config.PUMPDRIVERS && engineeringMode)
pluginsList.add(InsightPlugin.getPlugin());*/
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
if (Config.PUMPDRIVERS && engineeringMode) {
pluginsList.add(MedtronicPumpPlugin.getPlugin());
}
if (Config.PUMPDRIVERS)
pluginsList.add(ComboPlugin.getPlugin());
if (Config.MDI)
pluginsList.add(MDIPlugin.getPlugin());
pluginsList.add(VirtualPumpPlugin.getPlugin());
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin());
if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin());
if (Config.APS)
pluginsList.add(LoopPlugin.getPlugin());
if (Config.APS)
pluginsList.add(OpenAPSMAPlugin.getPlugin());
if (Config.APS)
pluginsList.add(OpenAPSAMAPlugin.getPlugin());
if (Config.APS)
pluginsList.add(OpenAPSSMBPlugin.getPlugin());
pluginsList.add(NSProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(LocalProfilePlugin.getPlugin());
if (Config.OTHERPROFILES)
pluginsList.add(SimpleProfilePlugin.getPlugin());
if (Config.OTHERPROFILES)
pluginsList.add(LocalProfilePlugin.getPlugin());
pluginsList.add(TreatmentsPlugin.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
if (Config.SAFETY)
pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS)
pluginsList.add(ObjectivesPlugin.getPlugin());
pluginsList.add(SourceXdripPlugin.getPlugin());
pluginsList.add(SourceNSClientPlugin.getPlugin());
pluginsList.add(SourceMM640gPlugin.getPlugin());
@ -298,11 +314,13 @@ public class MainApp extends Application {
}
}
public void stopKeepAliveService() {
if (keepAliveReceiver != null)
KeepAliveReceiver.cancelAlarm(this);
}
public static void subscribe(Object subscriber) {
try {
bus().register(subscriber);
@ -311,6 +329,7 @@ public class MainApp extends Application {
}
}
public static void unsubscribe(Object subscriber) {
try {
bus().unregister(subscriber);
@ -319,34 +338,42 @@ public class MainApp extends Application {
}
}
public static Bus bus() {
return sBus;
}
public static String gs(int id) {
return sResources.getString(id);
}
public static String gs(int id, Object... args) {
return sResources.getString(id, args);
}
public static String gq(@PluralsRes int id, int quantity, Object... args) {
return sResources.getQuantityString(id, quantity, args);
}
public static int gc(int id) {
return sResources.getColor(id);
}
public static MainApp instance() {
return sInstance;
}
public static DatabaseHelper getDbHelper() {
return sDatabaseHelper;
}
public static void closeDbHelper() {
if (sDatabaseHelper != null) {
sDatabaseHelper.close();
@ -354,14 +381,17 @@ public class MainApp extends Application {
}
}
public static ConstraintChecker getConstraintChecker() {
return sConstraintsChecker;
}
public static ArrayList<PluginBase> getPluginsList() {
return pluginsList;
}
public static ArrayList<PluginBase> getSpecificPluginsList(PluginType type) {
ArrayList<PluginBase> newList = new ArrayList<>();
@ -376,6 +406,7 @@ public class MainApp extends Application {
return newList;
}
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type) {
ArrayList<PluginBase> newList = new ArrayList<>();
@ -391,6 +422,7 @@ public class MainApp extends Application {
return newList;
}
public static ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass) {
ArrayList<PluginBase> newList = new ArrayList<>();
@ -405,6 +437,7 @@ public class MainApp extends Application {
return newList;
}
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type) {
ArrayList<PluginBase> newList = new ArrayList<>();
@ -420,12 +453,13 @@ public class MainApp extends Application {
return newList;
}
@Nullable
public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) {
if (pluginsList != null) {
for (PluginBase p : pluginsList) {
if (pluginClass.isAssignableFrom(p.getClass()))
return (T) p;
return (T)p;
}
} else {
log.error("pluginsList=null");
@ -433,6 +467,7 @@ public class MainApp extends Application {
return null;
}
public static boolean isEngineeringModeOrRelease() {
if (!Config.APS)
return true;
@ -449,6 +484,7 @@ public class MainApp extends Application {
return devBranch;
}
@Override
public void onTerminate() {
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.
*/
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
public static final String DATABASE_NAME = "AndroidAPSDb";
@ -111,12 +112,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private int oldVersion = 0;
private int newVersion = 0;
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
onCreate(getWritableDatabase(), getConnectionSource());
//onUpgrade(getWritableDatabase(), getConnectionSource(), 1,1);
}
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
@ -140,6 +143,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
try {
@ -172,20 +176,24 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
log.info("Do nothing for downgrading...");
log.debug("oldVersion: {}, newVersion: {}", oldVersion, newVersion);
}
public int getOldVersion() {
return oldVersion;
}
public int getNewVersion() {
return newVersion;
}
/**
* Close the database connections and clear any cached DAOs.
*/
@ -199,6 +207,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return DatabaseUtils.queryNumEntries(getReadableDatabase(), database);
}
// --------------------- DB resets ---------------------
public void resetDatabases() {
@ -243,6 +252,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
);
}
public void resetTempTargets() {
try {
TableUtils.dropTable(connectionSource, TempTarget.class, true);
@ -253,6 +263,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryTargetChange();
}
public void resetTemporaryBasals() {
try {
TableUtils.dropTable(connectionSource, TemporaryBasal.class, true);
@ -265,6 +276,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryBasalChange();
}
public void resetExtededBoluses() {
try {
TableUtils.dropTable(connectionSource, ExtendedBolus.class, true);
@ -276,6 +288,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleExtendedBolusChange();
}
public void resetCareportalEvents() {
try {
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
@ -286,6 +299,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleCareportalEventChange();
}
public void resetProfileSwitch() {
try {
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
@ -296,6 +310,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleProfileSwitchChange();
}
public void resetTDDs() {
try {
TableUtils.dropTable(connectionSource, TDD.class, true);
@ -305,40 +320,49 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
// ------------------ getDao -------------------------------------------
private Dao<TempTarget, Long> getDaoTempTargets() throws SQLException {
return getDao(TempTarget.class);
}
private Dao<BgReading, Long> getDaoBgReadings() throws SQLException {
return getDao(BgReading.class);
}
private Dao<DanaRHistoryRecord, String> getDaoDanaRHistory() throws SQLException {
return getDao(DanaRHistoryRecord.class);
}
private Dao<TDD, String> getDaoTDD() throws SQLException {
return getDao(TDD.class);
}
private Dao<DbRequest, String> getDaoDbRequest() throws SQLException {
return getDao(DbRequest.class);
}
private Dao<TemporaryBasal, Long> getDaoTemporaryBasal() throws SQLException {
return getDao(TemporaryBasal.class);
}
private Dao<ExtendedBolus, Long> getDaoExtendedBolus() throws SQLException {
return getDao(ExtendedBolus.class);
}
private Dao<CareportalEvent, Long> getDaoCareportalEvents() throws SQLException {
return getDao(CareportalEvent.class);
}
private Dao<ProfileSwitch, Long> getDaoProfileSwitch() throws SQLException {
return getDao(ProfileSwitch.class);
}
@ -362,7 +386,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
log.debug("Rounding " + date + " to " + rounded);
return rounded;
}
// ------------------- BgReading handling -----------------------
// ------------------- BgReading handling -----------------------
public boolean createIfNotExists(BgReading bgReading, String from) {
try {
@ -391,6 +417,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false;
}
public void update(BgReading bgReading) {
bgReading.date = roundDateToSec(bgReading.date);
try {
@ -400,8 +427,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
private static void scheduleBgChange(@Nullable final BgReading bgReading) {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(L.DATABASE))
log.debug("Firing EventNewBg");
@ -419,6 +448,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
/*
* Return last BgReading from database or null if db is empty
*/
@ -444,6 +474,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
/*
* Return bg reading if not old ( <9 min )
* or null if older
@ -479,6 +510,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<BgReading>();
}
public List<BgReading> getBgreadingsDataFromTime(long start, long end, boolean ascending) {
try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
@ -496,6 +528,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<BgReading>();
}
public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
@ -513,7 +546,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<BgReading>();
}
// ------------------- TDD handling -----------------------
// ------------------- TDD handling -----------------------
public void createOrUpdateTDD(TDD tdd) {
try {
Dao<TDD, String> dao = getDaoTDD();
@ -524,6 +558,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public List<TDD> getTDDs() {
List<TDD> tddList;
try {
@ -574,6 +609,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public int delete(DbRequest dbr) {
try {
return getDaoDbRequest().delete(dbr);
@ -583,6 +619,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return 0;
}
public int deleteDbRequest(String nsClientId) {
try {
return getDaoDbRequest().deleteById(nsClientId);
@ -592,6 +629,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return 0;
}
public void deleteDbRequestbyMongoId(String action, String id) {
try {
QueryBuilder<DbRequest, String> queryBuilder = getDaoDbRequest().queryBuilder();
@ -608,6 +646,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public void deleteAllDbRequests() {
try {
TableUtils.clearTable(connectionSource, DbRequest.class);
@ -616,6 +655,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public CloseableIterator getDbRequestInterator() {
try {
return getDaoDbRequest().closeableIterator();
@ -625,7 +665,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
// -------------------- TREATMENT HANDLING -------------------
// -------------------- TREATMENT HANDLING -------------------
public static void updateEarliestDataChange(long newDate) {
if (earliestDataChange == null) {
@ -637,6 +678,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
// ---------------- TempTargets handling ---------------
public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) {
@ -656,6 +698,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<TempTarget>();
}
public boolean createOrUpdate(TempTarget tempTarget) {
try {
TempTarget old;
@ -714,6 +757,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false;
}
public void delete(TempTarget tempTarget) {
try {
getDaoTempTargets().delete(tempTarget);
@ -723,8 +767,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
private static void scheduleTemporaryTargetChange() {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(L.DATABASE))
log.debug("Firing EventTempTargetChange");
@ -742,20 +788,21 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
/*
{
"_id": "58795998aa86647ba4d68ce7",
"enteredBy": "",
"eventType": "Temporary Target",
"reason": "Eating Soon",
"targetTop": 80,
"targetBottom": 80,
"duration": 120,
"created_at": "2017-01-13T22:50:00.782Z",
"carbs": null,
"insulin": null
}
*/
/*
* {
* "_id": "58795998aa86647ba4d68ce7",
* "enteredBy": "",
* "eventType": "Temporary Target",
* "reason": "Eating Soon",
* "targetTop": 80,
* "targetBottom": 80,
* "duration": 120,
* "created_at": "2017-01-13T22:50:00.782Z",
* "carbs": null,
* "insulin": null
* }
*/
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
try {
@ -774,6 +821,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public void deleteTempTargetById(String _id) {
TempTarget stored = findTempTargetById(_id);
if (stored != null) {
@ -783,6 +831,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public TempTarget findTempTargetById(String _id) {
try {
QueryBuilder<TempTarget, Long> queryBuilder = getDaoTempTargets().queryBuilder();
@ -802,6 +851,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
// ----------------- DanaRHistory handling --------------------
public void createOrUpdate(DanaRHistoryRecord record) {
@ -818,6 +868,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) {
List<DanaRHistoryRecord> historyList;
try {
@ -835,6 +886,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return historyList;
}
public void updateDanaRHistoryRecordId(JSONObject trJson) {
try {
QueryBuilder<DanaRHistoryRecord, String> queryBuilder = getDaoDanaRHistory().queryBuilder();
@ -860,6 +912,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
// ------------ TemporaryBasal handling ---------------
//return true if new record was created
@ -953,6 +1006,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false;
}
public void delete(TemporaryBasal tempBasal) {
try {
getDaoTemporaryBasal().delete(tempBasal);
@ -963,6 +1017,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryBasalChange();
}
public List<TemporaryBasal> getTemporaryBasalsDataFromTime(long mills, boolean ascending) {
try {
List<TemporaryBasal> tempbasals;
@ -979,8 +1034,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<TemporaryBasal>();
}
private static void scheduleTemporaryBasalChange() {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(L.DATABASE))
log.debug("Firing EventTempBasalChange");
@ -1002,6 +1059,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
/*
{
"_id": "59232e1ddd032d04218dab00",
@ -1074,6 +1132,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public void deleteTempBasalById(String _id) {
TemporaryBasal stored = findTempBasalById(_id);
if (stored != null) {
@ -1085,6 +1144,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public TemporaryBasal findTempBasalById(String _id) {
try {
QueryBuilder<TemporaryBasal, Long> queryBuilder = null;
@ -1105,6 +1165,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
// ------------ ExtendedBolus handling ---------------
public boolean createOrUpdate(ExtendedBolus extendedBolus) {
@ -1222,6 +1283,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleExtendedBolusChange();
}
public List<ExtendedBolus> getExtendedBolusDataFromTime(long mills, boolean ascending) {
try {
List<ExtendedBolus> extendedBoluses;
@ -1238,6 +1300,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<ExtendedBolus>();
}
public void deleteExtendedBolusById(String _id) {
ExtendedBolus stored = findExtendedBolusById(_id);
if (stored != null) {
@ -1249,6 +1312,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public ExtendedBolus findExtendedBolusById(String _id) {
try {
QueryBuilder<ExtendedBolus, Long> queryBuilder = null;
@ -1269,6 +1333,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
/*
{
"_id": "5924898d577eb0880e355337",
@ -1292,8 +1357,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
createOrUpdate(extendedBolus);
}
private static void scheduleExtendedBolusChange() {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(L.DATABASE))
log.debug("Firing EventExtendedBolusChange");
@ -1327,6 +1394,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleCareportalEventChange();
}
public void delete(CareportalEvent careportalEvent) {
try {
getDaoCareportalEvents().delete(careportalEvent);
@ -1336,6 +1404,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleCareportalEventChange();
}
public CareportalEvent getCareportalEventFromTimestamp(long timestamp) {
try {
return getDaoCareportalEvents().queryForId(timestamp);
@ -1345,6 +1414,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
@Nullable
public CareportalEvent getLastCareportalEvent(String event) {
try {
@ -1366,6 +1436,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
public List<CareportalEvent> getCareportalEventsFromTime(long mills, boolean ascending) {
try {
List<CareportalEvent> careportalEvents;
@ -1383,6 +1454,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>();
}
public void preprocessOpenAPSOfflineEvents(List<CareportalEvent> list) {
OverlappingIntervals offlineEvents = new OverlappingIntervals();
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) {
try {
List<CareportalEvent> careportalEvents;
@ -1410,6 +1483,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>();
}
public List<CareportalEvent> getCareportalEvents(boolean ascending) {
try {
List<CareportalEvent> careportalEvents;
@ -1425,6 +1499,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>();
}
public void deleteCareportalEventById(String _id) {
try {
QueryBuilder<CareportalEvent, Long> queryBuilder;
@ -1448,6 +1523,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public void createCareportalEventFromJsonIfNotExists(JSONObject trJson) {
try {
QueryBuilder<CareportalEvent, Long> queryBuilder;
@ -1481,8 +1557,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
private static void scheduleCareportalEventChange() {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(L.DATABASE))
log.debug("Firing scheduleCareportalEventChange");
@ -1500,6 +1578,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
// ---------------- ProfileSwitch handling ---------------
public List<ProfileSwitch> getProfileSwitchData(boolean ascending) {
@ -1518,6 +1597,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>();
}
public List<ProfileSwitch> getProfileSwitchEventsFromTime(long mills, boolean ascending) {
try {
Dao<ProfileSwitch, Long> daoProfileSwitch = getDaoProfileSwitch();
@ -1536,6 +1616,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>();
}
public boolean createOrUpdate(ProfileSwitch profileSwitch) {
try {
ProfileSwitch old;
@ -1597,6 +1678,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return false;
}
public void delete(ProfileSwitch profileSwitch) {
try {
getDaoProfileSwitch().delete(profileSwitch);
@ -1606,8 +1688,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
private static void scheduleProfileSwitchChange() {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(L.DATABASE))
log.debug("Firing EventProfileSwitchChange");
@ -1690,6 +1774,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public void deleteProfileSwitchById(String _id) {
ProfileSwitch stored = findProfileSwitchById(_id);
if (stored != null) {
@ -1700,6 +1785,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
public ProfileSwitch findProfileSwitchById(String _id) {
try {
QueryBuilder<ProfileSwitch, Long> queryBuilder = getDaoProfileSwitch().queryBuilder();

View file

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

View file

@ -91,7 +91,7 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
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.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) {
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.PluginType;
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.CustomActionType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@ -76,7 +77,7 @@ import info.nightscout.utils.SP;
*/
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;
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 gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
.setPrettyPrinting().create();
.setPrettyPrinting().create();
private MedtronicPumpPlugin() {
super(new PluginDescription() //
.mainType(PluginType.PUMP) //
.fragmentClass(MedtronicFragment.class.getName()) //
.pluginName(R.string.medtronic_name) //
.shortName(R.string.medtronic_name_short) //
.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
.mainType(PluginType.PUMP) //
.fragmentClass(MedtronicFragment.class.getName()) //
.pluginName(R.string.medtronic_name) //
.shortName(R.string.medtronic_name_short) //
.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
);
// TODO remove this later
@ -129,7 +130,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
public void onServiceConnected(ComponentName name, IBinder service) {
if (isLoggingEnabled())
LOG.debug("RileyLinkMedtronicService is connected");
RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder)service;
RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder) service;
medtronicService = mLocalBinder.getServiceInstance();
new Thread(() -> {
@ -218,7 +219,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (this.isInitialized) {
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(
StatusRefreshAction.GetData, null, null);
StatusRefreshAction.GetData, null, null);
if (doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Scheduled Status Refresh", null);
@ -324,8 +325,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
RileyLinkServiceState rileyLinkServiceState = MedtronicUtil.getServiceState();
if (rileyLinkServiceState != RileyLinkServiceState.PumpConnectorReady //
&& rileyLinkServiceState != RileyLinkServiceState.RileyLinkReady //
&& rileyLinkServiceState != RileyLinkServiceState.TuneUpDevice) {
&& rileyLinkServiceState != RileyLinkServiceState.RileyLinkReady //
&& rileyLinkServiceState != RileyLinkServiceState.TuneUpDevice) {
if (isLoggingEnabled())
LOG.error("RileyLink unreachable.");
return false;
@ -338,7 +339,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private void refreshAnyStatusThatNeedsToBeRefreshed() {
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(StatusRefreshAction.GetData, null,
null);
null);
if (!doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
return;
@ -367,7 +368,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
case PumpHistory: {
readPumpHistory();
}
break;
break;
case PumpTime:
case BatteryStatus:
@ -376,13 +377,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
refreshTypesNeededToReschedule.add(refreshType.getKey());
resetTime = true;
}
break;
break;
case Configuration: {
medtronicUIComm.executeCommand(refreshType.getKey().getCommandType());
resetTime = true;
}
break;
break;
}
}
}
@ -498,9 +499,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
FabricPrivacy.getInstance().logCustom( //
new CustomEvent("MedtronicInitializePump") //
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) //
.putCustomAttribute("version", BuildConfig.VERSION));
new CustomEvent("MedtronicInitializePump") //
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) //
.putCustomAttribute("version", BuildConfig.VERSION));
isInitialized = true;
// this.pumpState = PumpDriverState.Initialized;
@ -525,7 +526,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// LOG.info("isThisProfileSet: check");
LOG.info("isThisProfileSet: check [basalProfileChanged={}, basalByHourSet={}, isBasalProfileInvalid={}",
basalProfileChanged, getMDTPumpStatus().basalsByHour != null, isBasalProfileInvalid);
basalProfileChanged, getMDTPumpStatus().basalsByHour != null, isBasalProfileInvalid);
if (!basalProfileChanged && getMDTPumpStatus().basalsByHour != null && !isBasalProfileInvalid) {
if (isLoggingEnabled())
@ -601,7 +602,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (isLoggingEnabled())
LOG.debug("Current Basals (h): "
+ (basalsByHour == null ? "null" : BasalProfile.getProfilesByHourToString(basalsByHour)));
+ (basalsByHour == null ? "null" : BasalProfile.getProfilesByHourToString(basalsByHour)));
int index = 0;
@ -733,9 +734,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery");
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
detailedBolusInfo.insulin);
detailedBolusInfo.insulin);
Boolean response = (Boolean)responseTask.returnData;
Boolean response = (Boolean) responseTask.returnData;
setRefreshButtonEnabled(true);
@ -769,18 +770,18 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin;
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
: MedtronicConst.Statistics.StandardBoluses);
: MedtronicConst.Statistics.StandardBoluses);
return new PumpEnactResult().success(response) //
.enacted(response) //
.bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs);
.enacted(response) //
.bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs);
} else {
return new PumpEnactResult() //
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
}
} finally {
@ -800,13 +801,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (success) {
return new PumpEnactResult() //
.success(true) //
.enacted(false);
.success(true) //
.enacted(false);
} else {
return new PumpEnactResult() //
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
.success(false) //
.enacted(false) //
.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
@Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
boolean enforceNew) {
boolean enforceNew) {
setRefreshButtonEnabled(false);
@ -840,9 +841,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true);
return new PumpEnactResult() //
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
}
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.");
finishAction("TBR");
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 {
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
}
if (!enforceNew) {
@ -896,7 +897,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
Boolean response = (Boolean)responseTask2.returnData;
Boolean response = (Boolean) responseTask2.returnData;
if (response) {
if (isLoggingEnabled())
@ -908,15 +909,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
finishAction("TBR");
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
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal,
absoluteRate, durationInMinutes);
absoluteRate, durationInMinutes);
Boolean response = (Boolean)responseTask.returnData;
Boolean response = (Boolean) responseTask.returnData;
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response);
@ -928,10 +929,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
pumpStatusLocal.tempBasalLength = durationInMinutes;
TemporaryBasal tempStart = new TemporaryBasal() //
.date(System.currentTimeMillis()) //
.duration(durationInMinutes) //
.absolute(absoluteRate) //
.source(Source.USER);
.date(System.currentTimeMillis()) //
.duration(durationInMinutes) //
.absolute(absoluteRate) //
.source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
@ -940,13 +941,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
finishAction("TBR");
return new PumpEnactResult().success(response).enacted(response) //
.absolute(absoluteRate).duration(durationInMinutes);
.absolute(absoluteRate).duration(durationInMinutes);
} else {
finishAction("TBR");
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
&& medtronicHistoryData.hasBasalProfileChanged()) {
&& medtronicHistoryData.hasBasalProfileChanged()) {
medtronicHistoryData.processLastBasalProfileChange(getMDTPumpStatus());
// this.basalProfileChanged = true;
}
@ -1007,10 +1008,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
processTDDs(tdds);
}
List<PumpHistoryEntry> tdds2 = medtronicHistoryData.getTDDs2();
// FIXME
LOG.debug("TDDs2: {}", gsonInstancePretty.toJson(tdds2));
// List<PumpHistoryEntry> tdds2 = medtronicHistoryData.getTDDs2();
//
// // FIXME
// LOG.debug("TDDs2: {}", gsonInstancePretty.toJson(tdds2));
List<PumpHistoryEntry> treatments = medtronicHistoryData.getTreatments();
@ -1066,21 +1067,21 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (lastPumpHistoryEntryTime == 0L) {
if (isLoggingEnabled())
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: 0L - targetDate: "
+ targetDate);
+ targetDate);
targetDate = timeMinus36h;
} else {
// LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime);
if (isLoggingEnabled())
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: {} - targetDate: {}",
lastPumpHistoryEntryTime, targetDate);
lastPumpHistoryEntryTime, targetDate);
medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntryTime);
LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime);
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
if (timeMinus36h.isAfter(lastHistoryRecordTime)) {
@ -1095,7 +1096,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} else {
if (isLoggingEnabled())
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntry: not null - {}",
gsonInstancePretty.toJson(lastPumpHistoryEntry));
gsonInstancePretty.toJson(lastPumpHistoryEntry));
medtronicHistoryData.setIsInInit(false);
medtronicHistoryData.setLastHistoryRecordTime(null);
@ -1105,11 +1106,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.debug("HST: Target Date: {}", targetDate);
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,
lastPumpHistoryEntry, targetDate);
lastPumpHistoryEntry, targetDate);
LOG.debug("HST: After task");
PumpHistoryResult historyResult = (PumpHistoryResult)responseTask2.returnData;
PumpHistoryResult historyResult = (PumpHistoryResult) responseTask2.returnData;
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);
LOG.debug("HST: History: valid={}, unprocessed={}", historyResult.validEntries.size(),
historyResult.unprocessedEntries.size());
historyResult.unprocessedEntries.size());
this.medtronicHistoryData.addNewHistory(historyResult);
this.medtronicHistoryData.filterNewEntries();
@ -1173,15 +1174,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
workWithStatusRefresh(StatusRefreshAction.Add, refreshType, getTimeInFutureFromMinutes(min));
}
break;
break;
case PumpTime:
case Configuration:
case PumpHistory: {
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,
MedtronicStatusRefreshType statusRefreshType, Long time) {
MedtronicStatusRefreshType statusRefreshType, Long time) {
switch (action) {
@ -1230,7 +1231,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal);
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
if (tbr.getDurationMinutes() == 0) {
@ -1255,9 +1256,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true);
return new PumpEnactResult() //
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
}
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.");
finishAction("TBR");
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);
Boolean response = (Boolean)responseTask2.returnData;
Boolean response = (Boolean) responseTask2.returnData;
finishAction("TBR");
@ -1291,20 +1292,20 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
TemporaryBasal tempBasal = new TemporaryBasal() //
.date(System.currentTimeMillis()) //
.duration(0) //
.source(Source.USER);
.date(System.currentTimeMillis()) //
.duration(0) //
.source(Source.USER);
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
return new PumpEnactResult().success(response).enacted(response) //
.isTempCancel(true);
.isTempCancel(true);
} else {
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
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
if (isProfileSame(profile)) {
return new PumpEnactResult() //
.success(true) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
.success(true) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
}
setRefreshButtonEnabled(false);
@ -1329,9 +1330,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(true);
return new PumpEnactResult() //
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
}
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
@ -1342,15 +1343,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (profileInvalid != null) {
return new PumpEnactResult() //
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid));
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid));
}
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBasalProfileSTD,
basalProfile);
basalProfile);
Boolean response = (Boolean)responseTask.returnData;
Boolean response = (Boolean) responseTask.returnData;
if (isLoggingEnabled())
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);
} else {
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<>();
CustomAction ca = new CustomAction(R.string.medtronic_custom_action_wake_and_tune,
MedtronicCustomActionType.WakeUpAndTune);
MedtronicCustomActionType.WakeUpAndTune);
this.customActions.add(ca);
}
@ -1456,7 +1457,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
public PumpEnactResult executeCustomAction(CustomActionType customActionType) {
MedtronicCustomActionType mcat = (MedtronicCustomActionType)customActionType;
MedtronicCustomActionType mcat = (MedtronicCustomActionType) customActionType;
switch (mcat) {

View file

@ -465,7 +465,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// Bolus=1.7, Fodd, Corr, Manual=1.7,
// 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);
@ -487,6 +487,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
// }
//
// }
entry.addDecodedData("Object", totals);
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);
}

View file

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

View file

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

View file

@ -1,5 +1,10 @@
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.Collections;
import java.util.GregorianCalendar;
@ -7,11 +12,6 @@ import java.util.HashMap;
import java.util.List;
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.PumpMedtronic.MedtronicPumpPlugin;
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.data.dto.BasalProfile;
import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
//import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
@ -128,7 +129,7 @@ public class MedtronicHistoryData {
// FIXME not just 50 records, last 24 hours
public void finalizeNewHistoryRecords() {
List<PumpHistoryEntry> filteredListByLastRecord = getFilteredListByLastRecord((PumpHistoryEntryType)null);
List<PumpHistoryEntry> filteredListByLastRecord = getFilteredListByLastRecord((PumpHistoryEntryType) null);
LOG.debug("New records: " + filteredListByLastRecord.size());
@ -173,12 +174,12 @@ public class MedtronicHistoryData {
public boolean hasRelevantConfigurationChanged() {
return getStateFromFilteredList( //
PumpHistoryEntryType.ChangeBasalPattern, //
PumpHistoryEntryType.ClearSettings, //
PumpHistoryEntryType.SaveSettings, //
PumpHistoryEntryType.ChangeMaxBolus, //
PumpHistoryEntryType.ChangeMaxBasal, //
PumpHistoryEntryType.ChangeTempBasalType);
PumpHistoryEntryType.ChangeBasalPattern, //
PumpHistoryEntryType.ClearSettings, //
PumpHistoryEntryType.SaveSettings, //
PumpHistoryEntryType.ChangeMaxBolus, //
PumpHistoryEntryType.ChangeMaxBasal, //
PumpHistoryEntryType.ChangeTempBasalType);
}
@ -198,13 +199,13 @@ public class MedtronicHistoryData {
if (wasPumpSuspended == null) { // suspension status not known
List<PumpHistoryEntry> items = getFilteredItems(PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.PumpSuspend, //
PumpHistoryEntryType.PumpResume, //
PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BasalProfileStart);
PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.PumpSuspend, //
PumpHistoryEntryType.PumpResume, //
PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BasalProfileStart);
if (items.size() == 0)
return wasPumpSuspended == null ? false : wasPumpSuspended;
@ -212,20 +213,20 @@ public class MedtronicHistoryData {
PumpHistoryEntry pumpHistoryEntry = items.get(0);
return !(pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.TempBasalCombined || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume);
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume);
} else {
List<PumpHistoryEntry> items = getFilteredItems(PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.PumpSuspend, //
PumpHistoryEntryType.PumpResume, //
PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BasalProfileStart);
PumpHistoryEntryType.TempBasalCombined, //
PumpHistoryEntryType.Prime, //
PumpHistoryEntryType.PumpSuspend, //
PumpHistoryEntryType.PumpResume, //
PumpHistoryEntryType.Rewind, //
PumpHistoryEntryType.NoDeliveryAlarm, //
PumpHistoryEntryType.BasalProfileStart);
if (wasPumpSuspended) {
@ -235,9 +236,9 @@ public class MedtronicHistoryData {
PumpHistoryEntry pumpHistoryEntry = items.get(0);
if (pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.TempBasalCombined || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume)
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.BasalProfileStart || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Bolus || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpResume)
return false;
else
return true;
@ -250,8 +251,8 @@ public class MedtronicHistoryData {
PumpHistoryEntry pumpHistoryEntry = items.get(0);
if (pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.NoDeliveryAlarm || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpSuspend || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Prime)
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.PumpSuspend || //
pumpHistoryEntry.getEntryType() == PumpHistoryEntryType.Prime)
return true;
}
@ -266,16 +267,35 @@ public class MedtronicHistoryData {
public List<PumpHistoryEntry> getTDDs() {
return getFilteredListByLastRecord(PumpHistoryEntryType.EndResultTotals);
return getFilteredListByLastRecord(getTDDType());
}
// FIXME remove
public List<PumpHistoryEntry> getTDDs2() {
private PumpHistoryEntryType getTDDType() {
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() {
return getFilteredListByLastRecord( //
PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined);
PumpHistoryEntryType.Bolus, //
PumpHistoryEntryType.TempBasalCombined);
}
@ -373,7 +393,7 @@ public class MedtronicHistoryData {
if (newProfile != null) {
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();
}
@ -391,7 +411,7 @@ public class MedtronicHistoryData {
public boolean hasPumpTimeChanged() {
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 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.
*/
/**
* NOTE: Decoding is only done for insulin part, everything else is pretty must left undecoded.
*/
public class DailyTotalsDTO {
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,
// Bolus=1.7, Fodd, Corr, Manual=1.7,
// Num bOlus=1, food/corr, Food+corr, manual bolus=1
Double bgAvg;
Double bgLow;
Double bgHigh;
Integer bgCount;
private Double bgAvg;
private Double bgLow;
private Double bgHigh;
private Integer bgCount;
Double sensorAvg;
Double sensorMin;
Double sensorMax;
Integer sensorCalcCount;
Integer sensorDataCount;
private Double sensorAvg;
private Double sensorMin;
private Double sensorMax;
private Integer sensorCalcCount;
private Integer sensorDataCount;
Double insulinTotal;
Double insulinBasal;
Double insulinBolus;
Double insulinCarbs;
private Double insulinTotal;
private Double insulinBasal;
private Double insulinBolus;
private Double insulinCarbs;
Double bolusTotal;
Double bolusFood;
Double bolusFoodAndCorr;
Double bolusCorrection;
Double bolusManual;
private Double bolusTotal;
private Double bolusFood;
private Double bolusFoodAndCorr;
private Double bolusCorrection;
private Double bolusManual;
Integer bolusCount;
Integer bolusCountFoodOrCorr;
private Integer bolusCount;
private Integer bolusCountFoodOrCorr;
// Integer bolusCountCorr;
Integer bolusCountFoodAndCorr;
Integer bolusCountManual;
private Integer bolusCountFood;
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:
decodeDailyTotals515(data);
decodeDailyTotals515(entry.getBody());
break;
case DailyTotals522:
decodeDailyTotals522(data);
decodeDailyTotals522(entry.getBody());
break;
case DailyTotals523:
decodeDailyTotals523(data);
decodeDailyTotals523(entry.getBody());
break;
default:
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) {
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"?>
<!--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_d">No connection for %1$d day(s) %2$d hours</string>
<plurals name="objective_days">
<item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item>

View file

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