找回密码
 立即注册
查看: 2932|回复: 1

使用Tizen泰泽Time API的秒表

[复制链接]
发表于 2013-3-20 12:14:29 | 显示全部楼层 |阅读模式
Stopwatch is a time based utility that can be used to measure the amount of time elapsed from a particular time until a time of interest reached or an event occurs.
秒表是一个基于时间的使用工具,用来测量从特定时间到感兴趣的时间点或事件发生时刻的时间总数。
Using the application
使用应用程序
There are three buttons. Initially all buttons are enabled.
这里有3个按钮。首先所有按钮可用。
1. Start: - Initially the stopwatch is in zero position, “00:00:00:000”. On pressing the “Start” button, the stopwatch starts counting the time elapsed from the point of start.
1.开始: 首先秒表停在"00:00:00:000"。在按了"开始"按钮,秒表开始计时。
After clicking on the “Start” button, “Reset” and “Start” buttons are disabled and “Stop” button is enabled.
在点击"开始"按钮后,"重置"和"开始"按钮不可用。"停止"按钮可用。
2. Stop: - On pressing the “Stop” button, the calculation of elapsed time gets stopped and is shown by the stopwatch.
2.关闭:按了"停止"按钮,停止计数,并且显示在秒表上。
After clicking on the “Stop” button, “Start’ and “Reset” buttons are enabled and “Stop” button is disabled.
在按了"停止"按钮,"重置"按钮可用,"停止"按钮不可用。
3. Reset: - On pressing the “Reset” button, stopwatch is reset to the initial position i.e. “00:00:00:000”.
3.重置:在按了"重置"按钮后,秒表重置时间到"00:00:00:000"。
After clicking on the “Reset” button “Start” button is enabled and “Reset” and “Stop” buttons are disabled.
按了"重置"按钮后,"开始"按钮可用,"重置", "停止"按钮不可用。

Fig: Snap shot of stopwatch
秒表截屏
Code snippet to start stopwatch
开始秒表的代码片段
Initially the position of stopwatch is zero. Clicking on the “Start” button fetches the current time and invokes the Counter() method, which counts the difference between the current and the start time. ”setTimeout()” is a callback method used for calling the Counter() in every 10 milliseconds.
秒表的最初位置是0。单击"开始"按钮,获取当前时间并调用Counter()方法,计算当前和开始时间的差异。setTimeout()是一个回调函数,用于每10毫秒调用Counter()函数。
function Start() {
       startTime
= tizen.time.getCurrentDateTime();

Counter();

...}//code snippet for counter

function Counter() {

var duration = tizen.time.getCurrentDateTime().difference(startTime);

Refresh = setTimeout('Counter()',10);

Time_format(duration.length + Diff);

...}

Code snippet to stop stopwatch
停止秒表代码片段
After clicking on the “Stop” button, the counter stops and shows the difference between the stop and the start time. ”clearTimeout()” method is used to clear the interval.
单击"停止"按钮,计数器停止,并显示差异时间。
function Stop() {
       clearTimeout
(Refresh);

var duration = tizen.time.getCurrentDateTime().difference(startTime);

Diff += duration.length;

...}

Code snippet to reset stopwatch
重置秒表代码片段
After clicking on the “Reset” button, the stopwatch is set to initial position. Zero is assigned to the global variable Diff.
按下"重置"按钮后,秒表设为初始态。全局变量 Diff设为 0。
function Reset() {

Stp.innerText ="00:00:00:000";

Diff = 0;

...}

Build Requirements:
构建参数
The application is built for devices with Tizen 2.0 firmware.
SDK Environment used: 2.0.0a2
应用程序基于泰泽2.0固件而构建。
开发工具包环境是2.0.0a2

File attachments:
file:///C:/modules/file/icons/package-x-generic.png stopwatch.zip

欢迎来到泰泽网:http://www.tizennet.com/ 泰泽论坛:http://bbs.tizennet.com/ 好没有内涵哦,快到设置中更改这个无聊的签名吧!
回复

使用道具 举报

发表于 2013-3-20 12:15:11 | 显示全部楼层
路过的帮顶
欢迎来到泰泽网:http://www.tizennet.com/ 泰泽论坛:http://bbs.tizennet.com/ 好没有内涵哦,快到设置中更改这个无聊的签名吧!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|泰泽应用|泰泽论坛|泰泽网|小黑屋|Archiver|手机版|泰泽邮箱|泰泽网 ( 蜀ICP备13024062号-1 )

GMT+8, 2024-11-24 20:00 , Processed in 0.074035 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表