RL: code cleanup
This commit is contained in:
parent
cec6595d0b
commit
1b7ae4e704
11 changed files with 1 additions and 464 deletions
|
@ -20,9 +20,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.enco
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.BleAdvertisedData;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.BleAdvertisedData;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTask;
|
|
||||||
import info.nightscout.shared.logging.AAPSLogger;
|
import info.nightscout.shared.logging.AAPSLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +30,6 @@ import info.nightscout.shared.logging.AAPSLogger;
|
||||||
public class RileyLinkUtil {
|
public class RileyLinkUtil {
|
||||||
|
|
||||||
private final List<RLHistoryItem> historyRileyLink = new ArrayList<>();
|
private final List<RLHistoryItem> historyRileyLink = new ArrayList<>();
|
||||||
private ServiceTask currentTask;
|
|
||||||
|
|
||||||
private RileyLinkEncodingType encoding;
|
private RileyLinkEncodingType encoding;
|
||||||
private Encoding4b6b encoding4b6b;
|
private Encoding4b6b encoding4b6b;
|
||||||
|
@ -63,40 +59,6 @@ public class RileyLinkUtil {
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME remove ?
|
|
||||||
public void setCurrentTask(ServiceTask task) {
|
|
||||||
if (currentTask == null) {
|
|
||||||
currentTask = task;
|
|
||||||
} else {
|
|
||||||
//LOG.error("setCurrentTask: Cannot replace current task");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void finishCurrentTask(ServiceTask task) {
|
|
||||||
if (task != currentTask) {
|
|
||||||
//LOG.error("finishCurrentTask: task does not match");
|
|
||||||
}
|
|
||||||
// hack to force deep copy of transport contents
|
|
||||||
ServiceTransport transport = task.getServiceTransport().clone();
|
|
||||||
|
|
||||||
if (transport.hasServiceResult()) {
|
|
||||||
sendServiceTransportResponse(transport, transport.getServiceResult());
|
|
||||||
}
|
|
||||||
currentTask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static void sendServiceTransportResponse(ServiceTransport transport, ServiceResult serviceResult) {
|
|
||||||
// get the key (hashcode) of the client who requested this
|
|
||||||
Integer clientHashcode = transport.getSenderHashcode();
|
|
||||||
// make a new bundle to send as the message data
|
|
||||||
transport.setServiceResult(serviceResult);
|
|
||||||
// FIXME
|
|
||||||
// transport.setTransportType(RT2Const.IPC.MSG_ServiceResult);
|
|
||||||
// rileyLinkIPCConnection.sendTransport(transport, clientHashcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isSame(Double d1, Double d2) {
|
public static boolean isSame(Double d1, Double d2) {
|
||||||
double diff = d1 - d2;
|
double diff = d1 - d2;
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/25/16.
|
|
||||||
*/
|
|
||||||
public class ServiceCommand extends ServiceMessage {
|
|
||||||
|
|
||||||
public ServiceCommand() {
|
|
||||||
map = new Bundle();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// commandID is a string that the client can set on the message.
|
|
||||||
// The service does not use this value, but passes it back with the result
|
|
||||||
// so that the client can identify it.
|
|
||||||
public ServiceCommand(String commandName, String commandID) {
|
|
||||||
init();
|
|
||||||
map.putString("command", commandName);
|
|
||||||
map.putString("commandID", commandID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceCommand(Bundle commandBundle) {
|
|
||||||
if (commandBundle != null) {
|
|
||||||
map = commandBundle;
|
|
||||||
} else {
|
|
||||||
map = new Bundle();
|
|
||||||
init();
|
|
||||||
map.putString("command", "(null)");
|
|
||||||
map.putString("commandID", "(null");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
map.putString("ServiceMessageType", "ServiceCommand");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getCommandID() {
|
|
||||||
return map.getString("commandID");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getCommandName() {
|
|
||||||
return map.getString("command");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isPumpCommand() {
|
|
||||||
switch (getCommandName()) {
|
|
||||||
case "FetchPumpHistory":
|
|
||||||
case "ReadPumpClock":
|
|
||||||
case "RetrieveHistoryPage":
|
|
||||||
case "ReadISFProfile":
|
|
||||||
case "ReadBolusWizardCarbProfile":
|
|
||||||
case "UpdatePumpStatus":
|
|
||||||
case "WakeAndTune":
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 7/4/16.
|
|
||||||
* <p>
|
|
||||||
* Base class for all messages passed between service and client
|
|
||||||
*/
|
|
||||||
public class ServiceMessage {
|
|
||||||
|
|
||||||
protected Bundle map = new Bundle();
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceMessage() {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
map.putString("ServiceMessageClass", this.getClass().getCanonicalName());
|
|
||||||
map.putString("ServiceMessageType", this.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Bundle getMap() {
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setMap(Bundle map) {
|
|
||||||
this.map = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getServiceMessageType() {
|
|
||||||
return map.getString("ServiceMessageType");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 7/6/16.
|
|
||||||
* <p>
|
|
||||||
* These are "one liner" messages between client and service. Must still be contained within ServiceTransports
|
|
||||||
*/
|
|
||||||
public class ServiceNotification extends ServiceMessage {
|
|
||||||
|
|
||||||
public ServiceNotification() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceNotification(Bundle b) {
|
|
||||||
if (b != null) {
|
|
||||||
if ("ServiceNotification".equals(b.getString("ServiceMessageType"))) {
|
|
||||||
setMap(b);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceNotification(String notificationType) {
|
|
||||||
setNotificationType(notificationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
super.init();
|
|
||||||
map.putString("ServiceMessageType", "ServiceNotification");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getNotificationType() {
|
|
||||||
return map.getString("NotificationType", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setNotificationType(String notificationType) {
|
|
||||||
map.putString("NotificationType", notificationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/25/16.
|
|
||||||
*/
|
|
||||||
public class ServiceResult extends ServiceMessage {
|
|
||||||
|
|
||||||
public static final int ERROR_MALFORMED_PUMP_RESPONSE = 1;
|
|
||||||
public static final int ERROR_NULL_PUMP_RESPONSE = 2;
|
|
||||||
public static final int ERROR_INVALID_PUMP_RESPONSE = 3;
|
|
||||||
public static final int ERROR_PUMP_BUSY = 4;
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceResult() {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceResult(Bundle resultBundle) {
|
|
||||||
if (resultBundle != null) {
|
|
||||||
setMap(resultBundle);
|
|
||||||
} else {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static final String getErrorDescription(int errorCode) {
|
|
||||||
switch (errorCode) {
|
|
||||||
case ERROR_MALFORMED_PUMP_RESPONSE:
|
|
||||||
return "Malformed Pump Response";
|
|
||||||
case ERROR_NULL_PUMP_RESPONSE:
|
|
||||||
return "Null pump response";
|
|
||||||
case ERROR_INVALID_PUMP_RESPONSE:
|
|
||||||
return "Invalid pump response";
|
|
||||||
case ERROR_PUMP_BUSY:
|
|
||||||
return "A pump command session is already in progress";
|
|
||||||
default:
|
|
||||||
return "Unknown error code (" + errorCode + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
super.init();
|
|
||||||
map.putString("ServiceMessageType", "ServiceResult");
|
|
||||||
setServiceResultType(this.getClass().getSimpleName());
|
|
||||||
setResultError(0, "Uninitialized ServiceResult");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getServiceResultType() {
|
|
||||||
return map.getString("ServiceResultType", "ServiceResult");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setServiceResultType(String serviceResultType) {
|
|
||||||
map.putString("ServiceResultType", serviceResultType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setResultOK() {
|
|
||||||
map.putString("result", "OK");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setResultError(int errorCode) {
|
|
||||||
setResultError(errorCode, getErrorDescription(errorCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setResultError(int errorCode, String errorDescription) {
|
|
||||||
map.putString("result", "error");
|
|
||||||
map.putInt("errorCode", errorCode);
|
|
||||||
map.putString("errorDescription", errorDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean resultIsOK() {
|
|
||||||
return ("OK".equals(map.getString("result", "")));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getErrorDescription() {
|
|
||||||
return map.getString("errorDescription", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getResult() {
|
|
||||||
return map.getString("result", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 7/6/16.
|
|
||||||
* <p>
|
|
||||||
* This class exists to hold a ServiceCommand along with transport variables such as time sent, time received, sender.
|
|
||||||
* May also contain result, if the command is completed.
|
|
||||||
*/
|
|
||||||
public class ServiceTransport extends ServiceMessage {
|
|
||||||
|
|
||||||
private ServiceTransportType serviceTransportType = ServiceTransportType.Undefined;
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceTransport() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceTransport(Bundle b) {
|
|
||||||
if (b != null) {
|
|
||||||
if ("ServiceTransport".equals(b.getString("ServiceMessageType"))) {
|
|
||||||
setMap(b);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
super.init();
|
|
||||||
map.putString("ServiceMessageType", "ServiceTransport");
|
|
||||||
setTransportType("unknown");
|
|
||||||
setSenderHashcode(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Integer getSenderHashcode() {
|
|
||||||
return map.getInt("senderHashCode", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setSenderHashcode(Integer senderHashcode) {
|
|
||||||
map.putInt("senderHashcode", senderHashcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceCommand getServiceCommand() {
|
|
||||||
return new ServiceCommand(map.getBundle("ServiceCommand"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setServiceCommand(ServiceCommand serviceCommand) {
|
|
||||||
map.putBundle("ServiceCommand", serviceCommand.getMap());
|
|
||||||
this.serviceTransportType = ServiceTransportType.ServiceCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasServiceCommand() {
|
|
||||||
return (getMap().containsKey("ServiceCommand"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getTransportType() {
|
|
||||||
return map.getString("transportType", "unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// On remote end, this will be converted to the "action" of a local Intent,
|
|
||||||
// so can be used for separating types of messages to different internal handlers.
|
|
||||||
public void setTransportType(String transportType) {
|
|
||||||
map.putString("transportType", transportType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceResult getServiceResult() {
|
|
||||||
return new ServiceResult(map.getBundle("ServiceResult"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setServiceResult(ServiceResult serviceResult) {
|
|
||||||
map.putBundle("ServiceResult", serviceResult.getMap());
|
|
||||||
this.serviceTransportType = ServiceTransportType.ServiceResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasServiceResult() {
|
|
||||||
return (getMap().containsKey("ServiceResult"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceNotification getServiceNotification() {
|
|
||||||
return new ServiceNotification(map.getBundle("ServiceNotification"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setServiceNotification(ServiceNotification notification) {
|
|
||||||
map.putBundle("ServiceNotification", notification.getMap());
|
|
||||||
this.serviceTransportType = ServiceTransportType.ServiceNotification;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasServiceNotification() {
|
|
||||||
return (map.containsKey("ServiceNotification"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean commandDidCompleteOK() {
|
|
||||||
return getServiceResult().resultIsOK();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getOriginalCommandName() {
|
|
||||||
return getServiceCommand().getCommandName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String describeContentsShort() {
|
|
||||||
String rval = "";
|
|
||||||
rval += getTransportType();
|
|
||||||
|
|
||||||
if (this.serviceTransportType == ServiceTransportType.ServiceNotification) {
|
|
||||||
rval += "note: " + getServiceNotification().getNotificationType();
|
|
||||||
} else if (this.serviceTransportType == ServiceTransportType.ServiceCommand) {
|
|
||||||
rval += ", cmd=" + getOriginalCommandName();
|
|
||||||
} else if (this.serviceTransportType == ServiceTransportType.ServiceResult) {
|
|
||||||
rval += ", cmd=" + getOriginalCommandName();
|
|
||||||
rval += ", rslt=" + getServiceResult().getResult();
|
|
||||||
rval += ", err=" + getServiceResult().getErrorDescription();
|
|
||||||
}
|
|
||||||
return rval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override public ServiceTransport clone() {
|
|
||||||
Parcel p = Parcel.obtain();
|
|
||||||
Parcel p2 = Parcel.obtain();
|
|
||||||
getMap().writeToParcel(p, 0);
|
|
||||||
byte[] bytes = p.marshall();
|
|
||||||
p2.unmarshall(bytes, 0, bytes.length);
|
|
||||||
p2.setDataPosition(0);
|
|
||||||
Bundle b = p2.readBundle();
|
|
||||||
ServiceTransport rval = new ServiceTransport();
|
|
||||||
rval.setMap(b);
|
|
||||||
return rval;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 31/05/18.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum ServiceTransportType {
|
|
||||||
|
|
||||||
Undefined, //
|
|
||||||
ServiceNotification, //
|
|
||||||
|
|
||||||
ServiceCommand, //
|
|
||||||
ServiceResult
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport
|
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport
|
|
||||||
|
|
||||||
open class PumpTask(injector: HasAndroidInjector) : ServiceTask(injector)
|
open class PumpTask(injector: HasAndroidInjector) : ServiceTask(injector)
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,10 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.task
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
open class ServiceTask constructor(val injector: HasAndroidInjector, val serviceTransport: ServiceTransport = ServiceTransport()) : Runnable {
|
open class ServiceTask constructor(val injector: HasAndroidInjector) : Runnable {
|
||||||
|
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
@Inject lateinit var activePlugin: ActivePlugin
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
import info.nightscout.shared.logging.LTag
|
import info.nightscout.shared.logging.LTag
|
||||||
import java.util.concurrent.LinkedBlockingQueue
|
import java.util.concurrent.LinkedBlockingQueue
|
||||||
|
@ -12,7 +11,6 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class ServiceTaskExecutor @Inject constructor() : ThreadPoolExecutor(1, 1, 10000, TimeUnit.MILLISECONDS, taskQueue) {
|
class ServiceTaskExecutor @Inject constructor() : ThreadPoolExecutor(1, 1, 10000, TimeUnit.MILLISECONDS, taskQueue) {
|
||||||
|
|
||||||
@Inject lateinit var rileyLinkUtil: RileyLinkUtil
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -25,21 +23,17 @@ class ServiceTaskExecutor @Inject constructor() : ThreadPoolExecutor(1, 1, 10000
|
||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
|
||||||
override fun beforeExecute(t: Thread, r: Runnable) {
|
override fun beforeExecute(t: Thread, r: Runnable) {
|
||||||
// This is run on either caller UI thread or Service UI thread.
|
// This is run on either caller UI thread or Service UI thread.
|
||||||
val task = r as ServiceTask
|
val task = r as ServiceTask
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "About to run task ${task.javaClass.simpleName}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "About to run task ${task.javaClass.simpleName}")
|
||||||
rileyLinkUtil.setCurrentTask(task)
|
|
||||||
task.preOp()
|
task.preOp()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
|
||||||
override fun afterExecute(r: Runnable, t: Throwable) {
|
override fun afterExecute(r: Runnable, t: Throwable) {
|
||||||
// This is run on either caller UI thread or Service UI thread.
|
// This is run on either caller UI thread or Service UI thread.
|
||||||
val task = r as ServiceTask
|
val task = r as ServiceTask
|
||||||
task.postOp()
|
task.postOp()
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Finishing task ${task.javaClass.simpleName}")
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Finishing task ${task.javaClass.simpleName}")
|
||||||
rileyLinkUtil.finishCurrentTask(task)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue