source: EcnlProtoTool/trunk/webapp/webmrbc/Arduino/RtcBlock.cs@ 287

Last change on this file since 287 was 287, checked in by coas-nagasima, 7 years ago

ファイルヘッダーコメントを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csharp
File size: 12.8 KB
Line 
1/*
2 * TOPPERS/ECNL Prototyping tool
3 *
4 * Copyright (C) 2017 Cores Co., Ltd. Japan
5 *
6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
8 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
9 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
10 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
11 * スコード中に含まれていること.
12 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
13 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
14 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
15 * の無保証規定を掲載すること.
16 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
17 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
18 * と.
19 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
20 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
21 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
22 * 報告すること.
23 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
24 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
25 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
27 * 免責すること.
28 *
29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
31 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
33 * の責任を負わない.
34 *
35 * @(#) $Id: RtcBlock.cs 287 2017-05-05 14:22:23Z coas-nagasima $
36 */
37using System;
38using System.Collections.Generic;
39using System.Linq;
40
41namespace WebMrbc
42{
43 public class RtcYearBlock : Block
44 {
45 public const string type_name = "rtc_year";
46
47 public RtcYearBlock()
48 : base(type_name)
49 {
50 }
51
52 public void init()
53 {
54 this.appendDummyInput()
55 .appendField(new FieldNumber("2017", 2000, 2099, 1), "VALUE");
56 this.setOutput(true, "Number");
57 this.setColour(160);
58 this.setTooltip("年(2000-2099)");
59 this.setHelpUrl("http://www.example.com/");
60 }
61 }
62
63 public class RtcMonthBlock : Block
64 {
65 public const string type_name = "rtc_month";
66
67 public RtcMonthBlock()
68 : base(type_name)
69 {
70 }
71
72 public void init()
73 {
74 this.appendDummyInput()
75 .appendField(new FieldNumber("1", 1, 12, 1), "VALUE");
76 this.setOutput(true, "Number");
77 this.setColour(160);
78 this.setTooltip("月(1-12)");
79 this.setHelpUrl("http://www.example.com/");
80 }
81 }
82
83 public class RtcDayBlock : Block
84 {
85 public const string type_name = "rtc_day";
86
87 public RtcDayBlock()
88 : base(type_name)
89 {
90 }
91
92 public void init()
93 {
94 this.appendDummyInput()
95 .appendField(new FieldNumber("1", 1, 31, 1), "VALUE");
96 this.setOutput(true, "Number");
97 this.setColour(160);
98 this.setTooltip("日(1-31)");
99 this.setHelpUrl("http://www.example.com/");
100 }
101 }
102
103 public class RtcHourBlock : Block
104 {
105 public const string type_name = "rtc_hour";
106
107 public RtcHourBlock()
108 : base(type_name)
109 {
110 }
111
112 public void init()
113 {
114 this.appendDummyInput()
115 .appendField(new FieldNumber("0", 0, 23, 1), "VALUE");
116 this.setOutput(true, "Number");
117 this.setColour(160);
118 this.setTooltip("時(0-23)");
119 this.setHelpUrl("http://www.example.com/");
120 }
121 }
122
123 public class RtcMinuteBlock : Block
124 {
125 public const string type_name = "rtc_minute";
126
127 public RtcMinuteBlock()
128 : base(type_name)
129 {
130 }
131
132 public void init()
133 {
134 this.appendDummyInput()
135 .appendField(new FieldNumber("0", 0, 59, 1), "VALUE");
136 this.setOutput(true, "Number");
137 this.setColour(160);
138 this.setTooltip("分(0-59)");
139 this.setHelpUrl("http://www.example.com/");
140 }
141 }
142
143 public class RtcSecondBlock : Block
144 {
145 public const string type_name = "rtc_second";
146
147 public RtcSecondBlock()
148 : base(type_name)
149 {
150 }
151
152 public void init()
153 {
154 this.appendDummyInput()
155 .appendField(new FieldNumber("0", 0, 59, 1), "VALUE");
156 this.setOutput(true, "Number");
157 this.setColour(160);
158 this.setTooltip("秒(0-59)");
159 this.setHelpUrl("http://www.example.com/");
160 }
161 }
162
163 public class RtcWeekDayBlock : Block
164 {
165 public const string type_name = "rtc_weekday";
166
167 public RtcWeekDayBlock()
168 : base(type_name)
169 {
170 }
171
172 public void init()
173 {
174 this.appendDummyInput()
175 .appendField(new FieldDropdown(new[] {
176 new[] { "日曜", "0" },
177 new[] { "月曜", "1" },
178 new[] { "火曜", "2" },
179 new[] { "水曜", "3" },
180 new[] { "木曜", "4" },
181 new[] { "金曜", "5" },
182 new[] { "土曜", "6" }
183 }), "VALUE");
184 this.setInputsInline(true);
185 this.setOutput(true, "Number");
186 this.setColour(160);
187 this.setTooltip("");
188 this.setHelpUrl("http://www.example.com/");
189 }
190 }
191
192 public class RtcDateTimeBlock : Block
193 {
194 public const string type_name = "rtc_datetime";
195
196 public RtcDateTimeBlock()
197 : base(type_name)
198 {
199 }
200
201 public void init()
202 {
203 this.appendValueInput("YEAR")
204 .setCheck("Number")
205 .appendField("年");
206 this.appendValueInput("MONTH")
207 .setCheck("Number")
208 .appendField("月");
209 this.appendValueInput("DAY")
210 .setCheck("Number")
211 .appendField("日");
212 this.appendValueInput("HOUR")
213 .setCheck("Number")
214 .appendField("時");
215 this.appendValueInput("MINUTE")
216 .setCheck("Number")
217 .appendField("分");
218 this.appendValueInput("SECOND")
219 .setCheck("Number")
220 .appendField("秒");
221 this.setInputsInline(true);
222 this.setOutput(true, "Array");
223 this.setColour(160);
224 this.setTooltip("");
225 this.setHelpUrl("http://www.example.com/");
226 }
227 }
228
229 public class RtcDateTimeItemBlock : Block
230 {
231 public const string type_name = "rtc_get_datetime_item";
232
233 public RtcDateTimeItemBlock()
234 : base(type_name)
235 {
236 }
237
238 public void init()
239 {
240 this.appendDummyInput()
241 .appendField(new FieldVariable("item"), "ARRAY")
242 .appendField(new FieldDropdown(new[] {
243 new[] {"年", "0" },
244 new[] {"月", "1" },
245 new[] {"日", "2" },
246 new[] {"時", "3" },
247 new[] {"分", "4" },
248 new[] {"秒", "5" },
249 new[] {"週", "6" }
250 }), "ITEM");
251 this.setInputsInline(true);
252 this.setOutput(true, "Number");
253 this.setColour(160);
254 this.setTooltip("");
255 this.setHelpUrl("http://www.example.com/");
256 }
257 }
258
259 public class RtcSetDateTimeItemBlock : Block
260 {
261 public const string type_name = "rtc_set_datetime_item";
262
263 public RtcSetDateTimeItemBlock()
264 : base(type_name)
265 {
266 }
267
268 public void init()
269 {
270 this.appendDummyInput()
271 .appendField(new FieldVariable("item"), "ARRAY")
272 .appendField("の")
273 .appendField(new FieldDropdown(new[] {
274 new[] {"年", "0" },
275 new[] {"月", "1" },
276 new[] {"日", "2" },
277 new[] {"時", "3" },
278 new[] {"分", "4" },
279 new[] {"秒", "5" },
280 new[] {"週", "6" }
281 }), "ITEM")
282 .appendField("に");
283 this.appendValueInput("VALUE")
284 .setCheck("Number");
285 this.appendDummyInput()
286 .appendField("を設定");
287 this.setInputsInline(true);
288 this.setPreviousStatement(true, null);
289 this.setNextStatement(true, null);
290 this.setColour(160);
291 this.setTooltip("");
292 this.setHelpUrl("http://www.example.com/");
293 }
294 }
295
296 public class RtcGetTimeBlock : Block
297 {
298 public const string type_name = "rtc_gettime";
299
300 public RtcGetTimeBlock()
301 : base(type_name)
302 {
303 }
304
305 public void init()
306 {
307 this.appendDummyInput()
308 .appendField("RTCの時計を取得します");
309 this.setInputsInline(true);
310 this.setOutput(true, "Array");
311 this.setColour(160);
312 this.setTooltip("");
313 this.setHelpUrl("http://www.example.com/");
314 }
315 }
316
317 public class RtcSettimeBlock : Block
318 {
319 public const string type_name = "rtc_settime";
320
321 public RtcSettimeBlock()
322 : base(type_name)
323 {
324 }
325
326 public void init()
327 {
328 this.appendDummyInput()
329 .appendField("RTCの時計をセットします");
330 this.appendValueInput("DATE")
331 .setCheck("Array");
332 this.setInputsInline(true);
333 this.setOutput(true, "Boolean");
334 this.setColour(160);
335 this.setTooltip("");
336 this.setHelpUrl("http://www.example.com/");
337 }
338 }
339
340 public class RtcDeinitBlock : Block
341 {
342 public const string type_name = "rtc_deinit";
343
344 public RtcDeinitBlock()
345 : base(type_name)
346 {
347 }
348
349 public void init()
350 {
351 this.appendDummyInput()
352 .appendField("RTCを停止します");
353 this.setInputsInline(true);
354 this.setOutput(true, "Boolean");
355 this.setColour(160);
356 this.setTooltip("");
357 this.setHelpUrl("http://www.example.com/");
358 }
359 }
360
361 public class RtcInitBlock : Block
362 {
363 public const string type_name = "rtc_init";
364
365 public RtcInitBlock()
366 : base(type_name)
367 {
368 }
369
370 public void init()
371 {
372 this.appendDummyInput()
373 .appendField("RTCを起動します");
374 this.setInputsInline(true);
375 this.setOutput(true, "Number");
376 this.setColour(160);
377 this.setTooltip("");
378 this.setHelpUrl("http://www.example.com/");
379 }
380 }
381
382 partial class Ruby
383 {
384 public node rtc_year(RtcYearBlock block)
385 {
386 var value = block.getFieldValue("VALUE");
387 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
388 }
389
390 public node rtc_month(RtcMonthBlock block)
391 {
392 var value = block.getFieldValue("VALUE");
393 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
394 }
395
396 public node rtc_day(RtcDayBlock block)
397 {
398 var value = block.getFieldValue("VALUE");
399 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
400 }
401
402 public node rtc_hour(RtcHourBlock block)
403 {
404 var value = block.getFieldValue("VALUE");
405 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
406 }
407
408 public node rtc_minute(RtcMinuteBlock block)
409 {
410 var value = block.getFieldValue("VALUE");
411 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
412 }
413
414 public node rtc_second(RtcSecondBlock block)
415 {
416 var value = block.getFieldValue("VALUE");
417 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
418 }
419
420 public node rtc_weekday(RtcWeekDayBlock block)
421 {
422 var value = block.getFieldValue("VALUE");
423 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
424 }
425
426 public node rtc_datetime(RtcDateTimeBlock block)
427 {
428 var array = new node[] {
429 valueToCode(block, "YEAR"),
430 valueToCode(block, "MONTH"),
431 valueToCode(block, "DAY"),
432 valueToCode(block, "HOUR"),
433 valueToCode(block, "MINUTE"),
434 valueToCode(block, "SECOND"),
435 };
436 return new array_node(this, array);
437 }
438
439 public node rtc_get_datetime_item(RtcDateTimeItemBlock block)
440 {
441 var value_array = block.getFieldValue("ARRAY");
442 var value_item = block.getFieldValue("ITEM");
443 var a = new_var_node(get_var_name(value_array));
444 var p = new node[] {
445 new int_node(this, value_item == null ? 0 : Bridge.Script.ParseInt(value_item, 10))
446 };
447 return new call_node(this, a, intern("[]"), p, null);
448 }
449
450 public node rtc_set_datetime_item(RtcSetDateTimeItemBlock block)
451 {
452 var value_array = block.getFieldValue("ARRAY");
453 var value_item = block.getFieldValue("ITEM");
454 var a = new_var_node(get_var_name(value_array));
455 var p = new node[] {
456 new int_node(this, value_item == null ? 0 : Bridge.Script.ParseInt(value_item, 10))
457 };
458 var b = valueToCode(block, "VALUE");
459 return new asgn_node(this, new call_node(this, a, intern("[]"), p, null), b);
460 }
461
462 public node rtc_gettime(RtcGetTimeBlock block)
463 {
464 var c = new const_node(this, intern("Rtc"));
465 var p = new node[0];
466 return new call_node(this, c, intern("getTime"), p, null);
467 }
468
469 public node rtc_settime(RtcSettimeBlock block)
470 {
471 var value_date = valueToCode(block, "DATE");
472 var c = new const_node(this, intern("Rtc"));
473 var p = new node[] {
474 value_date
475 };
476 return new call_node(this, c, intern("setTime"), p, null);
477 }
478
479 public node rtc_deinit(RtcDeinitBlock block)
480 {
481 var c = new const_node(this, intern("Rtc"));
482 var p = new node[0];
483 return new call_node(this, c, intern("deinit"), p, null);
484 }
485
486 public node rtc_init(RtcInitBlock block)
487 {
488 var c = new const_node(this, intern("Rtc"));
489 var p = new node[0];
490 return new call_node(this, c, intern("init"), p, null);
491 }
492 }
493}
Note: See TracBrowser for help on using the repository browser.