GarminActivity.js
Summary
Garmin.Activity A data structure representing an activity
Version: 1.0
Author: Bobby Yang bobby.yang.at.garmin.com
if (Garmin == undefined) var Garmin = {};
Garmin.Activity = function(){};
Garmin.Activity = Class.create();
Garmin.Activity.prototype = {
initialize: function() {
this.attributes = new Hash();
this.summary = new Garmin.Sample();
this.series = new Array();
},
getAttributes: function() {
return this.attributes;
},
getAttribute: function(aKey) {
return this.attributes[aKey];
},
setAttribute: function(aKey, aValue) {
this.attributes[aKey] = aValue;
},
getSeries: function() {
return this.series;
},
getHistorySeries: function() {
for (var i = 0; i < this.series.length; i++) {
if (this.series[i].getSeriesType() == Garmin.Series.TYPES.history) {
return this.series[i];
}
}
return null;
},
addSeries: function(series) {
this.series.push(series);
},
getSingleSeries: function(index) {
var targetSeries = null;
if (index >= 0 && index < this.series.length) {
targetSeries = this.series[index];
}
return targetSeries;
},
getSummary: function() {
return this.summary;
},
getSummaryValue: function(sKey) {
return this.summary.getMeasurement(sKey);
},
setSummaryValue: function(sKey, sValue, sContext) {
this.summary.setMeasurement(sKey, sValue, sContext);
},
getEndTime: function() {
return this.getSummaryValue(Garmin.Activity.SUMMARY_KEYS.endTime).getValue();
},
getStartTime: function() {
return this.getSummaryValue(Garmin.Activity.SUMMARY_KEYS.startTime).getValue();
},
printMe: function(tabs) {
var output = "";
output += tabs + "\n\n[Activity]\n";
output += tabs + " attributes:\n";
var attKeys = this.attributes.keys();
for (var i = 0; i < attKeys.length; i++) {
output += tabs + " " + attKeys[i] + ": " + this.attributes[attKeys[i]] + "\n";
}
output += tabs + " summary:\n";
output += this.summary.printMe(tabs + " ");
output += tabs + " series:\n";
for (var i = 0; i < this.series.length; i++) {
output += this.series[i].printMe(tabs + " ");
}
return output;
},
toString: function() {
return "[Garmin.Activity]"
}
};
Garmin.Activity.ATTRIBUTE_KEYS = {
activityName: "activityName",
activitySport: "activitySport",
creatorName: "creatorName",
creatorUnitId: "creatorUnitId",
creatorProdId: "creatorProductId",
creatorVersion: "creatorVersion",
dom: "documentObjectModel"
};
Garmin.Activity.SECTION_KEYS = {
gpsSignals: "gpsSignal",
heartRateSignals: "heartRateSignal",
laps: "laps",
tracks: "tracks"
};
Garmin.Activity.SUMMARY_KEYS = {
avgHeartRate: "averageHeartRate",
calories: "calories",
endTime: "endTime",
intensity: "intensity",
maxHeartRate: "maximumHeartRate",
maxSpeed: "maximumSpeed",
startTime: "startTime",
totalDistance: "totalDistance",
totalTime: "totalTime"
};
Documentation generated by
JSDoc on Fri Sep 14 17:27:44 2007