-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88540ed
commit 5415219
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*- | ||
// | ||
// This file is part of ThingTalk | ||
// | ||
// Copyright 2017-2018 The Board of Trustees of the Leland Stanford Junior University | ||
// | ||
// Author: Giovanni Campagna <gcampagn@cs.stanford.edu> | ||
// | ||
// See COPYING for details | ||
|
||
{ | ||
const ThingTalk = require('thingtalk'); | ||
const Ast = ThingTalk.Ast; | ||
|
||
const TIMER_SCHEMA = new Ast.FunctionDef('stream', | ||
'timer', | ||
[], // args, | ||
false, // is_list | ||
true, // is_monitorable | ||
{ | ||
canonical: '每固定週期', | ||
confirmation: '每 ${interval}', | ||
}, | ||
{} // annotations | ||
); | ||
|
||
const AT_TIMER_SCHEMA = new Ast.FunctionDef('stream', | ||
'attimer', | ||
[], // args, | ||
false, // is_list | ||
true, // is_monitorable | ||
{ | ||
canonical: '每天的固定時間', | ||
confirmation: '每天的 ${interval}', | ||
}, | ||
{} // annotations | ||
); | ||
} | ||
|
||
timer = { | ||
'每天的' time:constant_Time => new Ast.Stream.AtTimer(time, AT_TIMER_SCHEMA); | ||
'每天在' time:constant_Time '的時候' => new Ast.Stream.AtTimer(time, AT_TIMER_SCHEMA); | ||
|
||
!turking { | ||
// TODO : Need to handle duration in Chinese | ||
'每' interval:constant_Measure_ms => new Ast.Stream.Timer(Ast.Value.Date.now(), interval, TIMER_SCHEMA); | ||
'每天' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'day'), TIMER_SCHEMA); | ||
'一天一次' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'day'), TIMER_SCHEMA); | ||
'每月' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'mon'), TIMER_SCHEMA); | ||
'每個月' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'mon'), TIMER_SCHEMA); | ||
'一個月一次' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'mon'), TIMER_SCHEMA); | ||
'每週' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'week'), TIMER_SCHEMA); | ||
'一週一次' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'week'), TIMER_SCHEMA); | ||
'每小時' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'h'), TIMER_SCHEMA); | ||
'每一小時' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'h'), TIMER_SCHEMA); | ||
'每小時一次' => new Ast.Stream.Timer(Ast.Value.Date.now(), new Ast.Value.Measure(1, 'h'), TIMER_SCHEMA); | ||
} | ||
} |