1 if (Garmin == undefined) var Garmin = {}; 2 /** Copyright © 2007 Garmin Ltd. or its subsidiaries. 3 * 4 * Licensed under the Apache License, Version 2.0 (the 'License') 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an 'AS IS' BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 * @fileoverview Garmin.Device A place-holder for Garmin device information. <br/> 17 * Source: 18 * <a href="http://developer.garmin.com/web/communicator-api/garmin/device/GarminDevice.js">Hosted Distribution</a> 19 * <a href="https://svn.garmindeveloper.com/web/trunk/communicator/communicator-api/src/main/webapp/garmin/device/GarminDevice.js">Source Control</a><br/> 20 * 21 * @author Michael Bina michael.bina.at.garmin.com 22 * @version 1.0 23 */ 24 /** A place-holder for Garmin device information. 25 * @class Garmin.Device 26 * 27 * @constructor 28 * @param {String} displayName for the device 29 * @param {Number} number of the model 30 */ 31 Garmin.Device = function(displayName, number){}; //just here for jsdoc 32 Garmin.Device = Class.create(); 33 Garmin.Device.prototype = { 34 35 initialize: function(displayName, number) { 36 this.displayName = displayName; 37 this.number = number; 38 39 this.partNumber = null; 40 this.softwareVersion = null; 41 this.description = null; 42 this.id = null; 43 44 this.dataTypes = new Hash({}); 45 }, 46 47 /** The display name of this device. 48 * @type String 49 * @return display name 50 * @member Garmin.Device 51 */ 52 getDisplayName: function() { 53 return this.displayName; 54 }, 55 56 /** The device number that the plug-in uses to identify this device 57 * @type Number 58 * @return device number 59 */ 60 getNumber: function() { 61 return this.number; 62 }, 63 64 /** Set part number of device 65 * @param {String} part number 66 */ 67 setPartNumber: function(partNumber) { 68 this.partNumber = partNumber; 69 }, 70 71 /** The part number of the device 72 * @type String 73 * @return The part number of the device 74 */ 75 getPartNumber: function() { 76 return this.partNumber; 77 }, 78 79 /** Software version installed on device 80 * @param {String} Garmin.Device 81 */ 82 setSoftwareVersion: function(softwareVersion) { 83 this.softwareVersion = softwareVersion; 84 }, 85 86 /** The software version currently on the device 87 * @type String 88 * @return software version 89 */ 90 getSoftwareVersion: function() { 91 return this.softwareVersion; 92 }, 93 94 /** Set description of the device 95 * @param {String} device description 96 */ 97 setDescription: function(description) { 98 this.description = description; 99 }, 100 101 /** A description of the device. This usually represents the model name of the device 102 * and includes the software version, i.e. "Forerunner 405 Jun 27 2008 2.17" 103 * In the GarminDevice XML, this is Model > Description. 104 * @type String 105 * @return device description 106 */ 107 getDescription: function() { 108 return this.description; 109 }, 110 111 /** set device id 112 * @param {String} device id 113 */ 114 setId: function(id) { 115 this.id = id; 116 }, 117 118 /** The device id 119 * @type String 120 * @return The device id 121 */ 122 getId: function() { 123 return this.id; 124 }, 125 126 /** Adds a data type to the list of data types supported by this device 127 * @param dataType A DeviceDataType object containing information about the data type being added 128 */ 129 addDeviceDataType: function(dataType) { 130 var newDataType = new Hash(); 131 newDataType.set(dataType.getTypeName(), dataType); 132 this.dataTypes.update(newDataType); 133 }, 134 135 /** Returns a specific DeviceDataType object 136 * @type Garmin.DeviceDataType 137 * @return The DeviceDataType object containing the specified extension 138 * @param extension The file extension of the data type you are trying to get 139 */ 140 getDeviceDataType: function(extension) { 141 return this.dataTypes.get(extension); 142 }, 143 144 /** Returns a hash containing all DeviceDataType objects 145 * @type Hash 146 * @return all DeviceDataType objects 147 */ 148 getDeviceDataTypes: function() { 149 return this.dataTypes; 150 }, 151 152 /** Returns true if the device has read support for the file type 153 * @param {String} The extension of the file type you are checking for support 154 * @type Boolean 155 * @return read support for the file type 156 */ 157 supportDeviceDataTypeRead: function(extension) { 158 var dataType = this.getDeviceDataType(extension); 159 if (dataType != null && dataType.hasReadAccess()) { 160 return true; 161 } else { 162 return false; 163 } 164 }, 165 166 /** Check if device has write support for the file type. 167 * @param extension The extension of the file type you are checking for support 168 * @type Boolean 169 * @return True if write support 170 */ 171 supportDeviceDataTypeWrite: function(extension) { 172 var dataType = this.getDeviceDataType(extension); 173 if (dataType != null && dataType.hasWriteAccess()) { 174 return true; 175 } else { 176 return false; 177 } 178 }, 179 180 toString: function() { 181 return "Device["+this.getDisplayName()+", "+this.getDescription()+", "+this.getNumber()+"]"; 182 } 183 184 }; 185 186 /** A place-holder for Garmin Device Data Type information 187 * @class Garmin.DeviceDataType 188 * 189 * @constructor 190 * @param {String} typeName for the data type 191 * @param {String} file extension for the data type 192 */ 193 Garmin.DeviceDataType = function(typeName, fileExtension){}; //just here for jsdoc 194 Garmin.DeviceDataType = Class.create(); 195 Garmin.DeviceDataType.prototype = { 196 197 initialize: function(typeName, fileExtension) { 198 this.typeName = typeName; 199 this.fileExtension = fileExtension; 200 this.readAccess = false; 201 this.writeAccess = false; 202 this.filePath = null; 203 this.readFilePath = null; 204 this.writeFilePath = null; 205 this.identifier = null; 206 }, 207 208 /** 209 * @type String 210 * @return The type name of this data type 211 */ 212 getTypeName: function() { 213 return this.typeName; 214 }, 215 216 /** 217 * @deprecated 218 * @type String 219 * @return The type/display name of this data type 220 */ 221 getDisplayName: function() { 222 return this.getTypeName(); 223 }, 224 225 /** 226 * @type String 227 * @return The file extension of this data type 228 */ 229 getFileExtension: function() { 230 return this.fileExtension; 231 }, 232 233 /** 234 * @type String 235 * @return The file path for this data type 236 */ 237 getFilePath: function() { 238 return this.filePath; 239 }, 240 241 /** 242 * @param filePath - the filepath for this datatype 243 */ 244 setFilePath: function(filePath) { 245 this.filePath = filePath; 246 }, 247 248 /** 249 * @param readFilePath - the readFilePath for this datatype 250 */ 251 getReadFilePath: function() { 252 return this.readFilePath; 253 }, 254 255 /** 256 * @type String 257 * @return The read file path for this data type 258 */ 259 setReadFilePath: function(readFilePath) { 260 this.readFilePath = readFilePath; 261 }, 262 263 /** 264 * @param writeFilePath - the readFilePath for this datatype 265 */ 266 getWriteFilePath: function() { 267 return this.writeFilePath; 268 }, 269 270 /** 271 * @type String 272 * @return The write file path for this data type 273 */ 274 setWriteFilePath: function(writeFilePath) { 275 this.writeFilePath = writeFilePath; 276 }, 277 278 /** 279 * @type String 280 * @return The identifier for this data type 281 */ 282 getIdentifier: function() { 283 return this.identifier; 284 }, 285 286 /** 287 * @param identifier- the identifier for this datatype 288 */ 289 setIdentifier: function(identifier) { 290 this.identifier = identifier; 291 }, 292 293 /** 294 * @param readAccess True == has read access 295 */ 296 setReadAccess: function(readAccess) { 297 this.readAccess = readAccess; 298 }, 299 300 /** Returns value indicating if the device supports read access for this file type 301 * @type Boolean 302 * @return supports read access for this file type 303 */ 304 hasReadAccess: function() { 305 return this.readAccess; 306 }, 307 308 /** 309 * @param {Boolean} has write access 310 */ 311 setWriteAccess: function(writeAccess) { 312 this.writeAccess = writeAccess; 313 }, 314 315 /** return the value indicating if the device supports write access for this file type 316 * @type Boolean 317 * @return supports write access for this file type 318 */ 319 hasWriteAccess: function() { 320 return this.writeAccess; 321 } 322 }; 323