public class CommunicationProcess extends Object implements ProgressListener
Modifier and Type | Field and Description |
---|---|
static int |
MAXROUTES |
Constructor and Description |
---|
CommunicationProcess(WatchInterface watchInterface,
Executor executor,
TomTomReader ttbinReader,
GpxReader gpxReader)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addRouteFile(String name,
String file,
int index)
This method loads and adds a route file to the array with route files
|
void |
clear()
Removes any track data.
|
void |
deleteAllRouteFiles()
Remove all route files from the array
|
void |
deleteRouteFile(int index)
Remote selected route from the array
|
ActivityData |
getActivityData(int index)
Get the ActivityData based on the index in the array
|
String |
getDeviceName()
Returns the device name
|
UsbFile |
getRouteFile(int index)
Returns route from array at given index.
|
boolean |
isConnected()
Indicates whether a watch is connected or not
|
void |
pushCommand(ThreadCommand command)
Push a command for executing on the command queue
|
void |
reportReadProgress(int bytesRead)
This method reports the progress file reading
|
void |
reportWriteProgress(int bytesWritten)
This method reports the progress file writing
|
void |
requestDeleteDeviceFileFromWatch(int fileId)
Deletes the file from the watch.
|
void |
requestLoadActivityFromTtbinFile(String fileName)
Loads the activity from a ttbin file on disk
|
void |
requestSetNewDeviceName(String name)
Writes a new device name to the watch.
|
void |
requestShowFile(int fileId)
This method requests to display the contents of indicated file.
|
void |
requestStop()
Stop the process.
|
void |
requestUploadFile(String fileName)
Request the upload of a file from disk to the watch
|
void |
requestUploadWorkouts(String fileName)
Request the upload of the workouts defined in the JSON file
|
void |
requestWriteDeviceFileToDisk(int fileId)
Writes a file from the watch as binary file to disk.
|
void |
setReadExpectedBytes(int bytes)
Sets the number of expected bytes to be read
|
void |
setTrackCompression(boolean enabled,
double maxError)
This method sets the track compression.
|
void |
setTrackSmoothing(boolean enabled,
float qFactor)
This method sets the track smoothing.
|
void |
setWriteExpectedBytes(int bytes)
Sets the number of expected bytes to be writen
|
void |
startProcess(TomTomWatchView view)
Set the view and start the processing
|
public static final int MAXROUTES
public CommunicationProcess(WatchInterface watchInterface, Executor executor, TomTomReader ttbinReader, GpxReader gpxReader)
watchInterface
- Interface to the watch to useexecutor
- Executor to use to execute subsequent requests to the watch in a
serialized orderttbinReader
- The reader/decoder to use for TTBIN filesgpxReader
- The reader to use for GPX filespublic void startProcess(TomTomWatchView view)
view
- TomTomWatchView instancepublic void requestStop()
public void pushCommand(ThreadCommand command)
command
- Command to push on the queuepublic void requestSetNewDeviceName(String name)
name
- The new namepublic void requestLoadActivityFromTtbinFile(String fileName)
fileName
- THe file to loadpublic void requestWriteDeviceFileToDisk(int fileId)
fileId
- Id of the filepublic void requestUploadFile(String fileName)
fileName
- The file to uploadpublic void requestDeleteDeviceFileFromWatch(int fileId)
fileId
- Id of the filepublic void requestShowFile(int fileId)
fileId
- ID of file to showpublic void requestUploadWorkouts(String fileName)
fileName
- The file defining the workouts, JSON formatpublic ActivityData getActivityData(int index)
index
- Array indexpublic boolean isConnected()
public String getDeviceName()
public void setTrackSmoothing(boolean enabled, float qFactor)
enabled
- Indicates whether smoothing is enabledqFactor
- The Q Factor for smoothingpublic void setTrackCompression(boolean enabled, double maxError)
enabled
- Indicates whether compression is enabledmaxError
- The maximum error for Douglas-Peucker compression methodpublic void addRouteFile(String name, String file, int index)
name
- Name of the routefile
- File name of the route gpx fileindex
- Location in the array to add the route file topublic void deleteAllRouteFiles()
public void deleteRouteFile(int index)
index
- Location of the route filepublic UsbFile getRouteFile(int index)
index
- Location of the route file in the arraypublic void clear()
public void setReadExpectedBytes(int bytes)
ProgressListener
setReadExpectedBytes
in interface ProgressListener
bytes
- Number of bytespublic void setWriteExpectedBytes(int bytes)
ProgressListener
setWriteExpectedBytes
in interface ProgressListener
bytes
- Number of bytespublic void reportReadProgress(int bytesRead)
reportReadProgress
in interface ProgressListener
bytesRead
- Number of bytes that have been writtenpublic void reportWriteProgress(int bytesWritten)
reportWriteProgress
in interface ProgressListener
bytesWritten
- Number of bytes that have been writtenCopyright © 2020. All rights reserved.