1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 |
|
---|
5 | namespace WebMrbc
|
---|
6 | {
|
---|
7 | public class BpsValueBlock : Block
|
---|
8 | {
|
---|
9 | public const string type_name = "bps_value";
|
---|
10 |
|
---|
11 | public BpsValueBlock()
|
---|
12 | : base(type_name)
|
---|
13 | {
|
---|
14 | }
|
---|
15 |
|
---|
16 | public void init()
|
---|
17 | {
|
---|
18 | this.appendDummyInput()
|
---|
19 | .appendField(new FieldDropdown(new[] {
|
---|
20 | new[] { "115.2kbps", "115200" },
|
---|
21 | new[] { "57.6kbps", "57600" },
|
---|
22 | new[] { "38.4kbps", "38400" },
|
---|
23 | new[] { "31.25kbps", "31250" },
|
---|
24 | new[] { "28.8kbps", "28800" },
|
---|
25 | new[] { "19.2kbps", "19200" },
|
---|
26 | new[] { "14.4kbps", "14400" },
|
---|
27 | new[] { "9.6kbps", "9600" },
|
---|
28 | new[] { "4.8kbps", "4800" },
|
---|
29 | new[] { "2.4kbps", "2400" },
|
---|
30 | new[] { "1.2kbps", "1200" },
|
---|
31 | new[] { "600bps", "600" },
|
---|
32 | new[] { "300bps", "300" }
|
---|
33 | }), "VALUE");
|
---|
34 | this.setInputsInline(true);
|
---|
35 | this.setOutput(true, "Number");
|
---|
36 | this.setColour(160);
|
---|
37 | this.setTooltip("");
|
---|
38 | this.setHelpUrl("http://www.example.com/");
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public class SerialNewBlock : Block
|
---|
43 | {
|
---|
44 | public const string type_name = "serial_new";
|
---|
45 |
|
---|
46 | public SerialNewBlock()
|
---|
47 | : base(type_name)
|
---|
48 | {
|
---|
49 | }
|
---|
50 |
|
---|
51 | public void init()
|
---|
52 | {
|
---|
53 | this.appendDummyInput()
|
---|
54 | .appendField("シリアル通信を初期化します")
|
---|
55 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
56 | this.appendValueInput("BPS")
|
---|
57 | .setCheck("Number")
|
---|
58 | .appendField("ボーレート");
|
---|
59 | this.setInputsInline(true);
|
---|
60 | this.setOutput(true, "Number");
|
---|
61 | this.setColour(160);
|
---|
62 | this.setTooltip("");
|
---|
63 | this.setHelpUrl("http://www.example.com/");
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | public class SerialBpsBlock : Block
|
---|
68 | {
|
---|
69 | public const string type_name = "serial_bps";
|
---|
70 |
|
---|
71 | public SerialBpsBlock()
|
---|
72 | : base(type_name)
|
---|
73 | {
|
---|
74 | }
|
---|
75 |
|
---|
76 | public void init()
|
---|
77 | {
|
---|
78 | this.appendDummyInput()
|
---|
79 | .appendField("ボーレートを設定します")
|
---|
80 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
81 | this.appendValueInput("BPS")
|
---|
82 | .setCheck("Number")
|
---|
83 | .appendField("ボーレート");
|
---|
84 | this.setInputsInline(true);
|
---|
85 | this.setPreviousStatement(true, null);
|
---|
86 | this.setNextStatement(true, null);
|
---|
87 | this.setColour(160);
|
---|
88 | this.setTooltip("");
|
---|
89 | this.setHelpUrl("http://www.example.com/");
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | public class SerialPrintBlock : Block
|
---|
94 | {
|
---|
95 | public const string type_name = "serial_print";
|
---|
96 |
|
---|
97 | public SerialPrintBlock()
|
---|
98 | : base(type_name)
|
---|
99 | {
|
---|
100 | }
|
---|
101 |
|
---|
102 | public void init()
|
---|
103 | {
|
---|
104 | this.appendDummyInput()
|
---|
105 | .appendField("シリアルに出力します")
|
---|
106 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
107 | this.appendValueInput("STR")
|
---|
108 | .setCheck("String")
|
---|
109 | .appendField("文字列");
|
---|
110 | this.setInputsInline(true);
|
---|
111 | this.setPreviousStatement(true, null);
|
---|
112 | this.setNextStatement(true, null);
|
---|
113 | this.setColour(160);
|
---|
114 | this.setTooltip("");
|
---|
115 | this.setHelpUrl("http://www.example.com/");
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | public class SerialPrintlnBlock : Block
|
---|
120 | {
|
---|
121 | public const string type_name = "serial_println";
|
---|
122 |
|
---|
123 | public SerialPrintlnBlock()
|
---|
124 | : base(type_name)
|
---|
125 | {
|
---|
126 | }
|
---|
127 |
|
---|
128 | public void init()
|
---|
129 | {
|
---|
130 | this.appendDummyInput()
|
---|
131 | .appendField("シリアルに\\r\\n付きで出力します")
|
---|
132 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
133 | this.appendValueInput("STR")
|
---|
134 | .setCheck("String")
|
---|
135 | .appendField("文字列");
|
---|
136 | this.setInputsInline(true);
|
---|
137 | this.setPreviousStatement(true, null);
|
---|
138 | this.setNextStatement(true, null);
|
---|
139 | this.setColour(160);
|
---|
140 | this.setTooltip("");
|
---|
141 | this.setHelpUrl("http://www.example.com/");
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 | public class SerialAvailableBlock : Block
|
---|
146 | {
|
---|
147 | public const string type_name = "serial_available";
|
---|
148 |
|
---|
149 | public SerialAvailableBlock()
|
---|
150 | : base(type_name)
|
---|
151 | {
|
---|
152 | }
|
---|
153 |
|
---|
154 | public void init()
|
---|
155 | {
|
---|
156 | this.appendDummyInput()
|
---|
157 | .appendField("シリアルデータがあるかどうか調べます")
|
---|
158 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
159 | this.setInputsInline(true);
|
---|
160 | this.setOutput(true, "Number");
|
---|
161 | this.setColour(160);
|
---|
162 | this.setTooltip("");
|
---|
163 | this.setHelpUrl("http://www.example.com/");
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | public class SerialReadBlock : Block
|
---|
168 | {
|
---|
169 | public const string type_name = "serial_read";
|
---|
170 |
|
---|
171 | public SerialReadBlock()
|
---|
172 | : base(type_name)
|
---|
173 | {
|
---|
174 | }
|
---|
175 |
|
---|
176 | public void init()
|
---|
177 | {
|
---|
178 | this.appendDummyInput()
|
---|
179 | .appendField("シリアルからデータを取得します")
|
---|
180 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
181 | this.setInputsInline(true);
|
---|
182 | this.setOutput(true, "Array");
|
---|
183 | this.setColour(160);
|
---|
184 | this.setTooltip("");
|
---|
185 | this.setHelpUrl("http://www.example.com/");
|
---|
186 | }
|
---|
187 | }
|
---|
188 |
|
---|
189 | public class SerialWriteBlock : Block
|
---|
190 | {
|
---|
191 | public const string type_name = "serial_write";
|
---|
192 |
|
---|
193 | public SerialWriteBlock()
|
---|
194 | : base(type_name)
|
---|
195 | {
|
---|
196 | }
|
---|
197 | public void init()
|
---|
198 | {
|
---|
199 | this.appendDummyInput()
|
---|
200 | .appendField("シリアルにデータを出力します")
|
---|
201 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
202 | this.appendValueInput("DATA")
|
---|
203 | .setCheck("String")
|
---|
204 | .appendField("データ");
|
---|
205 | this.appendValueInput("LENGTH")
|
---|
206 | .setCheck("Number")
|
---|
207 | .appendField("データサイズ");
|
---|
208 | this.setInputsInline(true);
|
---|
209 | this.setOutput(true, "Array");
|
---|
210 | this.setColour(160);
|
---|
211 | this.setTooltip("");
|
---|
212 | this.setHelpUrl("http://www.example.com/");
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | public class SerialFlashBlock : Block
|
---|
217 | {
|
---|
218 | public const string type_name = "serial_flash";
|
---|
219 |
|
---|
220 | public SerialFlashBlock()
|
---|
221 | : base(type_name)
|
---|
222 | {
|
---|
223 | }
|
---|
224 |
|
---|
225 | public void init()
|
---|
226 | {
|
---|
227 | this.appendDummyInput()
|
---|
228 | .appendField("シリアルデータをフラッシュします")
|
---|
229 | .appendField(App.TargetBoard.SerialPorts(), "SERIAL_PORT_NO");
|
---|
230 | this.setInputsInline(true);
|
---|
231 | this.setPreviousStatement(true, null);
|
---|
232 | this.setNextStatement(true, null);
|
---|
233 | this.setColour(160);
|
---|
234 | this.setTooltip("");
|
---|
235 | this.setHelpUrl("http://www.example.com/");
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 | partial class Ruby
|
---|
240 | {
|
---|
241 | public node bps_value(BpsValueBlock block)
|
---|
242 | {
|
---|
243 | var value = block.getFieldValue("VALUE");
|
---|
244 | return new int_node(this, value == null ? 0 : Bridge.Script.ParseInt(value, 10));
|
---|
245 | }
|
---|
246 |
|
---|
247 | public node serial_new(SerialNewBlock block)
|
---|
248 | {
|
---|
249 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
250 | var value_bps = valueToCode(block, "BPS");
|
---|
251 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
252 | var c = new const_node(this, intern("Serial"));
|
---|
253 | var p = new node[] {
|
---|
254 | new int_node(this, App.TargetBoard.SerialPortNameToNum(dropdown_serial_port_no)),
|
---|
255 | value_bps
|
---|
256 | };
|
---|
257 | return new asgn_node(this, a, new call_node(this, c, intern("new"), p, null));
|
---|
258 | }
|
---|
259 |
|
---|
260 | public node serial_bps(SerialBpsBlock block)
|
---|
261 | {
|
---|
262 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
263 | var value_bps = valueToCode(block, "BPS");
|
---|
264 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
265 | var p = new node[] {
|
---|
266 | value_bps
|
---|
267 | };
|
---|
268 | return new call_node(this, a, intern("bps"), p, null);
|
---|
269 | }
|
---|
270 |
|
---|
271 | public node serial_print(SerialPrintBlock block)
|
---|
272 | {
|
---|
273 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
274 | var value_str = valueToCode(block, "STR");
|
---|
275 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
276 | var p = new node[] {
|
---|
277 | value_str
|
---|
278 | };
|
---|
279 | return new call_node(this, a, intern("print"), p, null);
|
---|
280 | }
|
---|
281 |
|
---|
282 | public node serial_println(SerialPrintlnBlock block)
|
---|
283 | {
|
---|
284 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
285 | var value_str = valueToCode(block, "STR");
|
---|
286 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
287 | var p = new node[] {
|
---|
288 | value_str
|
---|
289 | };
|
---|
290 | return new call_node(this, a, intern("println"), p, null);
|
---|
291 | }
|
---|
292 |
|
---|
293 | public node serial_available(SerialAvailableBlock block)
|
---|
294 | {
|
---|
295 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
296 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
297 | var p = new node[0];
|
---|
298 | return new call_node(this, a, intern("available"), p, null);
|
---|
299 | }
|
---|
300 |
|
---|
301 | public node serial_read(SerialReadBlock block)
|
---|
302 | {
|
---|
303 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
304 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
305 | var p = new node[0];
|
---|
306 | return new call_node(this, a, intern("read"), p, null);
|
---|
307 | }
|
---|
308 |
|
---|
309 | public node serial_write(SerialWriteBlock block)
|
---|
310 | {
|
---|
311 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
312 | var value_data = valueToCode(block, "DATA");
|
---|
313 | var value_length = valueToCode(block, "LENGTH");
|
---|
314 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
315 | var p = new node[] {
|
---|
316 | value_data,
|
---|
317 | value_length
|
---|
318 | };
|
---|
319 | return new call_node(this, a, intern("write"), p, null);
|
---|
320 | }
|
---|
321 |
|
---|
322 | public node serial_flash(SerialFlashBlock block)
|
---|
323 | {
|
---|
324 | var dropdown_serial_port_no = block.getFieldValue("SERIAL_PORT_NO");
|
---|
325 | var a = new gvar_node(this, intern(App.TargetBoard.SerialPortNameToVariable(dropdown_serial_port_no)));
|
---|
326 | var p = new node[0];
|
---|
327 | return new call_node(this, a, intern("flash"), p, null);
|
---|
328 | }
|
---|
329 | }
|
---|
330 | }
|
---|