This commit is contained in:
Milos Kozak 2017-03-23 10:09:55 +01:00
commit a5b59d5092
8 changed files with 132 additions and 6 deletions

View file

@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment; import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment;
import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment; import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment; import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpFragment;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment; import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment; import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment; import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
@ -104,6 +105,7 @@ public class MainApp extends Application {
pluginsList.add(SourceXdripFragment.getPlugin()); pluginsList.add(SourceXdripFragment.getPlugin());
pluginsList.add(SourceNSClientFragment.getPlugin()); pluginsList.add(SourceNSClientFragment.getPlugin());
pluginsList.add(SourceMM640gFragment.getPlugin()); pluginsList.add(SourceMM640gFragment.getPlugin());
pluginsList.add(SourceGlimpFragment.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin()); if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this)); if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));

View file

@ -44,6 +44,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin; import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin; import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin; import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin; import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
@ -59,6 +60,7 @@ public class DataService extends IntentService {
boolean xDripEnabled = false; boolean xDripEnabled = false;
boolean nsClientEnabled = true; boolean nsClientEnabled = true;
boolean mm640gEnabled = false; boolean mm640gEnabled = false;
boolean glimpEnabled = false;
public DataService() { public DataService() {
super("DataService"); super("DataService");
@ -74,14 +76,22 @@ public class DataService extends IntentService {
xDripEnabled = true; xDripEnabled = true;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = true; nsClientEnabled = true;
mm640gEnabled = false; mm640gEnabled = false;
glimpEnabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) { } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) {
xDripEnabled = false; xDripEnabled = false;
nsClientEnabled = false; nsClientEnabled = false;
mm640gEnabled = true; mm640gEnabled = true;
glimpEnabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = false;
glimpEnabled = true;
} }
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfile().getClass().equals(NSProfilePlugin.class); boolean isNSProfile = ConfigBuilderPlugin.getActiveProfile().getClass().equals(NSProfilePlugin.class);
@ -99,6 +109,10 @@ public class DataService extends IntentService {
if (mm640gEnabled) { if (mm640gEnabled) {
handleNewDataFromMM640g(intent); handleNewDataFromMM640g(intent);
} }
} else if (Intents.GLIMP_BG.equals(action)) {
if (glimpEnabled) {
handleNewDataFromGlimp(intent);
}
} else if (Intents.ACTION_NEW_SGV.equals(action)) { } else if (Intents.ACTION_NEW_SGV.equals(action)) {
// always handle SGV if NS-Client is the source // always handle SGV if NS-Client is the source
if (nsClientEnabled) { if (nsClientEnabled) {
@ -185,6 +199,30 @@ public class DataService extends IntentService {
MainApp.bus().post(new EventNewBG()); MainApp.bus().post(new EventNewBG());
} }
private void handleNewDataFromGlimp(Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle == null) return;
BgReading bgReading = new BgReading();
bgReading.value = bundle.getDouble("mySGV");
bgReading.direction = bundle.getString("myTrend");
bgReading.battery_level = bundle.getInt("myBatLvl");
bgReading.timeIndex = bundle.getLong("myTimestamp");
bgReading.raw = 0;
if (Config.logIncommingBG)
log.debug(bundle.toString());
log.debug("GLIMP BG " + bgReading.toString());
try {
MainApp.getDbHelper().getDaoBgReadings().createIfNotExists(bgReading);
} catch (SQLException e) {
e.printStackTrace();
}
MainApp.bus().post(new EventNewBG());
}
private void handleNewDataFromMM640g(Intent intent) { private void handleNewDataFromMM640g(Intent intent) {
Bundle bundle = intent.getExtras(); Bundle bundle = intent.getExtras();
if (bundle == null) return; if (bundle == null) return;

View file

@ -35,4 +35,6 @@ public interface Intents {
String NS_EMULATOR = "com.eveningoutpost.dexdrip.NS_EMULATOR"; String NS_EMULATOR = "com.eveningoutpost.dexdrip.NS_EMULATOR";
String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration"; String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration";
String GLIMP_BG = "it.ct.glicemia.ACTION_GLUCOSE_MEASURED";
} }

View file

@ -47,7 +47,7 @@ public class BgReading implements DataPointInterface {
public BgReading(NSSgv sgv) { public BgReading(NSSgv sgv) {
timeIndex = sgv.getMills(); timeIndex = sgv.getMills();
value = sgv.getMgdl(); value = sgv.getMgdl();
raw = sgv.getFiltered(); raw = sgv.getFiltered() != null ? sgv.getFiltered() : value;
direction = sgv.getDirection(); direction = sgv.getDirection();
} }

View file

@ -38,6 +38,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientS
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
public class NSClientInternalPlugin implements PluginBase { public class NSClientInternalPlugin implements PluginBase {
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class); private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
@ -189,12 +190,16 @@ public class NSClientInternalPlugin implements PluginBase {
} }
private void updateLog() { private void updateLog() {
try {
Spanned newTextLog = Html.fromHtml(""); Spanned newTextLog = Html.fromHtml("");
for (EventNSClientNewLog log : listLog) { for (EventNSClientNewLog log : listLog) {
newTextLog = (Spanned) TextUtils.concat(newTextLog, log.toHtml()); newTextLog = (Spanned) TextUtils.concat(newTextLog, log.toHtml());
} }
textLog = newTextLog; textLog = newTextLog;
MainApp.bus().post(new EventNSClientUpdateGUI()); MainApp.bus().post(new EventNSClientUpdateGUI());
} catch (OutOfMemoryError e) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "Out of memory!\nStop using this phone !!!", R.raw.error);
}
} }
public void resend(String reason) { public void resend(String reason) {

View file

@ -0,0 +1,16 @@
package info.nightscout.androidaps.plugins.SourceGlimp;
import android.support.v4.app.Fragment;
import info.nightscout.androidaps.interfaces.FragmentBase;
public class SourceGlimpFragment extends Fragment implements FragmentBase {
private static SourceGlimpPlugin sourceGlimpPlugin = new SourceGlimpPlugin();
public static SourceGlimpPlugin getPlugin() {
return sourceGlimpPlugin;
}
}

View file

@ -0,0 +1,62 @@
package info.nightscout.androidaps.plugins.SourceGlimp;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
/**
* Created by mike on 05.08.2016.
*/
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
boolean fragmentEnabled = false;
@Override
public String getFragmentClass() {
return SourceGlimpFragment.class.getName();
}
@Override
public int getType() {
return PluginBase.BGSOURCE;
}
@Override
public String getName() {
return MainApp.instance().getString(R.string.Glimp);
}
@Override
public String getNameShort() {
// use long name as fallback (no tabs)
return getName();
}
@Override
public boolean isEnabled(int type) {
return type == BGSOURCE && fragmentEnabled;
}
@Override
public boolean isVisibleInTabs(int type) {
return false;
}
@Override
public boolean canBeHidden(int type) {
return true;
}
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
}
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
}
}

View file

@ -553,4 +553,5 @@
<string name="key_adult" translatable="false">adult</string> <string name="key_adult" translatable="false">adult</string>
<string name="patientage_summary">Please select patient age to setup safety limits</string> <string name="patientage_summary">Please select patient age to setup safety limits</string>
<string name="key_i_understand" translatable="false">I_understand</string> <string name="key_i_understand" translatable="false">I_understand</string>
<string name="Glimp">Glimp</string>
</resources> </resources>