Class Garmin.DeviceControl

Object
   |
   +--Garmin.DeviceControl

class Garmin.DeviceControl


Garmin.DeviceControl The controller must be unlocked before anything can be done with it. Then you'll have to find a device before you can start to read data from and write data to the device.

We use the observer pattern to handle the asynchronous nature of device communication. You must register your class as a listener to this Object and then implement methods that will get called on certain events.

Events:

onStartFindDevices called when starting to search for devices. the object returned is {controller: this}

onCancelFindDevices is called when the controller is told to cancel finding devices {controller: this}

onFinishFindDevices called when the devices are found. the object returned is {controller: this}

onException is called when an exception occurs in a method object passed back is {msg: exception}

onInteractionWithNoDevice is called when the device is lazy loaded, but finds no devices, yet still attempts a read/write action {controller: this}

onStartReadFromDevice is called when the controller is about to start reading from the device {controller: this}

onFinishReadFromDevice is called when the controller is done reading the device. the read is either a success or failure, which is communicated via json. object passed back contains {success:this.garminPlugin.GpsTransferSucceeded, controller: this}

onWaitingReadFromDevice is called when the controller is waiting for input from the user about the device. object passed back contains: {message: this.garminPlugin.MessageBoxXml, controller: this}

onProgressReadFromDevice is called when the controller is still reading information from the device. in this case the message is a percent complete/ {progress: this.getDeviceStatus(), controller: this}

onCancelReadFromDevice is called when the controller is told to cancel reading from the device {controller: this}

onFinishWriteToDevice is called when the controller is done writing to the device. the write is either a success or failure, which is communicated via json. object passed back contains {success:this.garminPlugin.GpsTransferSucceeded, controller: this}

onWaitingWriteToDevice is called when the controller is waiting for input from the user about the device. object passed back contains: {message: this.garminPlugin.MessageBoxXml, controller: this}

onProgressWriteToDevice is called when the controller is still writing information to the device. in this case the message is a percent complete/ {progress: this.getDeviceStatus(), controller: this}

onCancelWriteToDevice is called when the controller is told to cancel writing to the device {controller: this}


Defined in GarminDeviceControl.js

Requires:


Field Summary
<static>  Object FILE_TYPES
          Constants defining possible file types associated with read and write methods.
<static>  Object FINISH_STATES
          Constants defining possible states when you poll the finishActions
<static>  Object MESSAGES
          Constants defining possible errors messages for various errors on the page
<static>  Object TRANSFER_DIRECTIONS
          Constants defining the strings used by the Device.xml to indicate transfer direction of each file type
 
Constructor Summary
Garmin.DeviceControl()
            A controller object that can retrieve and send data to a Garmin device.

 
Method Summary
 void cancelFindDevices()
           Cancels the current find devices interaction.
 void cancelReadFromDevice()
           User canceled the read.
 void cancelWriteToDevice()
           Cancels the current write transfer to the device.
 void checkForUpdates()
           Checks plugin for updates.
 void downloadToDevice(xmlDownloadDescription, filename)
           Writes GPI info to the currently selected device.
 void findDevices()
           Finds any connected Garmin Devices.
 Object getCompressedFitnessData()
           Returns the last read fitness data in compressed format.
 Array getDevices()
           Get a list of the devices found
 Garmin.TransferProgress getDeviceStatus()
           Get the status/progress of the current state or transfer
 Object getGpsData()
           Returns the GPS data that was last read as an XML DOM.
 Object getGpsDataString()
           Returns the GPS data that was last read as an XML string.
 Array getPluginVersion()
           Gets the version number for the plugin the user has currently installed.
 String getPluginVersionString()
           Gets a string of the version number for the plugin the user has currently installed.
 Number getReadCompletionState()
           Returns the completion state of the current read.
 void initialize()
           Instantiates a Garmin.DeviceControl object, but does not unlock/activate plugin.
 Boolean isPluginInitialized()
           Determines if the plugin is initialized
 Boolean isPluginInstalled()
           Determines if the plugin is installed on the user's machine
 Boolean isUnlocked()
           True if plugin has been successfully created and unlocked.
 void readCourseDetailFromFitnessDevice(<String> courseId)
           Asynchronously reads a single fitness course from the connected device as TCX format.
 void readCoursesFromFitnessDevice()
           Asynchronously reads entire fitness course data (CRS) from the connected device.
 void readDataFromDevice(<String> fileType)
           Generic read method, supporting GPX, TCX, Courses, Workouts, User Profiles, TCX activity directory, and TCX course directory reads.
 void readDetailFromDevice(<String> fileType, <String> dataId)
           Generic detail read method, which reads a specific fitness activity from the device given an activity ID.
 void readFromDevice()
           Asynchronously reads GPX data from the connected device.
 void readHistoryDetailFromFitnessDevice(<String> historyId)
           Asynchronously reads a single fitness history record from the connected device as TCX format.
 void readHistoryFromFitnessDevice()
           Asynchronously reads entire fitness history data (TCX) from the connected device.
 void readUserProfileFromFitnessDevice()
           Asynchronously reads fitness profile data (TCX) from the connected device.
 void readWorkoutsFromFitnessDevice()
           Asynchronously reads fitness workout data (WKT) from the connected device.
 void register(<Object> listener)
           Register to be an event listener.
 void respondToMessageBox(<Number> response)
           Responds to a message box on the device.
 void setDeviceNumber(<Number> deviceNumber)
           Sets the deviceNumber variable which determines which connected device to talk to.
 void setPluginRequiredVersion(reqVersionArray)
           Sets the required version number for the plugin for the application.
 Boolean unlock(<Array> pathKeyPairsArray)
           Unlocks the GpsControl object to be used at the given web address.
 void writeAddressToDevice(<String> address)
           Writes an address to the currently selected device.
 void writeFitnessToDevice(tcxString, fileName)
           Writes the given TCX Course XML string to the device selected in this.deviceNumber.
 void writeToDevice(gpxString, fileName)
           Writes the given GPX XML string to the device selected in this.deviceNumber.
 void writeUserProfileToFitnessDevice(tcxString, fileName)
           Writes the given TCX User Profile XML string to the device selected in this.deviceNumber.
 void writeWorkoutsToFitnessDevice(tcxString, fileName)
           Writes the given TCX Workouts XML string to the device selected in this.deviceNumber.

Field Detail

FILE_TYPES

<static> Object FILE_TYPES

FINISH_STATES

<static> Object FINISH_STATES

MESSAGES

<static> Object MESSAGES

TRANSFER_DIRECTIONS

<static> Object TRANSFER_DIRECTIONS

Constructor Detail

Garmin.DeviceControl

Garmin.DeviceControl()

Method Detail

cancelFindDevices

void cancelFindDevices()

cancelReadFromDevice

void cancelReadFromDevice()

cancelWriteToDevice

void cancelWriteToDevice()

checkForUpdates

void checkForUpdates()

downloadToDevice

void downloadToDevice(xmlDownloadDescription, filename)

findDevices

void findDevices()

getCompressedFitnessData

Object getCompressedFitnessData()

getDevices

Array getDevices()

getDeviceStatus

Garmin.TransferProgress getDeviceStatus()

getGpsData

Object getGpsData()

getGpsDataString

Object getGpsDataString()

getPluginVersion

Array getPluginVersion()

getPluginVersionString

String getPluginVersionString()

getReadCompletionState

Number getReadCompletionState()

initialize

void initialize()

isPluginInitialized

Boolean isPluginInitialized()

isPluginInstalled

Boolean isPluginInstalled()

isUnlocked

Boolean isUnlocked()

readCourseDetailFromFitnessDevice

void readCourseDetailFromFitnessDevice(<String> courseId)

readCoursesFromFitnessDevice

void readCoursesFromFitnessDevice()

readDataFromDevice

void readDataFromDevice(<String> fileType)

readDetailFromDevice

void readDetailFromDevice(<String> fileType, <String> dataId)

readFromDevice

void readFromDevice()

readHistoryDetailFromFitnessDevice

void readHistoryDetailFromFitnessDevice(<String> historyId)

readHistoryFromFitnessDevice

void readHistoryFromFitnessDevice()

readUserProfileFromFitnessDevice

void readUserProfileFromFitnessDevice()

readWorkoutsFromFitnessDevice

void readWorkoutsFromFitnessDevice()

register

void register(<Object> listener)

respondToMessageBox

void respondToMessageBox(<Number> response)

setDeviceNumber

void setDeviceNumber(<Number> deviceNumber)

setPluginRequiredVersion

void setPluginRequiredVersion(reqVersionArray)

unlock

Boolean unlock(<Array> pathKeyPairsArray)

writeAddressToDevice

void writeAddressToDevice(<String> address)

writeFitnessToDevice

void writeFitnessToDevice(tcxString, fileName)

writeToDevice

void writeToDevice(gpxString, fileName)

writeUserProfileToFitnessDevice

void writeUserProfileToFitnessDevice(tcxString, fileName)

writeWorkoutsToFitnessDevice

void writeWorkoutsToFitnessDevice(tcxString, fileName)


Documentation generated by JSDoc on Wed Dec 19 11:16:23 2007