Merge pull request #1 from warstar2187/dev

20170425
This commit is contained in:
warstar2187 2017-04-25 10:06:47 +09:00 committed by GitHub
commit 87e647b185
193 changed files with 3001 additions and 1055 deletions

View file

@ -43,8 +43,8 @@ android {
applicationId "info.nightscout.androidaps"
minSdkVersion 21
targetSdkVersion 23
versionCode 1100
version "1.31"
versionCode 1400
version "1.4"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
@ -168,8 +168,8 @@ dependencies {
compile 'com.google.android.gms:play-services-wearable:7.5.0'
compile 'junit:junit:4.12'
testCompile 'org.json:json:20140107'
testCompile 'org.mockito:mockito-core:2.+'
androidTestCompile 'org.mockito:mockito-core:2.+'
testCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
compile(name: 'android-edittext-validator-v1.3.4-mod', ext: 'aar')
@ -177,7 +177,7 @@ dependencies {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.guava:guava:20.0'
}

View file

@ -41,10 +41,10 @@
android:name=".plugins.Overview.Dialogs.BolusProgressHelperActivity"
android:theme="@style/Theme.AppCompat.Translucent" />
<activity android:name=".AgreementActivity" />
<activity android:name=".plugins.DanaR.History.DanaRHistoryActivity" />
<activity android:name=".plugins.DanaRKorean.History.DanaRHistoryActivity" />
<activity android:name=".plugins.DanaR.History.DanaRStatsActivity" />
<activity android:name=".plugins.DanaRKorean.History.DanaRStatsActivity" />
<activity android:name=".plugins.PumpDanaR.History.DanaRHistoryActivity" />
<activity android:name=".plugins.PumpDanaRKorean.History.DanaRHistoryActivity" />
<activity android:name=".plugins.PumpDanaR.History.DanaRStatsActivity" />
<activity android:name=".plugins.PumpDanaRKorean.History.DanaRStatsActivity" />
<activity android:name=".plugins.Overview.activities.QuickWizardListActivity">
<intent-filter>
<action android:name="info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity" />
@ -116,11 +116,11 @@
android:name=".Services.DataService"
android:exported="false" />
<service
android:name=".plugins.DanaR.Services.ExecutionService"
android:name=".plugins.PumpDanaR.Services.ExecutionService"
android:enabled="true"
android:exported="false" />
<service
android:name=".plugins.DanaRKorean.Services.ExecutionService"
android:name=".plugins.PumpDanaRKorean.Services.ExecutionService"
android:enabled="true"
android:exported="false" />
<service

View file

@ -12,6 +12,8 @@ public class Constants {
public static final double MMOLL_TO_MGDL = 18; // 18.0182;
public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL;
public static final double defaultDIA = 3d;
public static final double basalAbsoluteOnlyForCheckLimit = 10101010d;
public static final Integer basalPercentOnlyForCheckLimit = 10101010;
public static final double bolusOnlyForCheckLimit = 10101010d;

View file

@ -22,22 +22,24 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfileFragment;
import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanFragment;
import info.nightscout.androidaps.plugins.LocalProfile.LocalProfileFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanFragment;
import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment;
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
import info.nightscout.androidaps.plugins.MDI.MDIFragment;
import info.nightscout.androidaps.plugins.PumpMDI.MDIFragment;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
import info.nightscout.androidaps.plugins.NSProfile.NSProfileFragment;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragment;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment;
import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyFragment;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpFragment;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
@ -46,9 +48,9 @@ import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangeFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpFragment;
import info.nightscout.androidaps.plugins.Wear.WearFragment;
import info.nightscout.androidaps.plugins.persistentnotification.PersistentNotificationPlugin;
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
import io.fabric.sdk.android.Fabric;
@ -86,6 +88,8 @@ public class MainApp extends Application {
// Register all tabs in app here
pluginsList.add(OverviewFragment.getPlugin());
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
pluginsList.add(InsulinFastactingFragment.getPlugin());
pluginsList.add(InsulinFastactingProlongedFragment.getPlugin());
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
pluginsList.add(CareportalFragment.getPlugin());
@ -140,8 +144,8 @@ public class MainApp extends Application {
if (keepAliveReceiver == null) {
keepAliveReceiver = new KeepAliveReceiver();
if (Config.DANAR) {
startService(new Intent(this, info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService.class));
startService(new Intent(this, info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService.class));
startService(new Intent(this, info.nightscout.androidaps.plugins.PumpDanaR.Services.ExecutionService.class));
startService(new Intent(this, info.nightscout.androidaps.plugins.PumpDanaRKorean.Services.ExecutionService.class));
}
keepAliveReceiver.setAlarm(this);
}

View file

@ -11,16 +11,15 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.BluetoothDevicePreference;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
import info.nightscout.utils.LocaleHelper;
@ -50,14 +49,14 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
updatePrefSummary(myPreferenceFragment.getPreference(key));
}
private static void updatePrefSummary(Preference pref) {
private static void updatePrefSummary(Preference pref) {
if (pref instanceof ListPreference || pref instanceof BluetoothDevicePreference) {
ListPreference listPref = (ListPreference) pref;
pref.setSummary(listPref.getEntry());
}
if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password")|| pref.getKey().contains("secret")) {
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
pref.setSummary("******");
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
@ -119,11 +118,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
VirtualPumpPlugin virtualPumpPlugin = (VirtualPumpPlugin) MainApp.getSpecificPlugin(VirtualPumpPlugin.class);
if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) {
addPreferencesFromResource(R.xml.pref_virtualpump);
addPreferencesFromResource(R.xml.pref_virtualpump);
}
NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
addPreferencesFromResource(R.xml.pref_nsclientinternal);
addPreferencesFromResource(R.xml.pref_nsclientinternal);
}
if (Config.SMSCOMMUNICATORENABLED)
addPreferencesFromResource(R.xml.pref_smscommunicator);
@ -131,7 +130,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced);
}
initSummary(getPreferenceScreen());
if (Config.WEAR) {
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
@ -139,9 +137,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_wear);
}
}
initSummary(getPreferenceScreen());
}
public Preference getPreference (String key) {
public Preference getPreference(String key) {
return findPreference(key);
}
}

View file

@ -32,12 +32,14 @@ import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.History.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.NSProfile.NSProfilePlugin;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.History.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@ -520,7 +522,9 @@ public class DataService extends IntentService {
} else {
if (Config.logIncommingData)
log.debug("ADD: New treatment: " + trstring);
Treatment treatment = new Treatment();
InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin();
if (insulinInterface == null) insulinInterface = InsulinFastactingFragment.getPlugin();
Treatment treatment = new Treatment(insulinInterface);
treatment._id = _id;
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
@ -575,7 +579,9 @@ public class DataService extends IntentService {
if (Config.logIncommingData)
log.debug("CHANGE: Adding new treatment: " + trstring);
Treatment treatment = new Treatment();
InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin();
if (insulinInterface == null) insulinInterface = InsulinFastactingFragment.getPlugin();
Treatment treatment = new Treatment(insulinInterface);
treatment._id = _id;
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;

View file

@ -41,7 +41,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
public static final String DATABASE_DBREQUESTS = "DBRequests";
private static final int DATABASE_VERSION = 5;
private static final int DATABASE_VERSION = 6;
private long latestTreatmentChange = 0;

View file

@ -11,6 +11,7 @@ import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
@ -55,6 +56,7 @@ public class TempBasal {
public IobTotal iobCalc(Date time) {
IobTotal result = new IobTotal(time.getTime());
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin();
if (profile == null)
return result;
@ -93,12 +95,12 @@ public class TempBasal {
if (tempBolusCount > 0) {
Long tempBolusSpacing = realDuration / tempBolusCount;
for (Long j = 0l; j < tempBolusCount; j++) {
Treatment tempBolusPart = new Treatment();
Treatment tempBolusPart = new Treatment(insulinInterface);
tempBolusPart.insulin = tempBolusSize;
Long date = this.timeStart.getTime() + j * tempBolusSpacing * 60 * 1000;
tempBolusPart.created_at = new Date(date);
Iob aIOB = tempBolusPart.iobCalc(time, profile.getDia());
Iob aIOB = insulinInterface.iobCalc(tempBolusPart, time, profile.getDia());
result.basaliob += aIOB.iobContrib;
result.activity += aIOB.activityContrib;
Double dia_ago = time.getTime() - profile.getDia() * 60 * 60 * 1000;

View file

@ -11,8 +11,10 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
@ -43,12 +45,34 @@ public class Treatment implements DataPointWithLabelInterface {
@DatabaseField
public Double insulin = 0d;
@DatabaseField
public int insulinType = InsulinInterface.FASTACTINGINSULIN;
@DatabaseField
public double dia = Constants.defaultDIA;
@DatabaseField
public Double carbs = 0d;
@DatabaseField
public boolean mealBolus = true; // true for meal bolus , false for correction bolus
public Treatment() {
InsulinInterface insulin = MainApp.getConfigBuilder().getActiveInsulin();
if (insulin != null) {
insulinType = insulin.getId();
dia = insulin.getDia();
} else {
insulinType = InsulinInterface.FASTACTINGINSULIN;
dia = Constants.defaultDIA;
}
}
public Treatment(InsulinInterface insulin) {
insulinType = insulin.getId();
dia = insulin.getDia();
}
public void copyFrom(Treatment t) {
this._id = t._id;
this.created_at = t.created_at;
@ -57,32 +81,6 @@ public class Treatment implements DataPointWithLabelInterface {
this.mealBolus = t.mealBolus;
}
public Iob iobCalc(Date time, Double dia) {
Iob result = new Iob();
Double scaleFactor = 3.0 / dia;
Double peak = 75d;
Double end = 180d;
if (this.insulin != 0d) {
Long bolusTime = this.created_at.getTime();
Double minAgo = scaleFactor * (time.getTime() - bolusTime) / 1000d / 60d;
if (minAgo < peak) {
Double x1 = minAgo / 5d + 1;
result.iobContrib = this.insulin * (1 - 0.001852 * x1 * x1 + 0.001852 * x1);
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
result.activityContrib = this.insulin * (2 / dia / 60 / peak) * minAgo;
} else if (minAgo < end) {
Double x2 = (minAgo - 75) / 5;
result.iobContrib = this.insulin * (0.001323 * x2 * x2 - 0.054233 * x2 + 0.55556);
result.activityContrib = this.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * 3 - peak));
}
}
return result;
}
public long getMillisecondsFromStart() {
return new Date().getTime() - created_at.getTime();
}

View file

@ -1,7 +0,0 @@
package info.nightscout.androidaps.interfaces;
/**
* Created by mike on 05.08.2016.
*/
public interface FragmentBase {
}

View file

@ -0,0 +1,21 @@
package info.nightscout.androidaps.interfaces;
import java.util.Date;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment;
/**
* Created by mike on 17.04.2017.
*/
public interface InsulinInterface {
final int FASTACTINGINSULIN = 0;
final int FASTACTINGINSULINPROLONGED = 1;
int getId();
String getFriendlyName();
String getComment();
double getDia();
public Iob iobCalc(Treatment treatment, Date time, Double dia);
}

View file

@ -15,7 +15,8 @@ public interface PluginBase {
int CONSTRAINTS = 7;
int LOOP = 8;
int BGSOURCE = 9;
int LAST = 10; // keep always highest number
int INSULIN = 10;
int LAST = 11; // keep always highest number
int getType();
String getFragmentClass();

View file

@ -39,7 +39,7 @@ public interface PumpInterface {
TempBasal getTempBasal();
TempBasal getExtendedBolus();
PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context);
PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context);
void stopBolusDelivering();
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);

View file

@ -17,17 +17,16 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog;
import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
/**
* A simple {@link Fragment} subclass.
*/
public class ActionsFragment extends Fragment implements FragmentBase, View.OnClickListener {
public class ActionsFragment extends Fragment implements View.OnClickListener {
static ActionsPlugin actionsPlugin = new ActionsPlugin();

View file

@ -159,7 +159,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
mHandler.post(new Runnable() {
@Override
public void run() {
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, 0, context, false);
PumpEnactResult result = pump.deliverTreatment(MainApp.getConfigBuilder().getActiveInsulin(), finalInsulinAfterConstraints, 0, context, false);
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));

View file

@ -9,10 +9,9 @@ import android.view.View;
import android.view.ViewGroup;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
public class CareportalFragment extends Fragment implements FragmentBase, View.OnClickListener {
public class CareportalFragment extends Fragment implements View.OnClickListener {
static CareportalPlugin careportalPlugin;

View file

@ -50,7 +50,7 @@ import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;

View file

@ -28,16 +28,17 @@ import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.NSProfile.NSProfilePlugin;
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingPlugin;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.PasswordProtection;
public class ConfigBuilderFragment extends Fragment implements FragmentBase {
public class ConfigBuilderFragment extends Fragment {
static ConfigBuilderPlugin configBuilderPlugin = new ConfigBuilderPlugin();
@ -45,6 +46,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
return configBuilderPlugin;
}
ListView insulinListView;
ListView bgsourceListView;
ListView pumpListView;
TextView pumpLabel;
@ -62,6 +64,10 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
TextView nsclientVerView;
TextView nightscoutVerView;
LinearLayout mainLayout;
Button unlock;
PluginCustomAdapter insulinDataAdapter = null;
PluginCustomAdapter bgsourceDataAdapter = null;
PluginCustomAdapter pumpDataAdapter = null;
PluginCustomAdapter loopDataAdapter = null;
@ -72,15 +78,14 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
PluginCustomAdapter constraintsDataAdapter = null;
PluginCustomAdapter generalDataAdapter = null;
LinearLayout mainLayout;
Button unlock;
// TODO: sorting
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
pumpLabel = (TextView) view.findViewById(R.id.configbuilder_pumplabel);
@ -98,6 +103,9 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
nsclientVerView = (TextView) view.findViewById(R.id.configbuilder_nsclientversion);
nightscoutVerView = (TextView) view.findViewById(R.id.configbuilder_nightscoutversion);
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
nsclientVerView.setText(ConfigBuilderPlugin.nsClientVersionName);
nightscoutVerView.setText(ConfigBuilderPlugin.nightscoutVersionName);
if (ConfigBuilderPlugin.nsClientVersionCode < 117) nsclientVerView.setTextColor(Color.RED);
@ -105,9 +113,6 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
nightscoutVerView.setTextColor(Color.RED);
setViews();
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
if (PasswordProtection.isLocked("settings_password")) {
mainLayout.setVisibility(View.GONE);
unlock.setOnClickListener(new View.OnClickListener() {
@ -129,6 +134,9 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
}
void setViews() {
insulinDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsListByInterface(InsulinInterface.class), PluginBase.INSULIN);
insulinListView.setAdapter(insulinDataAdapter);
setListViewHeightBasedOnChildren(insulinListView);
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsListByInterface(BgSourceInterface.class), PluginBase.BGSOURCE);
bgsourceListView.setAdapter(bgsourceDataAdapter);
setListViewHeightBasedOnChildren(bgsourceListView);
@ -253,7 +261,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
}
// Hide enabled control and force enabled plugin if there is only one plugin available
if (type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.TEMPBASAL || type == PluginBase.PROFILE)
if (type == PluginBase.INSULIN || type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.TEMPBASAL || type == PluginBase.PROFILE)
if (pluginList.size() < 2) {
holder.checkboxEnabled.setEnabled(false);
plugin.setFragmentEnabled(type, true);
@ -299,6 +307,9 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
case PluginBase.LOOP:
break;
// Single selection allowed
case PluginBase.INSULIN:
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
break;
case PluginBase.APS:
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
break;
@ -328,6 +339,8 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
} else { // enable first plugin in list
if (type == PluginBase.PUMP)
MainApp.getSpecificPlugin(VirtualPumpPlugin.class).setFragmentEnabled(type, true);
else if (type == PluginBase.INSULIN)
MainApp.getSpecificPlugin(InsulinFastactingPlugin.class).setFragmentEnabled(type, true);
else if (type == PluginBase.PROFILE)
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(type, true);
else

View file

@ -9,8 +9,6 @@ import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.squareup.otto.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -18,10 +16,6 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
@ -31,19 +25,19 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.TempBasal;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventBolusRequested;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgError;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgError;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.DeviceStatus;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
@ -59,6 +53,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.BatteryLevel;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
/**
* Created by mike on 05.08.2016.
@ -73,6 +68,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
static TempBasalsInterface activeTempBasals;
static APSInterface activeAPS;
static LoopPlugin activeLoop;
static InsulinInterface activeInsulin;
static public String nightscoutVersionName = "";
static public Integer nightscoutVersionCode = 0;
@ -204,6 +200,10 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
return activeTempBasals;
}
public static InsulinInterface getActiveInsulin() {
return activeInsulin;
}
public static APSInterface getActiveAPS() {
return activeAPS;
}
@ -223,7 +223,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
(p.isEnabled(6) ? " PUMP" : "") +
(p.isEnabled(7) ? " CONSTRAINTS" : "") +
(p.isEnabled(8) ? " LOOP" : "") +
(p.isEnabled(9) ? " BGSOURCE" : "")
(p.isEnabled(9) ? " BGSOURCE" : "") +
(p.isEnabled(10) ? " INSULIN" : "")
);
}
}
@ -244,7 +245,18 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
}
// PluginBase.PROFILE
// PluginBase.INSULIN
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
activeInsulin = (InsulinInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.INSULIN);
if (Config.logConfigBuilder)
log.debug("Selected insulin interface: " + ((PluginBase) activeInsulin).getName());
for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(((PluginBase) activeInsulin).getName())) {
p.setFragmentVisible(PluginBase.INSULIN, false);
}
}
// PluginBase.PROFILE
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PROFILE);
if (Config.logConfigBuilder)
@ -462,7 +474,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
return null;
}
public PumpEnactResult deliverTreatmentFromBolusWizard(Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
public PumpEnactResult deliverTreatmentFromBolusWizard(InsulinInterface insulinType, Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
mWakeLock.acquire();
PumpEnactResult result;
if (activePump != null) {
@ -478,14 +490,14 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
MainApp.bus().post(new EventBolusRequested(insulin));
result = activePump.deliverTreatment(insulin, carbs, context);
result = activePump.deliverTreatment(insulinType, insulin, carbs, context);
BolusProgressDialog.bolusEnded = true;
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
if (result.success) {
Treatment t = new Treatment();
Treatment t = new Treatment(insulinType);
t.insulin = result.bolusDelivered;
if (carbTime == 0)
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
@ -499,7 +511,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} else {
if (Config.logCongigBuilderActions)
log.debug("Creating treatment: " + insulin + " carbs: " + carbs);
Treatment t = new Treatment();
Treatment t = new Treatment(insulinType);
t.insulin = insulin;
t.carbs = (double) carbs;
t.created_at = new Date();
@ -517,11 +529,11 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
@Override
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context) {
return deliverTreatment(insulin, carbs, context, true);
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
return deliverTreatment(insulinType, insulin, carbs, context, true);
}
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context, boolean createTreatment) {
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context, boolean createTreatment) {
mWakeLock.acquire();
PumpEnactResult result;
if (activePump != null) {
@ -543,7 +555,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
MainApp.bus().post(new EventBolusRequested(insulin));
result = activePump.deliverTreatment(insulin, carbs, context);
result = activePump.deliverTreatment(insulinType, insulin, carbs, context);
BolusProgressDialog.bolusEnded = true;
@ -553,7 +565,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
if (result.success && createTreatment) {
Treatment t = new Treatment();
Treatment t = new Treatment(insulinType);
t.insulin = result.bolusDelivered;
t.carbs = (double) result.carbsDelivered;
t.created_at = new Date();
@ -565,7 +577,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} else {
if (Config.logCongigBuilderActions)
log.debug("Creating treatment: " + insulin + " carbs: " + carbs);
Treatment t = new Treatment();
Treatment t = new Treatment(insulinType);
t.insulin = insulin;
t.carbs = (double) carbs;
t.created_at = new Date();
@ -1128,24 +1140,26 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
public void uploadAppStart() {
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
JSONObject data = new JSONObject();
try {
data.put("eventType", "Note");
data.put("created_at", DateUtil.toISOString(new Date()));
data.put("notes", MainApp.sResources.getString(R.string.androidaps_start));
} catch (JSONException e) {
e.printStackTrace();
if (SP.getBoolean(R.string.key_ns_logappstartedevent, true)) {
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
JSONObject data = new JSONObject();
try {
data.put("eventType", "Note");
data.put("created_at", DateUtil.toISOString(new Date()));
data.put("notes", MainApp.sResources.getString(R.string.androidaps_start));
} catch (JSONException e) {
e.printStackTrace();
}
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), ConfigBuilderPlugin.class);
}
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), ConfigBuilderPlugin.class);
}
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.Objectives;
package info.nightscout.androidaps.plugins.ConstraintsObjectives;
import android.app.Activity;
import android.content.Context;
@ -7,7 +7,6 @@ import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -24,9 +23,8 @@ import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
public class ObjectivesFragment extends Fragment implements View.OnClickListener, FragmentBase {
public class ObjectivesFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
private static ObjectivesPlugin objectivesPlugin;
@ -44,15 +42,6 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
LinearLayout fake_layout;
TextView reset;
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
default:
break;
}
}
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ObjectiveViewHolder> {
List<ObjectivesPlugin.Objective> objectives;
@ -237,16 +226,4 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
});
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.Objectives;
package info.nightscout.androidaps.plugins.ConstraintsObjectives;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/**
* Created by mike on 05.08.2016.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.SafetyFragment;
package info.nightscout.androidaps.plugins.ConstraintsSafety;
import android.support.v4.app.Fragment;
@ -6,9 +6,7 @@ import android.support.v4.app.Fragment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.interfaces.FragmentBase;
public class SafetyFragment extends Fragment implements FragmentBase{
public class SafetyFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(SafetyFragment.class);
private static SafetyPlugin safetyPlugin = new SafetyPlugin();

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.SafetyFragment;
package info.nightscout.androidaps.plugins.ConstraintsSafety;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -0,0 +1,78 @@
package info.nightscout.androidaps.plugins.InsulinFastacting;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
/**
* Created by mike on 21.04.2017.
*/
public class ActivityGraph extends GraphView {
Context context;
public ActivityGraph(Context context) {
super(context);
this.context = context;
}
public ActivityGraph(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
public void show(InsulinInterface insulin) {
double dia = insulin.getDia();
int hours = (int) Math.floor(dia + 1);
Treatment t = new Treatment(insulin);
t.created_at = new Date(0);
t.timeIndex = 0;
t.insulin = 1d;
LineGraphSeries<DataPoint> activitySeries = null;
LineGraphSeries<DataPoint> iobSeries = null;
List<DataPoint> activityArray = new ArrayList<DataPoint>();
List<DataPoint> iobArray = new ArrayList<DataPoint>();
for (long time = 0; time <= hours * 60 * 60 * 1000; time += 5 * 60 * 1000L) {
Iob iob = insulin.iobCalc(t, new Date(time), dia);
activityArray.add(new DataPoint(time / 60 / 1000, iob.activityContrib));
iobArray.add(new DataPoint(time / 60 / 1000, iob.iobContrib));
}
DataPoint[] activityDataPoints = new DataPoint[activityArray.size()];
activityDataPoints = activityArray.toArray(activityDataPoints);
addSeries(activitySeries = new LineGraphSeries<DataPoint>(activityDataPoints));
activitySeries.setThickness(8);
getViewport().setXAxisBoundsManual(true);
getViewport().setMinX(0);
getViewport().setMaxX(hours * 60);
getGridLabelRenderer().setNumHorizontalLabels(hours + 1);
getGridLabelRenderer().setHorizontalAxisTitle("[min]");
DataPoint[] iobDataPoints = new DataPoint[iobArray.size()];
iobDataPoints = iobArray.toArray(iobDataPoints);
getSecondScale().addSeries(iobSeries = new LineGraphSeries<DataPoint>(iobDataPoints));
iobSeries.setDrawBackground(true);
iobSeries.setColor(Color.MAGENTA);
iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255));
getSecondScale().setMinY(0);
getSecondScale().setMaxY(1);
}
}

View file

@ -0,0 +1,46 @@
package info.nightscout.androidaps.plugins.InsulinFastacting;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
/**
* Created by mike on 17.04.2017.
*/
public class InsulinFastactingFragment extends Fragment {
static InsulinFastactingPlugin insulinFastactingPlugin = new InsulinFastactingPlugin();
static public InsulinFastactingPlugin getPlugin() {
return insulinFastactingPlugin;
}
TextView insulinName;
TextView insulinComment;
TextView insulinDia;
ActivityGraph insulinGraph;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
insulinName = (TextView) view.findViewById(R.id.insulin_name);
insulinComment = (TextView) view.findViewById(R.id.insulin_comment);
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
insulinComment.setText(insulinFastactingPlugin.getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingPlugin.getDia()).toString() + "h");
insulinGraph.show(insulinFastactingPlugin);
return view;
}
}

View file

@ -0,0 +1,119 @@
package info.nightscout.androidaps.plugins.InsulinFastacting;
import java.util.Date;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
/**
* Created by mike on 17.04.2017.
*/
public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = false;
@Override
public int getType() {
return INSULIN;
}
@Override
public String getFragmentClass() {
return InsulinFastactingFragment.class.getName();
}
@Override
public String getName() {
return MainApp.sResources.getString(R.string.fastactinginsulin);
}
@Override
public String getNameShort() {
return MainApp.sResources.getString(R.string.insulin_shortname);
}
@Override
public boolean isEnabled(int type) {
return type == INSULIN && fragmentEnabled;
}
@Override
public boolean isVisibleInTabs(int type) {
return type == INSULIN && fragmentVisible;
}
@Override
public boolean canBeHidden(int type) {
return true;
}
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
}
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
}
// Insulin interface
@Override
public int getId() {
return FASTACTINGINSULIN;
}
@Override
public String getFriendlyName() {
return MainApp.sResources.getString(R.string.fastactinginsulin);
}
@Override
public String getComment() {
return MainApp.sResources.getString(R.string.fastactinginsulincomment);
}
@Override
public double getDia() {
ProfileInterface profileInterface = MainApp.getConfigBuilder().getActiveProfile();
if (profileInterface.getProfile() != null)
return profileInterface.getProfile().getDia();
return Constants.defaultDIA;
}
@Override
public Iob iobCalc(Treatment treatment, Date time, Double dia) {
Iob result = new Iob();
Double scaleFactor = 3.0 / dia;
Double peak = 75d;
Double end = 180d;
if (treatment.insulin != 0d) {
Long bolusTime = treatment.created_at.getTime();
Double minAgo = scaleFactor * (time.getTime() - bolusTime) / 1000d / 60d;
if (minAgo < peak) {
Double x1 = minAgo / 5d + 1;
result.iobContrib = treatment.insulin * (1 - 0.001852 * x1 * x1 + 0.001852 * x1);
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
result.activityContrib = treatment.insulin * (2 / dia / 60 / peak) * minAgo;
} else if (minAgo < end) {
Double x2 = (minAgo - 75) / 5;
result.iobContrib = treatment.insulin * (0.001323 * x2 * x2 - 0.054233 * x2 + 0.55556);
result.activityContrib = treatment.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * 3 - peak));
}
}
return result;
}
}

View file

@ -0,0 +1,47 @@
package info.nightscout.androidaps.plugins.InsulinFastactingProlonged;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph;
/**
* Created by mike on 17.04.2017.
*/
public class InsulinFastactingProlongedFragment extends Fragment {
static InsulinFastactingProlongedPlugin insulinFastactingProlongedPlugin = new InsulinFastactingProlongedPlugin();
static public InsulinFastactingProlongedPlugin getPlugin() {
return insulinFastactingProlongedPlugin;
}
TextView insulinName;
TextView insulinComment;
TextView insulinDia;
ActivityGraph insulinGraph;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
insulinName = (TextView) view.findViewById(R.id.insulin_name);
insulinComment = (TextView) view.findViewById(R.id.insulin_comment);
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingProlongedPlugin.getDia()).toString() + "h");
insulinGraph.show(insulinFastactingProlongedPlugin);
return view;
}
}

View file

@ -0,0 +1,124 @@
package info.nightscout.androidaps.plugins.InsulinFastactingProlonged;
import java.util.Date;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
/**
* Created by mike on 17.04.2017.
*/
public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = false;
@Override
public int getType() {
return INSULIN;
}
@Override
public String getFragmentClass() {
return InsulinFastactingProlongedFragment.class.getName();
}
@Override
public String getName() {
return MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
}
@Override
public String getNameShort() {
return MainApp.sResources.getString(R.string.insulin_shortname);
}
@Override
public boolean isEnabled(int type) {
return type == INSULIN && fragmentEnabled;
}
@Override
public boolean isVisibleInTabs(int type) {
return type == INSULIN && fragmentVisible;
}
@Override
public boolean canBeHidden(int type) {
return true;
}
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
}
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
}
// Insulin interface
@Override
public int getId() {
return FASTACTINGINSULINPROLONGED;
}
@Override
public String getFriendlyName() {
return MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
}
@Override
public String getComment() {
return MainApp.sResources.getString(R.string.fastactinginsulincomment);
}
@Override
public double getDia() {
ProfileInterface profileInterface = MainApp.getConfigBuilder().getActiveProfile();
if (profileInterface.getProfile() != null)
return profileInterface.getProfile().getDia();
return Constants.defaultDIA;
}
@Override
public Iob iobCalc(Treatment treatment, Date time, Double dia) {
Iob result = new Iob();
//Double scaleFactor = 3.0 / dia;
Double peak = 75d * dia / 6.0;
Double tail = 180d * dia / 6.0;
Double end = 360d * dia / 6.0;
Double Total = 2 * peak + (tail - peak) * 5 / 2 + (end - tail) / 2;
if (treatment.insulin != 0d) {
Long bolusTime = treatment.created_at.getTime();
Double minAgo = (time.getTime() - bolusTime) / 1000d / 60d;
if (minAgo < peak) {
Double x1 = 6 / dia * minAgo / 5d + 1;
result.iobContrib = treatment.insulin * (1 - 0.0012595 * x1 * x1 + 0.0012595 * x1);
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
result.activityContrib = treatment.insulin * ((2 * peak / Total) * 2 / peak / peak * minAgo);
} else if (minAgo < tail) {
Double x2 = (6 / dia * (minAgo - peak)) / 5;
result.iobContrib = treatment.insulin * (0.00074 * x2 * x2 - 0.0403 * x2 + 0.69772);
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 3 / 4) / (tail - peak) * (minAgo - peak) + (2 * peak / Total) * 2 / peak);
} else if (minAgo < end) {
Double x3 = (6 / dia * (minAgo - tail)) / 5;
result.iobContrib = treatment.insulin * (0.0001323 * x3 * x3 - 0.0097 * x3 + 0.17776);
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 1 / 4) / (end - tail) * (minAgo - tail) + (2 * peak / Total) * 2 / peak / 4);
}
}
return result;
}
}

View file

@ -19,11 +19,10 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
public class LoopFragment extends Fragment implements View.OnClickListener, FragmentBase {
public class LoopFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
private static LoopPlugin loopPlugin;

View file

@ -47,6 +47,7 @@ public class LoopPlugin implements PluginBase {
private boolean fragmentVisible = true;
private long loopSuspendedTill = 0L; // end of manual loop suspend
private boolean isSuperBolus = false;
public class LastRun {
public APSResult request = null;
@ -68,6 +69,7 @@ public class LoopPlugin implements PluginBase {
}
MainApp.bus().register(this);
loopSuspendedTill = SP.getLong("loopSuspendedTill", 0L);
isSuperBolus = SP.getBoolean("isSuperBolus", false);
}
@Override
@ -137,6 +139,13 @@ public class LoopPlugin implements PluginBase {
public void suspendTo(long endTime) {
loopSuspendedTill = endTime;
isSuperBolus = false;
SP.putLong("loopSuspendedTill", loopSuspendedTill);
}
public void superBolusTo(long endTime) {
loopSuspendedTill = endTime;
isSuperBolus = true;
SP.putLong("loopSuspendedTill", loopSuspendedTill);
}
@ -169,6 +178,20 @@ public class LoopPlugin implements PluginBase {
return true;
}
public boolean isSuperBolus() {
if (loopSuspendedTill == 0)
return false;
long now = new Date().getTime();
if (loopSuspendedTill <= now) { // time exceeded
suspendTo(0L);
return false;
}
return isSuperBolus;
}
public void invoke(String initiator, boolean allowNotification) {
try {
if (Config.logFunctionCalls)

View file

@ -1,33 +0,0 @@
package info.nightscout.androidaps.plugins.MDI;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.VirtualPump.events.EventVirtualPumpUpdateGui;
public class MDIFragment extends Fragment implements FragmentBase {
private static Logger log = LoggerFactory.getLogger(MDIFragment.class);
private static MDIPlugin mdiPlugin = new MDIPlugin();
public static MDIPlugin getPlugin() {
return mdiPlugin;
}
}

View file

@ -28,13 +28,12 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.utils.SP;
public class NSClientInternalFragment extends Fragment implements FragmentBase, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
public class NSClientInternalFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
static NSClientInternalPlugin nsClientInternalPlugin;
@ -189,5 +188,4 @@ public class NSClientInternalFragment extends Fragment implements FragmentBase,
});
}
}

View file

@ -4,11 +4,9 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
@ -20,20 +18,15 @@ import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;

View file

@ -40,66 +40,78 @@ public class UploadQueue {
if (NSClientService.handler == null) {
Context context = MainApp.instance();
context.startService(new Intent(context, NSClientService.class));
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
}
}
public static void add(final DbRequest dbr) {
startService();
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
log.debug("QUEUE adding: " + dbr.data);
MainApp.getDbHelper().create(dbr);
NSClientInternalPlugin plugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
if (plugin != null) {
plugin.resend("newdata");
if (NSClientService.handler != null) {
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
log.debug("QUEUE adding: " + dbr.data);
MainApp.getDbHelper().create(dbr);
NSClientInternalPlugin plugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
if (plugin != null) {
plugin.resend("newdata");
}
}
}
});
});
}
}
public static void clearQueue() {
startService();
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
log.debug("QUEUE ClearQueue");
MainApp.getDbHelper().deleteAllDbRequests();
log.debug(status());
}
});
if (NSClientService.handler != null) {
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
log.debug("QUEUE ClearQueue");
MainApp.getDbHelper().deleteAllDbRequests();
log.debug(status());
}
});
}
}
public static void removeID(final JSONObject record) {
startService();
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
try {
String id;
if (record.has("NSCLIENT_ID")) {
id = record.getString("NSCLIENT_ID");
} else {
return;
if (NSClientService.handler != null) {
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
try {
String id;
if (record.has("NSCLIENT_ID")) {
id = record.getString("NSCLIENT_ID");
} else {
return;
}
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
log.debug("Removed item from UploadQueue. " + UploadQueue.status());
}
} catch (JSONException e) {
e.printStackTrace();
}
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
log.debug("Removed item from UploadQueue. " + UploadQueue.status());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
});
}
}
public static void removeID(final String action, final String _id) {
startService();
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
}
});
if (NSClientService.handler != null) {
NSClientService.handler.post(new Runnable() {
@Override
public void run() {
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
}
});
}
}
public String textList() {

View file

@ -120,7 +120,7 @@ public class NSProfile {
e.printStackTrace();
}
}
return 3D;
return Constants.defaultDIA;
}
/*
public Double getCarbAbsorbtionRate() {

View file

@ -25,8 +25,6 @@ import org.slf4j.LoggerFactory;
import java.net.URISyntaxException;
import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
@ -35,7 +33,7 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventConfigBuilderChange;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck;

View file

@ -25,6 +25,9 @@ public class Autosens {
//console.error(mealTime);
if (glucose_data.size() < 3)
return new AutosensResult();
double deviationSum = 0;
double carbsAbsorbed = 0;

View file

@ -20,12 +20,11 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener, FragmentBase {
public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
private static OpenAPSAMAPlugin openAPSAMAPlugin;

View file

@ -142,7 +142,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
return;
}
if (profile == null) {
if (profile == null || profile.getIc(NSProfile.secondsFromMidnight()) == null || profile.getIsf(NSProfile.secondsFromMidnight()) == null || profile.getBasal(NSProfile.secondsFromMidnight()) == null ) {
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noprofile)));
if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_noprofile));

View file

@ -18,18 +18,17 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener, FragmentBase {
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
private static OpenAPSMAPlugin openAPSMAPlugin;
public static OpenAPSMAPlugin getPlugin() {
if(openAPSMAPlugin==null){
if (openAPSMAPlugin == null) {
openAPSMAPlugin = new OpenAPSMAPlugin();
}
return openAPSMAPlugin;

View file

@ -22,7 +22,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRBolusStart;
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(BolusProgressDialog.class);

View file

@ -60,13 +60,18 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
Double bg = profile != null ? NSProfile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile.getUnits()) : 0d;
if (profile.getUnits().equals(Constants.MMOL))
String units = Constants.MGDL;
if (profile != null)
units = profile.getUnits();
if (units.equals(Constants.MMOL))
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
else
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
unitsView.setText(profile.getUnits());
unitsView.setText(units);
return view;
}

View file

@ -110,7 +110,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
mHandler.post(new Runnable() {
@Override
public void run() {
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints, context);
PumpEnactResult result = pump.deliverTreatment(MainApp.getConfigBuilder().getActiveInsulin(), finalInsulinAfterConstraints, finalCarbsAfterConstraints, context);
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@ -21,16 +22,19 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Text;
import java.text.DecimalFormat;
import java.util.ArrayList;
@ -42,36 +46,58 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
public class WizardDialog extends DialogFragment implements OnClickListener {
public class WizardDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener, Spinner.OnItemSelectedListener {
private static Logger log = LoggerFactory.getLogger(WizardDialog.class);
Button wizardDialogDeliverButton;
TextView correctionInput;
TextView carbsInput;
TextView bgInput;
TextView bg, bgInsulin, bgUnits;
TextView bg;
TextView bgInsulin;
TextView bgUnits;
CheckBox bgCheckbox;
TextView carbs, carbsInsulin;
TextView carbs;
TextView carbsInsulin;
TextView bolusIobInsulin;
TextView basalIobInsulin;
CheckBox bolusIobCheckbox;
CheckBox basalIobCheckbox;
TextView correctionInsulin;
TextView total, totalInsulin;
TextView total;
TextView totalInsulin;
EditText carbTimeEdit;
Spinner profileSpinner;
CheckBox superbolusCheckbox;
TextView superbolus;
TextView superbolusInsulin;
CheckBox bgtrendCheckbox;
TextView bgTrend;
TextView bgTrendInsulin;
LinearLayout cobLayout;
CheckBox cobCheckbox;
TextView cob;
TextView cobInsulin;
PlusMinusEditText editBg;
PlusMinusEditText editCarbs;
@ -81,6 +107,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
Integer calculatedCarbs = 0;
Double calculatedTotalInsulin = 0d;
JSONObject boluscalcJSON;
boolean cobAvailable = false;
Handler mHandler;
public static HandlerThread mHandlerThread;
@ -100,6 +127,51 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
this.context = context;
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
MainApp.bus().register(this);
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui e) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(new Date().getTime() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true;
} else {
cobLayout.setVisibility(View.GONE);
cobAvailable = false;
}
calculateInsulin();
}
});
}
@Subscribe
public void onStatusEvent(final EventNewBG e) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
calculateInsulin();
}
});
}
final private TextWatcher textWatcher = new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
@ -115,66 +187,61 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
}
};
final CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
calculateInsulin();
}
};
final AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calculateInsulin();
wizardDialogDeliverButton.setVisibility(View.VISIBLE);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected));
wizardDialogDeliverButton.setVisibility(View.GONE);
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.overview_wizard_dialog, null, false);
wizardDialogDeliverButton = (Button) view.findViewById(R.id.treatments_wizard_deliverButton);
wizardDialogDeliverButton.setOnClickListener(this);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
correctionInput = (TextView) view.findViewById(R.id.treatments_wizard_correctioninput);
carbsInput = (TextView) view.findViewById(R.id.treatments_wizard_carbsinput);
bgInput = (TextView) view.findViewById(R.id.treatments_wizard_bginput);
correctionInput.addTextChangedListener(textWatcher);
carbsInput.addTextChangedListener(textWatcher);
bgInput.addTextChangedListener(textWatcher);
wizardDialogDeliverButton = (Button) view.findViewById(R.id.treatments_wizard_deliverButton);
wizardDialogDeliverButton.setOnClickListener(this);
bg = (TextView) view.findViewById(R.id.treatments_wizard_bg);
bgInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bginsulin);
bgUnits = (TextView) view.findViewById(R.id.treatments_wizard_bgunits);
bgCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgcheckbox);
carbs = (TextView) view.findViewById(R.id.treatments_wizard_carbs);
carbsInsulin = (TextView) view.findViewById(R.id.treatments_wizard_carbsinsulin);
bolusIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bolusiobinsulin);
basalIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_basaliobinsulin);
bolusIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bolusiobcheckbox);
basalIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_basaliobcheckbox);
correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin);
total = (TextView) view.findViewById(R.id.treatments_wizard_total);
totalInsulin = (TextView) view.findViewById(R.id.treatments_wizard_totalinsulin);
carbTimeEdit = (EditText) view.findViewById(R.id.treatments_wizard_carbtimeinput);
profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile);
superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb);
superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin);
bgCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
basalIobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
bolusIobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
profileSpinner.setOnItemSelectedListener(onItemSelectedListener);
bgTrend = (TextView) view.findViewById(R.id.treatments_wizard_bgtrend);
bgTrendInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bgtrendinsulin);
cobLayout = (LinearLayout) view.findViewById(R.id.treatments_wizard_cob_layout);
cob = (TextView) view.findViewById(R.id.treatments_wizard_cob);;
cobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_cobinsulin);;
bgCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgcheckbox);
bolusIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bolusiobcheckbox);
basalIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_basaliobcheckbox);
superbolusCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_sbcheckbox);
bgtrendCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgtrendcheckbox);
cobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_cobcheckbox);
bgCheckbox.setOnCheckedChangeListener(this);
basalIobCheckbox.setOnCheckedChangeListener(this);
bolusIobCheckbox.setOnCheckedChangeListener(this);
superbolusCheckbox.setOnCheckedChangeListener(this);
bgtrendCheckbox.setOnCheckedChangeListener(this);
cobCheckbox.setOnCheckedChangeListener(this);
profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile);
profileSpinner.setOnItemSelectedListener(this);
correctionInput = (TextView) view.findViewById(R.id.treatments_wizard_correctioninput);
carbsInput = (TextView) view.findViewById(R.id.treatments_wizard_carbsinput);
bgInput = (TextView) view.findViewById(R.id.treatments_wizard_bginput);
correctionInput.addTextChangedListener(textWatcher);
carbsInput.addTextChangedListener(textWatcher);
bgInput.addTextChangedListener(textWatcher);
superbolusCheckbox.setVisibility(SP.getBoolean(R.string.key_usesuperbolus, false) ? View.VISIBLE : View.GONE);
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
Double maxCorrection = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
@ -188,6 +255,23 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
return view;
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
calculateInsulin();
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calculateInsulin();
wizardDialogDeliverButton.setVisibility(View.VISIBLE);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected));
wizardDialogDeliverButton.setVisibility(View.GONE);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
@ -213,6 +297,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
final Double bg = SafeParse.stringToDouble(bgInput.getText().toString());
final int carbTime = SafeParse.stringToInt(carbTimeEdit.getText().toString());
final boolean useSuperBolus = superbolusCheckbox.isChecked();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
@ -225,12 +312,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
@Override
public void run() {
PumpEnactResult result = pump.deliverTreatmentFromBolusWizard(
MainApp.getConfigBuilder().getActiveInsulin(),
context,
finalInsulinAfterConstraints,
finalCarbsAfterConstraints,
SafeParse.stringToDouble(bgInput.getText().toString()),
bg,
"Manual",
SafeParse.stringToInt(carbTimeEdit.getText().toString()),
carbTime,
boluscalcJSON
);
if (!result.success) {
@ -240,6 +328,21 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
builder.show();
}
if (useSuperBolus) {
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
result = pump.setTempBasalAbsolute(0d, 120);
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
builder.setMessage(result.comment);
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
builder.show();
}
if (activeloop != null) {
activeloop.superBolusTo(new Date().getTime() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
}
}
}
});
Answers.getInstance().logCustom(new CustomEvent("Wizard"));
@ -252,7 +355,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
}
break;
}
}
private void initDialog() {
@ -266,8 +368,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
ArrayList<CharSequence> profileList;
profileList = profile.getProfileList();
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
android.R.layout.simple_spinner_item, profileList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
R.layout.spinner_centered, profileList);
profileSpinner.setAdapter(adapter);
// set selected to actual profile
for (int p = 0; p < profileList.size(); p++) {
@ -327,13 +429,14 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
totalInsulin.setText("");
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// COB only if AMA is selected
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(new Date().getTime() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true;
} else {
cobLayout.setVisibility(View.GONE);
cobAvailable = false;
}
}
private void calculateInsulin() {
@ -368,8 +471,19 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
c_bg = bgCheckbox.isChecked() ? c_bg : 0d;
// COB
Double c_cob = 0d;
if (cobAvailable && cobCheckbox.isChecked()) {
if (ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(new Date().getTime() - 11 * 60 * 1000L))) {
try {
c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB"));
} catch (JSONException e) {
}
}
}
BolusWizard wizard = new BolusWizard();
wizard.doCalc(specificProfile, carbsAfterConstraint, c_bg, corrAfterConstraint, bolusIobCheckbox.isChecked(), basalIobCheckbox.isChecked());
wizard.doCalc(specificProfile, carbsAfterConstraint, c_cob, c_bg, corrAfterConstraint, bolusIobCheckbox.isChecked(), basalIobCheckbox.isChecked(), superbolusCheckbox.isChecked(), bgtrendCheckbox.isChecked());
bg.setText(c_bg + " ISF: " + DecimalFormatter.to1Decimal(wizard.sens));
bgInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromBG) + "U");
@ -393,6 +507,35 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
calculatedCarbs = carbsAfterConstraint;
// Superbolus
if (superbolusCheckbox.isChecked()) {
superbolus.setText("2h");
} else {
superbolus.setText("");
}
superbolusInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromSuperBolus) + "U");
// Trend
if (bgtrendCheckbox.isChecked()) {
if (wizard.glucoseStatus != null) {
bgTrend.setText((wizard.glucoseStatus.avgdelta > 0 ? "+" : "") + NSProfile.toUnitsString(wizard.glucoseStatus.avgdelta * 3, wizard.glucoseStatus.avgdelta * 3 / 18, profile.getUnits()) + " " + profile.getUnits());
} else {
bgTrend.setText("");
}
} else {
bgTrend.setText("");
}
bgTrendInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromTrend) + "U");
// COB
if (cobAvailable && cobCheckbox.isChecked()) {
cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic));
cobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCOB) + "U");
} else {
cob.setText("");
cobInsulin.setText("");
}
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U") : "";
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
@ -419,10 +562,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
boluscalcJSON.put("bgdiff", wizard.bgDiff);
boluscalcJSON.put("insulincarbs", wizard.insulinFromCarbs);
boluscalcJSON.put("carbs", c_carbs);
boluscalcJSON.put("cob", c_cob);
boluscalcJSON.put("insulincob", wizard.insulinFromCOB);
boluscalcJSON.put("othercorrection", corrAfterConstraint);
boluscalcJSON.put("insulinsuperbolus", wizard.insulinFromSuperBolus);
boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
boluscalcJSON.put("insulin", calculatedTotalInsulin);
} catch (JSONException e) {
e.printStackTrace();
}
}
}

View file

@ -3,14 +3,12 @@ package info.nightscout.androidaps.plugins.Overview;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
@ -28,13 +26,14 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.ValueDependentColor;
import com.jjoe64.graphview.series.BarGraphSeries;
import com.jjoe64.graphview.LabelFormatter;
import com.jjoe64.graphview.Viewport;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import com.jjoe64.graphview.series.PointsGraphSeries;
@ -76,9 +75,10 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
@ -86,12 +86,14 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.FixedLineGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
@ -100,7 +102,7 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
public class OverviewFragment extends Fragment {
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
@ -125,7 +127,13 @@ public class OverviewFragment extends Fragment {
LinearLayout loopStatusLayout;
LinearLayout pumpStatusLayout;
GraphView bgGraph;
GraphView iobGraph;
RelativeLayout iobGraphLayout;
CheckBox showPredictionView;
CheckBox showBasalsView;
CheckBox showIobView;
CheckBox showCobView;
RecyclerView notificationsView;
LinearLayoutManager llm;
@ -159,6 +167,7 @@ public class OverviewFragment extends Fragment {
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.overview_fragment, container, false);
bgView = (TextView) view.findViewById(R.id.overview_bg);
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
@ -175,144 +184,61 @@ public class OverviewFragment extends Fragment {
iobView = (TextView) view.findViewById(R.id.overview_iob);
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp);
treatmentButton = (Button) view.findViewById(R.id.overview_treatment);
wizardButton = (Button) view.findViewById(R.id.overview_wizard);
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp);
cancelTempLayout = (LinearLayout) view.findViewById(R.id.overview_canceltemplayout);
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
iobGraphLayout = (RelativeLayout) view.findViewById(R.id.overview_iobgraphlayout);
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton);
cancelTempButton.setOnClickListener(this);
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
treatmentButton.setOnClickListener(this);
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
wizardButton.setOnClickListener(this);
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton);
cancelTempButton.setOnClickListener(this);
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
acceptTempButton.setOnClickListener(this);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
quickWizardButton.setOnClickListener(this);
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
calibrationButton.setOnClickListener(this);
cancelTempLayout = (LinearLayout) view.findViewById(R.id.overview_canceltemplayout);
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
calibrationButton = (Button) view.findViewById(R.id.overview_calibration);
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
showBasalsView.setChecked(SP.getBoolean("showbasals", false));
showIobView.setChecked(SP.getBoolean("showiob", false));
showCobView.setChecked(SP.getBoolean("showcob", false));
showPredictionView.setOnCheckedChangeListener(this);
showBasalsView.setOnCheckedChangeListener(this);
showIobView.setOnCheckedChangeListener(this);
showCobView.setOnCheckedChangeListener(this);
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
notificationsView.setHasFixedSize(true);
llm = new LinearLayoutManager(view.getContext());
notificationsView.setLayoutManager(llm);
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
showPredictionView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("showprediction", showPredictionView.isChecked());
editor.apply();
updateGUI();
}
});
bgGraph.getGridLabelRenderer().setGridColor(Color.rgb(0x75, 0x75, 0x75));
bgGraph.getGridLabelRenderer().reloadStyles();
iobGraph.getGridLabelRenderer().setGridColor(Color.rgb(0x75, 0x75, 0x75));
iobGraph.getGridLabelRenderer().reloadStyles();
iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
treatmentButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager manager = getFragmentManager();
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
treatmentDialogFragment.show(manager, "TreatmentDialog");
}
});
wizardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager manager = getFragmentManager();
WizardDialog wizardDialog = new WizardDialog();
wizardDialog.show(manager, "WizardDialog");
}
});
quickWizardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
processQuickWizard();
}
});
cancelTempButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final PumpInterface pump = MainApp.getConfigBuilder();
if (pump.isTempBasalInProgress()) {
sHandler.post(new Runnable() {
@Override
public void run() {
pump.cancelTempBasal();
MainApp.bus().post(new EventTempBasalChange());
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
}
});
}
}
});
calibrationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager manager = getFragmentManager();
CalibrationDialog calibrationDialog = new CalibrationDialog();
calibrationDialog.show(manager, "CalibrationDialog");
}
});
acceptTempButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getContext().getString(R.string.confirmation));
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
sHandler.post(new Runnable() {
@Override
public void run() {
hideTempRecommendation();
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
if (applyResult.enacted) {
finalLastRun.setByPump = applyResult;
finalLastRun.lastEnact = new Date();
finalLastRun.lastOpenModeAccept = new Date();
MainApp.getConfigBuilder().uploadDeviceStatus();
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
if (objectivesPlugin != null) {
objectivesPlugin.manualEnacts++;
objectivesPlugin.saveProgress();
}
}
updateGUIIfVisible();
}
});
Answers.getInstance().logCustom(new CustomEvent("AcceptTemp"));
}
});
builder.setNegativeButton(getContext().getString(R.string.cancel), null);
builder.show();
}
updateGUI();
}
});
pumpStatusView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.getConfigBuilder().refreshDataFromPump("RefreshClicked");
}
});
}
});
updateGUI();
return view;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
@ -339,6 +265,28 @@ public class OverviewFragment extends Fragment {
menu.add(MainApp.sResources.getString(R.string.enableloop));
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.overview_showprediction:
SP.putBoolean("showprediction", showPredictionView.isChecked());
updateGUI("onPredictionCheckedChanged");
break;
case R.id.overview_showbasals:
SP.putBoolean("showbasals", showPredictionView.isChecked());
updateGUI("onBasalsCheckedChanged");
break;
case R.id.overview_showiob:
SP.putBoolean("showiob", showIobView.isChecked());
updateGUI("onIobCheckedChanged");
break;
case R.id.overview_showcob:
SP.putBoolean("showcob", showCobView.isChecked());
updateGUI("onCobCheckedChanged");
break;
}
}
@Override
public boolean onContextItemSelected(MenuItem item) {
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
@ -346,20 +294,18 @@ public class OverviewFragment extends Fragment {
activeloop.setFragmentEnabled(PluginBase.LOOP, false);
activeloop.setFragmentVisible(PluginBase.LOOP, false);
MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
activeloop.setFragmentEnabled(PluginBase.LOOP, true);
activeloop.setFragmentVisible(PluginBase.LOOP, true);
MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
activeloop.suspendTo(0L);
updateGUI("suspendmenu");
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@ -369,22 +315,23 @@ public class OverviewFragment extends Fragment {
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
activeloop.suspendTo(new Date().getTime() + 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
updateGUI("suspendmenu");
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
updateGUI("suspendmenu");
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
updateGUI("suspendmenu");
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
activeloop.suspendTo(new Date().getTime() + 10 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
updateGUI("suspendmenu");
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
activeloop.suspendTo(new Date().getTime() + 30L * 60 * 1000);
updateGUI("suspendmenu");
sHandler.post(new Runnable() {
@Override
public void run() {
@ -392,16 +339,15 @@ public class OverviewFragment extends Fragment {
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
MainApp.bus().post(new EventRefreshGui(false));
}
});
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
activeloop.suspendTo(new Date().getTime() + 1 * 60L * 60 * 1000);
updateGUI("suspendmenu");
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@ -411,10 +357,10 @@ public class OverviewFragment extends Fragment {
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
updateGUI("suspendmenu");
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@ -424,10 +370,10 @@ public class OverviewFragment extends Fragment {
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000);
updateGUI("suspendmenu");
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@ -440,7 +386,92 @@ public class OverviewFragment extends Fragment {
return super.onContextItemSelected(item);
}
void processQuickWizard() {
@Override
public void onClick(View v) {
FragmentManager manager = getFragmentManager();
switch (v.getId()) {
case R.id.overview_accepttempbutton:
onClickAcceptTemp();
break;
case R.id.overview_quickwizardbutton:
onClickQuickwizard();
break;
case R.id.overview_wizardbutton:
WizardDialog wizardDialog = new WizardDialog();
wizardDialog.show(manager, "WizardDialog");
break;
case R.id.overview_calibrationbutton:
CalibrationDialog calibrationDialog = new CalibrationDialog();
calibrationDialog.show(manager, "CalibrationDialog");
break;
case R.id.overview_treatmentbutton:
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
treatmentDialogFragment.show(manager, "TreatmentDialog");
break;
case R.id.overview_canceltempbutton:
final PumpInterface pump = MainApp.getConfigBuilder();
if (pump.isTempBasalInProgress()) {
sHandler.post(new Runnable() {
@Override
public void run() {
pump.cancelTempBasal();
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
}
});
}
break;
case R.id.overview_pumpstatus:
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.getConfigBuilder().refreshDataFromPump("RefreshClicked");
}
});
break;
}
}
private void onClickAcceptTemp() {
if (ConfigBuilderPlugin.getActiveLoop() != null) {
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getContext().getString(R.string.confirmation));
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
sHandler.post(new Runnable() {
@Override
public void run() {
hideTempRecommendation();
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
if (applyResult.enacted) {
finalLastRun.setByPump = applyResult;
finalLastRun.lastEnact = new Date();
finalLastRun.lastOpenModeAccept = new Date();
MainApp.getConfigBuilder().uploadDeviceStatus();
ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
if (objectivesPlugin != null) {
objectivesPlugin.manualEnacts++;
objectivesPlugin.saveProgress();
}
}
updateGUIIfVisible("onClickAcceptTemp");
}
});
Answers.getInstance().logCustom(new CustomEvent("AcceptTemp"));
}
});
builder.setNegativeButton(getContext().getString(R.string.cancel), null);
builder.show();
}
}
}
void onClickQuickwizard() {
final BgReading actualBg = GlucoseStatus.actualBg();
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
return;
@ -451,7 +482,7 @@ public class OverviewFragment extends Fragment {
quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText();
BolusWizard wizard = new BolusWizard();
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), actualBg.valueToUnits(profile.getUnits()), 0d, true, true);
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
final JSONObject boluscalcJSON = new JSONObject();
try {
@ -470,6 +501,7 @@ public class OverviewFragment extends Fragment {
boluscalcJSON.put("insulincarbs", wizard.insulinFromCarbs);
boluscalcJSON.put("carbs", quickWizardEntry.carbs());
boluscalcJSON.put("othercorrection", 0d);
boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
boluscalcJSON.put("insulin", wizard.calculatedTotalInsulin);
} catch (JSONException e) {
e.printStackTrace();
@ -507,6 +539,7 @@ public class OverviewFragment extends Fragment {
@Override
public void run() {
PumpEnactResult result = pump.deliverTreatmentFromBolusWizard(
MainApp.getConfigBuilder().getActiveInsulin(),
getContext(),
finalInsulinAfterConstraints,
finalCarbsAfterConstraints,
@ -550,58 +583,58 @@ public class OverviewFragment extends Fragment {
sRefreshLoop = new Runnable() {
@Override
public void run() {
updateGUIIfVisible();
updateGUIIfVisible("refreshLoop");
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
}
};
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
registerForContextMenu(apsModeView);
updateGUIIfVisible();
updateGUIIfVisible("onResume");
}
@Subscribe
public void onStatusEvent(final EventInitializationChanged ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventInitializationChanged");
}
@Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventPreferenceChange");
}
@Subscribe
public void onStatusEvent(final EventRefreshGui ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventRefreshGui");
}
@Subscribe
public void onStatusEvent(final EventTreatmentChange ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventTreatmentChange");
}
@Subscribe
public void onStatusEvent(final EventTempBasalChange ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventTempBasalChange");
}
@Subscribe
public void onStatusEvent(final EventNewBG ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventTempBasalChange");
}
@Subscribe
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventNewOpenLoopNotification");
}
@Subscribe
public void onStatusEvent(final EventNewBasalProfile ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventNewBasalProfile");
}
@Subscribe
public void onStatusEvent(final EventTempTargetRangeChange ev) {
updateGUIIfVisible();
updateGUIIfVisible("EventTempTargetRangeChange");
}
@Subscribe
@ -637,13 +670,13 @@ public class OverviewFragment extends Fragment {
});
}
private void updateGUIIfVisible() {
private void updateGUIIfVisible(final String from) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
updateGUI();
updateGUI(from);
}
});
}
@ -663,7 +696,8 @@ public class OverviewFragment extends Fragment {
}
@SuppressLint("SetTextI18n")
public void updateGUI() {
public void updateGUI(String from) {
log.debug("updateGUI entered from: " + from);
updateNotifications();
BgReading actualBG = GlucoseStatus.actualBg();
BgReading lastBG = GlucoseStatus.lastBg();
@ -694,7 +728,11 @@ public class OverviewFragment extends Fragment {
apsModeView.setBackgroundResource(R.drawable.loopmodeborder);
apsModeView.setTextColor(Color.BLACK);
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
apsModeView.setBackgroundResource(R.drawable.loopmodesuspendedborder);
apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
apsModeView.setTextColor(Color.WHITE);
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
apsModeView.setBackgroundResource(R.drawable.loopmodesuspendedborder);
apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
apsModeView.setTextColor(Color.WHITE);
@ -820,7 +858,7 @@ public class OverviewFragment extends Fragment {
quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
BolusWizard wizard = new BolusWizard();
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
quickWizardButton.setText(text);
if (wizard.calculatedTotalInsulin <= 0)
@ -921,89 +959,180 @@ public class OverviewFragment extends Fragment {
}
LineGraphSeries<DataPoint> basalsLineSeries = null;
BarGraphSeries<DataPoint> basalsSeries = null;
LineGraphSeries<DataPoint> seriesLow = null;
LineGraphSeries<DataPoint> seriesHigh = null;
LineGraphSeries<DataPoint> seriesNow = null;
PointsGraphSeries<BgReading> seriesInRage = null;
PointsGraphSeries<BgReading> seriesOutOfRange = null;
PointsGraphSeries<BgReading> predSeries = null;
PointsWithLabelGraphSeries<Treatment> seriesTreatments = null;
// remove old data from graph
bgGraph.removeAllSeries();
// **** HIGH and LOW targets graph ****
DataPoint[] lowDataPoints = new DataPoint[]{
new DataPoint(fromTime, lowLine),
new DataPoint(endTime, lowLine)
};
DataPoint[] highDataPoints = new DataPoint[]{
new DataPoint(fromTime, highLine),
new DataPoint(endTime, highLine)
};
bgGraph.addSeries(seriesLow = new LineGraphSeries<DataPoint>(lowDataPoints));
seriesLow.setColor(Color.RED);
bgGraph.addSeries(seriesHigh = new LineGraphSeries<DataPoint>(highDataPoints));
seriesHigh.setColor(Color.RED);
LineGraphSeries<DataPoint> baseBasalsSeries = null;
LineGraphSeries<DataPoint> tempBasalsSeries = null;
AreaGraphSeries<DoubleDataPoint> areaSeries;
LineGraphSeries<DataPoint> seriesNow, seriesNow2;
PointsGraphSeries<BgReading> seriesInRage;
PointsGraphSeries<BgReading> seriesOutOfRange;
PointsGraphSeries<BgReading> predSeries;
PointsWithLabelGraphSeries<Treatment> seriesTreatments;
// **** TEMP BASALS graph ****
class BarDataPoint extends DataPoint {
public BarDataPoint(double x, double y, boolean isTempBasal) {
super(x, y);
this.isTempBasal = isTempBasal;
}
public boolean isTempBasal = false;
}
Double maxBasalValueFound = 0d;
long now = new Date().getTime();
if (pump.getPumpDescription().isTempBasalCapable) {
List<BarDataPoint> basalArray = new ArrayList<BarDataPoint>();
List<DataPoint> basalLineArray = new ArrayList<DataPoint>();
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
List<DataPoint> baseBasalArray = new ArrayList<>();
List<DataPoint> tempBasalArray = new ArrayList<>();
List<DataPoint> basalLineArray = new ArrayList<>();
double lastLineBasal = 0;
double lastBaseBasal = 0;
double lastTempBasal = 0;
for (long time = fromTime; time < now; time += 5 * 60 * 1000L) {
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date(time));
double basebasal = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time)));
Double basal = 0d;
if (tb != null)
basalArray.add(new BarDataPoint(time, basal = tb.tempBasalConvertedToAbsolute(new Date(time)), true));
else {
basalArray.add(new BarDataPoint(time, basal = basebasal, false));
double baseBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time)));
double baseLineValue = baseBasalValue;
double tempBasalValue = 0;
double basal = 0d;
if (tb != null) {
tempBasalValue = tb.tempBasalConvertedToAbsolute(new Date(time));
if (tempBasalValue != lastTempBasal) {
tempBasalArray.add(new DataPoint(time, lastTempBasal));
tempBasalArray.add(new DataPoint(time, basal = tempBasalValue));
}
if (lastBaseBasal != 0d) {
baseBasalArray.add(new DataPoint(time, lastBaseBasal));
baseBasalArray.add(new DataPoint(time, 0d));
lastBaseBasal = 0d;
}
} else {
if (baseBasalValue != lastBaseBasal) {
baseBasalArray.add(new DataPoint(time, lastBaseBasal));
baseBasalArray.add(new DataPoint(time, basal = baseBasalValue));
lastBaseBasal = baseBasalValue;
}
if (lastTempBasal != 0) {
tempBasalArray.add(new DataPoint(time, lastTempBasal));
tempBasalArray.add(new DataPoint(time, 0d));
}
}
if (basebasal != lastBaseBasal)
basalLineArray.add(new DataPoint(time, lastBaseBasal));
basalLineArray.add(new DataPoint(time, basebasal));
lastBaseBasal = basebasal;
if (baseLineValue != lastLineBasal) {
basalLineArray.add(new DataPoint(time, lastLineBasal));
basalLineArray.add(new DataPoint(time, baseLineValue));
}
lastLineBasal = baseLineValue;
lastTempBasal = tempBasalValue;
maxBasalValueFound = Math.max(maxBasalValueFound, basal);
}
BarDataPoint[] basal = new BarDataPoint[basalArray.size()];
basal = basalArray.toArray(basal);
bgGraph.addSeries(basalsSeries = new BarGraphSeries<DataPoint>(basal));
basalsSeries.setValueDependentColor(new ValueDependentColor<DataPoint>() {
@Override
public int get(DataPoint data) {
BarDataPoint point = (BarDataPoint) data;
if (point.isTempBasal) return Color.BLUE;
else return Color.CYAN;
}
});
basalLineArray.add(new DataPoint(now, lastLineBasal));
baseBasalArray.add(new DataPoint(now, lastBaseBasal));
tempBasalArray.add(new DataPoint(now, lastTempBasal));
DataPoint[] baseBasal = new DataPoint[baseBasalArray.size()];
baseBasal = baseBasalArray.toArray(baseBasal);
baseBasalsSeries = new LineGraphSeries<>(baseBasal);
baseBasalsSeries.setDrawBackground(true);
baseBasalsSeries.setBackgroundColor(Color.argb(200, 0x3F, 0x51, 0xB5));
baseBasalsSeries.setThickness(0);
DataPoint[] tempBasal = new DataPoint[tempBasalArray.size()];
tempBasal = tempBasalArray.toArray(tempBasal);
tempBasalsSeries = new LineGraphSeries<>(tempBasal);
tempBasalsSeries.setDrawBackground(true);
tempBasalsSeries.setBackgroundColor(Color.argb(200, 0x03, 0xA9, 0xF4));
tempBasalsSeries.setThickness(0);
DataPoint[] basalLine = new DataPoint[basalLineArray.size()];
basalLine = basalLineArray.toArray(basalLine);
bgGraph.addSeries(basalsLineSeries = new LineGraphSeries<DataPoint>(basalLine));
basalsLineSeries.setColor(Color.CYAN);
basalsLineSeries.setDrawDataPoints(false);
basalsLineSeries.setThickness(2);
basalsLineSeries = new LineGraphSeries<>(basalLine);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
paint.setColor(Color.CYAN);
basalsLineSeries.setCustomPaint(paint);
}
// **** IOB COB graph ****
FixedLineGraphSeries<DataPoint> iobSeries;
FixedLineGraphSeries<DataPoint> cobSeries;
Double maxIobValueFound = 0d;
Double maxCobValueFound = 0d;
if (showIobView.isChecked() || showCobView.isChecked()) {
List<DataPoint> iobArray = new ArrayList<>();
List<DataPoint> cobArray = new ArrayList<>();
for (long time = fromTime; time <= endTime; time += 5 * 60 * 1000L) {
if (showIobView.isChecked()) {
IobTotal iob = IobTotal.calulateFromTreatmentsAndTemps(time);
iobArray.add(new DataPoint(time, iob.iob));
maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob.iob));
}
if (showCobView.isChecked()) {
//MealData mealData = MainApp.getConfigBuilder().getActiveTreatments().getMealData();
//cobArray.add(new DataPoint(time, mealData.mealCOB));
//maxCobValueFound = Math.max(maxCobValueFound, mealData.mealCOB);
}
}
DataPoint[] iobData = new DataPoint[iobArray.size()];
iobData = iobArray.toArray(iobData);
iobSeries = new FixedLineGraphSeries<>(iobData);
iobSeries.setDrawBackground(true);
iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.sResources.getColor(R.color.ioborange)); //50%
iobSeries.setColor(MainApp.sResources.getColor(R.color.ioborange));
iobSeries.setThickness(3);
iobSeries.setTitle("IOB");
iobGraph.getGridLabelRenderer().setVerticalLabelsAlign(Paint.Align.LEFT);
DataPoint[] cobData = new DataPoint[cobArray.size()];
cobData = cobArray.toArray(cobData);
cobSeries = new FixedLineGraphSeries<>(cobData);
cobSeries.setDrawBackground(true);
cobSeries.setBackgroundColor(Color.RED);
cobSeries.setThickness(0);
iobGraph.removeAllSeries();
if (showIobView.isChecked()) {
iobGraph.addSeries(iobSeries);
}
if (showCobView.isChecked()) {
iobGraph.getSecondScale().addSeries(cobSeries);
iobGraph.getSecondScale().setLabelFormatter(new LabelFormatter() {
@Override
public String formatLabel(double value, boolean isValueX) {
return "";
}
@Override
public void setViewport(Viewport viewport) {
}
});
}
iobGraphLayout.setVisibility(View.VISIBLE);
} else {
iobGraphLayout.setVisibility(View.GONE);
}
// remove old data from graph
bgGraph.getSecondScale().getSeries().clear();
bgGraph.removeAllSeries();
// **** HIGH and LOW targets graph ****
DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
new DoubleDataPoint(fromTime, lowLine, highLine),
new DoubleDataPoint(endTime, lowLine, highLine)
};
bgGraph.addSeries(areaSeries = new AreaGraphSeries<>(areaDataPoints));
areaSeries.setColor(0);
areaSeries.setDrawBackground(true);
areaSeries.setBackgroundColor(Color.argb(40, 0, 255, 0));
// set manual x bounds to have nice steps
bgGraph.getViewport().setMaxX(endTime);
bgGraph.getViewport().setMinX(fromTime);
bgGraph.getViewport().setXAxisBoundsManual(true);
bgGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
iobGraph.getViewport().setMaxX(endTime);
iobGraph.getViewport().setMinX(fromTime);
iobGraph.getViewport().setXAxisBoundsManual(true);
iobGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
iobGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
// **** BG graph ****
List<BgReading> bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
@ -1066,9 +1195,14 @@ public class OverviewFragment extends Fragment {
new DataPoint(now, 0),
new DataPoint(now, maxBgValue)
};
bgGraph.addSeries(seriesNow = new LineGraphSeries<DataPoint>(nowPoints));
seriesNow.setColor(Color.GREEN);
bgGraph.addSeries(seriesNow = new LineGraphSeries<>(nowPoints));
seriesNow.setDrawDataPoints(false);
DataPoint[] nowPoints2 = new DataPoint[]{
new DataPoint(now, 0),
new DataPoint(now, maxIobValueFound)
};
iobGraph.addSeries(seriesNow2 = new LineGraphSeries<>(nowPoints2));
seriesNow2.setDrawDataPoints(false);
//seriesNow.setThickness(1);
// custom paint to make a dotted line
Paint paint = new Paint();
@ -1077,6 +1211,7 @@ public class OverviewFragment extends Fragment {
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
paint.setColor(Color.WHITE);
seriesNow.setCustomPaint(paint);
seriesNow2.setCustomPaint(paint);
// Treatments
@ -1105,15 +1240,26 @@ public class OverviewFragment extends Fragment {
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines);
// set second scale
if (pump.getPumpDescription().isTempBasalCapable) {
bgGraph.getSecondScale().addSeries(basalsSeries);
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
bgGraph.getSecondScale().addSeries(baseBasalsSeries);
bgGraph.getSecondScale().addSeries(tempBasalsSeries);
bgGraph.getSecondScale().addSeries(basalsLineSeries);
bgGraph.getSecondScale().setMinY(0);
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(ContextCompat.getColor(MainApp.instance(), R.color.background_material_dark)); // same color as backround = hide
}
bgGraph.getSecondScale().setLabelFormatter(new LabelFormatter() {
@Override
public String formatLabel(double value, boolean isValueX) {
return "";
}
@Override
public void setViewport(Viewport viewport) {
}
});
//updatePumpStatus(null);
}
//Notifications

View file

@ -0,0 +1,456 @@
/**
* GraphView
* Copyright (C) 2014 Jonas Gehring
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License,
* with the "Linking Exception", which can be found at the license.txt
* file in this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* with the "Linking Exception" along with this program; if not,
* write to the author Jonas Gehring <g.jjoe64@gmail.com>.
*/
package info.nightscout.androidaps.plugins.Overview.graphExtensions;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.BaseSeries;
import com.jjoe64.graphview.series.DataPointInterface;
import java.util.Iterator;
/**
* Series to plot the data as line.
* The line can be styled with many options.
*
* @author jjoe64
*/
public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
/**
* wrapped styles regarding the line
*/
private final class Styles {
/**
* the thickness of the line.
* This option will be ignored if you are
* using a custom paint via {@link #setCustomPaint(android.graphics.Paint)}
*/
private int thickness = 5;
/**
* flag whether the area under the line to the bottom
* of the viewport will be filled with a
* specific background color.
*
* @see #backgroundColor
*/
private boolean drawBackground = false;
/**
* flag whether the data points are highlighted as
* a visible point.
*
* @see #dataPointsRadius
*/
private boolean drawDataPoints = false;
/**
* the radius for the data points.
*
* @see #drawDataPoints
*/
private float dataPointsRadius = 10f;
/**
* the background color for the filling under
* the line.
*
* @see #drawBackground
*/
private int backgroundColor = Color.argb(100, 172, 218, 255);
}
/**
* wrapped styles
*/
private Styles mStyles;
/**
* internal paint object
*/
private Paint mPaint;
/**
* paint for the background
*/
private Paint mPaintBackground;
/**
* path for the background filling
*/
private Path mPathBackground;
/**
* path to the line
*/
private Path mPath;
private Path mSecondPath;
/**
* custom paint that can be used.
* this will ignore the thickness and color styles.
*/
private Paint mCustomPaint;
/**
* creates a series without data
*/
public AreaGraphSeries() {
init();
}
/**
* creates a series with data
*
* @param data data points
*/
public AreaGraphSeries(E[] data) {
super(data);
init();
}
/**
* do the initialization
* creates internal objects
*/
protected void init() {
mStyles = new Styles();
mPaint = new Paint();
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStyle(Paint.Style.STROKE);
mPaintBackground = new Paint();
mPathBackground = new Path();
mPath = new Path();
mSecondPath = new Path();
}
/**
* plots the series
* draws the line and the background
*
* @param graphView graphview
* @param canvas canvas
* @param isSecondScale flag if it is the second scale
*/
@Override
public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) {
resetDataPoints();
// get data
double maxX = graphView.getViewport().getMaxX(false);
double minX = graphView.getViewport().getMinX(false);
double maxY;
double minY;
if (isSecondScale) {
maxY = graphView.getSecondScale().getMaxY();
minY = graphView.getSecondScale().getMinY();
} else {
maxY = graphView.getViewport().getMaxY(false);
minY = graphView.getViewport().getMinY(false);
}
Iterator<E> values = getValues(minX, maxX);
// draw background
double lastEndY1 = 0;
double lastEndY2 = 0;
double lastEndX = 0;
// draw data
mPaint.setStrokeWidth(mStyles.thickness);
mPaint.setColor(getColor());
mPaintBackground.setColor(mStyles.backgroundColor);
Paint paint;
if (mCustomPaint != null) {
paint = mCustomPaint;
} else {
paint = mPaint;
}
if (mStyles.drawBackground) {
mPathBackground.reset();
}
double diffY = maxY - minY;
double diffX = maxX - minX;
float graphHeight = graphView.getGraphContentHeight();
float graphWidth = graphView.getGraphContentWidth();
float graphLeft = graphView.getGraphContentLeft();
float graphTop = graphView.getGraphContentTop();
lastEndY1 = 0;
lastEndY2 = 0;
lastEndX = 0;
double lastUsedEndX = 0;
float firstX = 0;
int i=0;
while (values.hasNext()) {
E value = values.next();
double valY1 = value.getY() - minY;
double ratY1 = valY1 / diffY;
double y1 = graphHeight * ratY1;
double valY2 = value.getY2() - minY;
double ratY2 = valY2 / diffY;
double y2 = graphHeight * ratY2;
double valX = value.getX() - minX;
double ratX = valX / diffX;
double x = graphWidth * ratX;
double orgX = x;
double orgY1 = y1;
double orgY2 = y2;
if (i > 0) {
// overdraw
if (x > graphWidth) { // end right
double b = ((graphWidth - lastEndX) * (y1 - lastEndY1)/(x - lastEndX));
y1 = lastEndY1+b;
x = graphWidth;
}
if (x > graphWidth) { // end right
double b = ((graphWidth - lastEndX) * (y2 - lastEndY2)/(x - lastEndX));
y2 = lastEndY2+b;
x = graphWidth;
}
if (y1 < 0) { // end bottom
double b = ((0 - lastEndY1) * (x - lastEndX)/(y1 - lastEndY1));
x = lastEndX+b;
y1 = 0;
}
if (y2 < 0) { // end bottom
double b = ((0 - lastEndY2) * (x - lastEndX)/(y2 - lastEndY2));
x = lastEndX+b;
y2 = 0;
}
if (y1 > graphHeight) { // end top
double b = ((graphHeight - lastEndY1) * (x - lastEndX)/(y1 - lastEndY1));
x = lastEndX+b;
y1 = graphHeight;
}
if (y2 > graphHeight) { // end top
double b = ((graphHeight - lastEndY2) * (x - lastEndX)/(y2 - lastEndY2));
x = lastEndX+b;
y2 = graphHeight;
}
if (lastEndY1 < 0) { // start bottom
double b = ((0 - y1) * (x - lastEndX)/(lastEndY1 - y1));
lastEndX = x-b;
lastEndY1 = 0;
}
if (lastEndY2 < 0) { // start bottom
double b = ((0 - y2) * (x - lastEndX)/(lastEndY2 - y2));
lastEndX = x-b;
lastEndY2 = 0;
}
if (lastEndX < 0) { // start left
double b = ((0 - x) * (y1 - lastEndY1)/(lastEndX - x));
lastEndY1 = y1-b;
lastEndX = 0;
}
if (lastEndX < 0) { // start left
double b = ((0 - x) * (y2 - lastEndY2)/(lastEndX - x));
lastEndY2 = y2-b;
lastEndX = 0;
}
if (lastEndY1 > graphHeight) { // start top
double b = ((graphHeight - y1) * (x - lastEndX)/(lastEndY1 - y1));
lastEndX = x-b;
lastEndY1 = graphHeight;
}
if (lastEndY2 > graphHeight) { // start top
double b = ((graphHeight - y2) * (x - lastEndX)/(lastEndY2 - y2));
lastEndX = x-b;
lastEndY2 = graphHeight;
}
float startX = (float) lastEndX + (graphLeft + 1);
float startY1 = (float) (graphTop - lastEndY1) + graphHeight;
float startY2 = (float) (graphTop - lastEndY2) + graphHeight;
float endX = (float) x + (graphLeft + 1);
float endY1 = (float) (graphTop - y1) + graphHeight;
float endY2 = (float) (graphTop - y2) + graphHeight;
// draw data point
if (mStyles.drawDataPoints) {
//fix: last value was not drawn. Draw here now the end values
canvas.drawCircle(endX, endY1, mStyles.dataPointsRadius, mPaint);
canvas.drawCircle(endX, endY2, mStyles.dataPointsRadius, mPaint);
}
registerDataPoint(endX, endY1, value);
registerDataPoint(endX, endY2, value);
mPath.reset();
mSecondPath.reset();
mPath.moveTo(startX, startY1);
mSecondPath.moveTo(startX, startY2);
mPath.lineTo(endX, endY1);
mSecondPath.lineTo(endX, endY2);
canvas.drawPath(mPath, paint);
canvas.drawPath(mSecondPath, paint);
if (mStyles.drawBackground) {
canvas.drawRect((float)startX, (float)startY2, endX, endY1, mPaintBackground);
}
} else if (mStyles.drawDataPoints) {
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)
//float first_X = (float) x + (graphLeft + 1);
//float first_Y = (float) (graphTop - y) + graphHeight;
//TODO canvas.drawCircle(first_X, first_Y, dataPointsRadius, mPaint);
}
lastEndY1 = orgY1;
lastEndY2 = orgY2;
lastEndX = orgX;
i++;
}
/*
if (mStyles.drawBackground) {
// end / close path
mPathBackground.lineTo((float) lastUsedEndX, graphHeight + graphTop);
mPathBackground.lineTo(firstX, graphHeight + graphTop);
mPathBackground.close();
canvas.drawPath(mPathBackground, mPaintBackground);
}
*/
}
/**
* the thickness of the line.
* This option will be ignored if you are
* using a custom paint via {@link #setCustomPaint(android.graphics.Paint)}
*
* @return the thickness of the line
*/
public int getThickness() {
return mStyles.thickness;
}
/**
* the thickness of the line.
* This option will be ignored if you are
* using a custom paint via {@link #setCustomPaint(android.graphics.Paint)}
*
* @param thickness thickness of the line
*/
public void setThickness(int thickness) {
mStyles.thickness = thickness;
}
/**
* flag whether the area under the line to the bottom
* of the viewport will be filled with a
* specific background color.
*
* @return whether the background will be drawn
* @see #getBackgroundColor()
*/
public boolean isDrawBackground() {
return mStyles.drawBackground;
}
/**
* flag whether the area under the line to the bottom
* of the viewport will be filled with a
* specific background color.
*
* @param drawBackground whether the background will be drawn
* @see #setBackgroundColor(int)
*/
public void setDrawBackground(boolean drawBackground) {
mStyles.drawBackground = drawBackground;
}
/**
* flag whether the data points are highlighted as
* a visible point.
*
* @return flag whether the data points are highlighted
* @see #setDataPointsRadius(float)
*/
public boolean isDrawDataPoints() {
return mStyles.drawDataPoints;
}
/**
* flag whether the data points are highlighted as
* a visible point.
*
* @param drawDataPoints flag whether the data points are highlighted
* @see #setDataPointsRadius(float)
*/
public void setDrawDataPoints(boolean drawDataPoints) {
mStyles.drawDataPoints = drawDataPoints;
}
/**
* @return the radius for the data points.
* @see #setDrawDataPoints(boolean)
*/
public float getDataPointsRadius() {
return mStyles.dataPointsRadius;
}
/**
* @param dataPointsRadius the radius for the data points.
* @see #setDrawDataPoints(boolean)
*/
public void setDataPointsRadius(float dataPointsRadius) {
mStyles.dataPointsRadius = dataPointsRadius;
}
/**
* @return the background color for the filling under
* the line.
* @see #setDrawBackground(boolean)
*/
public int getBackgroundColor() {
return mStyles.backgroundColor;
}
/**
* @param backgroundColor the background color for the filling under
* the line.
* @see #setDrawBackground(boolean)
*/
public void setBackgroundColor(int backgroundColor) {
mStyles.backgroundColor = backgroundColor;
}
/**
* custom paint that can be used.
* this will ignore the thickness and color styles.
*
* @param customPaint the custom paint to be used for rendering the line
*/
public void setCustomPaint(Paint customPaint) {
this.mCustomPaint = customPaint;
}
}

View file

@ -0,0 +1,41 @@
package info.nightscout.androidaps.plugins.Overview.graphExtensions;
import com.jjoe64.graphview.series.DataPointInterface;
import java.io.Serializable;
import java.util.Date;
/**
* Created by mike on 21.04.2017.
*/
public class DoubleDataPoint implements DataPointInterface, Serializable {
private static final long serialVersionUID=1428267322645L;
private double x;
private double y1;
private double y2;
public DoubleDataPoint(double x, double y1, double y2) {
this.x=x;
this.y1=y1;
this.y2=y2;
}
public double getX() {
return x;
}
@Override
public double getY() {
return y1;
}
public double getY1() {
return y1;
}
public double getY2() {
return y2;
}
}

View file

@ -0,0 +1,405 @@
package info.nightscout.androidaps.plugins.Overview.graphExtensions;
/**
* Created by mike on 24.04.2017.
*/
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.BaseSeries;
import com.jjoe64.graphview.series.DataPointInterface;
import java.util.Iterator;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import com.jjoe64.graphview.GraphView;
import java.util.Iterator;
/**
* Series to plot the data as line.
* The line can be styled with many options.
*
* @author jjoe64
*/
public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeries<E> {
/**
* wrapped styles regarding the line
*/
private final class Styles {
/**
* the thickness of the line.
* This option will be ignored if you are
* using a custom paint via {@link #setCustomPaint(android.graphics.Paint)}
*/
private int thickness = 5;
/**
* flag whether the area under the line to the bottom
* of the viewport will be filled with a
* specific background color.
*
* @see #backgroundColor
*/
private boolean drawBackground = false;
/**
* flag whether the data points are highlighted as
* a visible point.
*
* @see #dataPointsRadius
*/
private boolean drawDataPoints = false;
/**
* the radius for the data points.
*
* @see #drawDataPoints
*/
private float dataPointsRadius = 10f;
/**
* the background color for the filling under
* the line.
*
* @see #drawBackground
*/
private int backgroundColor = Color.argb(100, 172, 218, 255);
}
/**
* wrapped styles
*/
private Styles mStyles;
/**
* internal paint object
*/
private Paint mPaint;
/**
* paint for the background
*/
private Paint mPaintBackground;
/**
* path for the background filling
*/
private Path mPathBackground;
/**
* path to the line
*/
private Path mPath;
/**
* custom paint that can be used.
* this will ignore the thickness and color styles.
*/
private Paint mCustomPaint;
/**
* creates a series without data
*/
public FixedLineGraphSeries() {
init();
}
/**
* creates a series with data
*
* @param data data points
*/
public FixedLineGraphSeries(E[] data) {
super(data);
init();
}
/**
* do the initialization
* creates internal objects
*/
protected void init() {
mStyles = new Styles();
mPaint = new Paint();
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStyle(Paint.Style.STROKE);
mPaintBackground = new Paint();
mPathBackground = new Path();
mPath = new Path();
}
/**
* plots the series
* draws the line and the background
*
* @param graphView graphview
* @param canvas canvas
* @param isSecondScale flag if it is the second scale
*/
@Override
public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) {
resetDataPoints();
// get data
double maxX = graphView.getViewport().getMaxX(false);
double minX = graphView.getViewport().getMinX(false);
double maxY;
double minY;
if (isSecondScale) {
maxY = graphView.getSecondScale().getMaxY();
minY = graphView.getSecondScale().getMinY();
} else {
maxY = graphView.getViewport().getMaxY(false);
minY = graphView.getViewport().getMinY(false);
}
Iterator<E> values = getValues(minX, maxX);
// draw background
double lastEndY = 0;
double lastEndX = 0;
// draw data
mPaint.setStrokeWidth(mStyles.thickness);
mPaint.setColor(getColor());
mPaintBackground.setColor(mStyles.backgroundColor);
Paint paint;
if (mCustomPaint != null) {
paint = mCustomPaint;
} else {
paint = mPaint;
}
if (mStyles.drawBackground) {
mPathBackground.reset();
}
double diffY = maxY - minY;
double diffX = maxX - minX;
float graphHeight = graphView.getGraphContentHeight();
float graphWidth = graphView.getGraphContentWidth();
float graphLeft = graphView.getGraphContentLeft();
float graphTop = graphView.getGraphContentTop();
lastEndY = 0;
lastEndX = 0;
double lastUsedEndX = 0;
float firstX = 0;
int i=0;
while (values.hasNext()) {
E value = values.next();
double valY = value.getY() - minY;
double ratY = valY / diffY;
double y = graphHeight * ratY;
double valX = value.getX() - minX;
double ratX = valX / diffX;
double x = graphWidth * ratX;
double orgX = x;
double orgY = y;
if (i > 0) {
// overdraw
if (x > graphWidth) { // end right
double b = ((graphWidth - lastEndX) * (y - lastEndY)/(x - lastEndX));
y = lastEndY+b;
x = graphWidth;
}
if (y < 0) { // end bottom
double b = ((0 - lastEndY) * (x - lastEndX)/(y - lastEndY));
x = lastEndX+b;
y = 0;
}
if (y > graphHeight) { // end top
double b = ((graphHeight - lastEndY) * (x - lastEndX)/(y - lastEndY));
x = lastEndX+b;
y = graphHeight;
}
if (lastEndY < 0) { // start bottom
double b = ((0 - y) * (x - lastEndX)/(lastEndY - y));
lastEndX = x-b;
lastEndY = 0;
}
if (lastEndX < 0) { // start left
double b = ((0 - x) * (y - lastEndY)/(lastEndX - x));
lastEndY = y-b;
lastEndX = 0;
}
if (lastEndY > graphHeight) { // start top
double b = ((graphHeight - y) * (x - lastEndX)/(lastEndY - y));
lastEndX = x-b;
lastEndY = graphHeight;
}
float startX = (float) lastEndX + (graphLeft + 1);
float startY = (float) (graphTop - lastEndY) + graphHeight;
float endX = (float) x + (graphLeft + 1);
float endY = (float) (graphTop - y) + graphHeight;
// draw data point
if (mStyles.drawDataPoints) {
//fix: last value was not drawn. Draw here now the end values
canvas.drawCircle(endX, endY, mStyles.dataPointsRadius, mPaint);
}
registerDataPoint(endX, endY, value);
mPath.reset();
mPath.moveTo(startX, startY);
mPath.lineTo(endX, endY);
canvas.drawPath(mPath, paint);
if (mStyles.drawBackground) {
if (i==1) {
firstX = startX;
mPathBackground.moveTo(startX, startY);
}
mPathBackground.lineTo(endX, endY);
}
lastUsedEndX = endX;
} else if (mStyles.drawDataPoints) {
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)
float first_X = (float) x + (graphLeft + 1);
float first_Y = (float) (graphTop - y) + graphHeight;
//TODO canvas.drawCircle(first_X, first_Y, dataPointsRadius, mPaint);
}
lastEndY = orgY;
lastEndX = orgX;
i++;
}
if (mStyles.drawBackground) {
// end / close path
mPathBackground.lineTo((float) lastUsedEndX, (float) (graphTop - (-minY / diffY * graphHeight)) + graphHeight);
mPathBackground.lineTo(firstX, (float) (graphTop - (-minY / diffY * graphHeight)) + graphHeight);
mPathBackground.close();
canvas.drawPath(mPathBackground, mPaintBackground);
}
}
/**
* the thickness of the line.
* This option will be ignored if you are
* using a custom paint via {@link #setCustomPaint(android.graphics.Paint)}
*
* @return the thickness of the line
*/
public int getThickness() {
return mStyles.thickness;
}
/**
* the thickness of the line.
* This option will be ignored if you are
* using a custom paint via {@link #setCustomPaint(android.graphics.Paint)}
*
* @param thickness thickness of the line
*/
public void setThickness(int thickness) {
mStyles.thickness = thickness;
}
/**
* flag whether the area under the line to the bottom
* of the viewport will be filled with a
* specific background color.
*
* @return whether the background will be drawn
* @see #getBackgroundColor()
*/
public boolean isDrawBackground() {
return mStyles.drawBackground;
}
/**
* flag whether the area under the line to the bottom
* of the viewport will be filled with a
* specific background color.
*
* @param drawBackground whether the background will be drawn
* @see #setBackgroundColor(int)
*/
public void setDrawBackground(boolean drawBackground) {
mStyles.drawBackground = drawBackground;
}
/**
* flag whether the data points are highlighted as
* a visible point.
*
* @return flag whether the data points are highlighted
* @see #setDataPointsRadius(float)
*/
public boolean isDrawDataPoints() {
return mStyles.drawDataPoints;
}
/**
* flag whether the data points are highlighted as
* a visible point.
*
* @param drawDataPoints flag whether the data points are highlighted
* @see #setDataPointsRadius(float)
*/
public void setDrawDataPoints(boolean drawDataPoints) {
mStyles.drawDataPoints = drawDataPoints;
}
/**
* @return the radius for the data points.
* @see #setDrawDataPoints(boolean)
*/
public float getDataPointsRadius() {
return mStyles.dataPointsRadius;
}
/**
* @param dataPointsRadius the radius for the data points.
* @see #setDrawDataPoints(boolean)
*/
public void setDataPointsRadius(float dataPointsRadius) {
mStyles.dataPointsRadius = dataPointsRadius;
}
/**
* @return the background color for the filling under
* the line.
* @see #setDrawBackground(boolean)
*/
public int getBackgroundColor() {
return mStyles.backgroundColor;
}
/**
* @param backgroundColor the background color for the filling under
* the line.
* @see #setDrawBackground(boolean)
*/
public void setBackgroundColor(int backgroundColor) {
mStyles.backgroundColor = backgroundColor;
}
/**
* custom paint that can be used.
* this will ignore the thickness and color styles.
*
* @param customPaint the custom paint to be used for rendering the line
*/
public void setCustomPaint(Paint customPaint) {
this.mCustomPaint = customPaint;
}
}

View file

@ -0,0 +1,12 @@
package info.nightscout.androidaps.plugins.Persistentnotification;
import android.support.v4.app.Fragment;
/**
* Created by adrian on 23/12/16.
*/
public class PersistentNotificationFragment extends Fragment {
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.persistentnotification;
package info.nightscout.androidaps.plugins.Persistentnotification;
import android.app.NotificationManager;
import android.app.PendingIntent;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
package info.nightscout.androidaps.plugins.ProfileCircadianPercentage;
import android.app.Activity;
@ -33,14 +33,13 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
public class CircadianPercentageProfileFragment extends Fragment implements FragmentBase {
public class CircadianPercentageProfileFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class);
private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin();

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
package info.nightscout.androidaps.plugins.ProfileCircadianPercentage;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@ -129,7 +129,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
mgdl = SP.getBoolean(SETTINGS_PREFIX + "mgdl", true);
mmol = SP.getBoolean(SETTINGS_PREFIX + "mmol", false);
dia = SP.getDouble(SETTINGS_PREFIX + "dia", 3d);
dia = SP.getDouble(SETTINGS_PREFIX + "dia", Constants.defaultDIA);
targetLow = SP.getDouble(SETTINGS_PREFIX + "targetlow", 80d);
targetHigh = SP.getDouble(SETTINGS_PREFIX + "targethigh", 120d);
percentage = SP.getInt(SETTINGS_PREFIX + "percentage", 100);

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.LocalProfile;
package info.nightscout.androidaps.plugins.ProfileLocal;
import android.app.Activity;
@ -11,7 +11,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import com.squareup.otto.Subscribe;
@ -24,14 +23,13 @@ import java.text.DecimalFormat;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.TimeListEdit;
public class LocalProfileFragment extends Fragment implements FragmentBase {
public class LocalProfileFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(LocalProfileFragment.class);
private static LocalProfilePlugin localProfilePlugin = new LocalProfilePlugin();

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.LocalProfile;
package info.nightscout.androidaps.plugins.ProfileLocal;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/**
* Created by mike on 05.08.2016.
@ -120,7 +119,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
mgdl = SP.getBoolean("LocalProfile" + "mgdl", false);
mmol = SP.getBoolean("LocalProfile" + "mmol", true);
dia = SP.getDouble("LocalProfile" + "dia", 3d);
dia = SP.getDouble("LocalProfile" + "dia", Constants.defaultDIA);
try {
ic = new JSONArray(SP.getString("LocalProfile" + "ic", DEFAULTARRAY));
} catch (JSONException e1) {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.NSProfile;
package info.nightscout.androidaps.plugins.ProfileNS;
import android.app.Activity;
import android.os.Bundle;
@ -12,11 +12,10 @@ import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.NSProfile.events.EventNSProfileUpdateGUI;
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
import info.nightscout.utils.DecimalFormatter;
public class NSProfileFragment extends Fragment implements FragmentBase {
public class NSProfileFragment extends Fragment {
private static NSProfilePlugin nsProfilePlugin = new NSProfilePlugin();
public static NSProfilePlugin getPlugin() {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.NSProfile;
package info.nightscout.androidaps.plugins.ProfileNS;
import android.content.Intent;
import android.content.SharedPreferences;
@ -20,7 +20,7 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.NSProfile.events.EventNSProfileUpdateGUI;
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
import info.nightscout.utils.SP;
/**

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.NSProfile.events;
package info.nightscout.androidaps.plugins.ProfileNS.events;
/**
* Created by mike on 05.08.2016.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.SimpleProfile;
package info.nightscout.androidaps.plugins.ProfileSimple;
import android.app.Activity;
@ -11,30 +11,22 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import com.squareup.otto.Subscribe;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.TimeListEdit;
public class SimpleProfileFragment extends Fragment implements FragmentBase {
public class SimpleProfileFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
private static SimpleProfilePlugin simpleProfilePlugin = new SimpleProfilePlugin();

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.SimpleProfile;
package info.nightscout.androidaps.plugins.ProfileSimple;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
/**
* Created by mike on 05.08.2016.
@ -118,7 +117,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true);
mmol = SP.getBoolean("SimpleProfile" + "mmol", false);
dia = SP.getDouble("SimpleProfile" + "dia", 3d);
dia = SP.getDouble("SimpleProfile" + "dia", Constants.defaultDIA);
ic = SP.getDouble("SimpleProfile" + "ic", 20d);
isf = SP.getDouble("SimpleProfile" + "isf", 200d);
basal = SP.getDouble("SimpleProfile" + "basal", 1d);

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR;
package info.nightscout.androidaps.plugins.PumpDanaR;
import android.bluetooth.*;
import android.content.Context;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR;
package info.nightscout.androidaps.plugins.PumpDanaR;
import android.annotation.SuppressLint;
@ -26,22 +26,21 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
import info.nightscout.androidaps.plugins.DanaR.History.DanaRStatsActivity;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
import info.nightscout.androidaps.plugins.PumpDanaR.History.DanaRHistoryActivity;
import info.nightscout.androidaps.plugins.PumpDanaR.History.DanaRStatsActivity;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SetWarnColor;
public class DanaRFragment extends Fragment implements FragmentBase {
public class DanaRFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(DanaRFragment.class);
private static DanaRPlugin danaRPlugin;
public static DanaRPlugin getPlugin() {
if(danaRPlugin==null){
if (danaRPlugin == null) {
danaRPlugin = new DanaRPlugin();
}
return danaRPlugin;
@ -211,7 +210,7 @@ public class DanaRFragment extends Fragment implements FragmentBase {
}
if (pump.lastBolusTime.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime();
double agoHours = agoMsec / 60d / 60d / 1000d;
double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U");
else lastBolusView.setText("");

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR;
package info.nightscout.androidaps.plugins.PumpDanaR;
import android.content.ComponentName;
import android.content.Context;
@ -30,13 +30,14 @@ import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.NSProfile.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@ -357,11 +358,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
@Override
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context) {
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
insulin = configBuilderPlugin.applyBolusConstraints(insulin);
if (insulin > 0 || carbs > 0) {
Treatment t = new Treatment();
Treatment t = new Treatment(insulinType);
boolean connectionOK = false;
if (insulin > 0 || carbs > 0) connectionOK = sExecutionService.bolus(insulin, carbs, t);
PumpEnactResult result = new PumpEnactResult();

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR;
package info.nightscout.androidaps.plugins.PumpDanaR;
import org.json.JSONArray;
import org.json.JSONException;
@ -119,7 +119,7 @@ public class DanaRPump {
// Evening / 17:0021:59
// Night / 22:005:59
double dia = SP.getDouble(R.string.key_danarprofile_dia, 3d);
double dia = SP.getDouble(R.string.key_danarprofile_dia, Constants.defaultDIA);
try {
json.put("defaultProfile", PROFILE_PREFIX + (activeProfile + 1));

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.Dialogs;
package info.nightscout.androidaps.plugins.PumpDanaR.Dialogs;
import android.os.Bundle;
import android.os.Handler;
@ -17,7 +17,7 @@ import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.DecimalFormatter;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.History;
package info.nightscout.androidaps.plugins.PumpDanaR.History;
import android.app.Activity;
import android.content.ComponentName;
@ -40,9 +40,9 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.History;
package info.nightscout.androidaps.plugins.PumpDanaR.History;
import org.json.JSONException;
import org.json.JSONObject;
@ -12,8 +12,8 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.ToastUtils;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaRKorean.History;
package info.nightscout.androidaps.plugins.PumpDanaR.History;
import android.app.Activity;
import android.content.ComponentName;
@ -50,11 +50,11 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR;
package info.nightscout.androidaps.plugins.PumpDanaR;
import android.bluetooth.BluetoothSocket;
@ -14,8 +14,8 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageHashTable;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable;
import info.nightscout.utils.CRC;
/**

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.Services;
package info.nightscout.androidaps.plugins.PumpDanaR.Services;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
@ -8,11 +8,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Binder;
import android.os.IBinder;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import com.squareup.otto.Subscribe;
@ -35,55 +33,54 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.DanaR.SerialIOThread;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgCheckValue;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryAlarm;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryBasalHour;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryBolus;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryCarbo;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryDailyInsulin;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryDone;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryError;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryGlucose;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistoryRefill;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgHistorySuspend;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgPCCommStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgPCCommStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetActivateBasalProfile;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetBasalProfile;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetCarbsEntry;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetExtendedBolusStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStart;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStop;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingActiveProfile;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingBasal;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingMeal;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingGlucose;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingMaxValues;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingProfileRatios;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingProfileRatiosAll;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingPumpTime;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSettingShippingInfo;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatus;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusBasic;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.SerialIOThread;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusProgress;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStop;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgCheckValue;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryAlarm;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryBasalHour;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryBolus;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryCarbo;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryDailyInsulin;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryDone;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryError;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryGlucose;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistoryRefill;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgHistorySuspend;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStart;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgPCCommStop;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetActivateBasalProfile;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetBasalProfile;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetCarbsEntry;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetExtendedBolusStart;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetExtendedBolusStop;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetTempBasalStart;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetTempBasalStop;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetTime;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingActiveProfile;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingMeal;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingGlucose;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingMaxValues;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingProfileRatios;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingProfileRatiosAll;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingPumpTime;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingShippingInfo;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusBasic;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRBolusStart;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
public class ExecutionService extends Service {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import android.annotation.TargetApi;
import android.os.Build;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,6 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
import com.squareup.otto.Bus;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,9 +1,8 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.utils.HardLimits;

View file

@ -1,6 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
import com.squareup.otto.Bus;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -6,8 +6,8 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.utils.ToastUtils;
/**

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import com.j256.ormlite.dao.Dao;
@ -10,7 +10,7 @@ import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DateUtil;
public class MsgHistoryAll extends MessageBase {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
public class MsgInitConnStatusBasic extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic.class);

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -6,8 +6,8 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
/**
* Created by mike on 28.05.2016.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -10,9 +10,8 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.utils.ToastUtils;
public class MsgInitConnStatusTime extends MessageBase {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.DanaR.comm;
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Some files were not shown because too many files have changed in this diff Show more