|
|
Jump to this file's LXR Page |
|
|
File: [CENS] / tos-contrib / StatisticsTracker / msClockM.nc
(download)
/
(as text)
Revision: 1.1, Wed Sep 22 17:51:26 2004 UTC (5 years, 2 months ago) by nithya Branch: MAIN CVS Tags: rdd_alpha_version_1, pregeonet, acoustic-05-18-06, PRE_TOSNIC_FIX, PRE_NOMEGA_MOTENIC, PRE_CEILING_FIX, PRE_64BIT, MOTENIC_PRE_BUGFIX_20050415, LAURA_CALIBRATION_EXPERIMENTS, HOSTMOTE_PROTOCOL_VERSION_7, HEAD, ESS_RELEASE_3_5, ESS_RELEASE_3_4, ESS_RELEASE_3_3, ESS_RELEASE_3_2, ESS_RELEASE_3_1, ESS_RELEASE_3_0, ESS_RELEASE_2_0, ESS_CONNECTIVITY, ESS_CENTROUTE_TESTING, ESS2-CMS-V1_5_pretest, ESS2-CMS-V1_4cMergeSympathy_2, ESS2-CMS-V1_4c, ESS2-CMS-V1_4b, ESS2-CMS-V1_4a, ESS2-CMS-V1_3, ESS2-CMS-V1_2, ESS2-CMS-V1_1, ESS2-CMS-V1_0, EMSTAR_RELEASE_2_5, EMSTAR_RELEASE_2_1_BRANCH, EMSTAR_RELEASE_2_1, EMSTAR_PRE_HTML, CYCLOPS_RELEASE_CANDIDATE_2_0, CYCLOPS_PRERELEASE_STABLE, CENTROUTE_EMSTAR_SOCKETS, BG_1_0, BANGLADESH_ARSENIC_1_2, BANGLADESH_ARSENIC_1_1, AMARSS_JR_DEPLOYMENT_6_05_07 This module can be used to track various power-related statistics (e.g. time the radio is on, number of packets sent, time spent transmitting). It is very easy to use - in order to indicate the start/stop of an event, the ReportPacketEvent interface is used. n order to retreive the latest snapshot, or to reset the stats, the RetreiveStatistics interface is used. StatisticsC/M provide both of these interfaces. I implemented a milli-second granularity clock as well in order to get ms times (o/w the options were micro-second, or 32 millisecond granularities). |
// $Id: msClockM.nc,v 1.1 2004/09/22 18:51:26 nithya Exp $
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
includes TosTime;
//includes Timer;
module msClockM {
provides {
interface StdControl;
interface SysTime;
}
uses {
interface Timer;
interface SysTime as SysClock;
}
}
implementation
{
// Interval can't be higher than 64 cuz we only grab
// 16 bits for usec offset!
uint32_t INTERVAL = 511;
uint32_t partial_time;
uint32_t last_usec_offset;
command result_t StdControl.init() {
atomic {
partial_time=0;
}
return SUCCESS;
}
command result_t StdControl.start() {
call Timer.start(TIMER_REPEAT, INTERVAL);
return SUCCESS ;
}
command result_t StdControl.stop() {
call Timer.stop();
return SUCCESS;
}
async command uint16_t SysTime.getTime16() {
uint32_t t;
t = call SysTime.getTime32();
return (uint16_t) t;
}
async command uint32_t SysTime.getTime32() {
uint32_t current_usec = call SysClock.getTime32();
uint32_t usec_offset = (current_usec - last_usec_offset)/1000;
uint32_t t;
atomic {
t = partial_time + usec_offset;
}
return t;
}
async command uint32_t SysTime.castTime16(uint16_t n) {
return 0;
}
event result_t Timer.fired() {
uint32_t new_time;
atomic {
new_time = call SysClock.getTime32();
partial_time += (new_time - last_usec_offset)/1000;
last_usec_offset = new_time;
}
return SUCCESS;
}
}
| CENS CVS Mailing List |
Powered by ViewCVS 0.9.2 |