2017-02-19 19:15:14 +01:00
|
|
|
package info.nightscout.androidaps.events;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.MainApp;
|
|
|
|
import info.nightscout.androidaps.R;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by mike on 19.02.2017.
|
|
|
|
*/
|
|
|
|
|
2017-10-14 16:06:01 +02:00
|
|
|
public class EventPumpStatusChanged extends Event {
|
2017-02-19 19:15:14 +01:00
|
|
|
public static final int CONNECTING = 0;
|
|
|
|
public static final int CONNECTED = 1;
|
|
|
|
public static final int PERFORMING = 2;
|
|
|
|
public static final int DISCONNECTING = 3;
|
|
|
|
public static final int DISCONNECTED = 4;
|
|
|
|
|
|
|
|
public int sStatus = DISCONNECTED;
|
|
|
|
public int sSecondsElapsed = 0;
|
|
|
|
public String sPerfomingAction = "";
|
|
|
|
|
2017-09-14 00:29:34 +02:00
|
|
|
public static String error = "";
|
|
|
|
|
2017-02-19 19:15:14 +01:00
|
|
|
public EventPumpStatusChanged(int status) {
|
|
|
|
sStatus = status;
|
|
|
|
sSecondsElapsed = 0;
|
2017-09-14 00:29:34 +02:00
|
|
|
error = "";
|
2017-02-19 19:15:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public EventPumpStatusChanged(int status, int secondsElapsed) {
|
|
|
|
sStatus = status;
|
|
|
|
sSecondsElapsed = secondsElapsed;
|
2017-09-14 00:29:34 +02:00
|
|
|
error = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public EventPumpStatusChanged(int status, String error) {
|
|
|
|
sStatus = status;
|
|
|
|
sSecondsElapsed = 0;
|
|
|
|
this.error = error;
|
2017-02-19 19:15:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public EventPumpStatusChanged(String action) {
|
|
|
|
sStatus = PERFORMING;
|
|
|
|
sSecondsElapsed = 0;
|
|
|
|
sPerfomingAction = action;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String textStatus() {
|
|
|
|
if (sStatus == CONNECTING)
|
|
|
|
return String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), sSecondsElapsed);
|
|
|
|
else if (sStatus == CONNECTED)
|
|
|
|
return MainApp.sResources.getString(R.string.connected);
|
|
|
|
else if (sStatus == PERFORMING)
|
|
|
|
return sPerfomingAction;
|
|
|
|
else if (sStatus == DISCONNECTING)
|
|
|
|
return MainApp.sResources.getString(R.string.disconnecting);
|
|
|
|
else if (sStatus == DISCONNECTED)
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|