redundant code cleanup

This commit is contained in:
Milos Kozak 2016-12-24 14:13:35 +01:00
parent 7719e2ac63
commit 79aee157e3
31 changed files with 62 additions and 919 deletions

View file

@ -15,7 +15,7 @@ public class Config {
public static final boolean SMSCOMMUNICATORENABLED = true;
public static final boolean DANAR = true && BuildConfig.PUMPDRIVERS;
public static final boolean DANARKOREAN = false && BuildConfig.PUMPDRIVERS;
public static final boolean DANARKOREAN = true && BuildConfig.PUMPDRIVERS;
public static final boolean detailedLog = true;
public static final boolean logFunctionCalls = true;

View file

@ -166,10 +166,8 @@ public class DanaRHistoryActivity extends Activity {
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BOLUS, getString(R.string.danar_history_bolus)));
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, getString(R.string.danar_history_carbohydrates)));
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, getString(R.string.danar_history_dailyinsulin)));
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, getString(R.string.danar_history_errors)));
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, getString(R.string.danar_history_glucose)));
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, getString(R.string.danar_history_refill)));
typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, getString(R.string.danar_history_syspend)));
ArrayAdapter<TypeList> spinnerAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, typeList);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

View file

@ -32,37 +32,37 @@ import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.plugins.DanaR.comm.*;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryAlarm;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryBasalHour;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryBolus;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryCarbo;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryDailyInsulin;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryDone;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryError;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryGlucose;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryRefill;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistorySuspend;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgPCCommStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgPCCommStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetCarbsEntry;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetSingleBasalProfile;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
import info.nightscout.androidaps.plugins.DanaRKorean.SerialIOThread;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.*;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgBolusProgress;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgBolusStop;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgCheckValue;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryAlarm;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryBasalHour;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryBolus;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryCarbo;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryDailyInsulin;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryDone;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryError;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryGlucose;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistoryRefill;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgHistorySuspend;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgPCCommStart;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgPCCommStop;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetCarbsEntry;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetExtendedBolusStart;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetExtendedBolusStop;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetSingleBasalProfile;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetTempBasalStart;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetTempBasalStop;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSetTime;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingBasal;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingGlucose;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingMaxValues;

View file

@ -5,7 +5,27 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
import info.nightscout.androidaps.plugins.DanaR.comm.*;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgError;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryAlarm;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryAll;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryBolus;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryCarbo;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryDailyInsulin;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryGlucose;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryNew;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryNewDone;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgPCCommStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgPCCommStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetCarbsEntry;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetSingleBasalProfile;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStop;
/**
* Created by mike on 28.05.2016.
@ -41,12 +61,7 @@ public class MessageHashTable {
put(new MsgHistoryDailyInsulin()); // 0x3102 CMD_HISTORY_DAY_INS
put(new MsgHistoryGlucose()); // 0x3104 CMD_HISTORY_GLUCOSE
put(new MsgHistoryAlarm()); // 0x3105 CMD_HISTORY_ALARM
put(new MsgHistoryError()); // 0x3106 CMD_HISTORY_ERROR
put(new MsgHistoryCarbo()); // 0x3107 CMD_HISTORY_CARBOHY
put(new MsgHistoryRefill()); // 0x3108 CMD_HISTORY_REFILL
put(new MsgHistorySuspend()); // 0x3109 CMD_HISTORY_SUSPEND
put(new MsgHistoryBasalHour()); // 0x310A CMD_HISTORY_BASAL_HOUR
put(new MsgHistoryDone()); // 0x31F1 CMD_HISTORY_DONT_USED
put(new MsgSettingBasal()); // 0x3202 CMD_SETTING_V_BASAL_INS_I
put(new MsgSettingMeal()); // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
put(new MsgSettingProfileRatios()); // 0x3204 CMD_SETTING_V_CCC_I

View file

@ -1,51 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import com.squareup.otto.Bus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
public class MsgBolusProgress extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusProgress.class);
private static Bus bus = null;
private static Treatment t;
private static double amount;
public int progress = -1;
public MsgBolusProgress() {
SetCommand(0x0202);
}
public MsgBolusProgress(Bus bus, double amount, Treatment t) {
this();
this.amount = amount;
this.t = t;
this.bus = bus;
}
@Override
public void handleMessage(byte[] bytes) {
progress = intFromBuff(bytes, 0, 2);
Double done = (amount * 100 - progress) / 100d;
t.insulin = done;
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), done);
bolusingEvent.t = t;
bolusingEvent.percent = Math.min((int) (done / amount * 100), 100);
if (Config.logDanaMessageDetail) {
log.debug("Bolus remaining: " + progress + " delivered: " + done);
}
bus.post(bolusingEvent);
}
}

View file

@ -1,40 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class);
public MsgBolusStart() {
SetCommand(0x0102);
}
public MsgBolusStart(double amount) {
this();
// HARDCODED LIMIT
amount = MainApp.getConfigBuilder().applyBolusConstraints(amount);
if (amount < 0) amount = 0d;
if (amount > BuildConfig.MAXBOLUS) amount = BuildConfig.MAXBOLUS;
AddParamInt((int) (amount * 100));
}
@Override
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 2) {
failed = true;
log.debug("Messsage response: " + result + " FAILED!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Messsage response: " + result);
}
}
}

View file

@ -1,49 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import com.squareup.otto.Bus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
public class MsgBolusStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStop.class);
private static Treatment t;
private static Double amount;
private static Bus bus = null;
public static boolean stopped = false;
public static boolean forced = false;
public MsgBolusStop() {
SetCommand(0x0101);
stopped = false;
}
public MsgBolusStop(Bus bus, Double amount, Treatment t) {
this();
this.bus = bus;
this.t = t;
this.amount = amount;
forced = false;
}
@Override
public void handleMessage(byte[] bytes) {
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
stopped = true;
if (!forced) {
t.insulin = amount;
bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_delivered);
bolusingEvent.percent = 100;
} else {
bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusprogress_stoped);
}
bus.post(bolusingEvent);
}
}

View file

@ -1,52 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
public class MsgError extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgError.class);
public MsgError() {
SetCommand(0x0601);
}
@Override
public void handleMessage(byte[] bytes) {
int errorCode = intFromBuff(bytes, 0, 1);
String errorString = "";
switch (errorCode) {
case 1:
case 2:
case 3: // Pump error
errorString = MainApp.sResources.getString(R.string.pumperror) + " " + errorCode;
break;
case 4: // Shutdown
errorString = MainApp.sResources.getString(R.string.pumpshutdown);
break;
case 5: // Occlusion
errorString = MainApp.sResources.getString(R.string.occlusion);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
MsgBolusStop.stopped = true;
bolusingEvent.status = errorString;
MainApp.bus().post(bolusingEvent);
break;
case 7: // Low Battery
errorString = MainApp.sResources.getString(R.string.lowbattery);
break;
case 8: // Battery 0%
errorString = MainApp.sResources.getString(R.string.batterydischarged);
break;
}
if (Config.logDanaMessageDetail)
log.debug("Error detected: " + errorString);
MainApp.getConfigBuilder().uploadError(errorString);
}
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryAlarm extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryAlarm.class);
public MsgHistoryAlarm() {
SetCommand(0x3105);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,162 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import com.j256.ormlite.dao.Dao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
public class MsgHistoryAll extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgHistoryAll.class);
public MsgHistoryAll() {
SetCommand(0x41F2);
}
@Override
public void handleMessage(byte[] bytes) {
byte recordCode = (byte) intFromBuff(bytes, 0, 1);
Date date = dateFromBuff(bytes, 1); // 3 bytes
Date datetime = dateTimeFromBuff(bytes, 1); // 5 bytes
Date datetimewihtsec = dateTimeSecFromBuff(bytes, 1); // 6 bytes
double dailyBasal = intFromBuff(bytes, 4, 2) * 0.01d;
double dailyBolus = intFromBuff(bytes, 6, 2) * 0.01d;
byte paramByte5 = (byte) intFromBuff(bytes, 4, 1);
byte paramByte6 = (byte) intFromBuff(bytes, 5, 1);
byte paramByte7 = (byte) intFromBuff(bytes, 6, 1);
byte paramByte8 = (byte) intFromBuff(bytes, 7, 1);
double value = (double) intFromBuff(bytes, 8, 2);
EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
DanaRHistoryRecord danaRHistoryRecord = new DanaRHistoryRecord();
danaRHistoryRecord.setRecordCode(recordCode);
danaRHistoryRecord.setBytes(bytes);
String messageType = "";
switch (recordCode) {
case RecordTypes.RECORD_TYPE_BOLUS:
danaRHistoryRecord.setRecordDate(datetime);
switch (0xF0 & paramByte8) {
case 0xA0:
danaRHistoryRecord.setBolusType("DS");
messageType += "DS bolus";
break;
case 0xC0:
danaRHistoryRecord.setBolusType("E");
messageType += "E bolus";
break;
case 0x80:
danaRHistoryRecord.setBolusType("S");
messageType += "S bolus";
break;
case 0x90:
danaRHistoryRecord.setBolusType("DE");
messageType += "DE bolus";
break;
default:
danaRHistoryRecord.setBolusType("None");
break;
}
danaRHistoryRecord.setRecordDuration(((int) paramByte8 & 0x0F) * 60 + (int) paramByte7);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_DAILY:
messageType += "dailyinsulin";
danaRHistoryRecord.setRecordDate(date);
danaRHistoryRecord.setRecordDailyBasal(dailyBasal);
danaRHistoryRecord.setRecordDailyBolus(dailyBolus);
break;
case RecordTypes.RECORD_TYPE_PRIME:
messageType += "prime";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_ERROR:
messageType += "error";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_REFILL:
messageType += "refill";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_BASALHOUR:
messageType += "basal hour";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_TB:
messageType += "tb";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_GLUCOSE:
messageType += "glucose";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value);
break;
case RecordTypes.RECORD_TYPE_CARBO:
messageType += "carbo";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
danaRHistoryRecord.setRecordValue(value);
break;
case RecordTypes.RECORD_TYPE_ALARM:
messageType += "alarm";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
String strAlarm = "None";
switch ((int) paramByte8) {
case 67:
strAlarm = "Check";
break;
case 79:
strAlarm = "Occlusion";
break;
case 66:
strAlarm = "Low Battery";
break;
case 83:
strAlarm = "Shutdown";
break;
}
danaRHistoryRecord.setRecordAlarm(strAlarm);
danaRHistoryRecord.setRecordValue(value * 0.01);
break;
case RecordTypes.RECORD_TYPE_SUSPEND:
messageType += "suspend";
danaRHistoryRecord.setRecordDate(datetimewihtsec);
String strRecordValue = "Off";
if ((int) paramByte8 == 79)
strRecordValue = "On";
danaRHistoryRecord.setStringRecordValue(strRecordValue);
break;
}
try {
Dao<DanaRHistoryRecord, String> daoHistoryRecords = MainApp.getDbHelper().getDaoDanaRHistory();
daoHistoryRecords.createIfNotExists(danaRHistoryRecord);
} catch (SQLException e) {
log.error(e.getMessage(), e);
}
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
ev.message = df.format(new Date(danaRHistoryRecord.getRecordDate()));
ev.message += " " + messageType;
MainApp.bus().post(ev);
return;
}
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryBasalHour extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryBasalHour.class);
public MsgHistoryBasalHour() {
SetCommand(0x310A);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryBolus extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryBolus.class);
public MsgHistoryBolus() {
SetCommand(0x3101);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryCarbo extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryCarbo.class);
public MsgHistoryCarbo() {
SetCommand(0x3107);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryDailyInsulin extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryDailyInsulin.class);
public MsgHistoryDailyInsulin() {
SetCommand(0x3102);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,28 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryDone extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgHistoryDone.class);
public static boolean received = false;
public MsgHistoryDone() {
SetCommand(0x31F1);
received = false;
}
@Override
public void handleMessage(byte[] bytes) {
received = true;
if (Config.logDanaMessageDetail)
log.debug("History done received");
}
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryError extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryError.class);
public MsgHistoryError() {
SetCommand(0x3106);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryGlucose extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryGlucose.class);
public MsgHistoryGlucose() {
SetCommand(0x3104);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryNew extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryNew.class);
public MsgHistoryNew() {
SetCommand(0x42F2);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,27 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryNewDone extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgHistoryNewDone.class);
public static boolean received = false;
public MsgHistoryNewDone() {
SetCommand(0x42F1);
received = false;
}
@Override
public void handleMessage(byte[] bytes) {
received = true;
if (Config.logDanaMessageDetail)
log.debug("History new done received");
}
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistoryRefill extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistoryRefill.class);
public MsgHistoryRefill() {
SetCommand(0x3108);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 20.07.2016.
*/
public class MsgHistorySuspend extends MsgHistoryAll {
private static Logger log = LoggerFactory.getLogger(MsgHistorySuspend.class);
public MsgHistorySuspend() {
SetCommand(0x3109);
}
// Handle message taken from MsgHistoryAll
}

View file

@ -1,20 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgPCCommStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgPCCommStart.class);
public MsgPCCommStart() {
SetCommand(0x3001);
}
@Override
public void handleMessage(byte[] bytes) {
if (Config.logDanaMessageDetail)
log.debug("PC comm start received");
}
}

View file

@ -1,20 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgPCCommStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgPCCommStop.class);
public MsgPCCommStop() {
SetCommand(0x3002);
}
@Override
public void handleMessage(byte[] bytes) {
if (Config.logDanaMessageDetail)
log.debug("PC comm stop received");
}
}

View file

@ -1,46 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Calendar;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
public class MsgSetCarbsEntry extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetCarbsEntry.class);
public MsgSetCarbsEntry() {
SetCommand(0x0402);
}
public MsgSetCarbsEntry(Calendar time, int amount) {
this();
AddParamByte((byte) RecordTypes.RECORD_TYPE_CARBO);
AddParamByte((byte) (time.get(Calendar.YEAR) % 100));
AddParamByte((byte) (time.get(Calendar.MONTH) + 1));
AddParamByte((byte) (time.get(Calendar.DAY_OF_MONTH)));
AddParamByte((byte) (time.get(Calendar.HOUR_OF_DAY)));
AddParamByte((byte) (time.get(Calendar.MINUTE)));
AddParamByte((byte) (time.get(Calendar.SECOND)));
AddParamByte((byte) 0x43); //??
AddParamInt(amount);
if (Config.logDanaMessageDetail)
log.debug("Set carb entry: " + amount + " date " + time.toString());
}
@Override
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set carb entry result: " + result + " FAILED!!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Set carb entry result: " + result);
}
}
}

View file

@ -1,44 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgSetExtendedBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStart.class);
public MsgSetExtendedBolusStart() {
SetCommand(0x0407);
}
public MsgSetExtendedBolusStart(double amount, byte halfhours) {
this();
// HARDCODED LIMITS
if (halfhours < 1) halfhours = 1;
if (halfhours > 16) halfhours = 16;
amount = MainApp.getConfigBuilder().applyBolusConstraints(amount);
if (amount < 0d) amount = 0d;
if (amount > 10d) amount = 10d;
AddParamInt((int) (amount * 100));
AddParamByte(halfhours);
if (Config.logDanaMessageDetail)
log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours);
}
@Override
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set extended bolus start result: " + result + " FAILED!!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Set extended bolus start result: " + result);
}
}
}

View file

@ -1,31 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgSetExtendedBolusStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetExtendedBolusStop.class);
public MsgSetExtendedBolusStop() {
SetCommand(0x0406);
if (Config.logDanaMessageDetail)
log.debug("Set extended bolus stop");
}
@Override
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set extended bolus stop result: " + result + " FAILED!!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Set extended bolus stop result: " + result);
}
}
}

View file

@ -1,47 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
public class MsgSetSingleBasalProfile extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class);
public MsgSetSingleBasalProfile() {
SetCommand(0x3302);
}
// index 0-3
public MsgSetSingleBasalProfile(double[] values) {
this();
for (Integer i = 0; i < 24; i++) {
AddParamInt((int) (values[i] * 100));
}
if (Config.logDanaMessageDetail)
log.debug("Set basal profile");
}
@Override
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set basal profile result: " + result + " FAILED!!!");
Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.sResources.getString(R.string.profile_set_failed), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(reportFail));
} else {
if (Config.logDanaMessageDetail)
log.debug("Set basal profile result: " + result);
Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(reportOK));
}
}
}

View file

@ -1,44 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgSetTempBasalStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStart.class);
public MsgSetTempBasalStart() {
SetCommand(0x0401);
}
public MsgSetTempBasalStart(int percent, int durationInHours) {
this();
//HARDCODED LIMITS
if (percent < 0) percent = 0;
if (percent > 200) percent = 200;
if (durationInHours < 1) durationInHours = 1;
if (durationInHours > 24) durationInHours = 24;
AddParamByte((byte) (percent & 255));
AddParamByte((byte) (durationInHours & 255));
if (Config.logDanaMessageDetail)
log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours);
}
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set temp basal start result: " + result + " FAILED!!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Set temp basal start result: " + result);
}
}
}

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
public class MsgSetTempBasalStop extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetTempBasalStop.class);
public MsgSetTempBasalStop() {
SetCommand(0x0403);
if (Config.logDanaMessageDetail)
log.debug("Temp basal stop");
}
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (result != 1) {
failed = true;
log.debug("Set temp basal stop result: " + result + " FAILED!!!");
} else {
if (Config.logDanaMessageDetail)
log.debug("Set temp basal stop result: " + result);
}
}
}

View file

@ -1,29 +0,0 @@
package info.nightscout.androidaps.plugins.DanaRKorean.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
/**
* Created by mike on 09.12.2016.
*/
public class MsgSetTime extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetTime.class);
public MsgSetTime(Date time) {
SetCommand(0x330a);
AddParamDateTime(time);
}
public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1);
if (Config.logDanaMessageDetail)
log.debug("Result: " + result);
}
}

View file

@ -43,6 +43,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
@ -51,13 +58,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
@ -106,14 +106,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@ -122,6 +114,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />