synchronize pump time

This commit is contained in:
Milos Kozak 2016-12-09 09:31:51 +01:00
parent ccda992161
commit 064de0f64e
6 changed files with 117 additions and 17 deletions

View file

@ -58,6 +58,7 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStop;
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.MsgSettingActiveProfile;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingBasal;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingGlucose;
@ -320,6 +321,7 @@ public class ExecutionService extends Service {
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
danaRPump.lastSettingsRead = now;
}

View file

@ -51,6 +51,15 @@ public class MessageBase {
AddParamByte((byte) (date.get(Calendar.MINUTE)));
}
public void AddParamDateTime(Date date) {
AddParamByte((byte) (date.getSeconds()));
AddParamByte((byte) (date.getMinutes()));
AddParamByte((byte) (date.getHours()));
AddParamByte((byte) (date.getDate()));
AddParamByte((byte) (date.getMonth() + 1));
AddParamByte((byte) (date.getYear() - 100));
}
public byte[] getRawMessageBytes() {
this.buffer[0] = (byte) 0x7E;
this.buffer[1] = (byte) 0x7E;

View file

@ -0,0 +1,28 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.Config;
/**
* 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

@ -31,8 +31,8 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.comm.*;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
@ -40,6 +40,37 @@ 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.MsgSettingBasal;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingGlucose;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingMaxValues;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingProfileRatios;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingPumpTime;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgSettingShippingInfo;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusBasic;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.plugins.DanaRKorean.comm.MsgStatusTempBasal;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
@ -281,6 +312,7 @@ public class ExecutionService extends Service {
mSerialIOThread.sendMessage(new MsgSettingGlucose());
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
danaRKoreanPump.lastSettingsRead = now;
}

View file

@ -0,0 +1,29 @@
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,13 +43,6 @@
<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" />
@ -58,6 +51,13 @@
<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/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />