Insight driver (Sight remote) removal
This commit is contained in:
parent
ed917267de
commit
b0dd2f464b
48 changed files with 48 additions and 3549 deletions
|
@ -58,7 +58,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
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.PumpVirtual.VirtualPumpPlugin;
|
||||
|
@ -161,10 +160,8 @@ public class MainApp extends Application {
|
|||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS && engineeringMode) pluginsList.add(LocalInsightPlugin.getInstance());
|
||||
if (Config.PUMPDRIVERS && engineeringMode) pluginsList.add(LocalInsightPlugin.getPlugin());
|
||||
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());
|
||||
pluginsList.add(VirtualPumpPlugin.getPlugin());
|
||||
|
|
|
@ -32,7 +32,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
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.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref0Plugin;
|
||||
|
@ -164,7 +164,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRv2Plugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(InsightPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(LocalInsightPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), PluginType.PUMP);
|
||||
|
||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|
|
|
@ -46,7 +46,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
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.queue.Callback;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -550,7 +550,7 @@ public class TDDStatsActivity extends Activity {
|
|||
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||
PumpInterface insight = MainApp.getSpecificPlugin(InsightPlugin.class);
|
||||
PumpInterface insight = MainApp.getSpecificPlugin(LocalInsightPlugin.class);
|
||||
|
||||
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
||||
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.ui.StatusItemViewAdapter;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
||||
|
||||
public class InsightFragment extends SubscriberFragment {
|
||||
private static final Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
private static final Handler sLoopHandler = new Handler();
|
||||
private static volatile boolean refresh = false;
|
||||
private static volatile boolean pending = false;
|
||||
StatusItemViewAdapter viewAdapter;
|
||||
LinearLayout holder;
|
||||
private final Runnable sRefreshLoop = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pending = false;
|
||||
updateGUI();
|
||||
if (refresh) {
|
||||
scheduleRefresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private synchronized void scheduleRefresh() {
|
||||
if (!pending) {
|
||||
pending = true;
|
||||
sLoopHandler.postDelayed(sRefreshLoop, 30 * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
try {
|
||||
final View view = inflater.inflate(R.layout.insightpump_fragment, container, false);
|
||||
holder = (LinearLayout) view.findViewById(R.id.insightholder);
|
||||
viewAdapter = new StatusItemViewAdapter(getActivity(), holder);
|
||||
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.logException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean visible) {
|
||||
super.setUserVisibleHint(visible);
|
||||
if (visible) {
|
||||
refresh = true;
|
||||
pending = false;
|
||||
updateGUI();
|
||||
scheduleRefresh();
|
||||
} else {
|
||||
refresh = false;
|
||||
//sLoopHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInsightUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null && holder != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final InsightPlugin insightPlugin = InsightPlugin.getPlugin();
|
||||
final List<StatusItem> l = insightPlugin.getStatusItems(refresh);
|
||||
|
||||
holder.removeAllViews();
|
||||
|
||||
for (StatusItem row : l) {
|
||||
viewAdapter.inflateStatus(row);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,941 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusSilentlyTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelTBRSilentlyTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.SetTBRTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.StatusTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.WriteBasalProfileTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightCallback;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.SP;
|
||||
import sugar.free.sightparser.applayer.descriptors.ActiveBolus;
|
||||
import sugar.free.sightparser.applayer.descriptors.ActiveBolusType;
|
||||
import sugar.free.sightparser.applayer.descriptors.MessagePriority;
|
||||
import sugar.free.sightparser.applayer.descriptors.PumpStatus;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock;
|
||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.BolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.CancelBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.ExtendedBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.StandardBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.ActiveBolusesMessage;
|
||||
import sugar.free.sightparser.handling.SingleMessageTaskRunner;
|
||||
import sugar.free.sightparser.handling.TaskRunner;
|
||||
import sugar.free.sightparser.pipeline.Status;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.getRecordUniqueID;
|
||||
|
||||
|
||||
/**
|
||||
* Created by jamorham on 23/01/2018.
|
||||
* <p>
|
||||
* Connects to SightRemote app service using SightParser library
|
||||
* <p>
|
||||
* SightRemote and SightParser created by Tebbe Ubben
|
||||
* <p>
|
||||
* Original proof of concept SightProxy by jamorham
|
||||
*/
|
||||
|
||||
@SuppressWarnings("AccessStaticViaInstance")
|
||||
public class InsightPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private static volatile InsightPlugin plugin;
|
||||
|
||||
public static InsightPlugin getPlugin() {
|
||||
if (plugin == null) {
|
||||
plugin = new InsightPlugin();
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private static final long BUSY_WAIT_TIME = 20000;
|
||||
private static Integer batteryPercent = 0;
|
||||
private static Integer reservoirInUnits = 0;
|
||||
private static boolean initialized = false;
|
||||
private static volatile boolean update_pending = false;
|
||||
private StatusTaskRunner.Result statusResult;
|
||||
private long statusResultTime = -1;
|
||||
private long lastDataTime = 0;
|
||||
private boolean fauxTBRcancel = true;
|
||||
private PumpDescription pumpDescription = new PumpDescription();
|
||||
private double basalRate = 0;
|
||||
private Connector connector;
|
||||
private volatile boolean connector_enabled = false;
|
||||
private List<BRProfileBlock.ProfileBlock> profileBlocks;
|
||||
|
||||
private InsightPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.fragmentClass(InsightFragment.class.getName())
|
||||
.pluginName(R.string.insightpump)
|
||||
.shortName(R.string.insightpump_shortname)
|
||||
.preferencesId(R.xml.pref_insightpump)
|
||||
.description(R.string.description_pump_insight)
|
||||
);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("InsightPlugin instantiated");
|
||||
pumpDescription.setPumpDescription(PumpType.AccuChekInsight);
|
||||
}
|
||||
|
||||
|
||||
private static void updateGui() {
|
||||
update_pending = false;
|
||||
MainApp.bus().post(new EventInsightUpdateGui());
|
||||
}
|
||||
|
||||
private static void pushCallbackEvent(EventInsightCallback e) {
|
||||
MainApp.bus().post(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
if (!connector_enabled) {
|
||||
synchronized (this) {
|
||||
if (!connector_enabled) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Instantiating connector");
|
||||
connector_enabled = true;
|
||||
this.connector = Connector.get();
|
||||
this.connector.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
protected void onStop() {
|
||||
if (connector_enabled) {
|
||||
synchronized (this) {
|
||||
if (connector_enabled) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Shutting down connector");
|
||||
Connector.get().shutdown();
|
||||
connector_enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult loadTDDs() {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity context) {
|
||||
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
|
||||
if (allowHardwarePump || context == null) {
|
||||
pluginSwitcher.invoke();
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setMessage(R.string.allow_hardware_pump_text)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
pluginSwitcher.invoke();
|
||||
SP.putBoolean("allow_hardware_pump", true);
|
||||
log.debug("First time HW pump allowed!");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
pluginSwitcher.cancel();
|
||||
log.debug("User does not allow switching to HW pump!");
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspended() {
|
||||
return !isPumpRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return Connector.get().isPumpConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnecting() {
|
||||
return Connector.get().isPumpConnecting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHandshakeInProgress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishHandshaking() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(String reason) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("InsightPlugin::connect()");
|
||||
try {
|
||||
if (!connector.isPumpConnected()) {
|
||||
if (Helpers.ratelimit("insight-connect-timer", 40)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Actually requesting a connect");
|
||||
connector.connectToPump();
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Already connected");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
log.error("Could not sconnect - null pointer: " + e);
|
||||
}
|
||||
|
||||
// TODO review
|
||||
if (!Config.NSCLIENT)
|
||||
NSUpload.uploadDeviceStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String reason) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("InsightPlugin::disconnect()");
|
||||
try {
|
||||
if (!SP.getBoolean("insight_always_connected", false)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Requesting disconnect");
|
||||
connector.disconnectFromPump();
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Not disconnecting due to preference");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
log.error("Could not disconnect - null pointer: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopConnecting() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("InsightPlugin::stopConnecting()");
|
||||
try {
|
||||
if (isConnecting()) {
|
||||
if (!SP.getBoolean("insight_always_connected", false)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Requesting disconnect");
|
||||
connector.disconnectFromPump();
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Not disconnecting due to preference");
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Not currently trying to connect so not stopping connection");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
log.error("Could not stop connecting - null pointer: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPumpStatus() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("getPumpStatus");
|
||||
if (Connector.get().isPumpConnected()) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("is connected.. requesting status");
|
||||
try {
|
||||
setStatusResult(fetchTaskRunner(new StatusTaskRunner(connector.getServiceConnector()), StatusTaskRunner.Result.class));
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("GOT STATUS RESULT!!! PARTY WOOHOO!!!");
|
||||
statusResultTime = Helpers.tsl();
|
||||
processStatusResult();
|
||||
updateGui();
|
||||
connector.requestHistoryReSync();
|
||||
connector.requestHistorySync();
|
||||
} catch (Exception e) {
|
||||
log.error("StatusTaskRunner wasn't successful.");
|
||||
if (connector.getServiceConnector().isConnectedToService() && connector.getServiceConnector().getStatus() != Status.CONNECTED) {
|
||||
if (Helpers.ratelimit("insight-reconnect", 2)) {
|
||||
Connector.connectToPump();
|
||||
updateGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("not connected.. not requesting status");
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatusResult(StatusTaskRunner.Result result) {
|
||||
this.statusResult = result;
|
||||
this.pumpDescription.basalMinimumRate = result.minimumBasalAmount;
|
||||
this.pumpDescription.basalMaximumRate = result.maximumBasalAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
if (!isInitialized()) {
|
||||
log.error("setNewBasalProfile not initialized");
|
||||
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
result.comment = MainApp.gs(R.string.pumpNotInitializedProfileNotSet);
|
||||
return result;
|
||||
}
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
List<BRProfileBlock.ProfileBlock> profileBlocks = new ArrayList<>();
|
||||
for (int i = 0; i < profile.getBasalValues().length; i++) {
|
||||
Profile.BasalValue basalValue = profile.getBasalValues()[i];
|
||||
Profile.BasalValue nextValue = null;
|
||||
if (profile.getBasalValues().length > i + 1)
|
||||
nextValue = profile.getBasalValues()[i + 1];
|
||||
profileBlocks.add(new BRProfileBlock.ProfileBlock((((nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds) / 60), Helpers.roundDouble(basalValue.value, 2)));
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("setNewBasalProfile: " + basalValue.value + " for " + Integer.toString(((nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds) / 60));
|
||||
}
|
||||
try {
|
||||
fetchTaskRunner(new WriteBasalProfileTaskRunner(connector.getServiceConnector(), profileBlocks));
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
result.success = true;
|
||||
result.enacted = true;
|
||||
result.comment = "OK";
|
||||
this.profileBlocks = profileBlocks;
|
||||
} catch (Exception e) {
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
result.comment = MainApp.gs(R.string.failedupdatebasalprofile);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisProfileSet(Profile profile) {
|
||||
if (!isInitialized() || profileBlocks == null) return true;
|
||||
if (profile.getBasalValues().length != profileBlocks.size()) return false;
|
||||
for (int i = 0; i < profileBlocks.size(); i++) {
|
||||
BRProfileBlock.ProfileBlock profileBlock = profileBlocks.get(i);
|
||||
Profile.BasalValue basalValue = profile.getBasalValues()[i];
|
||||
Profile.BasalValue nextValue = null;
|
||||
if (profile.getBasalValues().length > i + 1)
|
||||
nextValue = profile.getBasalValues()[i + 1];
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("isThisProfileSet - Comparing block: Pump: " + profileBlock.getAmount() + " for " + profileBlock.getDuration()
|
||||
+ " Profile: " + basalValue.value + " for " + Integer.toString(((nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds) / 60));
|
||||
if (profileBlock.getDuration() * 60 != (nextValue != null ? nextValue.timeAsSeconds : 24 * 60 * 60) - basalValue.timeAsSeconds)
|
||||
return false;
|
||||
//Allow a little imprecision due to rounding errors
|
||||
if (Math.abs(profileBlock.getAmount() - Helpers.roundDouble(basalValue.value, 2)) >= 0.01D)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long lastDataTime() {
|
||||
return lastDataTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseBasalRate() {
|
||||
return basalRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return reservoirInUnits; }
|
||||
|
||||
@Override
|
||||
public int getBatteryLevel() { return batteryPercent; }
|
||||
|
||||
public String getBaseBasalRateString() {
|
||||
final DecimalFormat df = new DecimalFormat("#.##");
|
||||
return df.format(basalRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
final PumpEnactResult result = new PumpEnactResult();
|
||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||
result.carbsDelivered = detailedBolusInfo.carbs;
|
||||
result.enacted = result.bolusDelivered > 0 || result.carbsDelivered > 0;
|
||||
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||
|
||||
result.percent = 100;
|
||||
|
||||
int bolusId = 0;
|
||||
|
||||
// is there an insulin component to the treatment?
|
||||
if (detailedBolusInfo.insulin > 0) {
|
||||
try {
|
||||
bolusId = deliverBolus(detailedBolusInfo.insulin);
|
||||
result.success = true;
|
||||
detailedBolusInfo.pumpId = getRecordUniqueID(bolusId);
|
||||
} catch (Exception e) {
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
} else {
|
||||
result.success = true; // always true with carb only treatments
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Success!");
|
||||
|
||||
Treatment t = new Treatment();
|
||||
t.isSMB = detailedBolusInfo.isSMB;
|
||||
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
bolusingEvent.t = t;
|
||||
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), 0F);
|
||||
bolusingEvent.bolusId = bolusId;
|
||||
bolusingEvent.percent = 0;
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Failure to deliver treatment");
|
||||
}
|
||||
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||
|
||||
updateGui();
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
|
||||
if (result.success) while (true) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
final EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
ActiveBolusesMessage activeBolusesMessage = fetchSingleMessage(new ActiveBolusesMessage(), ActiveBolusesMessage.class);
|
||||
ActiveBolus activeBolus = null;
|
||||
if (activeBolusesMessage.getBolus1() != null && activeBolusesMessage.getBolus1().getBolusID() == bolusingEvent.bolusId)
|
||||
activeBolus = activeBolusesMessage.getBolus1();
|
||||
else if (activeBolusesMessage.getBolus2() != null && activeBolusesMessage.getBolus2().getBolusID() == bolusingEvent.bolusId)
|
||||
activeBolus = activeBolusesMessage.getBolus2();
|
||||
else if (activeBolusesMessage.getBolus3() != null && activeBolusesMessage.getBolus3().getBolusID() == bolusingEvent.bolusId)
|
||||
activeBolus = activeBolusesMessage.getBolus3();
|
||||
if (activeBolus == null) break;
|
||||
else {
|
||||
int percentBefore = bolusingEvent.percent;
|
||||
bolusingEvent.percent = (int) (100D / activeBolus.getInitialAmount() * (activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount()));
|
||||
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), activeBolus.getInitialAmount() - activeBolus.getLeftoverAmount());
|
||||
if (percentBefore != bolusingEvent.percent) MainApp.bus().post(bolusingEvent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
connector.requestHistorySync(2000);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
CancelBolusMessage cancelBolusMessage = new CancelBolusMessage();
|
||||
cancelBolusMessage.setMessagePriority(MessagePriority.HIGHEST);
|
||||
cancelBolusMessage.setBolusId(EventOverviewBolusProgress.getInstance().bolusId);
|
||||
try {
|
||||
fetchSingleMessage(cancelBolusMessage);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary Basals
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Set TBR absolute: " + absoluteRate);
|
||||
if (getBaseBasalRate() == 0) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Base basal rate appears to be zero!");
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
double percent = 100D / getBaseBasalRate() * absoluteRate;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Calculated requested rate: " + absoluteRate + " base rate: " + getBaseBasalRate() + " percentage: " + percent + "%");
|
||||
try {
|
||||
if (percent > 250) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Calculated rate is above 250%, switching to emulation using extended boluses");
|
||||
cancelTempBasal(true);
|
||||
if (!setExtendedBolus((absoluteRate - getBaseBasalRate()) / 60D * ((double) durationInMinutes), durationInMinutes).success) {
|
||||
//Fallback to TBR if setting an extended bolus didn't work
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Setting an extended bolus didn't work, falling back to normal TBR");
|
||||
return setTempBasalPercent((int) percent, durationInMinutes, profile, true);
|
||||
}
|
||||
return new PumpEnactResult().success(true).enacted(true).absolute(absoluteRate).duration(durationInMinutes);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Calculated rate is below or equal to 250%, using normal TBRs");
|
||||
cancelExtendedBolus();
|
||||
return setTempBasalPercent((int) percent, durationInMinutes, profile, true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Set TBR %");
|
||||
|
||||
percent = (int) Math.round(((double) percent) / 10d) * 10;
|
||||
if (percent == 100) {
|
||||
// This would cause a cancel if a tbr is in progress so treat as a cancel
|
||||
return cancelTempBasal(false);
|
||||
} else if (percent > 250) percent = 250;
|
||||
|
||||
try {
|
||||
fetchTaskRunner(new SetTBRTaskRunner(connector.getServiceConnector(), percent, durationInMinutes));
|
||||
final TemporaryBasal tempBasal = new TemporaryBasal()
|
||||
.date(System.currentTimeMillis())
|
||||
.percent(percent)
|
||||
.duration(durationInMinutes)
|
||||
.source(Source.USER);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||
updateGui();
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Set temp basal " + percent + "% for " + durationInMinutes + "m");
|
||||
connector.requestHistorySync(5000);
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
return new PumpEnactResult().success(true).enacted(true).percent(percent);
|
||||
} catch (Exception e) {
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Cancel TBR called");
|
||||
|
||||
try {
|
||||
cancelExtendedBolus();
|
||||
SystemClock.sleep(1100); // to be sure db records are at least 1 sec off (for NS)
|
||||
realTBRCancel();
|
||||
SystemClock.sleep(1100); // to be sure db records are at least 1 sec off (for NS)
|
||||
updateGui();
|
||||
connector.requestHistorySync(5000);
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
return new PumpEnactResult().success(true).enacted(true).isTempCancel(true);
|
||||
} catch (Exception e) {
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
}
|
||||
|
||||
private void realTBRCancel() throws Exception {
|
||||
if (fetchTaskRunner(new CancelTBRSilentlyTaskRunner(connector.getServiceConnector()), Boolean.class) && TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Extended Boluses
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Set Extended bolus " + insulin + " " + durationInMinutes);
|
||||
try {
|
||||
ExtendedBolusMessage extendedBolusMessage = new ExtendedBolusMessage();
|
||||
extendedBolusMessage.setAmount(insulin);
|
||||
extendedBolusMessage.setDuration(durationInMinutes);
|
||||
BolusMessage bolusMessage = fetchSingleMessage(extendedBolusMessage, BolusMessage.class);
|
||||
final ExtendedBolus extendedBolus = new ExtendedBolus()
|
||||
.date(System.currentTimeMillis())
|
||||
.insulin(insulin)
|
||||
.durationInMinutes(durationInMinutes)
|
||||
.source(Source.USER)
|
||||
.pumpId(getRecordUniqueID(bolusMessage.getBolusId()));
|
||||
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||
updateGui();
|
||||
connector.requestHistorySync(30000);
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
return new PumpEnactResult().success(true).enacted(true).duration(durationInMinutes).bolusDelivered(insulin);
|
||||
} catch (Exception e) {
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelExtendedBolus() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Cancel Extended bolus called");
|
||||
|
||||
Integer bolusId = null;
|
||||
|
||||
try {
|
||||
bolusId = fetchTaskRunner(new CancelBolusSilentlyTaskRunner(connector.getServiceConnector(), ActiveBolusType.EXTENDED), Integer.class);
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
||||
exStop.source = Source.USER;
|
||||
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(exStop);
|
||||
}
|
||||
if (bolusId != null) connector.requestHistorySync(5000);
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
updateGui();
|
||||
return new PumpEnactResult().success(true).enacted(bolusId != null);
|
||||
} catch (Exception e) {
|
||||
return pumpEnactFailure();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int deliverBolus(double bolusValue) throws Exception {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("DeliverBolus: " + bolusValue);
|
||||
|
||||
final StandardBolusMessage message = new StandardBolusMessage();
|
||||
message.setAmount(bolusValue);
|
||||
|
||||
return fetchSingleMessage(message, BolusMessage.class).getBolusId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (Helpers.msSince(connector.getLastContactTime()) > (60 * 60 * 1000)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("getJSONStatus not returning as data likely stale");
|
||||
return null;
|
||||
}
|
||||
|
||||
final JSONObject pump = new JSONObject();
|
||||
final JSONObject battery = new JSONObject();
|
||||
final JSONObject status = new JSONObject();
|
||||
final JSONObject extended = new JSONObject();
|
||||
try {
|
||||
battery.put("percent", batteryPercent);
|
||||
status.put("status", isSuspended() ? "suspended" : "normal");
|
||||
status.put("timestamp", DateUtil.toISOString(connector.getLastContactTime()));
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
try {
|
||||
extended.put("ActiveProfile", ProfileFunctions.getInstance().getProfileName());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||
if (tb != null) {
|
||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
|
||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||
}
|
||||
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||
if (eb != null) {
|
||||
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
|
||||
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
|
||||
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
||||
}
|
||||
extended.put("BaseBasalRate", getBaseBasalRate());
|
||||
status.put("timestamp", DateUtil.toISOString(now));
|
||||
|
||||
pump.put("battery", battery);
|
||||
pump.put("status", status);
|
||||
pump.put("extended", extended);
|
||||
pump.put("reservoir", reservoirInUnits);
|
||||
pump.put("clock", DateUtil.toISOString(now));
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return pump;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deviceID() {
|
||||
return "InsightPump";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpDescription getPumpDescription() {
|
||||
return pumpDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shortStatus(boolean veryShort) {
|
||||
String msg = gs(R.string.insightpump_shortname) + " Batt: " + batteryPercent + " Reserv: " + reservoirInUnits + " Basal: " + basalRate;
|
||||
if (LiveHistory.getStatus().length() > 0) {
|
||||
msg += LiveHistory.getStatus();
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
private void processStatusResult() {
|
||||
if (statusResult != null) {
|
||||
batteryPercent = statusResult.battery;
|
||||
reservoirInUnits = (int) statusResult.cartridge;
|
||||
basalRate = statusResult.baseBasalRate;
|
||||
profileBlocks = statusResult.basalProfile;
|
||||
initialized = true; // basic communication test
|
||||
}
|
||||
}
|
||||
|
||||
private String gs(int id) {
|
||||
return MainApp.gs(id);
|
||||
}
|
||||
|
||||
private boolean isPumpRunning() {
|
||||
if (statusResult == null) return true; // assume running if we have no information
|
||||
return statusResult.pumpStatus == PumpStatus.STARTED;
|
||||
}
|
||||
|
||||
List<StatusItem> getStatusItems(boolean refresh) {
|
||||
final List<StatusItem> l = new ArrayList<>();
|
||||
|
||||
// Todo last contact time
|
||||
|
||||
l.add(new StatusItem(gs(R.string.status_no_colon), connector.getLastStatusMessage()));
|
||||
l.add(new StatusItem(gs(R.string.changed), connector.getNiceLastStatusTime()));
|
||||
|
||||
boolean pumpRunning;
|
||||
// also check time since received
|
||||
if (statusResult != null) {
|
||||
|
||||
pumpRunning = isPumpRunning();
|
||||
if (pumpRunning) {
|
||||
l.add(new StatusItem(gs(R.string.pump_basebasalrate_label), getBaseBasalRateString() + "U"));
|
||||
} else {
|
||||
l.add(new StatusItem(gs(R.string.combo_warning), gs(R.string.pump_stopped_uppercase), StatusItem.Highlight.CRITICAL));
|
||||
}
|
||||
}
|
||||
|
||||
final long offset_ms = Helpers.msSince(statusResultTime);
|
||||
final long offset_minutes = offset_ms / 60000;
|
||||
|
||||
if (statusResult != null) {
|
||||
l.add(new StatusItem(gs(R.string.status_updated), Helpers.niceTimeScalar(Helpers.msSince(statusResultTime)) + " " + gs(R.string.ago)));
|
||||
l.add(new StatusItem(gs(R.string.pump_battery_label), batteryPercent + "%", batteryPercent < 100 ?
|
||||
(batteryPercent < 90 ?
|
||||
(batteryPercent < 70 ?
|
||||
(StatusItem.Highlight.BAD) : StatusItem.Highlight.NOTICE) : StatusItem.Highlight.NORMAL) : StatusItem.Highlight.GOOD));
|
||||
l.add(new StatusItem(gs(R.string.pump_reservoir_label), reservoirInUnits + "U"));
|
||||
try {
|
||||
if (statusResult.tbrAmount != 100) {
|
||||
l.add(new StatusItem(gs(R.string.insight_active_tbr), statusResult.tbrAmount + "% " + gs(R.string.with) + " "
|
||||
+ Helpers.qs(statusResult.tbrLeftoverDuration - offset_minutes, 0)
|
||||
+ " " + gs(R.string.insight_min_left), StatusItem.Highlight.NOTICE));
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
// currentTBRMessage may be null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||
try {
|
||||
l.add(new StatusItem(gs(R.string.pump_tempbasal_label), TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull()));
|
||||
} catch (NullPointerException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
if (statusResult != null) {
|
||||
try {
|
||||
statusActiveBolus(statusResult.activeBolus1, offset_minutes, l);
|
||||
statusActiveBolus(statusResult.activeBolus2, offset_minutes, l);
|
||||
statusActiveBolus(statusResult.activeBolus3, offset_minutes, l);
|
||||
} catch (NullPointerException e) {
|
||||
// getActiveBolusesMessage() may be null
|
||||
}
|
||||
}
|
||||
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||
try {
|
||||
|
||||
l.add(new StatusItem(gs(R.string.virtualpump_extendedbolus_label), TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis()).toString()));
|
||||
} catch (NullPointerException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
l.add(new StatusItem(gs(R.string.log_book), HistoryReceiver.getStatusString()));
|
||||
|
||||
if (LiveHistory.getStatus().length() > 0) {
|
||||
l.add(new StatusItem(gs(R.string.insight_last_completed_action), LiveHistory.getStatus()));
|
||||
}
|
||||
|
||||
final String keep_alive_status = Connector.getKeepAliveString();
|
||||
if (keep_alive_status != null) {
|
||||
l.add(new StatusItem(gs(R.string.insight_keep_alive_status), keep_alive_status));
|
||||
}
|
||||
|
||||
final List<StatusItem> status_statistics = connector.getStatusStatistics();
|
||||
if (status_statistics.size() > 0) {
|
||||
l.addAll(status_statistics);
|
||||
}
|
||||
|
||||
if (Helpers.ratelimit("insight-status-ui-refresh", 10)) {
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
}
|
||||
connector.requestHistorySync();
|
||||
if (refresh) scheduleGUIUpdate();
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
private synchronized void scheduleGUIUpdate() {
|
||||
if (!update_pending && connector.uiFresh()) {
|
||||
update_pending = true;
|
||||
Helpers.runOnUiThreadDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateGui();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void statusActiveBolus(ActiveBolus activeBolus, long offset_mins, List<StatusItem> l) {
|
||||
if (activeBolus == null) return;
|
||||
switch (activeBolus.getBolusType()) {
|
||||
|
||||
case STANDARD:
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " " + gs(R.string.bolus), activeBolus.getInitialAmount() + "U", StatusItem.Highlight.NOTICE));
|
||||
break;
|
||||
case EXTENDED:
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " " + gs(R.string.bolus), activeBolus.getInitialAmount() + "U " + gs(R.string.insight_total_with) + " "
|
||||
+ activeBolus.getLeftoverAmount() + "U " + gs(R.string.insight_remaining_over) + " " + (activeBolus.getDuration() - offset_mins) + " " + gs(R.string.insight_min), StatusItem.Highlight.NOTICE));
|
||||
break;
|
||||
case MULTIWAVE:
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " " + gs(R.string.bolus), activeBolus.getInitialAmount() + "U " + gs(R.string.insight_upfront_with) + " "
|
||||
+ activeBolus.getLeftoverAmount() + "U " + gs(R.string.insight_remaining_over) + " " + (activeBolus.getDuration() - offset_mins) + " " + gs(R.string.insight_min), StatusItem.Highlight.NOTICE));
|
||||
|
||||
break;
|
||||
default:
|
||||
log.error("ERROR: unknown bolus type! " + activeBolus.getBolusType());
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchTaskRunner(TaskRunner taskRunner) throws Exception {
|
||||
fetchTaskRunner(taskRunner, Object.class);
|
||||
}
|
||||
|
||||
private void fetchSingleMessage(AppLayerMessage message) throws Exception {
|
||||
fetchSingleMessage(message, AppLayerMessage.class);
|
||||
}
|
||||
|
||||
private <T> T fetchTaskRunner(TaskRunner taskRunner, Class<T> resultType) throws Exception {
|
||||
try {
|
||||
T result = (T) taskRunner.fetchAndWaitUsingLatch(BUSY_WAIT_TIME);
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("Error while fetching " + taskRunner.getClass().getSimpleName() + ": " + e.getClass().getSimpleName());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends AppLayerMessage> T fetchSingleMessage(AppLayerMessage message, Class<T> resultType) throws Exception {
|
||||
try {
|
||||
T result = (T) new SingleMessageTaskRunner(connector.getServiceConnector(), message).fetchAndWaitUsingLatch(BUSY_WAIT_TIME);
|
||||
lastDataTime = System.currentTimeMillis();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("Error while fetching " + message.getClass().getSimpleName() + ": " + e.getClass().getSimpleName());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private PumpEnactResult pumpEnactFailure() {
|
||||
return new PumpEnactResult().success(false).enacted(false);
|
||||
}
|
||||
|
||||
// Constraints
|
||||
|
||||
@Override
|
||||
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile) {
|
||||
percentRate.setIfGreater(0, String.format(MainApp.gs(R.string.limitingpercentrate), 0, MainApp.gs(R.string.itmustbepositivevalue)), this);
|
||||
percentRate.setIfSmaller(getPumpDescription().maxTempPercent, String.format(MainApp.gs(R.string.limitingpercentrate), getPumpDescription().maxTempPercent, MainApp.gs(R.string.pumplimit)), this);
|
||||
|
||||
return percentRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
|
||||
if (statusResult != null) {
|
||||
insulin.setIfSmaller(statusResult.maximumBolusAmount, String.format(MainApp.gs(R.string.limitingbolus), statusResult.maximumBolusAmount, MainApp.gs(R.string.pumplimit)), this);
|
||||
if (insulin.value() < statusResult.minimumBolusAmount) {
|
||||
|
||||
//TODO: Add function to Constraints or use different approach
|
||||
// This only works if the interface of the InsightPlugin is called last.
|
||||
// If not, another contraint could theoretically set the value between 0 and minimumBolusAmount
|
||||
|
||||
insulin.set(0d, String.format(MainApp.gs(R.string.limitingbolus), statusResult.minimumBolusAmount, MainApp.gs(R.string.pumplimit)), this);
|
||||
}
|
||||
}
|
||||
return insulin;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||
|
||||
import sugar.free.sightparser.applayer.descriptors.ActiveBolusType;
|
||||
import sugar.free.sightparser.applayer.descriptors.MessagePriority;
|
||||
import sugar.free.sightparser.applayer.descriptors.alerts.Warning38BolusCancelled;
|
||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.CancelBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.DismissAlertMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.ActiveAlertMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.ActiveBolusesMessage;
|
||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||
import sugar.free.sightparser.handling.TaskRunner;
|
||||
|
||||
// by Tebbe Ubben
|
||||
|
||||
public class CancelBolusSilentlyTaskRunner extends TaskRunner {
|
||||
|
||||
private ActiveBolusType bolusType;
|
||||
private long cancelledAt;
|
||||
private int bolusId;
|
||||
|
||||
public CancelBolusSilentlyTaskRunner(SightServiceConnector serviceConnector, ActiveBolusType bolusType) {
|
||||
super(serviceConnector);
|
||||
this.bolusType = bolusType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
|
||||
if (message == null) return new ActiveBolusesMessage();
|
||||
else if (message instanceof ActiveBolusesMessage) {
|
||||
ActiveBolusesMessage bolusesMessage = (ActiveBolusesMessage) message;
|
||||
CancelBolusMessage cancelBolusMessage = new CancelBolusMessage();
|
||||
if (bolusesMessage.getBolus1().getBolusType() == bolusType)
|
||||
bolusId = bolusesMessage.getBolus1().getBolusID();
|
||||
else if (bolusesMessage.getBolus2().getBolusType() == bolusType)
|
||||
bolusId = bolusesMessage.getBolus2().getBolusID();
|
||||
else if (bolusesMessage.getBolus3().getBolusType() == bolusType)
|
||||
bolusId = bolusesMessage.getBolus3().getBolusID();
|
||||
else finish(null);
|
||||
cancelBolusMessage.setBolusId(bolusId);
|
||||
return cancelBolusMessage;
|
||||
} else if (message instanceof CancelBolusMessage) {
|
||||
cancelledAt = System.currentTimeMillis();
|
||||
ActiveAlertMessage activeAlertMessage = new ActiveAlertMessage();
|
||||
activeAlertMessage.setMessagePriority(MessagePriority.HIGHER);
|
||||
return activeAlertMessage;
|
||||
} else if (message instanceof ActiveAlertMessage) {
|
||||
ActiveAlertMessage activeAlertMessage = (ActiveAlertMessage) message;
|
||||
if (activeAlertMessage.getAlert() == null) {
|
||||
if (System.currentTimeMillis() - cancelledAt >= 10000) finish(bolusId);
|
||||
else {
|
||||
ActiveAlertMessage activeAlertMessage2 = new ActiveAlertMessage();
|
||||
activeAlertMessage2.setMessagePriority(MessagePriority.HIGHER);
|
||||
return activeAlertMessage2;
|
||||
}
|
||||
} else if (!(activeAlertMessage.getAlert() instanceof Warning38BolusCancelled)) finish(bolusId);
|
||||
else {
|
||||
DismissAlertMessage dismissAlertMessage = new DismissAlertMessage();
|
||||
dismissAlertMessage.setAlertID(activeAlertMessage.getAlertID());
|
||||
dismissAlertMessage.setMessagePriority(MessagePriority.HIGHER);
|
||||
return dismissAlertMessage;
|
||||
}
|
||||
} else if (message instanceof DismissAlertMessage) finish(bolusId);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||
|
||||
import sugar.free.sightparser.applayer.descriptors.MessagePriority;
|
||||
import sugar.free.sightparser.applayer.descriptors.alerts.Warning36TBRCancelled;
|
||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.CancelTBRMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.DismissAlertMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.ActiveAlertMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.CurrentTBRMessage;
|
||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||
import sugar.free.sightparser.handling.TaskRunner;
|
||||
|
||||
public class CancelTBRSilentlyTaskRunner extends TaskRunner {
|
||||
|
||||
private long cancelledAt;
|
||||
|
||||
public CancelTBRSilentlyTaskRunner(SightServiceConnector serviceConnector) {
|
||||
super(serviceConnector);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
|
||||
if (message == null) return new CurrentTBRMessage();
|
||||
else if (message instanceof CurrentTBRMessage) {
|
||||
if (((CurrentTBRMessage) message).getPercentage() == 100) finish(false);
|
||||
else return new CancelTBRMessage();
|
||||
} else if (message instanceof CancelTBRMessage) {
|
||||
ActiveAlertMessage activeAlertMessage = new ActiveAlertMessage();
|
||||
activeAlertMessage.setMessagePriority(MessagePriority.HIGHER);
|
||||
return activeAlertMessage;
|
||||
} else if (message instanceof ActiveAlertMessage) {
|
||||
ActiveAlertMessage activeAlertMessage = (ActiveAlertMessage) message;
|
||||
if (activeAlertMessage.getAlert() == null) {
|
||||
if (System.currentTimeMillis() - cancelledAt >= 10000) finish(true);
|
||||
else {
|
||||
ActiveAlertMessage activeAlertMessage2 = new ActiveAlertMessage();
|
||||
activeAlertMessage2.setMessagePriority(MessagePriority.HIGHER);
|
||||
return activeAlertMessage2;
|
||||
}
|
||||
} else if (!(activeAlertMessage.getAlert() instanceof Warning36TBRCancelled)) finish(true);
|
||||
else {
|
||||
DismissAlertMessage dismissAlertMessage = new DismissAlertMessage();
|
||||
dismissAlertMessage.setAlertID(activeAlertMessage.getAlertID());
|
||||
dismissAlertMessage.setMessagePriority(MessagePriority.HIGHER);
|
||||
return dismissAlertMessage;
|
||||
}
|
||||
} else if (message instanceof DismissAlertMessage) finish(true);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,574 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventFeatureRunning;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||
import info.nightscout.utils.SP;
|
||||
import sugar.free.sightparser.handling.ServiceConnectionCallback;
|
||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||
import sugar.free.sightparser.handling.StatusCallback;
|
||||
import sugar.free.sightparser.pipeline.Status;
|
||||
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_START_RESYNC;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_START_SYNC;
|
||||
import static sugar.free.sightparser.handling.SightService.COMPATIBILITY_VERSION;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 23/01/2018.
|
||||
* <p>
|
||||
* Connects to SightRemote app service using SightParser library
|
||||
* <p>
|
||||
* SightRemote and SightParser created by Tebbe Ubben
|
||||
* <p>
|
||||
* Original proof of concept SightProxy by jamorham
|
||||
*/
|
||||
|
||||
public class Connector {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
// TODO connection statistics
|
||||
|
||||
private static final String TAG = "InsightConnector";
|
||||
private static final String COMPANION_APP_PACKAGE = "sugar.free.sightremote";
|
||||
private final static long FRESH_MS = 70000;
|
||||
private static final Map<Status, Long> statistics = new HashMap<>();
|
||||
private static volatile Connector instance;
|
||||
private static volatile HistoryReceiver historyReceiver;
|
||||
private static volatile long stayConnectedTill = -1;
|
||||
private static volatile long stayConnectedTime = 0;
|
||||
private static volatile boolean disconnect_thread_running = false;
|
||||
private volatile SightServiceConnector serviceConnector;
|
||||
private volatile Status lastStatus = null;
|
||||
private String compatabilityMessage = null;
|
||||
private volatile long lastStatusTime = -1;
|
||||
private volatile long lastContactTime = -1;
|
||||
private boolean companionAppInstalled = false;
|
||||
private int serviceReconnects = 0;
|
||||
private StatusCallback statusCallback = new StatusCallback() {
|
||||
@Override
|
||||
public synchronized void onStatusChange(Status status, long statusTime, long waitTime) {
|
||||
|
||||
if ((status != lastStatus) || (Helpers.msSince(lastStatusTime) > 2000)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Status change: " + status);
|
||||
|
||||
updateStatusStatistics(lastStatus, lastStatusTime);
|
||||
lastStatus = status;
|
||||
lastStatusTime = Helpers.tsl();
|
||||
|
||||
if (status == Status.CONNECTED) {
|
||||
lastContactTime = lastStatusTime;
|
||||
extendKeepAliveIfActive();
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventInsightUpdateGui());
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Same status as before: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
private ServiceConnectionCallback connectionCallback = new ServiceConnectionCallback() {
|
||||
|
||||
@Override
|
||||
public synchronized void onServiceConnected() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("On service connected");
|
||||
try {
|
||||
final String remoteVersion = serviceConnector.getRemoteVersion();
|
||||
if (remoteVersion.equals(COMPATIBILITY_VERSION)) {
|
||||
serviceConnector.connect();
|
||||
} else {
|
||||
log.error("PROTOCOL VERSION MISMATCH! local: " + COMPATIBILITY_VERSION + " remote: " + remoteVersion);
|
||||
statusCallback.onStatusChange(Status.INCOMPATIBLE, 0, 0);
|
||||
compatabilityMessage = MainApp.gs(R.string.insight_incompatible_compantion_app_we_need_version) + " " + getLocalVersion();
|
||||
serviceConnector.disconnectFromService();
|
||||
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
log.error("ERROR: null pointer when trying to connect to pump");
|
||||
}
|
||||
statusCallback.onStatusChange(safeGetStatus(), 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onServiceDisconnected() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Disconnected from service");
|
||||
if (Helpers.ratelimit("insight-automatic-reconnect", 30)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Scheduling automatic service reconnection");
|
||||
Helpers.runOnUiThreadDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
}
|
||||
}, 20000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Connector() {
|
||||
initializeHistoryReceiver();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
public static Connector get() {
|
||||
if (instance == null) {
|
||||
init_instance();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private synchronized static void init_instance() {
|
||||
if (instance == null) {
|
||||
instance = new Connector();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCompanionAppInstalled() {
|
||||
return Helpers.checkPackageExists(MainApp.instance(), TAG, COMPANION_APP_PACKAGE);
|
||||
}
|
||||
|
||||
public static void connectToPump() {
|
||||
connectToPump(0);
|
||||
}
|
||||
|
||||
public synchronized static void connectToPump(long keep_alive) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Attempting to connect to pump.");
|
||||
if (keep_alive > 0 && Helpers.tsl() + keep_alive > stayConnectedTill) {
|
||||
stayConnectedTime = keep_alive;
|
||||
stayConnectedTill = Helpers.tsl() + keep_alive;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Staying connected till: " + Helpers.dateTimeText(stayConnectedTill));
|
||||
delayedDisconnectionThread();
|
||||
}
|
||||
get().getServiceConnector().connect();
|
||||
}
|
||||
|
||||
public static void disconnectFromPump() {
|
||||
if (Helpers.tsl() >= stayConnectedTill) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Requesting real pump disconnect");
|
||||
get().getServiceConnector().disconnect();
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Cannot disconnect as due to keep alive till: " + Helpers.dateTimeText(stayConnectedTill));
|
||||
// TODO set a disconnection timer?
|
||||
}
|
||||
}
|
||||
|
||||
static String getLocalVersion() {
|
||||
return COMPATIBILITY_VERSION;
|
||||
}
|
||||
|
||||
private static String statusToString(Status status) {
|
||||
switch (status) {
|
||||
|
||||
case EXCHANGING_KEYS:
|
||||
return MainApp.gs(R.string.connecting).toUpperCase();
|
||||
case WAITING_FOR_CODE_CONFIRMATION:
|
||||
return MainApp.gs(R.string.insight_waiting_for_code).toUpperCase();
|
||||
case CODE_REJECTED:
|
||||
return MainApp.gs(R.string.insight_code_rejected).toUpperCase();
|
||||
case APP_BINDING:
|
||||
return MainApp.gs(R.string.insight_app_binding).toUpperCase();
|
||||
case CONNECTING:
|
||||
return MainApp.gs(R.string.connecting).toUpperCase();
|
||||
case CONNECTED:
|
||||
return MainApp.gs(R.string.connected).toUpperCase();
|
||||
case DISCONNECTED:
|
||||
return MainApp.gs(R.string.disconnected).toUpperCase();
|
||||
case NOT_AUTHORIZED:
|
||||
return MainApp.gs(R.string.insight_not_authorized).toUpperCase();
|
||||
case INCOMPATIBLE:
|
||||
return MainApp.gs(R.string.insight_incompatible).toUpperCase();
|
||||
|
||||
default:
|
||||
return status.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void extendKeepAliveIfActive() {
|
||||
if (keepAliveActive()) {
|
||||
if (Helpers.ratelimit("extend-insight-keepalive", 10)) {
|
||||
stayConnectedTill = Helpers.tsl() + stayConnectedTime;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Keep-alive extended until: " + Helpers.dateTimeText(stayConnectedTill));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean keepAliveActive() {
|
||||
return Helpers.tsl() <= stayConnectedTill;
|
||||
}
|
||||
|
||||
public static String getKeepAliveString() {
|
||||
if (keepAliveActive()) {
|
||||
return MainApp.gs(R.string.insight_keepalive_format_string,
|
||||
stayConnectedTime / 1000, Helpers.hourMinuteSecondString(stayConnectedTill));
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void delayedDisconnectionThread() {
|
||||
if (keepAliveActive()) {
|
||||
if (!disconnect_thread_running) {
|
||||
disconnect_thread_running = true;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PowerManager.WakeLock wl = Helpers.getWakeLock("insight-disconnection-timer", 600000);
|
||||
try {
|
||||
while (disconnect_thread_running && keepAliveActive()) {
|
||||
if (Helpers.ratelimit("insight-expiry-notice", 5)) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Staying connected thread expires: " + Helpers.dateTimeText(stayConnectedTill));
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
if (disconnect_thread_running) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Sending the real delayed disconnect");
|
||||
get().getServiceConnector().disconnect();
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Disconnect thread already terminating");
|
||||
}
|
||||
} finally {
|
||||
Helpers.releaseWakeLock(wl);
|
||||
disconnect_thread_running = false;
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Disconnect thread already running");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static long percentage(long t, long total) {
|
||||
return (long) (Helpers.roundDouble(((double) t * 100) / total, 0));
|
||||
}
|
||||
|
||||
public synchronized void shutdown() {
|
||||
if (instance != null) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Attempting to shut down connector");
|
||||
try {
|
||||
disconnect_thread_running = false;
|
||||
try {
|
||||
instance.serviceConnector.setConnectionCallback(null);
|
||||
} catch (Exception e) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
instance.serviceConnector.removeStatusCallback(statusCallback);
|
||||
} catch (Exception e) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
instance.serviceConnector.disconnect();
|
||||
} catch (Exception e) {
|
||||
log.error("Exception disconnecting: " + e);
|
||||
}
|
||||
try {
|
||||
instance.serviceConnector.disconnectFromService();
|
||||
} catch (Exception e) {
|
||||
log.error("Excpetion disconnecting service: " + e);
|
||||
}
|
||||
instance.serviceConnector = null;
|
||||
instance = null;
|
||||
} catch (Exception e) {
|
||||
log.error("Exception shutting down: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("AccessStaticViaInstance")
|
||||
private synchronized void initializeHistoryReceiver() {
|
||||
if (historyReceiver == null) {
|
||||
historyReceiver = new HistoryReceiver();
|
||||
}
|
||||
historyReceiver.registerHistoryReceiver();
|
||||
}
|
||||
|
||||
public synchronized void init() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Connector::init()");
|
||||
if (serviceConnector == null) {
|
||||
companionAppInstalled = isCompanionAppInstalled();
|
||||
if (companionAppInstalled) {
|
||||
serviceConnector = new SightServiceConnector(MainApp.instance());
|
||||
serviceConnector.removeStatusCallback(statusCallback);
|
||||
serviceConnector.addStatusCallback(statusCallback);
|
||||
serviceConnector.setConnectionCallback(connectionCallback);
|
||||
serviceConnector.connectToService();
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Trying to connect");
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Not trying init due to missing companion app");
|
||||
}
|
||||
} else {
|
||||
if (!serviceConnector.isConnectedToService()) {
|
||||
if (serviceReconnects > 0) {
|
||||
serviceConnector = null;
|
||||
init();
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Trying to reconnect to service (" + serviceReconnects + ")");
|
||||
serviceConnector.connectToService();
|
||||
serviceReconnects++;
|
||||
}
|
||||
} else {
|
||||
serviceReconnects = 0; // everything ok
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SightServiceConnector getServiceConnector() {
|
||||
init();
|
||||
return serviceConnector;
|
||||
}
|
||||
|
||||
public String getCurrent() {
|
||||
init();
|
||||
return safeGetStatus().toString();
|
||||
}
|
||||
|
||||
public Status safeGetStatus() {
|
||||
try {
|
||||
if (isConnected()) return serviceConnector.getStatus();
|
||||
return Status.DISCONNECTED;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Status.INCOMPATIBLE;
|
||||
}
|
||||
}
|
||||
|
||||
public Status getLastStatus() {
|
||||
return lastStatus;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return serviceConnector != null && serviceConnector.isConnectedToService();
|
||||
}
|
||||
|
||||
public boolean isPumpConnected() {
|
||||
return isConnected() && getLastStatus() == Status.CONNECTED;
|
||||
}
|
||||
|
||||
public boolean isPumpConnecting() {
|
||||
return isConnected() && getLastStatus() == Status.CONNECTING;
|
||||
}
|
||||
|
||||
public long getLastContactTime() {
|
||||
return lastContactTime;
|
||||
}
|
||||
|
||||
public String getLastStatusMessage() {
|
||||
|
||||
if (!companionAppInstalled) {
|
||||
return MainApp.gs(R.string.insight_companion_app_not_installed);
|
||||
}
|
||||
|
||||
if (!isConnected()) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Not connected to companion");
|
||||
if (Helpers.ratelimit("insight-app-not-connected", 5)) {
|
||||
init();
|
||||
}
|
||||
|
||||
if ((lastStatus == null) || (lastStatus != Status.INCOMPATIBLE)) {
|
||||
if (compatabilityMessage != null) {
|
||||
// if disconnected but previous state was incompatible
|
||||
return compatabilityMessage;
|
||||
} else {
|
||||
return MainApp.gs(R.string.insight_not_connected_to_companion_app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastStatus == null) {
|
||||
return MainApp.gs(R.string.insight_unknown);
|
||||
}
|
||||
|
||||
switch (lastStatus) {
|
||||
case CONNECTED:
|
||||
if (Helpers.msSince(lastStatusTime) > (60 * 10 * 1000)) {
|
||||
tryToGetPumpStatusAgain();
|
||||
}
|
||||
break;
|
||||
case INCOMPATIBLE:
|
||||
return statusToString(lastStatus) + " " + MainApp.gs(R.string.insight_needs) + " " + getLocalVersion();
|
||||
}
|
||||
return statusToString(lastStatus);
|
||||
}
|
||||
|
||||
public String getNiceLastStatusTime() {
|
||||
if (lastStatusTime < 1) {
|
||||
return MainApp.gs(R.string.insight_startup_uppercase);
|
||||
} else {
|
||||
return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " " + MainApp.gs(R.string.ago);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean uiFresh() {
|
||||
// todo check other changes
|
||||
|
||||
if (Helpers.msSince(lastStatusTime) < FRESH_MS) {
|
||||
return true;
|
||||
}
|
||||
if (Helpers.msSince(LiveHistory.getStatusTime()) < FRESH_MS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("AccessStaticViaInstance")
|
||||
public void tryToGetPumpStatusAgain() {
|
||||
if (Helpers.ratelimit("insight-retry-status-request", 5)) {
|
||||
try {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Insight. Status missing", null);
|
||||
} catch (NullPointerException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void requestHistorySync() {
|
||||
requestHistorySync(0);
|
||||
}
|
||||
|
||||
public void requestHistoryReSync() {
|
||||
requestHistoryReSync(0);
|
||||
}
|
||||
|
||||
public void requestHistorySync(long delay) {
|
||||
if (Helpers.ratelimit("insight-history-sync-request", 10)) {
|
||||
final Intent intent = new Intent(ACTION_START_SYNC);
|
||||
sendBroadcastToCompanion(intent, delay);
|
||||
}
|
||||
}
|
||||
|
||||
public void requestHistoryReSync(long delay) {
|
||||
if (Helpers.ratelimit("insight-history-resync-request", 300)) {
|
||||
final Intent intent = new Intent(ACTION_START_RESYNC);
|
||||
sendBroadcastToCompanion(intent, delay);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendBroadcastToCompanion(final Intent intent, final long delay) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PowerManager.WakeLock wl = Helpers.getWakeLock("insight-companion-delay", 60000);
|
||||
intent.setPackage(COMPANION_APP_PACKAGE);
|
||||
intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
try {
|
||||
if (delay > 0) {
|
||||
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
//
|
||||
} finally {
|
||||
Helpers.releaseWakeLock(wl);
|
||||
}
|
||||
MainApp.instance().sendBroadcast(intent);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public boolean lastStatusRecent() {
|
||||
return true; // TODO evaluate whether current
|
||||
}
|
||||
|
||||
private void updateStatusStatistics(Status last, long since) {
|
||||
if ((last != null) && (since > 0)) {
|
||||
Long total = statistics.get(last);
|
||||
if (total == null) total = 0L;
|
||||
statistics.put(last, total + Helpers.msSince(since));
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Updated statistics for: " + last + " total: " + Helpers.niceTimeScalar(statistics.get(last)));
|
||||
// TODO persist data
|
||||
}
|
||||
}
|
||||
|
||||
public List<StatusItem> getStatusStatistics() {
|
||||
final List<StatusItem> l = new ArrayList<>();
|
||||
long total = 0;
|
||||
for (Map.Entry entry : statistics.entrySet()) {
|
||||
total += getEntryTime(entry);
|
||||
}
|
||||
for (Map.Entry entry : statistics.entrySet()) {
|
||||
if ((long) entry.getValue() > 1000) {
|
||||
l.add(new StatusItem(MainApp.gs(R.string.statistics) + " " + Helpers.capitalize(entry.getKey().toString()),
|
||||
new Formatter().format("%4s %12s",
|
||||
percentage(getEntryTime(entry), total) + "%",
|
||||
Helpers.niceTimeScalar(getEntryTime(entry))).toString()));
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
private long getEntryTime(Map.Entry entry) {
|
||||
return (long) entry.getValue() + (entry.getKey().equals(lastStatus) ? Helpers.msSince(lastStatusTime) : 0);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventFeatureRunning ev) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isConnected()) {
|
||||
if (SP.getBoolean("insight_preemptive_connect", true)) {
|
||||
switch (ev.getFeature()) {
|
||||
case WIZARD:
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Wizard feature detected, preconnecting to pump");
|
||||
connectToPump(120 * 1000);
|
||||
break;
|
||||
case MAIN:
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Main feature detected, preconnecting to pump");
|
||||
connectToPump(30 * 1000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||
|
||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.ChangeTBRMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.SetTBRMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.CurrentTBRMessage;
|
||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||
import sugar.free.sightparser.handling.TaskRunner;
|
||||
|
||||
// from Tebbe - note this uses 1 minute duration to silently cancel existing TBR
|
||||
|
||||
public class SetTBRTaskRunner extends TaskRunner {
|
||||
|
||||
private int amount;
|
||||
private int duration;
|
||||
|
||||
public SetTBRTaskRunner(SightServiceConnector serviceConnector, int amount, int duration) {
|
||||
super(serviceConnector);
|
||||
this.amount = amount;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
|
||||
if (message == null) return new CurrentTBRMessage();
|
||||
else if (message instanceof CurrentTBRMessage) {
|
||||
if (((CurrentTBRMessage) message).getPercentage() == 100) {
|
||||
SetTBRMessage setTBRMessage = new SetTBRMessage();
|
||||
setTBRMessage.setDuration(duration);
|
||||
setTBRMessage.setAmount(amount);
|
||||
return setTBRMessage;
|
||||
} else {
|
||||
ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage();
|
||||
changeTBRMessage.setDuration(duration);
|
||||
changeTBRMessage.setAmount(amount);
|
||||
return changeTBRMessage;
|
||||
}
|
||||
} else if (message instanceof SetTBRMessage) finish(amount);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import sugar.free.sightparser.applayer.descriptors.ActiveBolus;
|
||||
import sugar.free.sightparser.applayer.descriptors.PumpStatus;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ActiveProfileBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile1Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile2Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile3Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile4Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile5Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.FactoryMinBRAmountBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.FactoryMinBolusAmountBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.MaxBRAmountBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.MaxBolusAmountBlock;
|
||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.ActiveBolusesMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.BatteryAmountMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.CartridgeAmountMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.CurrentBasalMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.CurrentTBRMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.PumpStatusMessage;
|
||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||
import sugar.free.sightparser.handling.TaskRunner;
|
||||
|
||||
/**
|
||||
* Created by Tebbe Ubben on 12.03.2018.
|
||||
*/
|
||||
|
||||
public class StatusTaskRunner extends TaskRunner {
|
||||
|
||||
private Result result = new Result();
|
||||
|
||||
public StatusTaskRunner(SightServiceConnector serviceConnector) {
|
||||
super(serviceConnector);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
|
||||
if (message == null) return new PumpStatusMessage();
|
||||
else if (message instanceof PumpStatusMessage) {
|
||||
result.pumpStatus = ((PumpStatusMessage) message).getPumpStatus();
|
||||
if (result.pumpStatus == PumpStatus.STOPPED) return new BatteryAmountMessage();
|
||||
else return new CurrentTBRMessage();
|
||||
} else if (message instanceof CurrentTBRMessage) {
|
||||
CurrentTBRMessage currentTBRMessage = (CurrentTBRMessage) message;
|
||||
result.tbrAmount = currentTBRMessage.getPercentage();
|
||||
result.tbrInitialDuration = currentTBRMessage.getInitialTime();
|
||||
result.tbrLeftoverDuration = currentTBRMessage.getLeftoverTime();
|
||||
return new ActiveBolusesMessage();
|
||||
} else if (message instanceof ActiveBolusesMessage) {
|
||||
ActiveBolusesMessage activeBolusesMessage = (ActiveBolusesMessage) message;
|
||||
result.activeBolus1 = activeBolusesMessage.getBolus1();
|
||||
result.activeBolus2 = activeBolusesMessage.getBolus2();
|
||||
result.activeBolus3 = activeBolusesMessage.getBolus3();
|
||||
return new CurrentBasalMessage();
|
||||
} else if (message instanceof CurrentBasalMessage) {
|
||||
result.baseBasalRate = ((CurrentBasalMessage) message).getCurrentBasalAmount();
|
||||
return new BatteryAmountMessage();
|
||||
} else if (message instanceof BatteryAmountMessage) {
|
||||
result.battery = ((BatteryAmountMessage) message).getBatteryAmount();
|
||||
return new CartridgeAmountMessage();
|
||||
} else if (message instanceof CartridgeAmountMessage) {
|
||||
result.cartridge = ((CartridgeAmountMessage) message).getCartridgeAmount();
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
readMessage.setConfigurationBlockID(ActiveProfileBlock.ID);
|
||||
return readMessage;
|
||||
} else if (message instanceof ReadConfigurationBlockMessage) {
|
||||
ConfigurationBlock configurationBlock = ((ReadConfigurationBlockMessage) message).getConfigurationBlock();
|
||||
if (configurationBlock instanceof ActiveProfileBlock) {
|
||||
ActiveProfileBlock activeProfileBlock = (ActiveProfileBlock) configurationBlock;
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
switch (activeProfileBlock.getActiveProfile()) {
|
||||
case BR_PROFILE_1:
|
||||
readMessage.setConfigurationBlockID(BRProfile1Block.ID);
|
||||
break;
|
||||
case BR_PROFILE_2:
|
||||
readMessage.setConfigurationBlockID(BRProfile2Block.ID);
|
||||
break;
|
||||
case BR_PROFILE_3:
|
||||
readMessage.setConfigurationBlockID(BRProfile3Block.ID);
|
||||
break;
|
||||
case BR_PROFILE_4:
|
||||
readMessage.setConfigurationBlockID(BRProfile4Block.ID);
|
||||
break;
|
||||
case BR_PROFILE_5:
|
||||
readMessage.setConfigurationBlockID(BRProfile5Block.ID);
|
||||
break;
|
||||
}
|
||||
return readMessage;
|
||||
} else if (configurationBlock instanceof BRProfileBlock) {
|
||||
result.basalProfile = ((BRProfileBlock) configurationBlock).getProfileBlocks();
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
readMessage.setConfigurationBlockID(MaxBolusAmountBlock.ID);
|
||||
return readMessage;
|
||||
} else if (configurationBlock instanceof MaxBolusAmountBlock) {
|
||||
result.maximumBolusAmount = ((MaxBolusAmountBlock) configurationBlock).getMaximumAmount();
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
readMessage.setConfigurationBlockID(MaxBRAmountBlock.ID);
|
||||
return readMessage;
|
||||
} else if (configurationBlock instanceof MaxBRAmountBlock) {
|
||||
result.maximumBasalAmount = ((MaxBRAmountBlock) configurationBlock).getMaximumAmount();
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
readMessage.setConfigurationBlockID(FactoryMinBRAmountBlock.ID);
|
||||
return readMessage;
|
||||
} else if (configurationBlock instanceof FactoryMinBRAmountBlock) {
|
||||
result.minimumBasalAmount = ((FactoryMinBRAmountBlock) configurationBlock).getMinimumAmount();
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
readMessage.setConfigurationBlockID(FactoryMinBolusAmountBlock.ID);
|
||||
return readMessage;
|
||||
} else if (configurationBlock instanceof FactoryMinBolusAmountBlock) {
|
||||
result.minimumBolusAmount = ((FactoryMinBolusAmountBlock) configurationBlock).getMinimumAmount();
|
||||
finish(result);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Result {
|
||||
public PumpStatus pumpStatus;
|
||||
public double baseBasalRate;
|
||||
public int battery;
|
||||
public double cartridge ;
|
||||
public int tbrAmount = 100;
|
||||
public int tbrInitialDuration = 0;
|
||||
public int tbrLeftoverDuration = 0;
|
||||
public ActiveBolus activeBolus1;
|
||||
public ActiveBolus activeBolus2;
|
||||
public ActiveBolus activeBolus3;
|
||||
public List<BRProfileBlock.ProfileBlock> basalProfile;
|
||||
public double maximumBolusAmount;
|
||||
public double maximumBasalAmount;
|
||||
public double minimumBolusAmount;
|
||||
public double minimumBasalAmount;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ActiveProfileBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile1Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile2Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile3Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile4Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile5Block;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock;
|
||||
import sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock;
|
||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.configuration.CloseWriteSessionMessage;
|
||||
import sugar.free.sightparser.applayer.messages.configuration.OpenWriteSessionMessage;
|
||||
import sugar.free.sightparser.applayer.messages.configuration.ReadConfigurationBlockMessage;
|
||||
import sugar.free.sightparser.applayer.messages.configuration.WriteConfigurationBlockMessage;
|
||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||
import sugar.free.sightparser.handling.TaskRunner;
|
||||
|
||||
/**
|
||||
* Created by Tebbe Ubben on 10.03.2018.
|
||||
*/
|
||||
|
||||
public class WriteBasalProfileTaskRunner extends TaskRunner {
|
||||
|
||||
private List<BRProfileBlock.ProfileBlock> profileBlocks;
|
||||
private BRProfileBlock profileBlock;
|
||||
|
||||
public WriteBasalProfileTaskRunner(SightServiceConnector serviceConnector, List<BRProfileBlock.ProfileBlock> profileBlocks) {
|
||||
super(serviceConnector);
|
||||
this.profileBlocks = profileBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
|
||||
if (message == null) {
|
||||
ReadConfigurationBlockMessage readMessage = new ReadConfigurationBlockMessage();
|
||||
readMessage.setConfigurationBlockID(ActiveProfileBlock.ID);
|
||||
return readMessage;
|
||||
} else if (message instanceof ReadConfigurationBlockMessage) {
|
||||
ConfigurationBlock configurationBlock = ((ReadConfigurationBlockMessage) message).getConfigurationBlock();
|
||||
ActiveProfileBlock activeProfileBlock = (ActiveProfileBlock) configurationBlock;
|
||||
switch (activeProfileBlock.getActiveProfile()) {
|
||||
case BR_PROFILE_1:
|
||||
profileBlock = new BRProfile1Block();
|
||||
break;
|
||||
case BR_PROFILE_2:
|
||||
profileBlock = new BRProfile2Block();
|
||||
break;
|
||||
case BR_PROFILE_3:
|
||||
profileBlock = new BRProfile3Block();
|
||||
break;
|
||||
case BR_PROFILE_4:
|
||||
profileBlock = new BRProfile4Block();
|
||||
break;
|
||||
case BR_PROFILE_5:
|
||||
profileBlock = new BRProfile5Block();
|
||||
break;
|
||||
}
|
||||
profileBlock.setProfileBlocks(profileBlocks);
|
||||
return new OpenWriteSessionMessage();
|
||||
} else if (message instanceof OpenWriteSessionMessage) {
|
||||
WriteConfigurationBlockMessage writeMessage = new WriteConfigurationBlockMessage();
|
||||
writeMessage.setConfigurationBlock(profileBlock);
|
||||
return writeMessage;
|
||||
} else if (message instanceof WriteConfigurationBlockMessage) {
|
||||
return new CloseWriteSessionMessage();
|
||||
} else if (message instanceof CloseWriteSessionMessage) finish(null);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 23/01/2018.
|
||||
*/
|
||||
public class EventInsightCallback extends Event {
|
||||
|
||||
public UUID request_uuid;
|
||||
public boolean success = false;
|
||||
public String message = null;
|
||||
public Object response_object = null;
|
||||
|
||||
public EventInsightCallback() {
|
||||
request_uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Event: " + request_uuid + " success: " + success + " msg: " + message + " Object: " + response_object;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.events;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 23/01/2018.
|
||||
*/
|
||||
public class EventInsightUpdateGui extends EventUpdateGui {
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.TDD;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import sugar.free.sightparser.handling.HistoryBroadcast;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.updatePumpSerialNumber;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 27/01/2018.
|
||||
* <p>
|
||||
* Parse inbound logbook intents
|
||||
*/
|
||||
|
||||
class HistoryIntentAdapter {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private HistoryLogAdapter logAdapter = new HistoryLogAdapter();
|
||||
|
||||
private static long getDateExtra(Intent intent, String name) {
|
||||
return ((Date) intent.getSerializableExtra(name)).getTime();
|
||||
}
|
||||
|
||||
static long getRecordUniqueID(long pump_serial_number, long pump_record_id) {
|
||||
updatePumpSerialNumber(pump_serial_number);
|
||||
return (pump_serial_number * 10000000) + pump_record_id;
|
||||
}
|
||||
|
||||
void processTBRIntent(Intent intent) {
|
||||
|
||||
final int pump_tbr_duration = intent.getIntExtra(HistoryBroadcast.EXTRA_DURATION, -1);
|
||||
final int pump_tbr_percent = intent.getIntExtra(HistoryBroadcast.EXTRA_TBR_AMOUNT, -1);
|
||||
long pump_record_id = intent.getLongExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
|
||||
if (pump_record_id == -1) {
|
||||
pump_record_id = intent.getIntExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
|
||||
}
|
||||
final long pump_serial_number = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER));
|
||||
final long start_time = getDateExtra(intent, HistoryBroadcast.EXTRA_START_TIME);
|
||||
|
||||
if ((pump_tbr_duration == -1) || (pump_tbr_percent == -1) || (pump_record_id == -1)) {
|
||||
log.error("Invalid TBR record!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
final long record_unique_id = getRecordUniqueID(pump_serial_number, pump_record_id);
|
||||
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Creating TBR record: " + pump_tbr_percent + "% " + pump_tbr_duration + "m" + " id:" + record_unique_id);
|
||||
logAdapter.createTBRrecord(start_time, pump_tbr_percent, pump_tbr_duration, record_unique_id);
|
||||
}
|
||||
|
||||
void processDeliveredBolusIntent(Intent intent) {
|
||||
|
||||
final String bolus_type = intent.getStringExtra(HistoryBroadcast.EXTRA_BOLUS_TYPE);
|
||||
final int bolus_id = intent.getIntExtra(HistoryBroadcast.EXTRA_BOLUS_ID, -1);
|
||||
long pump_record_id = intent.getLongExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
|
||||
if (pump_record_id == -1) {
|
||||
pump_record_id = intent.getIntExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
|
||||
}
|
||||
final long pump_serial_number = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER));
|
||||
final long event_time = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||
final long start_time = getDateExtra(intent, HistoryBroadcast.EXTRA_START_TIME);
|
||||
final double immediate_amount = intent.getDoubleExtra(HistoryBroadcast.EXTRA_IMMEDIATE_AMOUNT, -1);
|
||||
final double extended_insulin = intent.getDoubleExtra(HistoryBroadcast.EXTRA_EXTENDED_AMOUNT, -1);
|
||||
final int extended_minutes = intent.getIntExtra(HistoryBroadcast.EXTRA_DURATION, -1);
|
||||
|
||||
final long record_unique_id = getRecordUniqueID(pump_serial_number, bolus_id > -1 ? bolus_id : pump_record_id);
|
||||
|
||||
switch (bolus_type) {
|
||||
case "STANDARD":
|
||||
if (immediate_amount == -1) {
|
||||
log.error("ERROR Standard bolus fails sanity check");
|
||||
return;
|
||||
}
|
||||
LiveHistory.setStatus(bolus_type + " BOLUS\n" + immediate_amount + "U ", event_time);
|
||||
logAdapter.createStandardBolusRecord(start_time, immediate_amount, record_unique_id);
|
||||
break;
|
||||
|
||||
case "EXTENDED":
|
||||
if ((extended_insulin == -1) || (extended_minutes == -1)) {
|
||||
log.error("ERROR: Extended bolus fails sanity check");
|
||||
return;
|
||||
}
|
||||
LiveHistory.setStatus(bolus_type + " BOLUS\n" + extended_insulin + "U over " + extended_minutes + " min, ", event_time);
|
||||
logAdapter.createExtendedBolusRecord(start_time, extended_insulin, extended_minutes, record_unique_id);
|
||||
break;
|
||||
|
||||
case "MULTIWAVE":
|
||||
if ((immediate_amount == -1) || (extended_insulin == -1) || (extended_minutes == -1)) {
|
||||
log.error("ERROR: Multiwave bolus fails sanity check");
|
||||
return;
|
||||
}
|
||||
LiveHistory.setStatus(bolus_type + " BOLUS\n" + immediate_amount + "U + " + extended_insulin + "U over " + extended_minutes + " min, ", event_time);
|
||||
logAdapter.createStandardBolusRecord(start_time, immediate_amount, pump_serial_number + pump_record_id);
|
||||
logAdapter.createExtendedBolusRecord(start_time, extended_insulin, extended_minutes, record_unique_id);
|
||||
break;
|
||||
default:
|
||||
log.error("ERROR, UNKNWON BOLUS TYPE: " + bolus_type);
|
||||
}
|
||||
}
|
||||
|
||||
void processDailyTotalIntent(Intent intent) {
|
||||
long date = getDateExtra(intent, HistoryBroadcast.EXTRA_TOTAL_DATE);
|
||||
double basal = intent.getDoubleExtra(HistoryBroadcast.EXTRA_BASAL_TOTAL, 0D);
|
||||
double bolus = intent.getDoubleExtra(HistoryBroadcast.EXTRA_BOLUS_TOTAL, 0D);
|
||||
TDD tdd = new TDD(date, bolus, basal, bolus + basal);
|
||||
MainApp.getDbHelper().createOrUpdateTDD(tdd);
|
||||
}
|
||||
|
||||
void processCannulaFilledIntent(Intent intent) {
|
||||
long date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||
uploadCareportalEvent(date, CareportalEvent.SITECHANGE);
|
||||
}
|
||||
|
||||
void processCartridgeInsertedIntent(Intent intent) {
|
||||
long date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||
uploadCareportalEvent(date, CareportalEvent.INSULINCHANGE);
|
||||
}
|
||||
|
||||
void processBatteryInsertedIntent(Intent intent) {
|
||||
long date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||
uploadCareportalEvent(date, CareportalEvent.PUMPBATTERYCHANGE);
|
||||
}
|
||||
|
||||
private void uploadCareportalEvent(long date, String event) {
|
||||
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
|
||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null)
|
||||
return;
|
||||
try {
|
||||
JSONObject data = new JSONObject();
|
||||
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", event);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void processOccurenceOfAlertIntent(Intent intent) {
|
||||
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
|
||||
long date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||
String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE);
|
||||
int alertText = getAlertText(alertType);
|
||||
if (alertText == 0) return;
|
||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null)
|
||||
return;
|
||||
logNote(date, MainApp.gs(alertText));
|
||||
}
|
||||
}
|
||||
|
||||
void processPumpStatusChangedIntent(Intent intent) {
|
||||
long newStatusTime = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
|
||||
if (SP.getBoolean("insight_automatic_careportal_events", false)) {
|
||||
String newStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_NEW_STATUS);
|
||||
switch (newStatus) {
|
||||
case "STARTED":
|
||||
logNote(newStatusTime, MainApp.gs(R.string.pump_started));
|
||||
break;
|
||||
case "STOPPED":
|
||||
logNote(newStatusTime, MainApp.gs(R.string.pump_stopped));
|
||||
break;
|
||||
case "PAUSED":
|
||||
logNote(newStatusTime, MainApp.gs(R.string.pump_paused));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (intent.hasExtra(HistoryBroadcast.EXTRA_OLD_STATUS_TIME)) {
|
||||
String oldStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_OLD_STATUS);
|
||||
if (oldStatus.equals("STOPPED")) {
|
||||
long oldStatusTime = getDateExtra(intent, HistoryBroadcast.EXTRA_OLD_STATUS_TIME);
|
||||
int duration = (int) ((newStatusTime - oldStatusTime) / 60000);
|
||||
|
||||
long serialNumber = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER));
|
||||
long recordId = intent.getLongExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
|
||||
long uniqueRecordId = getRecordUniqueID(serialNumber, recordId);
|
||||
|
||||
logAdapter.createTBRrecord(oldStatusTime, 0, duration, uniqueRecordId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void logNote(long date, String note) {
|
||||
try {
|
||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null)
|
||||
return;
|
||||
JSONObject data = new JSONObject();
|
||||
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", CareportalEvent.NOTE);
|
||||
data.put("notes", note);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private int getAlertText(String type) {
|
||||
if (type.equals("Error6MechanicalError")) return R.string.alert_e6;
|
||||
if (type.equals("Error7ElectronicError")) return R.string.alert_e7;
|
||||
if (type.equals("Error10RewindError")) return R.string.alert_e10;
|
||||
if (type.equals("Error13LanguageError")) return R.string.alert_e13;
|
||||
if (type.equals("Maintenance20CartridgeNotInserted")) return R.string.alert_m20;
|
||||
if (type.equals("Maintenance21CartridgeEmpty")) return R.string.alert_m21;
|
||||
if (type.equals("Maintenance22BatteryEmpty")) return R.string.alert_m22;
|
||||
if (type.equals("Maintenance23AutomaticOff")) return R.string.alert_m23;
|
||||
if (type.equals("Maintenance24Occlusion")) return R.string.alert_m24;
|
||||
if (type.equals("Maintenance25LoantimeOver")) return R.string.alert_m25;
|
||||
if (type.equals("Maintenance26CartridgeChangeNotCompleted")) return R.string.alert_m26;
|
||||
if (type.equals("Maintenance27DataDownloadFailed")) return R.string.alert_m27;
|
||||
if (type.equals("Maintenance28PauseModeTimeout")) return R.string.alert_m28;
|
||||
if (type.equals("Maintenance29BatteryTypeNotSet")) return R.string.alert_m29;
|
||||
if (type.equals("Maintenance30CartridgeTypeNotSet")) return R.string.alert_m30;
|
||||
if (type.equals("Warning31CartridgeLow")) return R.string.alert_w31;
|
||||
if (type.equals("Warning32BatteryLow")) return R.string.alert_w32;
|
||||
if (type.equals("Warning33InvalidDateTime")) return R.string.alert_w33;
|
||||
if (type.equals("Warning34EndOfWarranty")) return R.string.alert_w34;
|
||||
if (type.equals("Warning36TBRCancelled")) return 0;
|
||||
if (type.equals("Warning38BolusCancelled")) return 0;
|
||||
if (type.equals("Warning39LoantimeWarning")) return R.string.alert_w39;
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.T;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 27/01/2018.
|
||||
* <p>
|
||||
* Write to the History Log
|
||||
*/
|
||||
|
||||
class HistoryLogAdapter {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private static final long MAX_TIME_DIFFERENCE = T.secs(61).msecs();
|
||||
|
||||
void createTBRrecord(long eventDate, int percent, int duration, long record_id) {
|
||||
|
||||
TemporaryBasal temporaryBasal = new TemporaryBasal().date(eventDate);
|
||||
|
||||
final TemporaryBasal temporaryBasalFromHistory = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(eventDate);
|
||||
|
||||
if (temporaryBasalFromHistory == null) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Create new TBR: " + eventDate + " " + percent + " " + duration);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Loaded existing TBR record: " + temporaryBasalFromHistory.toString());
|
||||
if (Math.abs(eventDate - temporaryBasalFromHistory.date) < MAX_TIME_DIFFERENCE) {
|
||||
if (temporaryBasalFromHistory.source != Source.PUMP) {
|
||||
if (temporaryBasalFromHistory.percentRate == percent) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Things seem to match: %" + percent);
|
||||
temporaryBasal = temporaryBasalFromHistory;
|
||||
String _id = temporaryBasal._id;
|
||||
if (NSUpload.isIdValid(_id)) {
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
} else {
|
||||
UploadQueue.removeID("dbAdd", _id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(temporaryBasalFromHistory);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("This record has different percent rates: " + temporaryBasalFromHistory.percentRate + " vs us: " + percent);
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("This record is already a pump record!");
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Time difference too big! : " + (eventDate - temporaryBasalFromHistory.date));
|
||||
}
|
||||
}
|
||||
|
||||
temporaryBasal.source(Source.PUMP)
|
||||
.pumpId(record_id)
|
||||
.percent(percent)
|
||||
.duration(duration);
|
||||
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||
}
|
||||
|
||||
void createExtendedBolusRecord(long eventDate, double insulin, int durationInMinutes, long record_id) {
|
||||
|
||||
final ExtendedBolus extendedBolusFromHistory = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(eventDate);
|
||||
|
||||
if (extendedBolusFromHistory == null) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Create new EB: " + eventDate + " " + insulin + " " + durationInMinutes);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Loaded existing EB record: " + extendedBolusFromHistory.log());
|
||||
if (Math.abs(eventDate - extendedBolusFromHistory.date) < MAX_TIME_DIFFERENCE) {
|
||||
if (extendedBolusFromHistory.source != Source.PUMP) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Date seem to match: " + DateUtil.dateAndTimeFullString(eventDate));
|
||||
String _id = extendedBolusFromHistory._id;
|
||||
if (NSUpload.isIdValid(_id)) {
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
} else {
|
||||
UploadQueue.removeID("dbAdd", _id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(extendedBolusFromHistory);
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("This record is already a pump record!");
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Time difference too big! : " + (eventDate - extendedBolusFromHistory.date));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO trap items below minimum period
|
||||
|
||||
// TODO (mike) find and remove ending record with Source.USER
|
||||
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus()
|
||||
.date(eventDate)
|
||||
.insulin(insulin)
|
||||
.durationInMinutes(durationInMinutes)
|
||||
.source(Source.PUMP)
|
||||
.pumpId(record_id);
|
||||
|
||||
if (ProfileFunctions.getInstance().getProfile(extendedBolus.date) != null) // actual basal rate is needed for absolute rate calculation
|
||||
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||
}
|
||||
|
||||
void createStandardBolusRecord(long eventDate, double insulin, long record_id) {
|
||||
|
||||
//DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(eventDate.getTime());
|
||||
|
||||
// TODO do we need to do the same delete + insert that we are doing for temporary basals here too?
|
||||
|
||||
final DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.date = eventDate;
|
||||
detailedBolusInfo.source = Source.PUMP;
|
||||
detailedBolusInfo.pumpId = record_id;
|
||||
detailedBolusInfo.insulin = insulin;
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.BUSY;
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCED;
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCING;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.*;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 27/01/2018.
|
||||
*/
|
||||
|
||||
public class HistoryReceiver {
|
||||
|
||||
private static BroadcastReceiver historyReceiver;
|
||||
private volatile static Status status = Status.IDLE;
|
||||
private volatile HistoryIntentAdapter intentAdapter;
|
||||
|
||||
public HistoryReceiver() {
|
||||
initializeHistoryReceiver();
|
||||
}
|
||||
|
||||
public static synchronized void registerHistoryReceiver() {
|
||||
try {
|
||||
MainApp.instance().unregisterReceiver(historyReceiver);
|
||||
} catch (Exception e) {
|
||||
//
|
||||
}
|
||||
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ACTION_PUMP_STATUS_CHANGED);
|
||||
filter.addAction(ACTION_BOLUS_PROGRAMMED);
|
||||
filter.addAction(ACTION_BOLUS_DELIVERED);
|
||||
filter.addAction(ACTION_END_OF_TBR);
|
||||
filter.addAction(ACTION_DAILY_TOTAL);
|
||||
filter.addAction(ACTION_SYNC_STARTED);
|
||||
filter.addAction(ACTION_STILL_SYNCING);
|
||||
filter.addAction(ACTION_SYNC_FINISHED);
|
||||
filter.addAction(ACTION_CANNULA_FILLED);
|
||||
filter.addAction(ACTION_CARTRIDGE_INSERTED);
|
||||
filter.addAction(ACTION_BATTERY_INSERTED);
|
||||
filter.addAction(ACTION_OCCURENCE_OF_ALERT);
|
||||
filter.addAction(ACTION_PUMP_STATUS_CHANGED);
|
||||
|
||||
MainApp.instance().registerReceiver(historyReceiver, filter);
|
||||
}
|
||||
|
||||
// History
|
||||
|
||||
public static String getStatusString() {
|
||||
return status.toString();
|
||||
}
|
||||
|
||||
private synchronized void initializeHistoryReceiver() {
|
||||
historyReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, final Intent intent) {
|
||||
|
||||
final String action = intent.getAction();
|
||||
if (action == null) return;
|
||||
|
||||
if (intentAdapter == null) {
|
||||
synchronized (this) {
|
||||
if (intentAdapter == null) {
|
||||
intentAdapter = new HistoryIntentAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case ACTION_SYNC_STARTED:
|
||||
status = SYNCING;
|
||||
break;
|
||||
case ACTION_STILL_SYNCING:
|
||||
status = BUSY;
|
||||
break;
|
||||
case ACTION_SYNC_FINISHED:
|
||||
status = SYNCED;
|
||||
break;
|
||||
case ACTION_BOLUS_DELIVERED:
|
||||
intentAdapter.processDeliveredBolusIntent(intent);
|
||||
break;
|
||||
case ACTION_END_OF_TBR:
|
||||
intentAdapter.processTBRIntent(intent);
|
||||
break;
|
||||
case ACTION_DAILY_TOTAL:
|
||||
intentAdapter.processDailyTotalIntent(intent);
|
||||
break;
|
||||
case ACTION_CANNULA_FILLED:
|
||||
intentAdapter.processCannulaFilledIntent(intent);
|
||||
break;
|
||||
case ACTION_CARTRIDGE_INSERTED:
|
||||
intentAdapter.processCartridgeInsertedIntent(intent);
|
||||
break;
|
||||
case ACTION_BATTERY_INSERTED:
|
||||
intentAdapter.processBatteryInsertedIntent(intent);
|
||||
break;
|
||||
case ACTION_OCCURENCE_OF_ALERT:
|
||||
intentAdapter.processOccurenceOfAlertIntent(intent);
|
||||
break;
|
||||
case ACTION_PUMP_STATUS_CHANGED:
|
||||
intentAdapter.processPumpStatusChangedIntent(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
enum Status {
|
||||
IDLE(R.string.insight_history_idle),
|
||||
SYNCING(R.string.insight_history_syncing),
|
||||
BUSY(R.string.insight_history_busy),
|
||||
SYNCED(R.string.insight_history_synced);
|
||||
|
||||
private final int string_id;
|
||||
|
||||
Status(int string_id) {
|
||||
this.string_id = string_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MainApp.gs(string_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 27/01/2018.
|
||||
*
|
||||
* In memory status storage class
|
||||
*/
|
||||
|
||||
public class LiveHistory {
|
||||
|
||||
private static String status = "";
|
||||
private static long status_time = -1;
|
||||
|
||||
public static String getStatus() {
|
||||
if (status.equals("")) return status;
|
||||
return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " " + MainApp.gs(R.string.ago);
|
||||
}
|
||||
|
||||
public static long getStatusTime() {
|
||||
return status_time;
|
||||
}
|
||||
|
||||
static void setStatus(String mystatus, long eventtime) {
|
||||
if (eventtime > status_time) {
|
||||
status_time = eventtime;
|
||||
status = mystatus;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 01/02/2018.
|
||||
*/
|
||||
|
||||
public class PumpIdCache {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private static final String INSIGHT_PUMP_ID_PREF = "insight-pump-id";
|
||||
private static long cachedPumpSerialNumber = -1;
|
||||
|
||||
static void updatePumpSerialNumber(long pump_serial_number) {
|
||||
if (pump_serial_number != cachedPumpSerialNumber) {
|
||||
cachedPumpSerialNumber = pump_serial_number;
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Updating pump serial number: " + pump_serial_number);
|
||||
SP.putLong(INSIGHT_PUMP_ID_PREF, cachedPumpSerialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public static long getRecordUniqueID(long record_id) {
|
||||
if (cachedPumpSerialNumber == -1) {
|
||||
cachedPumpSerialNumber = SP.getLong(INSIGHT_PUMP_ID_PREF, 0L);
|
||||
}
|
||||
return HistoryIntentAdapter.getRecordUniqueID(cachedPumpSerialNumber, record_id);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 24/01/2018.
|
||||
* <p>
|
||||
* Useful utility methods from xDrip+
|
||||
*/
|
||||
|
||||
public class Helpers {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
|
||||
private static final Map<String, Long> rateLimits = new HashMap<>();
|
||||
// singletons to avoid repeated allocation
|
||||
private static DecimalFormatSymbols dfs;
|
||||
private static DecimalFormat df;
|
||||
|
||||
// return true if below rate limit
|
||||
public static synchronized boolean ratelimit(String name, int seconds) {
|
||||
// check if over limit
|
||||
if ((rateLimits.containsKey(name)) && (tsl() - rateLimits.get(name) < (seconds * 1000))) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug(name + " rate limited: " + seconds + " seconds");
|
||||
return false;
|
||||
}
|
||||
// not over limit
|
||||
rateLimits.put(name, tsl());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long tsl() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static long msSince(long when) {
|
||||
return (tsl() - when);
|
||||
}
|
||||
|
||||
public static long msTill(long when) {
|
||||
return (when - tsl());
|
||||
}
|
||||
|
||||
public static boolean checkPackageExists(Context context, String TAG, String packageName) {
|
||||
try {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
final PackageInfo pi = pm.getPackageInfo(packageName, 0);
|
||||
return pi.packageName.equals(packageName);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.error("Exception trying to determine packages! " + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean runOnUiThreadDelayed(Runnable theRunnable, long delay) {
|
||||
return new Handler(MainApp.instance().getMainLooper()).postDelayed(theRunnable, delay);
|
||||
}
|
||||
|
||||
public static PowerManager.WakeLock getWakeLock(final String name, int millis) {
|
||||
final PowerManager pm = (PowerManager) MainApp.instance().getSystemService(Context.POWER_SERVICE);
|
||||
if (pm == null) return null;
|
||||
final PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, name);
|
||||
wl.acquire(millis);
|
||||
return wl;
|
||||
}
|
||||
|
||||
public static void releaseWakeLock(PowerManager.WakeLock wl) {
|
||||
if (wl == null) return;
|
||||
if (wl.isHeld()) wl.release();
|
||||
}
|
||||
|
||||
public static String niceTimeSince(long t) {
|
||||
return niceTimeScalar(msSince(t));
|
||||
}
|
||||
|
||||
public static String niceTimeTill(long t) {
|
||||
return niceTimeScalar(-msSince(t));
|
||||
}
|
||||
|
||||
public static String niceTimeScalar(long t) {
|
||||
String unit = MainApp.gs(R.string.second);
|
||||
t = t / 1000;
|
||||
if (t > 59) {
|
||||
unit = MainApp.gs(R.string.minute);
|
||||
t = t / 60;
|
||||
if (t > 59) {
|
||||
unit = MainApp.gs(R.string.hour);
|
||||
t = t / 60;
|
||||
if (t > 24) {
|
||||
unit = MainApp.gs(R.string.day);
|
||||
t = t / 24;
|
||||
if (t > 28) {
|
||||
unit = MainApp.gs(R.string.week);
|
||||
t = t / 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t != 1) unit = unit + MainApp.gs(R.string.time_plural);
|
||||
return qs((double) t, 0) + " " + unit;
|
||||
}
|
||||
|
||||
public static String qs(double x, int digits) {
|
||||
|
||||
if (digits == -1) {
|
||||
digits = 0;
|
||||
if (((int) x != x)) {
|
||||
digits++;
|
||||
if ((((int) x * 10) / 10 != x)) {
|
||||
digits++;
|
||||
if ((((int) x * 100) / 100 != x)) digits++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dfs == null) {
|
||||
final DecimalFormatSymbols local_dfs = new DecimalFormatSymbols();
|
||||
local_dfs.setDecimalSeparator('.');
|
||||
dfs = local_dfs; // avoid race condition
|
||||
}
|
||||
|
||||
final DecimalFormat this_df;
|
||||
// use singleton if on ui thread otherwise allocate new as DecimalFormat is not thread safe
|
||||
if (Thread.currentThread().getId() == 1) {
|
||||
if (df == null) {
|
||||
final DecimalFormat local_df = new DecimalFormat("#", dfs);
|
||||
local_df.setMinimumIntegerDigits(1);
|
||||
df = local_df; // avoid race condition
|
||||
}
|
||||
this_df = df;
|
||||
} else {
|
||||
this_df = new DecimalFormat("#", dfs);
|
||||
}
|
||||
|
||||
this_df.setMaximumFractionDigits(digits);
|
||||
return this_df.format(x);
|
||||
}
|
||||
|
||||
public static String niceTimeScalarRedux(long t) {
|
||||
return niceTimeScalar(t).replaceFirst("^1 ", "");
|
||||
}
|
||||
|
||||
public static String niceTimeScalarBrief(long t) {
|
||||
// TODO i18n wont work for non-latin characterset
|
||||
return niceTimeScalar(t).replaceFirst("([a-z])[a-z]*", "$1").replace(" ", "");
|
||||
}
|
||||
|
||||
public static String hourMinuteString(long timestamp) {
|
||||
return android.text.format.DateFormat.format("kk:mm", timestamp).toString();
|
||||
}
|
||||
|
||||
public static String hourMinuteSecondString(long timestamp) {
|
||||
return android.text.format.DateFormat.format("kk:mm:ss", timestamp).toString();
|
||||
}
|
||||
|
||||
public static String dateTimeText(long timestamp) {
|
||||
return android.text.format.DateFormat.format("yyyy-MM-dd kk:mm:ss", timestamp).toString();
|
||||
}
|
||||
|
||||
public static String dateText(long timestamp) {
|
||||
return android.text.format.DateFormat.format("yyyy-MM-dd", timestamp).toString();
|
||||
}
|
||||
|
||||
public static String capitalize(String text) {
|
||||
return text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
public static double roundDouble(double value, int places) {
|
||||
if (places < 0) throw new IllegalArgumentException("Invalid decimal places");
|
||||
BigDecimal bd = new BigDecimal(value);
|
||||
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
||||
return bd.doubleValue();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.utils;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 26/01/2018.
|
||||
*
|
||||
* For representing row status items
|
||||
*/
|
||||
|
||||
public class StatusItem {
|
||||
|
||||
public enum Highlight {
|
||||
NORMAL,
|
||||
GOOD,
|
||||
BAD,
|
||||
NOTICE,
|
||||
CRITICAL
|
||||
}
|
||||
|
||||
public String name;
|
||||
public String value;
|
||||
public Highlight highlight;
|
||||
public String button_name;
|
||||
public Runnable runnable;
|
||||
|
||||
|
||||
public StatusItem(String name, String value) {
|
||||
this(name, value, Highlight.NORMAL);
|
||||
}
|
||||
|
||||
public StatusItem() {
|
||||
this("line-break", "", Highlight.NORMAL);
|
||||
}
|
||||
|
||||
public StatusItem(String name, Highlight highlight) {
|
||||
this("heading-break", name, highlight);
|
||||
}
|
||||
|
||||
public StatusItem(String name, Runnable runnable) {
|
||||
this("button-break", "", Highlight.NORMAL, name, runnable);
|
||||
}
|
||||
|
||||
public StatusItem(String name, String value, Highlight highlight) {
|
||||
this(name, value, highlight, null, null);
|
||||
}
|
||||
|
||||
public StatusItem(String name, String value, Highlight highlight, String button_name, Runnable runnable) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.highlight = highlight;
|
||||
this.button_name = button_name;
|
||||
this.runnable = runnable;
|
||||
}
|
||||
|
||||
public StatusItem(String name, Integer value) {
|
||||
this(name, value, Highlight.NORMAL);
|
||||
}
|
||||
|
||||
public StatusItem(String name, Integer value, Highlight highlight) {
|
||||
this.name = name;
|
||||
this.value = Integer.toString(value);
|
||||
this.highlight = highlight;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.utils.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 26/01/2018.
|
||||
*
|
||||
* Convert StatusItem to View
|
||||
*/
|
||||
|
||||
public class StatusItemViewAdapter {
|
||||
|
||||
private final Activity activity;
|
||||
private final ViewGroup holder;
|
||||
|
||||
public StatusItemViewAdapter(Activity activity, ViewGroup holder) {
|
||||
this.activity = activity;
|
||||
this.holder = holder;
|
||||
}
|
||||
|
||||
public View inflateStatus(StatusItem statusItem) {
|
||||
if (activity == null) return null;
|
||||
final View child = activity.getLayoutInflater().inflate(R.layout.insightpump_statuselements, null);
|
||||
final TextView name = (TextView) child.findViewById(R.id.insightstatuslabel);
|
||||
final TextView value = (TextView)child.findViewById(R.id.insightstatusvalue);
|
||||
final TextView spacer = (TextView)child.findViewById(R.id.insightstatusspacer);
|
||||
final LinearLayout layout = (LinearLayout)child.findViewById(R.id.insightstatuslayout);
|
||||
|
||||
if (statusItem.name.equals("line-break")) {
|
||||
spacer.setVisibility(View.GONE);
|
||||
name.setVisibility(View.GONE);
|
||||
value.setVisibility(View.GONE);
|
||||
layout.setPadding(10, 10, 10, 10);
|
||||
} else if (statusItem.name.equals("heading-break")) {
|
||||
value.setVisibility(View.GONE);
|
||||
spacer.setVisibility(View.GONE);
|
||||
name.setText(statusItem.value);
|
||||
name.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
name.setTextColor(Color.parseColor("#fff9c4"));
|
||||
} else {
|
||||
name.setText(statusItem.name);
|
||||
value.setText(statusItem.value);
|
||||
}
|
||||
|
||||
final int this_color = getHighlightColor(statusItem);
|
||||
name.setBackgroundColor(this_color);
|
||||
value.setBackgroundColor(this_color);
|
||||
spacer.setBackgroundColor(this_color);
|
||||
|
||||
if (this_color != Color.TRANSPARENT) {
|
||||
name.setTextColor(Color.WHITE);
|
||||
spacer.setTextColor(Color.WHITE);
|
||||
}
|
||||
|
||||
if (holder != null) {
|
||||
holder.addView(child);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
private static int getHighlightColor(StatusItem row) {
|
||||
switch (row.highlight) {
|
||||
case BAD:
|
||||
return Color.parseColor("#480000");
|
||||
case NOTICE:
|
||||
return Color.parseColor("#403000");
|
||||
case GOOD:
|
||||
return Color.parseColor("#003000");
|
||||
case CRITICAL:
|
||||
return Color.parseColor("#770000");
|
||||
default:
|
||||
return Color.TRANSPARENT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
|
@ -71,7 +70,7 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == operatingMode) {
|
||||
if (LocalInsightPlugin.getInstance().getOperatingMode() != null) {
|
||||
if (LocalInsightPlugin.getPlugin().getOperatingMode() != null) {
|
||||
operatingMode.setEnabled(false);
|
||||
operatingModeCallback = new Callback() {
|
||||
@Override
|
||||
|
@ -82,7 +81,7 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
});
|
||||
}
|
||||
};
|
||||
switch (LocalInsightPlugin.getInstance().getOperatingMode()) {
|
||||
switch (LocalInsightPlugin.getPlugin().getOperatingMode()) {
|
||||
case PAUSED:
|
||||
case STOPPED:
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().startPump(operatingModeCallback);
|
||||
|
@ -92,7 +91,7 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
}
|
||||
}
|
||||
} else if (v == tbrOverNotification) {
|
||||
TBROverNotificationBlock notificationBlock = LocalInsightPlugin.getInstance().getTBROverNotificationBlock();
|
||||
TBROverNotificationBlock notificationBlock = LocalInsightPlugin.getPlugin().getTBROverNotificationBlock();
|
||||
if (notificationBlock != null) {
|
||||
tbrOverNotification.setEnabled(false);
|
||||
tbrOverNotificationCallback = new Callback() {
|
||||
|
@ -131,7 +130,7 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
protected void updateGUI() {
|
||||
if (!viewsCreated) return;
|
||||
statusItemContainer.removeAllViews();
|
||||
if (!LocalInsightPlugin.getInstance().isInitialized()) {
|
||||
if (!LocalInsightPlugin.getPlugin().isInitialized()) {
|
||||
operatingMode.setVisibility(View.GONE);
|
||||
tbrOverNotification.setVisibility(View.GONE);
|
||||
refresh.setVisibility(View.GONE);
|
||||
|
@ -139,7 +138,7 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
}
|
||||
refresh.setVisibility(View.VISIBLE);
|
||||
refresh.setEnabled(refreshCallback == null);
|
||||
TBROverNotificationBlock notificationBlock = LocalInsightPlugin.getInstance().getTBROverNotificationBlock();
|
||||
TBROverNotificationBlock notificationBlock = LocalInsightPlugin.getPlugin().getTBROverNotificationBlock();
|
||||
tbrOverNotification.setVisibility(notificationBlock == null ? View.GONE : View.VISIBLE);
|
||||
if (notificationBlock != null)
|
||||
tbrOverNotification.setText(notificationBlock.isEnabled() ? R.string.disable_tbr_over_notification : R.string.enable_tbr_over_notification);
|
||||
|
@ -170,7 +169,7 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
|
||||
private void getConnectionStatusItem(List<View> statusItems) {
|
||||
int string = 0;
|
||||
InsightState state = LocalInsightPlugin.getInstance().getConnectionService().getState();
|
||||
InsightState state = LocalInsightPlugin.getPlugin().getConnectionService().getState();
|
||||
switch (state) {
|
||||
case NOT_PAIRED:
|
||||
string = R.string.not_paired;
|
||||
|
@ -202,17 +201,17 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
}
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.insight_status), MainApp.gs(string)));
|
||||
if (state == InsightState.RECOVERING) {
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.recovery_duration), LocalInsightPlugin.getInstance().getConnectionService().getRecoveryDuration() / 1000 + "s"));
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.recovery_duration), LocalInsightPlugin.getPlugin().getConnectionService().getRecoveryDuration() / 1000 + "s"));
|
||||
}
|
||||
}
|
||||
|
||||
private void getLastConnectedItem(List<View> statusItems) {
|
||||
switch (LocalInsightPlugin.getInstance().getConnectionService().getState()) {
|
||||
switch (LocalInsightPlugin.getPlugin().getConnectionService().getState()) {
|
||||
case CONNECTED:
|
||||
case NOT_PAIRED:
|
||||
return;
|
||||
default:
|
||||
long lastConnection = LocalInsightPlugin.getInstance().getConnectionService().getLastConnected();
|
||||
long lastConnection = LocalInsightPlugin.getPlugin().getConnectionService().getLastConnected();
|
||||
if (lastConnection == 0) return;
|
||||
int min = (int) ((System.currentTimeMillis() - lastConnection) / 60000);
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.last_connected), DateUtil.timeString(lastConnection)));
|
||||
|
@ -220,14 +219,14 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
}
|
||||
|
||||
private void getOperatingModeItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getOperatingMode() == null) {
|
||||
if (LocalInsightPlugin.getPlugin().getOperatingMode() == null) {
|
||||
operatingMode.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
int string = 0;
|
||||
if (ENABLE_OPERATING_MODE_BUTTON) operatingMode.setVisibility(View.VISIBLE);
|
||||
operatingMode.setEnabled(operatingModeCallback == null);
|
||||
switch (LocalInsightPlugin.getInstance().getOperatingMode()) {
|
||||
switch (LocalInsightPlugin.getPlugin().getOperatingMode()) {
|
||||
case STARTED:
|
||||
operatingMode.setText(R.string.stop_pump);
|
||||
string = R.string.started;
|
||||
|
@ -245,46 +244,46 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
|||
}
|
||||
|
||||
private void getBatteryStatusItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getBatteryStatus() == null) return;
|
||||
if (LocalInsightPlugin.getPlugin().getBatteryStatus() == null) return;
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_battery_label),
|
||||
LocalInsightPlugin.getInstance().getBatteryStatus().getBatteryAmount() + "%"));
|
||||
LocalInsightPlugin.getPlugin().getBatteryStatus().getBatteryAmount() + "%"));
|
||||
}
|
||||
|
||||
private void getCartridgeStatusItem(List<View> statusItems) {
|
||||
CartridgeStatus cartridgeStatus = LocalInsightPlugin.getInstance().getCartridgeStatus();
|
||||
CartridgeStatus cartridgeStatus = LocalInsightPlugin.getPlugin().getCartridgeStatus();
|
||||
if (cartridgeStatus == null) return;
|
||||
String status;
|
||||
if (cartridgeStatus.isInserted())
|
||||
status = DecimalFormatter.to2Decimal(LocalInsightPlugin.getInstance().getCartridgeStatus().getRemainingAmount()) + "U";
|
||||
status = DecimalFormatter.to2Decimal(LocalInsightPlugin.getPlugin().getCartridgeStatus().getRemainingAmount()) + "U";
|
||||
else status = MainApp.gs(R.string.not_inserted);
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_reservoir_label), status));
|
||||
}
|
||||
|
||||
private void getTDDItems(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getTotalDailyDose() == null) return;
|
||||
TotalDailyDose tdd = LocalInsightPlugin.getInstance().getTotalDailyDose();
|
||||
if (LocalInsightPlugin.getPlugin().getTotalDailyDose() == null) return;
|
||||
TotalDailyDose tdd = LocalInsightPlugin.getPlugin().getTotalDailyDose();
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.tdd_bolus), DecimalFormatter.to2Decimal(tdd.getBolus())));
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.tdd_basal), DecimalFormatter.to2Decimal(tdd.getBasal())));
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.tdd_total), DecimalFormatter.to2Decimal(tdd.getBolusAndBasal())));
|
||||
}
|
||||
|
||||
private void getBaseBasalRateItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getActiveBasalRate() == null) return;
|
||||
ActiveBasalRate activeBasalRate = LocalInsightPlugin.getInstance().getActiveBasalRate();
|
||||
if (LocalInsightPlugin.getPlugin().getActiveBasalRate() == null) return;
|
||||
ActiveBasalRate activeBasalRate = LocalInsightPlugin.getPlugin().getActiveBasalRate();
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_basebasalrate_label),
|
||||
DecimalFormatter.to2Decimal(activeBasalRate.getActiveBasalRate()) + " U/h (" + activeBasalRate.getActiveBasalProfileName() + ")"));
|
||||
}
|
||||
|
||||
private void getTBRItem(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getActiveTBR() == null) return;
|
||||
ActiveTBR activeTBR = LocalInsightPlugin.getInstance().getActiveTBR();
|
||||
if (LocalInsightPlugin.getPlugin().getActiveTBR() == null) return;
|
||||
ActiveTBR activeTBR = LocalInsightPlugin.getPlugin().getActiveTBR();
|
||||
statusItems.add(getStatusItem(MainApp.gs(R.string.pump_tempbasal_label),
|
||||
MainApp.gs(R.string.tbr_formatter, activeTBR.getPercentage(), activeTBR.getInitialDuration() - activeTBR.getRemainingDuration(), activeTBR.getInitialDuration())));
|
||||
}
|
||||
|
||||
private void getBolusItems(List<View> statusItems) {
|
||||
if (LocalInsightPlugin.getInstance().getActiveBoluses() == null) return;
|
||||
for (ActiveBolus activeBolus : LocalInsightPlugin.getInstance().getActiveBoluses()) {
|
||||
if (LocalInsightPlugin.getPlugin().getActiveBoluses() == null) return;
|
||||
for (ActiveBolus activeBolus : LocalInsightPlugin.getPlugin().getActiveBoluses()) {
|
||||
String label;
|
||||
switch (activeBolus.getBolusType()) {
|
||||
case MULTIWAVE:
|
||||
|
|
|
@ -169,7 +169,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
private boolean statusLoaded;
|
||||
private TBROverNotificationBlock tbrOverNotificationBlock;
|
||||
|
||||
public static LocalInsightPlugin getInstance() {
|
||||
public static LocalInsightPlugin getPlugin() {
|
||||
if (instance == null) instance = new LocalInsightPlugin();
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
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.Treatments.CarbsGenerator;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
@ -452,7 +452,7 @@ public class ActionStringHandler {
|
|||
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||
PumpInterface insight = MainApp.getSpecificPlugin(InsightPlugin.class);
|
||||
PumpInterface insight = MainApp.getSpecificPlugin(LocalInsightPlugin.class);
|
||||
|
||||
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Waarskuwing W31: Kasset laag</string>
|
||||
<string name="alert_w32">Waarskuwing W32: Battery laag</string>
|
||||
<string name="alert_w33">Waarskuwing W33: Ongeldige tyd/datum</string>
|
||||
<string name="alert_w34">Waakskuwing W34: Einde van waarborg</string>
|
||||
<string name="alert_w36">Waarskuwing W36: TBR gekanselleer</string>
|
||||
<string name="alert_w38">Waarskuwing W38: Bolus gekanselleer</string>
|
||||
<string name="alert_w39">Waarskuwing W39: Leentyd waarskuwing</string>
|
||||
<string name="alert_m20">Onderhoud M20: Kasset nie ingevoeg</string>
|
||||
<string name="alert_m21">Onderhoud M21: kasset leeg</string>
|
||||
<string name="alert_m22">Onderhoud M22: Battery leeg</string>
|
||||
<string name="alert_m23">Onderhoud M23: Outomaties af</string>
|
||||
<string name="alert_m24">Onderhoud M24: verstopping</string>
|
||||
<string name="alert_m25">Onderhoud M25: Leentyd oor - einde van bewerking</string>
|
||||
<string name="alert_m26">Onderhoud M26: Kasset-verandering nie voltooi nie</string>
|
||||
<string name="alert_m27">Onderhoud M27: Data aflaai het misluk</string>
|
||||
<string name="alert_m28">Onderhoud M28: Wag-modus uit tyd uit</string>
|
||||
<string name="alert_m29">Onderhoud M29: Battery-tipe nie voltooi nie</string>
|
||||
<string name="alert_m30">Onderhoud M30: Kasset-tipe nie voltooi nie</string>
|
||||
<string name="alert_e6">Fout E6: Meganiese fout</string>
|
||||
<string name="alert_e7">Fout E7: Elektroniese fout</string>
|
||||
<string name="alert_e10">Fout E10: Terugdraai fout</string>
|
||||
<string name="alert_e13">Fout E13: Taal fout</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Предупреждение за W31: Празен резервоар</string>
|
||||
<string name="alert_w32">Предупреждение W32: Изтощена батерия</string>
|
||||
<string name="alert_w33">Предупреждение W33: Невалиден час/дата</string>
|
||||
<string name="alert_w34">Предупреждение за W34: Край на гаранция</string>
|
||||
<string name="alert_w36">Предупреждение за W36: Временен базал отменен</string>
|
||||
<string name="alert_w38">Предупреждение за W38: Болус отказан</string>
|
||||
<string name="alert_w39">Предупреждение за W39: Loantime предупреждение</string>
|
||||
<string name="alert_m20">Поддръжка M20: Резервоарът не е поставен</string>
|
||||
<string name="alert_m21">Поддръжка M21: Резервоарът е празен</string>
|
||||
<string name="alert_m22">Поддръжка M22: Батерията е изтощена</string>
|
||||
<string name="alert_m23">Поддръжка M23: Автоматично изключване</string>
|
||||
<string name="alert_m24">Поддръжка М24: Запушване</string>
|
||||
<string name="alert_m25">Поддръжка M25: Loantime приключи - край на операцията</string>
|
||||
<string name="alert_m26">Поддръжка M26: Смяната на резервоар не е завършена</string>
|
||||
<string name="alert_m27">Поддръжка M27: Неуспешно изтегляне данни</string>
|
||||
<string name="alert_m28">Поддръжка Месие 28: Режим пауза - таймаут</string>
|
||||
<string name="alert_m29">Поддръжка M29: Незададен тип батерия</string>
|
||||
<string name="alert_m30">Поддръжка M30: Незададен тип резетвоар</string>
|
||||
<string name="alert_e6">Грешка E6: Механична грешка</string>
|
||||
<string name="alert_e7">Грешка E7: Гешка в електрониката</string>
|
||||
<string name="alert_e10">Грешка E10: Грешка в превъртането</string>
|
||||
<string name="alert_e13">Грешка E13: Езикова грешка</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Varování W31: Zásobník</string>
|
||||
<string name="alert_w32">Varování W32: Nízký stav baterie</string>
|
||||
<string name="alert_w33">Varování W33: Neplatný čas/datum</string>
|
||||
<string name="alert_w34">Varování W34: Konec záruky</string>
|
||||
<string name="alert_w36">Varování W36: Dočasný bazál zrušen</string>
|
||||
<string name="alert_w38">Varování W38: Bolus zrušen</string>
|
||||
<string name="alert_w39">Varování W39: Varování doba výpůjčky</string>
|
||||
<string name="alert_m20">Údržba M20: Není vložen zásobník</string>
|
||||
<string name="alert_m21">Údržba M21: Prázdný zásobník</string>
|
||||
<string name="alert_m22">Údržba M22: Vybitá baterie</string>
|
||||
<string name="alert_m23">Údržba M23: Automatické vypnutí</string>
|
||||
<string name="alert_m24">Údržba M24: Okluze</string>
|
||||
<string name="alert_m25">Údržba M25: Doba vypůjčení vypršela - ukončení provozu</string>
|
||||
<string name="alert_m26">Údržba M26: Výměna zásobníku nedokončena</string>
|
||||
<string name="alert_m27">Údržba M27: Stahování se nezdařilo</string>
|
||||
<string name="alert_m28">Údržba M28: Časový limit režimu pauza</string>
|
||||
<string name="alert_m29">Údržba M29: Nenastavený typ baterie</string>
|
||||
<string name="alert_m30">Údržba M30: Nenastavený typ zásobníku</string>
|
||||
<string name="alert_e6">Chyba E6: Mechanická chyba</string>
|
||||
<string name="alert_e7">Chyba E7: Elektronická chyba</string>
|
||||
<string name="alert_e10">Chyba E10: Chyba převinutí</string>
|
||||
<string name="alert_e13">Chyba E13: Chyba jazyka</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Warnung W31: Ampulle fast leer</string>
|
||||
<string name="alert_w32">Warnung W32: Batterie fast leer</string>
|
||||
<string name="alert_w33">Warnung W33: Zeit/Datum ungültig</string>
|
||||
<string name="alert_w34">Warnung W34: Garantie abgelaufen</string>
|
||||
<string name="alert_w36">Warnung W36: TBR abgebrochen</string>
|
||||
<string name="alert_w38">Warnung W38: Bolus abgebrochen</string>
|
||||
<string name="alert_w39">Warnung W39: Leihdauer-Warnung</string>
|
||||
<string name="alert_m20">Wartung M20: Keine Ampulle eingesetzt</string>
|
||||
<string name="alert_m21">Wartung M21: Ampulle leer</string>
|
||||
<string name="alert_m22">Wartung M22: Batterie leer</string>
|
||||
<string name="alert_m23">Wartung M23: Sicherheitsabschaltung</string>
|
||||
<string name="alert_m24">Wartung M24: Verstopfung</string>
|
||||
<string name="alert_m25">Wartung M25: Leihdauer abgelaufen</string>
|
||||
<string name="alert_m26">Wartung M26: Ampullenwechsel nicht abgeschlossen</string>
|
||||
<string name="alert_m27">Wartung M27: Datenübertragung fehlgeschlagen</string>
|
||||
<string name="alert_m28">Wartung M28: Zeitüberschreitung bei Pause</string>
|
||||
<string name="alert_m29">Wartung M29: Batterietyp nicht eingestellt</string>
|
||||
<string name="alert_m30">Wartung M30: Ampullentyp nicht eingestellt</string>
|
||||
<string name="alert_e6">Fehler E6: Mechanikfehler</string>
|
||||
<string name="alert_e7">Fehler E7: Elektronikfehler</string>
|
||||
<string name="alert_e10">Fehler E10: Fehler beim Zurückfahren</string>
|
||||
<string name="alert_e13">Fehler E13: Fehler in der Sprachanzeige</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Ειδοποίηση W31: Χαμηλή αμπούλα</string>
|
||||
<string name="alert_w32">Ειδοποίηση W32: Χαμηλή μπαταρία</string>
|
||||
<string name="alert_w33">Ειδοποίηση W33: Μη έγκυρη ώρα/ημερομηνία</string>
|
||||
<string name="alert_w34">Ειδοποίηση W34: Λήξη εγγύησης</string>
|
||||
<string name="alert_w36">Ειδοποίηση W36: Ακύρωση TBR</string>
|
||||
<string name="alert_w38">Ειδοποίηση W38: Ακύρωση bolus</string>
|
||||
<string name="alert_w39">Ειδοποίηση W39: Ειδοποίηση διάρκειας</string>
|
||||
<string name="alert_m20">Συντήρηση M20: Η αμπούλα δεν έχει τοποθετηθεί</string>
|
||||
<string name="alert_m21">Συντήρηση M21: Αμπούλα άδεια</string>
|
||||
<string name="alert_m22">Συντήρηση M22: Μπαταρία άδεια</string>
|
||||
<string name="alert_m23">Συντήρηση Μ23: Αυτόματη απενεργοποίηση</string>
|
||||
<string name="alert_m24">Συντήρηση M24: Έμφραξη</string>
|
||||
<string name="alert_m25">Συντήρηση M25: Διάρκεια τέλος - τέλος της λειτουργίας</string>
|
||||
<string name="alert_m26">Συντήρηση M26: Η αλλαγή αμπούλας δεν έχει ολοκληρωθεί</string>
|
||||
<string name="alert_m27">Συντήρηση Μ27: Απέτυχε η λήψη δεδομένων</string>
|
||||
<string name="alert_m28">Συντήρηση M28: Λειτουργία παύσης έληξε</string>
|
||||
<string name="alert_m29">Συντήρηση M29: Ο τύπος μπαταρίας δεν ταιριάζει</string>
|
||||
<string name="alert_m30">Συντήρηση M30: Ο τύπος αμπούλας δεν ταιριάζει</string>
|
||||
<string name="alert_e6">Σφάλμα Ε6: Μηχανικό σφάλμα</string>
|
||||
<string name="alert_e7">Σφάλμα Ε7: Ηλεκτρονικό σφάλμα</string>
|
||||
<string name="alert_e10">Σφάλματος E10: Σφάλμα Rewind</string>
|
||||
<string name="alert_e13">Σφάλματος E13: Λάθος γλώσσα</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">ADVERTENCIA W31: Cartucho bajo</string>
|
||||
<string name="alert_w32">ADVERTENCIA W32: Batería baja</string>
|
||||
<string name="alert_w33">ADVERTENCIA W33: Fecha/Hora no válida</string>
|
||||
<string name="alert_w34">ADVERTENCIA W34: Fin de la garantía</string>
|
||||
<string name="alert_w36">ADVERTENCIA W36: TBR cancelada</string>
|
||||
<string name="alert_w38">ADVERTENCIA W38: Bolo cancelado</string>
|
||||
<string name="alert_w39">W39 Advertencia: Advertencia de tiempo préstamo</string>
|
||||
<string name="alert_m20">Mantenimiento M20: Cartucho no insertado</string>
|
||||
<string name="alert_m21">Mantenimiento M21: Cartucho vacío</string>
|
||||
<string name="alert_m22">Mantenimiento M22: Batería vacía</string>
|
||||
<string name="alert_m23">Mantenimiento M23: Apagado automático</string>
|
||||
<string name="alert_m24">Mantenimiento M24: oclusión</string>
|
||||
<string name="alert_m25">Mantenimiento M25: Tiempo préstamo finalizado - final de la operación</string>
|
||||
<string name="alert_m26">Mantenimiento M26: Cambio de cartucho no completado</string>
|
||||
<string name="alert_m27">Mantenimiento M27: Error de descarga de datos</string>
|
||||
<string name="alert_m28">Mantenimiento M28: Tiempo de espera vencido</string>
|
||||
<string name="alert_m29">Mantenimiento M29: Tipo de batería no establecido</string>
|
||||
<string name="alert_m30">Mantenimiento M30: Tipo cartucho no establecido</string>
|
||||
<string name="alert_e6">Error E6: Error mecánico</string>
|
||||
<string name="alert_e7">Error E7: Error electrónico</string>
|
||||
<string name="alert_e10">Error E10: Error de rebobinado</string>
|
||||
<string name="alert_e13">Error E13: Error de lenguaje</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Alerte W31 : Réservoir presque vide</string>
|
||||
<string name="alert_w32">Alerte W32 : Batterie presque déchargée</string>
|
||||
<string name="alert_w33">Avertissement W33 : Heure/date non valides</string>
|
||||
<string name="alert_w34">Alerte W34 : Fin de garantie</string>
|
||||
<string name="alert_w36">Alerte W36 : TBR annulé</string>
|
||||
<string name="alert_w38">Alerte W38 : Bolus annulé</string>
|
||||
<string name="alert_w39">Alerte W39 : Avertissement Loantime</string>
|
||||
<string name="alert_m20">Maintenance M20 : Cartouche pas inséré</string>
|
||||
<string name="alert_m21">Maintenance M21 : Cartouche vide</string>
|
||||
<string name="alert_m22">Maintenance M22 : Batterie vide</string>
|
||||
<string name="alert_m23">Maintenance M23 : Arrêt automatique</string>
|
||||
<string name="alert_m24">Maintenance M24 : Occlusion</string>
|
||||
<string name="alert_m25">Maintenance M25 : Loantime terminé - fin d’opération</string>
|
||||
<string name="alert_m26">Maintenance M26 : Changement de cartouche non terminé</string>
|
||||
<string name="alert_m27">Maintenance M27 : Le téléchargement de données a échoué</string>
|
||||
<string name="alert_m28">Maintenance M28 : Pause mode timeout</string>
|
||||
<string name="alert_m29">Maintenance M29 : Type de batterie non défini</string>
|
||||
<string name="alert_m30">Maintenance M30 : Réservoir type non défini</string>
|
||||
<string name="alert_e6">Erreur E6 : Problème mécanique</string>
|
||||
<string name="alert_e7">Erreur E7 : Problème d\'électronique</string>
|
||||
<string name="alert_e10">Erreur E10 : Erreur de rembobinage</string>
|
||||
<string name="alert_e13">Erreur E13 : Erreur de langage</string>
|
||||
</resources>
|
|
@ -1,3 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources></resources>
|
|
@ -1,3 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources></resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Avviso W31: Cartuccia in esaurimento</string>
|
||||
<string name="alert_w32">Avviso W32: Batteria bassa</string>
|
||||
<string name="alert_w33">W33 avviso: Data/ora non valido</string>
|
||||
<string name="alert_w34">W34 avviso: Fine della garanzia</string>
|
||||
<string name="alert_w36">Avviso W36: TBR annullato</string>
|
||||
<string name="alert_w38">Avviso W38: Bolo annullato</string>
|
||||
<string name="alert_w39">Avviso W39: Avviso Loantime</string>
|
||||
<string name="alert_m20">Manutenzione M20: Cartuccia non inserita</string>
|
||||
<string name="alert_m21">Manutenzione M21: Cartuccia vuota</string>
|
||||
<string name="alert_m22">Manutenzione M22: Batteria scarica</string>
|
||||
<string name="alert_m23">Manutenzione M23: Spegnimento automatico</string>
|
||||
<string name="alert_m24">Manutenzione M24: occlusione</string>
|
||||
<string name="alert_m25">Manutenzione M25: Loantime sopra - fine dell\'operazione</string>
|
||||
<string name="alert_m26">Manutenzione M26: Sostituzione cartuccia non completata</string>
|
||||
<string name="alert_m27">Manutenzione M27: Download dati fallito</string>
|
||||
<string name="alert_m28">Manutenzione M28: Timeout modalità pausa</string>
|
||||
<string name="alert_m29">Manutenzione M29: Tipo di batteria non impostata</string>
|
||||
<string name="alert_m30">Manutenzione M30: Tipo di cartuccia non impostata</string>
|
||||
<string name="alert_e6">Errore E6: Errore meccanico</string>
|
||||
<string name="alert_e7">E7 errore: Errore elettronico</string>
|
||||
<string name="alert_e10">Errore E10: Errore Rewind</string>
|
||||
<string name="alert_e13">Errore E13: Errore lingua</string>
|
||||
</resources>
|
|
@ -1,3 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources></resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">경고 W31: 주사기양 낮음</string>
|
||||
<string name="alert_w32">경고 W32: 배터리양 낮음</string>
|
||||
<string name="alert_w33">경고 W33: 시간/날짜 유효하지 않음</string>
|
||||
<string name="alert_w34">경고 W34: 보증만료</string>
|
||||
<string name="alert_w36">경고 W36: 임시Basal 취소</string>
|
||||
<string name="alert_w38">경고 W38: Bolus 취소</string>
|
||||
<string name="alert_w39">경고 W39: Loantime 경고</string>
|
||||
<string name="alert_m20">정비 M20: 주사기가 삽입되지 않았습니다.</string>
|
||||
<string name="alert_m21">정비 M21: 주사기가 비었습니다.</string>
|
||||
<string name="alert_m22">정비 M22: 배터리가 방전되었습니다.</string>
|
||||
<string name="alert_m23">정비 M23: 자동 OFF</string>
|
||||
<string name="alert_m24">정비 M24: 막힘</string>
|
||||
<string name="alert_m25">정비 M25: Loantime 종료 - 작업 종료</string>
|
||||
<string name="alert_m26">정비 M26: 주사기 교체가 완료되지 않았습니다.</string>
|
||||
<string name="alert_m27">정비 M27: 데이터 다운로드가 실패하였습니다.</string>
|
||||
<string name="alert_m28">정비 M28: 일시정지모드 시간만료</string>
|
||||
<string name="alert_m29">정비 M29: 배터리 타입이 설정되지 않았습니다.</string>
|
||||
<string name="alert_m30">정비 M30: 주사기 타입이 설정되지 않았습니다.</string>
|
||||
<string name="alert_e6">에러 E6: 기계적 에러</string>
|
||||
<string name="alert_e7">에러 E7: 전기적 에러</string>
|
||||
<string name="alert_e10">에러 E10: Rewind 에러</string>
|
||||
<string name="alert_e13">에러 E13: 언어 에러</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Waarschuwing W31: Cartridge bijna leeg</string>
|
||||
<string name="alert_w32">Waarschuwing W32: Batterij bijna leeg</string>
|
||||
<string name="alert_w33">Waarschuwing W33: Onjuiste tijd/datum</string>
|
||||
<string name="alert_w34">Waarschuwing W34: Einde van garantie</string>
|
||||
<string name="alert_w36">Waarschuwing W36: TBR geannuleerd</string>
|
||||
<string name="alert_w38">Waarschuwing W38: Bolus geannuleerd</string>
|
||||
<string name="alert_w39">Waarschuwing W39: Leentijd waarschuwing</string>
|
||||
<string name="alert_m20">Onderhoud M20: Cartridge niet geplaatst</string>
|
||||
<string name="alert_m21">Onderhoud M21: Cartridge leeg</string>
|
||||
<string name="alert_m22">Onderhoud M22: Batterij leeg</string>
|
||||
<string name="alert_m23">Onderhoud M23: Automatisch uit</string>
|
||||
<string name="alert_m24">Onderhoud M24: Verstopping</string>
|
||||
<string name="alert_m25">Onderhoud M25: Leentijd verstreken - werking geëindigd</string>
|
||||
<string name="alert_m26">Onderhoud M26: Cartridge verwisselen niet afgerond</string>
|
||||
<string name="alert_m27">Onderhoud M27: Data download mislukt</string>
|
||||
<string name="alert_m28">Onderhoud M28: Pauze modus timeout</string>
|
||||
<string name="alert_m29">Onderhoud M29: Batterij type niet ingesteld</string>
|
||||
<string name="alert_m30">Onderhoud M30: Cartridge type niet ingesteld</string>
|
||||
<string name="alert_e6">Fout E6: Mechanische fout</string>
|
||||
<string name="alert_e7">Fout E7: Elektronische fout</string>
|
||||
<string name="alert_e10">Fout E10: Terugdraaien fout</string>
|
||||
<string name="alert_e13">Fout E13: Taal fout</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Ostrzeżenie W31: Niski poziom insuliny</string>
|
||||
<string name="alert_w32">Ostrzeżenie W32: Niski stan baterii</string>
|
||||
<string name="alert_w33">Ostrzeżenie W33: Nieprawidłowa godzina/data</string>
|
||||
<string name="alert_w34">Ostrzeżenie W34: Koniec gwarancji</string>
|
||||
<string name="alert_w36">Ostrzeżenie W36: Anulowana baza tymczasowa [TBR]</string>
|
||||
<string name="alert_w38">Ostrzeżenie W38: Bolus anulowany</string>
|
||||
<string name="alert_w39">Ostrzeżenie W39: ostrzeżenie o użyczonym/przyznanym czasie</string>
|
||||
<string name="alert_m20">Konserwacja M20: Brak pojemnika na isulinę</string>
|
||||
<string name="alert_m21">Konserwacja M21: Pusty zbiornik na insulinę</string>
|
||||
<string name="alert_m22">Konserwacja M22: Koniec baterii</string>
|
||||
<string name="alert_m23">Konserwacja M23: Wyłącz automatycznie</string>
|
||||
<string name="alert_m24">Konserwacja M24: Niedrożność</string>
|
||||
<string name="alert_m25">Obsługa M25: koniec użyczonego czasu - koniec działania</string>
|
||||
<string name="alert_m26">Konserwacja M26: Nie zakończono wymiany zbiornika</string>
|
||||
<string name="alert_m27">Konserwacja M27: Błąd pobierania danych</string>
|
||||
<string name="alert_m28">Obsługa M28: koniec czasu trybu pauza</string>
|
||||
<string name="alert_m29">Konserwacja M29: Nie wybrano rodzaju baterii</string>
|
||||
<string name="alert_m30">Konserwacja M30: Nie ustawiono rodzaju pojemnika</string>
|
||||
<string name="alert_e6">Błąd E6: Usterka mechaniczna</string>
|
||||
<string name="alert_e7">Błąd E7: Usterka elektroniczna</string>
|
||||
<string name="alert_e10">Błąd E10: Usterka przewijania</string>
|
||||
<string name="alert_e13">Błąd E6: Błąd języka</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Alerta W31: Cartucho com pouca insulina</string>
|
||||
<string name="alert_w32">Aviso W32: Bateria baixa</string>
|
||||
<string name="alert_w33">Aviso W33: Data/hora inválida</string>
|
||||
<string name="alert_w34">Aviso W34: Fim da garantia</string>
|
||||
<string name="alert_w36">W36 aviso: DTB cancelada</string>
|
||||
<string name="alert_w38">Aviso W38: Bolus cancelado</string>
|
||||
<string name="alert_w39">Alerta W39: Alerta Tempo de Empréstimo</string>
|
||||
<string name="alert_m20">Manutenção M20: Cartucho não inserido</string>
|
||||
<string name="alert_m21">Manutenção M21: Cartucho vazio</string>
|
||||
<string name="alert_m22">Manutenção M22: Bateria vazia</string>
|
||||
<string name="alert_m23">Manutenção M23: Desligar automático</string>
|
||||
<string name="alert_m24">Manutenção M24: Oclusão</string>
|
||||
<string name="alert_m25">Manutenção M25: Tempo de empréstimo expirado - operação finalizada</string>
|
||||
<string name="alert_m26">Manutenção M26: Mudança de cartucho não concluída</string>
|
||||
<string name="alert_m27">Manutenção M27: Transferência de dados falhada</string>
|
||||
<string name="alert_m28">Manutenção M28: Tempo pausa expirado</string>
|
||||
<string name="alert_m29">Manutenção M29: Tipo de bateria não definido</string>
|
||||
<string name="alert_m30">Manutenção M30: Tipo de cartucho não definido</string>
|
||||
<string name="alert_e6">E6 de erro: Erro mecânico</string>
|
||||
<string name="alert_e7">E7 de erro: Erro electrónico</string>
|
||||
<string name="alert_e10">Erro E10: Erro a recuar embolo</string>
|
||||
<string name="alert_e13">E13 de erro: Erro de idioma</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Atenționarea W31: rezervor pe terminate</string>
|
||||
<string name="alert_w32">Atenționarea W32: baterie pe terminate</string>
|
||||
<string name="alert_w33">Atenționarea W33: Timp/dată invalide</string>
|
||||
<string name="alert_w34">Atenționarea W34: Sfârșitul perioadei de garanție</string>
|
||||
<string name="alert_w36">Atenționarea W36: RBT anulată</string>
|
||||
<string name="alert_w38">Atenționarea W38: Bolus anulat</string>
|
||||
<string name="alert_w39">Atenționarea W39: Atenționare perioadă de închiriere</string>
|
||||
<string name="alert_m20">Mentenanță M20: Rezervor neinserat</string>
|
||||
<string name="alert_m21">Mentenanță M21: Rezervor gol</string>
|
||||
<string name="alert_m22">Mentenanță M22: Baterie terminată</string>
|
||||
<string name="alert_m23">Mentenanță M23: Oprire automată</string>
|
||||
<string name="alert_m24">Mentenanță M24: Ocluzie</string>
|
||||
<string name="alert_m25">Mentenanță M25: Perioadă de închiriere terminată - sfârșitul operării</string>
|
||||
<string name="alert_m26">Mentenanță M26: Schimbarea rezervorului este incompletă</string>
|
||||
<string name="alert_m27">Mentenanță M27: Descărcarea datelor a eșuat</string>
|
||||
<string name="alert_m28">Mentenanță M28: Sfârșitul modului de pauză</string>
|
||||
<string name="alert_m29">Mentenanță M29: Tipul de baterie nu este configurat</string>
|
||||
<string name="alert_m30">Mentenanță M30: Tipul de rezervor nu este configurat</string>
|
||||
<string name="alert_e6">Eroarea E6: Eroare mecanică</string>
|
||||
<string name="alert_e7">Eroarea E7: Eroare de electronică</string>
|
||||
<string name="alert_e10">Eroarea E10: Eroare de derulare</string>
|
||||
<string name="alert_e13">Eroarea E13: Eroare de limbaj</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Предупреждение W31: Картридж заканчивается</string>
|
||||
<string name="alert_w32">Предупреждение W32: Низкий заряд батареи</string>
|
||||
<string name="alert_w33">Предупреждение W33: Недопустимое время/Дата</string>
|
||||
<string name="alert_w34">Предупреждение W34: Окончание гарантии</string>
|
||||
<string name="alert_w36">W36 предупреждение: временный базал TBR отменен</string>
|
||||
<string name="alert_w38">Предупреждение W38: Болюс отменен</string>
|
||||
<string name="alert_w39">Предупреждение W39: окончание заемного периода</string>
|
||||
<string name="alert_m20">Техническое обслуживание M20: Картридж не вставлен</string>
|
||||
<string name="alert_m21">Техническое обслуживание M21: Картридж пуст</string>
|
||||
<string name="alert_m22">Техническое обслуживание M22: Батарея разряжена</string>
|
||||
<string name="alert_m23">Техническое обслуживание: M23: Автоматическое выключение</string>
|
||||
<string name="alert_m24">Техническое обслуживание M24: закупорка</string>
|
||||
<string name="alert_m25">Техническое обслуживание M25: Конец заемного периода - конец операции</string>
|
||||
<string name="alert_m26">Техническое обслуживание M26: Замена картриджа не завершена</string>
|
||||
<string name="alert_m27">Техническое обслуживание M27: Ошибка загрузки данных</string>
|
||||
<string name="alert_m28">Техническое обслуживание M28: Тайм-аут режима паузы</string>
|
||||
<string name="alert_m29">Техническое обслуживание M29: Тип батареи не задан</string>
|
||||
<string name="alert_m30">Техническое обслуживание M30: Тип картриджа не задан</string>
|
||||
<string name="alert_e6">Ошибка E6: Механическая ошибка</string>
|
||||
<string name="alert_e7">Ошибка E7: Ошибка электроники</string>
|
||||
<string name="alert_e10">Ошибка Е10: Ошибка возврата</string>
|
||||
<string name="alert_e13">Ошибка E13: Ошибка языка</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Upozornenie W31: Zásobník takmer prázdny</string>
|
||||
<string name="alert_w32">Upozornenie W32: Batéria takmer vybitá</string>
|
||||
<string name="alert_w33">Upozornenie W33: Neplatný čas/dátum</string>
|
||||
<string name="alert_w34">Upozornenie W34: Koniec záruky</string>
|
||||
<string name="alert_w36">Upozornenie W36: Dočasný bazál zrušený</string>
|
||||
<string name="alert_w38">Upozornenie W38: Bolus zrušený</string>
|
||||
<string name="alert_w39">Upozornenie W39: Upozornenie na dobu zapožičania</string>
|
||||
<string name="alert_m20">Údržba M20: Nie je vložený zásobník</string>
|
||||
<string name="alert_m21">Údržba M21: Prázdny zásobník</string>
|
||||
<string name="alert_m22">Údržba M22: Vybitá batéria</string>
|
||||
<string name="alert_m23">Údržba M23: Automatické vypnutie</string>
|
||||
<string name="alert_m24">Údržba M24: Oklúzia</string>
|
||||
<string name="alert_m25">Údržba M25: Doba zapožičania uplynula - koniec prevádzky</string>
|
||||
<string name="alert_m26">Údržba M26: Výmena zásobníka nedokončená</string>
|
||||
<string name="alert_m27">Údržba M27: Sťahovanie sa nepodarilo</string>
|
||||
<string name="alert_m28">Údržba M28: Časový limit režimu pauza</string>
|
||||
<string name="alert_m29">Údržba M29: Nenastavený typ batérie</string>
|
||||
<string name="alert_m30">Údržba M30: Nenastavený typ zásobníka</string>
|
||||
<string name="alert_e6">Chyba E6: Mechanická chyba</string>
|
||||
<string name="alert_e7">Chyba E7: Elektronická chyba</string>
|
||||
<string name="alert_e10">Chyba E10: Chyba previnutia</string>
|
||||
<string name="alert_e13">Chyba E13: Chyba jazyka</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Varning W31: Reservoarnivå låg</string>
|
||||
<string name="alert_w32">Varning W32: Batterinivå låg</string>
|
||||
<string name="alert_w33">Varning W33: Ogiltig tid/datum</string>
|
||||
<string name="alert_w34">Varning W34: Garantiperioden har upphört</string>
|
||||
<string name="alert_w36">Varning W36: Tempbasal avbruten</string>
|
||||
<string name="alert_w38">Varning W38: Bolus avbruten</string>
|
||||
<string name="alert_w39">Varning W39: Låneperioden upphör snart</string>
|
||||
<string name="alert_m20">Underhåll M20: Reservoar inte monterad</string>
|
||||
<string name="alert_m21">Underhåll M21: Reservoar tom</string>
|
||||
<string name="alert_m22">Underhåll M22: Batteri tomt</string>
|
||||
<string name="alert_m23">Underhåll M23: Automatisk avstängning</string>
|
||||
<string name="alert_m24">Underhåll M24: Ocklusion</string>
|
||||
<string name="alert_m25">Underhåll M25: Låneperioden över. Stänger av pumpen</string>
|
||||
<string name="alert_m26">Underhåll M26: Reservoarbyte ej slutfört</string>
|
||||
<string name="alert_m27">Underhåll M27: Datanedladdning misslyckades</string>
|
||||
<string name="alert_m28">Underhåll M28: Pausläge timeout</string>
|
||||
<string name="alert_m29">Underhåll M29: Batterityp inte inställd</string>
|
||||
<string name="alert_m30">Underhåll M30: Reservoartyp inte inställd</string>
|
||||
<string name="alert_e6">Fel E6: Mekaniskt fel</string>
|
||||
<string name="alert_e7">Fel E7: Elektroniskt fel</string>
|
||||
<string name="alert_e10">Felet E10: Återställningsfel</string>
|
||||
<string name="alert_e13">Fel E13: Språkfel</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">Uyarı W31: Kartuş düşük</string>
|
||||
<string name="alert_w32">Uyarı W32: Pil bitmek üzere</string>
|
||||
<string name="alert_w33">Uyarı W33: Geçersiz saat/tarih</string>
|
||||
<string name="alert_w34">Garanti süresi doldu</string>
|
||||
<string name="alert_w36">Uyarı W36: Geçici bazal iptal edildi</string>
|
||||
<string name="alert_w38">Uyarı W38: Bolus iptal edildi</string>
|
||||
<string name="alert_w39">Uyarı W39: Kiralama süresi uyarısı</string>
|
||||
<string name="alert_m20">Bakım M20: Kartuş takılı değil</string>
|
||||
<string name="alert_m21">Bakım M21: Kartuş boş</string>
|
||||
<string name="alert_m22">Bakım M22: Pil boş</string>
|
||||
<string name="alert_m23">Bakım M23: Otomatik kapalı</string>
|
||||
<string name="alert_m24">Bakım M24: Tıkanıklık</string>
|
||||
<string name="alert_m25">Bakım M25: Kiralama süresi doldu</string>
|
||||
<string name="alert_m26">Bakım M26: Kartuş değişimi tamamlanamadı</string>
|
||||
<string name="alert_m27">Bakım M27: Veri yükleme başarısız</string>
|
||||
<string name="alert_m28">Bakım M28: Duraklat modunda zaman aşımı</string>
|
||||
<string name="alert_m29">Bakım M29: Pil türü seçili değil</string>
|
||||
<string name="alert_m30">Bakım M30: Kartuş türü ayarlı değil</string>
|
||||
<string name="alert_e6">Hata E6: Mekanik hata</string>
|
||||
<string name="alert_e7">Hata E7: Elektronik hata</string>
|
||||
<string name="alert_e10">Hata E10: Geri sarma hata</string>
|
||||
<string name="alert_e13">Hata E13: Dil ekranında hata</string>
|
||||
</resources>
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources>
|
||||
<string name="alert_w31">警告 W31:储药器药量低</string>
|
||||
<string name="alert_w32">警告 W32:电池电量低</string>
|
||||
<string name="alert_w33">警告 W33:不合规的时间/日期</string>
|
||||
<string name="alert_w34">警告 W34:保修期结束</string>
|
||||
<string name="alert_w36">警告 W36:临时基础率被取消了</string>
|
||||
<string name="alert_w38">警告 W38:大剂量被取消了</string>
|
||||
<string name="alert_w39">警告 W39:Loantime 警告</string>
|
||||
<string name="alert_m20">维护 M10:储药器没有插入</string>
|
||||
<string name="alert_m21">维护 M21:储药器空了</string>
|
||||
<string name="alert_m22">维护 M22:电池没有插入</string>
|
||||
<string name="alert_m23">维护 M23:自动关机</string>
|
||||
<string name="alert_m24">维护 M24:堵管</string>
|
||||
<string name="alert_m25">维护 M25:Loantime结束,操作结束</string>
|
||||
<string name="alert_m26">维护 M26:储药器更换没有完成</string>
|
||||
<string name="alert_m27">维护 M27:数据下载失败</string>
|
||||
<string name="alert_m28">维护 M28:暂停模式超时</string>
|
||||
<string name="alert_m29">维护 M29:电池类型没有设置</string>
|
||||
<string name="alert_m30">维护 M30:储药器类型没有设置</string>
|
||||
<string name="alert_e6">错误 E6:机械错误</string>
|
||||
<string name="alert_e7">错误 E7:电子错误</string>
|
||||
<string name="alert_e10">错误 E10:复位错误</string>
|
||||
<string name="alert_e13">错误 E13:语言错误</string>
|
||||
</resources>
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="alert_w31">Warning W31: Cartridge low</string>
|
||||
<string name="alert_w32">Warning W32: Battery low</string>
|
||||
<string name="alert_w33">Warning W33: Invalid time/date</string>
|
||||
<string name="alert_w34">Warning W34: End of warranty</string>
|
||||
<string name="alert_w36">Warning W36: TBR canceled</string>
|
||||
<string name="alert_w38">Warning W38: Bolus canceled</string>
|
||||
<string name="alert_w39">Warning W39: Loantime warning</string>
|
||||
|
||||
<string name="alert_m20">Maintenance M20: Cartridge not inserted</string>
|
||||
<string name="alert_m21">Maintenance M21: Cartridge empty</string>
|
||||
<string name="alert_m22">Maintenance M22: Battery empty</string>
|
||||
<string name="alert_m23">Maintenance M23: Automatic off</string>
|
||||
<string name="alert_m24">Maintenance M24: Occlusion</string>
|
||||
<string name="alert_m25">Maintenance M25: Loantime over - end of operation</string>
|
||||
<string name="alert_m26">Maintenance M26: Cartridge change not completed</string>
|
||||
<string name="alert_m27">Maintenance M27: Data download failed</string>
|
||||
<string name="alert_m28">Maintenance M28: Pause mode timeout</string>
|
||||
<string name="alert_m29">Maintenance M29: Battery type not set</string>
|
||||
<string name="alert_m30">Maintenance M30: Cartridge type not set</string>
|
||||
|
||||
<string name="alert_e6">Error E6: Mechanical error</string>
|
||||
<string name="alert_e7">Error E7: Electronic error</string>
|
||||
<string name="alert_e10">Error E10: Rewind error</string>
|
||||
<string name="alert_e13">Error E13: Language error</string>
|
||||
</resources>
|
|
@ -15,7 +15,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
@ -31,8 +30,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.StatusTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpInsightLocal.LocalInsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
@ -55,7 +53,7 @@ public class ConstraintsCheckerTest {
|
|||
ComboPlugin comboPlugin;
|
||||
DanaRPlugin danaRPlugin;
|
||||
DanaRSPlugin danaRSPlugin;
|
||||
InsightPlugin insightPlugin;
|
||||
LocalInsightPlugin insightPlugin;
|
||||
|
||||
boolean notificationSent = false;
|
||||
|
||||
|
@ -142,10 +140,10 @@ public class ConstraintsCheckerTest {
|
|||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
// Insight
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBasalAmount = 1.1d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
// insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
// StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
// result.maximumBasalAmount = 1.1d;
|
||||
// insightPlugin.setStatusResult(result);
|
||||
|
||||
// No limit by default
|
||||
when(SP.getDouble(R.string.key_openapsma_max_basal, 1d)).thenReturn(1d);
|
||||
|
@ -169,10 +167,10 @@ public class ConstraintsCheckerTest {
|
|||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
// Insight
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBasalAmount = 1.1d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
// insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
// StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
// result.maximumBasalAmount = 1.1d;
|
||||
// insightPlugin.setStatusResult(result);
|
||||
|
||||
// No limit by default
|
||||
when(SP.getDouble(R.string.key_openapsma_max_basal, 1d)).thenReturn(1d);
|
||||
|
@ -183,7 +181,7 @@ public class ConstraintsCheckerTest {
|
|||
// Apply all limits
|
||||
Constraint<Integer> i = constraintChecker.getMaxBasalPercentAllowed(AAPSMocker.getValidProfile());
|
||||
Assert.assertEquals((Integer) 100, i.value());
|
||||
Assert.assertEquals(9, i.getReasonList().size()); // 6x Safety & RS & R & Insight
|
||||
Assert.assertEquals(8, i.getReasonList().size()); // 6x Safety & RS & R
|
||||
Assert.assertEquals("Safety: Limiting percent rate to 100% because of pump limit", i.getMostLimitedReasons());
|
||||
|
||||
}
|
||||
|
@ -197,10 +195,10 @@ public class ConstraintsCheckerTest {
|
|||
DanaRPump.getInstance().maxBolus = 6d;
|
||||
|
||||
// Insight
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBolusAmount = 7d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
// insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
// StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
// result.maximumBolusAmount = 7d;
|
||||
// insightPlugin.setStatusResult(result);
|
||||
|
||||
// No limit by default
|
||||
when(SP.getDouble(R.string.key_treatmentssafety_maxbolus, 3d)).thenReturn(3d);
|
||||
|
@ -209,7 +207,7 @@ public class ConstraintsCheckerTest {
|
|||
// Apply all limits
|
||||
Constraint<Double> d = constraintChecker.getMaxBolusAllowed();
|
||||
Assert.assertEquals(3d, d.value());
|
||||
Assert.assertEquals(true, d.getReasonList().size() == 5); // 2x Safety & RS & R & Insight
|
||||
Assert.assertEquals(4, d.getReasonList().size()); // 2x Safety & RS & R
|
||||
Assert.assertEquals("Safety: Limiting bolus to 3.0 U because of max value in preferences", d.getMostLimitedReasons());
|
||||
|
||||
}
|
||||
|
@ -289,7 +287,7 @@ public class ConstraintsCheckerTest {
|
|||
comboPlugin = ComboPlugin.getPlugin();
|
||||
danaRPlugin = DanaRPlugin.getPlugin();
|
||||
danaRSPlugin = DanaRSPlugin.getPlugin();
|
||||
insightPlugin = InsightPlugin.getPlugin();
|
||||
insightPlugin = LocalInsightPlugin.getPlugin();
|
||||
ArrayList<PluginBase> constraintsPluginsList = new ArrayList<>();
|
||||
constraintsPluginsList.add(safetyPlugin);
|
||||
constraintsPluginsList.add(objectivesPlugin);
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight;
|
||||
|
||||
|
||||
import com.google.common.truth.Truth;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers.roundDouble;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 26.01.2018.
|
||||
*/
|
||||
|
||||
public class HelpersTest {
|
||||
|
||||
@Test
|
||||
public void checkRounding() throws Exception {
|
||||
|
||||
// TODO more test cases including known precision breakdowns
|
||||
|
||||
Truth.assertThat(roundDouble(Double.parseDouble("0.999999"),0))
|
||||
.isEqualTo(1d);
|
||||
|
||||
Truth.assertThat(roundDouble(Double.parseDouble("0.123456"),0))
|
||||
.isEqualTo(0d);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue