| 1 |
package com.ridelogger.listners; |
| 2 |
|
| 3 |
import com.dsi.ant.plugins.antplus.pcc.defines.DeviceState; |
| 4 |
import com.dsi.ant.plugins.antplus.pccbase.PccReleaseHandle; |
| 5 |
import com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc.IDeviceStateChangeReceiver; |
| 6 |
import com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc.IPluginAccessResultReceiver; |
| 7 |
import com.ridelogger.RideService; |
| 8 |
|
| 9 |
|
| 10 |
/** |
| 11 |
* Ant |
| 12 |
* @author Chet Henry |
| 13 |
* Listen to and log Ant+ events base class |
| 14 |
*/ |
| 15 |
public abstract class Ant extends Base<Object> |
| 16 |
{ |
| 17 |
protected PccReleaseHandle<?> releaseHandle; //Handle class |
| 18 |
public IPluginAccessResultReceiver<?> mResultReceiver; //Receiver class |
| 19 |
protected int deviceNumber = 0; |
| 20 |
|
| 21 |
|
| 22 |
//setup listeners and logging |
| 23 |
public Ant(int pDeviceNumber, RideService mContext) |
| 24 |
{ |
| 25 |
super(mContext); |
| 26 |
deviceNumber = pDeviceNumber; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
public IDeviceStateChangeReceiver mDeviceStateChangeReceiver = new IDeviceStateChangeReceiver() |
| 31 |
{ |
| 32 |
@Override |
| 33 |
public void onDeviceStateChange(final DeviceState newDeviceState){ |
| 34 |
//if we lose a device zero out its values |
| 35 |
if(newDeviceState.equals(DeviceState.DEAD)) { |
| 36 |
zeroReadings(); |
| 37 |
} |
| 38 |
} |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
abstract protected void requestAccess(); |
| 43 |
|
| 44 |
|
| 45 |
@Override |
| 46 |
public void onDestroy() |
| 47 |
{ |
| 48 |
if(releaseHandle != null) { |
| 49 |
releaseHandle.close(); |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
|