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

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

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csharp
File size: 10.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5namespace WebMrbc
6{
7 public class RtcYearBlock : Block
8 {
9 public const string type_name = "rtc_year";
10
11 public RtcYearBlock()
12 : base(type_name)
13 {
14 }
15
16 public void init()
17 {
18 this.appendDummyInput()
19 .appendField(new FieldNumber("2017", 2000, 2099, 1), "VALUE");
20 this.setOutput(true, "Number");
21 this.setColour(160);
22 this.setTooltip("年(2000-2099)");
23 this.setHelpUrl("http://www.example.com/");
24 }
25 }
26
27 public class RtcMonthBlock : Block
28 {
29 public const string type_name = "rtc_month";
30
31 public RtcMonthBlock()
32 : base(type_name)
33 {
34 }
35
36 public void init()
37 {
38 this.appendDummyInput()
39 .appendField(new FieldNumber("1", 1, 12, 1), "VALUE");
40 this.setOutput(true, "Number");
41 this.setColour(160);
42 this.setTooltip("月(1-12)");
43 this.setHelpUrl("http://www.example.com/");
44 }
45 }
46
47 public class RtcDayBlock : Block
48 {
49 public const string type_name = "rtc_day";
50
51 public RtcDayBlock()
52 : base(type_name)
53 {
54 }
55
56 public void init()
57 {
58 this.appendDummyInput()
59 .appendField(new FieldNumber("1", 1, 31, 1), "VALUE");
60 this.setOutput(true, "Number");
61 this.setColour(160);
62 this.setTooltip("日(1-31)");
63 this.setHelpUrl("http://www.example.com/");
64 }
65 }
66
67 public class RtcHourBlock : Block
68 {
69 public const string type_name = "rtc_hour";
70
71 public RtcHourBlock()
72 : base(type_name)
73 {
74 }
75
76 public void init()
77 {
78 this.appendDummyInput()
79 .appendField(new FieldNumber("0", 0, 23, 1), "VALUE");
80 this.setOutput(true, "Number");
81 this.setColour(160);
82 this.setTooltip("時(0-23)");
83 this.setHelpUrl("http://www.example.com/");
84 }
85 }
86
87 public class RtcMinuteBlock : Block
88 {
89 public const string type_name = "rtc_minute";
90
91 public RtcMinuteBlock()
92 : base(type_name)
93 {
94 }
95
96 public void init()
97 {
98 this.appendDummyInput()
99 .appendField(new FieldNumber("0", 0, 59, 1), "VALUE");
100 this.setOutput(true, "Number");
101 this.setColour(160);
102 this.setTooltip("分(0-59)");
103 this.setHelpUrl("http://www.example.com/");
104 }
105 }
106
107 public class RtcSecondBlock : Block
108 {
109 public const string type_name = "rtc_second";
110
111 public RtcSecondBlock()
112 : base(type_name)
113 {
114 }
115
116 public void init()
117 {
118 this.appendDummyInput()
119 .appendField(new FieldNumber("0", 0, 59, 1), "VALUE");
120 this.setOutput(true, "Number");
121 this.setColour(160);
122 this.setTooltip("秒(0-59)");
123 this.setHelpUrl("http://www.example.com/");
124 }
125 }
126
127 public class RtcWeekDayBlock : Block
128 {
129 public const string type_name = "rtc_weekday";
130
131 public RtcWeekDayBlock()
132 : base(type_name)
133 {
134 }
135
136 public void init()
137 {
138 this.appendDummyInput()
139 .appendField(new FieldDropdown(new[] {
140 new[] { "日曜", "0" },
141 new[] { "月曜", "1" },
142 new[] { "火曜", "2" },
143 new[] { "水曜", "3" },
144 new[] { "木曜", "4" },
145 new[] { "金曜", "5" },
146 new[] { "土曜", "6" }
147 }), "VALUE");
148 this.setInputsInline(true);
149 this.setOutput(true, "Number");
150 this.setColour(160);
151 this.setTooltip("");
152 this.setHelpUrl("http://www.example.com/");
153 }
154 }
155
156 public class RtcDateTimeBlock : Block
157 {
158 public const string type_name = "rtc_datetime";
159
160 public RtcDateTimeBlock()
161 : base(type_name)
162 {
163 }
164
165 public void init()
166 {
167 this.appendValueInput("YEAR")
168 .setCheck("Number")
169 .appendField("年");
170 this.appendValueInput("MONTH")
171 .setCheck("Number")
172 .appendField("月");
173 this.appendValueInput("DAY")
174 .setCheck("Number")
175 .appendField("日");
176 this.appendValueInput("HOUR")
177 .setCheck("Number")
178 .appendField("時");
179 this.appendValueInput("MINUTE")
180 .setCheck("Number")
181 .appendField("分");
182 this.appendValueInput("SECOND")
183 .setCheck("Number")
184 .appendField("秒");
185 this.setInputsInline(true);
186 this.setOutput(true, "Array");
187 this.setColour(160);
188 this.setTooltip("");
189 this.setHelpUrl("http://www.example.com/");
190 }
191 }
192
193 public class RtcDateTimeItemBlock : Block
194 {
195 public const string type_name = "rtc_get_datetime_item";
196
197 public RtcDateTimeItemBlock()
198 : base(type_name)
199 {
200 }
201
202 public void init()
203 {
204 this.appendDummyInput()
205 .appendField(new FieldVariable("item"), "ARRAY")
206 .appendField(new FieldDropdown(new[] {
207 new[] {"年", "0" },
208 new[] {"月", "1" },
209 new[] {"日", "2" },
210 new[] {"時", "3" },
211 new[] {"分", "4" },
212 new[] {"秒", "5" },
213 new[] {"週", "6" }
214 }), "ITEM");
215 this.setInputsInline(true);
216 this.setOutput(true, "Number");
217 this.setColour(160);
218 this.setTooltip("");
219 this.setHelpUrl("http://www.example.com/");
220 }
221 }
222
223 public class RtcSetDateTimeItemBlock : Block
224 {
225 public const string type_name = "rtc_set_datetime_item";
226
227 public RtcSetDateTimeItemBlock()
228 : base(type_name)
229 {
230 }
231
232 public void init()
233 {
234 this.appendDummyInput()
235 .appendField(new FieldVariable("item"), "ARRAY")
236 .appendField("の")
237 .appendField(new FieldDropdown(new[] {
238 new[] {"年", "0" },
239 new[] {"月", "1" },
240 new[] {"日", "2" },
241 new[] {"時", "3" },
242 new[] {"分", "4" },
243 new[] {"秒", "5" },
244 new[] {"週", "6" }
245 }), "ITEM")
246 .appendField("に");
247 this.appendValueInput("VALUE")
248 .setCheck("Number");
249 this.appendDummyInput()
250 .appendField("を設定");
251 this.setInputsInline(true);
252 this.setPreviousStatement(true, null);
253 this.setNextStatement(true, null);
254 this.setColour(160);
255 this.setTooltip("");
256 this.setHelpUrl("http://www.example.com/");
257 }
258 }
259
260 public class RtcGetTimeBlock : Block
261 {
262 public const string type_name = "rtc_gettime";
263
264 public RtcGetTimeBlock()
265 : base(type_name)
266 {
267 }
268
269 public void init()
270 {
271 this.appendDummyInput()
272 .appendField("RTCの時計を取得します");
273 this.setInputsInline(true);
274 this.setOutput(true, "Array");
275 this.setColour(160);
276 this.setTooltip("");
277 this.setHelpUrl("http://www.example.com/");
278 }
279 }
280
281 public class RtcSettimeBlock : Block
282 {
283 public const string type_name = "rtc_settime";
284
285 public RtcSettimeBlock()
286 : base(type_name)
287 {
288 }
289
290 public void init()
291 {
292 this.appendDummyInput()
293 .appendField("RTCの時計をセットします");
294 this.appendValueInput("DATE")
295 .setCheck("Array");
296 this.setInputsInline(true);
297 this.setOutput(true, "Boolean");
298 this.setColour(160);
299 this.setTooltip("");
300 this.setHelpUrl("http://www.example.com/");
301 }
302 }
303
304 public class RtcDeinitBlock : Block
305 {
306 public const string type_name = "rtc_deinit";
307
308 public RtcDeinitBlock()
309 : base(type_name)
310 {
311 }
312
313 public void init()
314 {
315 this.appendDummyInput()
316 .appendField("RTCを停止します");
317 this.setInputsInline(true);
318 this.setOutput(true, "Boolean");
319 this.setColour(160);
320 this.setTooltip("");
321 this.setHelpUrl("http://www.example.com/");
322 }
323 }
324
325 public class RtcInitBlock : Block
326 {
327 public const string type_name = "rtc_init";
328
329 public RtcInitBlock()
330 : base(type_name)
331 {
332 }
333
334 public void init()
335 {
336 this.appendDummyInput()
337 .appendField("RTCを起動します");
338 this.setInputsInline(true);
339 this.setOutput(true, "Number");
340 this.setColour(160);
341 this.setTooltip("");
342 this.setHelpUrl("http://www.example.com/");
343 }
344 }
345
346 partial class Ruby
347 {
348 public node rtc_year(RtcYearBlock block)
349 {
350 var value = block.getFieldValue("VALUE");
351 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
352 }
353
354 public node rtc_month(RtcMonthBlock block)
355 {
356 var value = block.getFieldValue("VALUE");
357 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
358 }
359
360 public node rtc_day(RtcDayBlock block)
361 {
362 var value = block.getFieldValue("VALUE");
363 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
364 }
365
366 public node rtc_hour(RtcHourBlock block)
367 {
368 var value = block.getFieldValue("VALUE");
369 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
370 }
371
372 public node rtc_minute(RtcMinuteBlock block)
373 {
374 var value = block.getFieldValue("VALUE");
375 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
376 }
377
378 public node rtc_second(RtcSecondBlock block)
379 {
380 var value = block.getFieldValue("VALUE");
381 return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
382 }
383
384 public node rtc_weekday(RtcWeekDayBlock 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_datetime(RtcDateTimeBlock block)
391 {
392 var array = new node[] {
393 valueToCode(block, "YEAR"),
394 valueToCode(block, "MONTH"),
395 valueToCode(block, "DAY"),
396 valueToCode(block, "HOUR"),
397 valueToCode(block, "MINUTE"),
398 valueToCode(block, "SECOND"),
399 };
400 return new array_node(this, array);
401 }
402
403 public node rtc_get_datetime_item(RtcDateTimeItemBlock block)
404 {
405 var value_array = block.getFieldValue("ARRAY");
406 var value_item = block.getFieldValue("ITEM");
407 var a = new_var_node(get_var_name(value_array));
408 var p = new node[] {
409 new int_node(this, value_item == null ? 0 : Bridge.Script.ParseInt(value_item, 10))
410 };
411 return new call_node(this, a, intern("[]"), p, null);
412 }
413
414 public node rtc_set_datetime_item(RtcSetDateTimeItemBlock block)
415 {
416 var value_array = block.getFieldValue("ARRAY");
417 var value_item = block.getFieldValue("ITEM");
418 var a = new_var_node(get_var_name(value_array));
419 var p = new node[] {
420 new int_node(this, value_item == null ? 0 : Bridge.Script.ParseInt(value_item, 10))
421 };
422 var b = valueToCode(block, "VALUE");
423 return new asgn_node(this, new call_node(this, a, intern("[]"), p, null), b);
424 }
425
426 public node rtc_gettime(RtcGetTimeBlock block)
427 {
428 var c = new const_node(this, intern("Rtc"));
429 var p = new node[0];
430 return new call_node(this, c, intern("getTime"), p, null);
431 }
432
433 public node rtc_settime(RtcSettimeBlock block)
434 {
435 var value_date = valueToCode(block, "DATE");
436 var c = new const_node(this, intern("Rtc"));
437 var p = new node[] {
438 value_date
439 };
440 return new call_node(this, c, intern("setTime"), p, null);
441 }
442
443 public node rtc_deinit(RtcDeinitBlock block)
444 {
445 var c = new const_node(this, intern("Rtc"));
446 var p = new node[0];
447 return new call_node(this, c, intern("deinit"), p, null);
448 }
449
450 public node rtc_init(RtcInitBlock block)
451 {
452 var c = new const_node(this, intern("Rtc"));
453 var p = new node[0];
454 return new call_node(this, c, intern("init"), p, null);
455 }
456 }
457}
Note: See TracBrowser for help on using the repository browser.