[287] | 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$
|
---|
| 36 | */
|
---|
| 37 | using System;
|
---|
[270] | 38 | using System.Collections.Generic;
|
---|
| 39 | using System.Linq;
|
---|
| 40 |
|
---|
| 41 | namespace WebMrbc
|
---|
| 42 | {
|
---|
| 43 | public class MemFileOpenBlock : Block
|
---|
| 44 | {
|
---|
| 45 | public const string type_name = "memfile_open";
|
---|
| 46 |
|
---|
| 47 | public MemFileOpenBlock()
|
---|
| 48 | : base(type_name)
|
---|
| 49 | {
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | public void init()
|
---|
| 53 | {
|
---|
| 54 | this.appendDummyInput()
|
---|
| 55 | .appendField("ファイルをオープンします")
|
---|
[273] | 56 | .appendField(App.TargetBoard.MemFileHandles(), "MEM_FILE_NO");
|
---|
[270] | 57 | this.appendValueInput("FILENAME")
|
---|
| 58 | .setCheck("String")
|
---|
| 59 | .appendField("ファイル名(8.3形式)");
|
---|
| 60 | this.appendDummyInput()
|
---|
| 61 | .appendField("モード")
|
---|
| 62 | .appendField(new FieldDropdown(new[] {
|
---|
| 63 | new[] { "Read", "EEP_READ" },
|
---|
| 64 | new[] { "Append", "EEP_APPEND" },
|
---|
| 65 | new[] { "New Create", "EEP_WRITE" }
|
---|
| 66 | }), "EEP_OPEN_MODE");
|
---|
| 67 | this.setInputsInline(true);
|
---|
| 68 | this.setPreviousStatement(true, null);
|
---|
| 69 | this.setNextStatement(true, null);
|
---|
| 70 | this.setColour(160);
|
---|
| 71 | this.setTooltip("");
|
---|
| 72 | this.setHelpUrl("http://www.example.com/");
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | public class MemFileCloseBlock : Block
|
---|
| 77 | {
|
---|
| 78 | public const string type_name = "memfile_close";
|
---|
| 79 |
|
---|
| 80 | public MemFileCloseBlock()
|
---|
| 81 | : base(type_name)
|
---|
| 82 | {
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | public void init()
|
---|
| 86 | {
|
---|
| 87 | this.appendDummyInput()
|
---|
| 88 | .appendField("ファイルをクローズします")
|
---|
[273] | 89 | .appendField(App.TargetBoard.MemFileHandles(), "MEM_FILE_NO");
|
---|
[270] | 90 | this.setInputsInline(true);
|
---|
| 91 | this.setPreviousStatement(true, null);
|
---|
| 92 | this.setNextStatement(true, null);
|
---|
| 93 | this.setColour(160);
|
---|
| 94 | this.setTooltip("");
|
---|
| 95 | this.setHelpUrl("http://www.example.com/");
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | public class MemFileReadBlock : Block
|
---|
| 100 | {
|
---|
| 101 | public const string type_name = "memfile_read";
|
---|
| 102 |
|
---|
| 103 | public MemFileReadBlock()
|
---|
| 104 | : base(type_name)
|
---|
| 105 | {
|
---|
| 106 | }
|
---|
| 107 | public void init()
|
---|
| 108 | {
|
---|
| 109 | this.appendDummyInput()
|
---|
| 110 | .appendField("ファイルから1バイト読み込みます")
|
---|
[273] | 111 | .appendField(App.TargetBoard.MemFileHandles(), "MEM_FILE_NO");
|
---|
[270] | 112 | this.setInputsInline(true);
|
---|
| 113 | this.setOutput(true, "Number");
|
---|
| 114 | this.setColour(160);
|
---|
| 115 | this.setTooltip("");
|
---|
| 116 | this.setHelpUrl("http://www.example.com/");
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | public class MemFileWriteBlock : Block
|
---|
| 121 | {
|
---|
| 122 | public const string type_name = "memfile_write";
|
---|
| 123 |
|
---|
| 124 | public MemFileWriteBlock()
|
---|
| 125 | : base(type_name)
|
---|
| 126 | {
|
---|
| 127 | }
|
---|
| 128 | public void init()
|
---|
| 129 | {
|
---|
| 130 | this.appendDummyInput()
|
---|
| 131 | .appendField("ファイルにバイナリデータを書き込みます")
|
---|
[273] | 132 | .appendField(App.TargetBoard.MemFileHandles(), "MEM_FILE_NO");
|
---|
[270] | 133 | this.appendValueInput("DATA")
|
---|
| 134 | .setCheck("String")
|
---|
| 135 | .appendField("データ");
|
---|
| 136 | this.appendValueInput("LENGTH")
|
---|
| 137 | .setCheck("Number")
|
---|
| 138 | .appendField("データサイズ");
|
---|
| 139 | this.setInputsInline(true);
|
---|
| 140 | this.setOutput(true, "Number");
|
---|
| 141 | this.setColour(160);
|
---|
| 142 | this.setTooltip("");
|
---|
| 143 | this.setHelpUrl("http://www.example.com/");
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | public class MemFileSeekBlock : Block
|
---|
| 148 | {
|
---|
| 149 | public const string type_name = "memfile_seek";
|
---|
| 150 |
|
---|
| 151 | public MemFileSeekBlock()
|
---|
| 152 | : base(type_name)
|
---|
| 153 | {
|
---|
| 154 | }
|
---|
| 155 | public void init()
|
---|
| 156 | {
|
---|
| 157 | this.appendDummyInput()
|
---|
| 158 | .appendField("ファイルの読み出し位置を移動する")
|
---|
[273] | 159 | .appendField(App.TargetBoard.MemFileHandles(), "MEM_FILE_NO");
|
---|
[270] | 160 | this.appendValueInput("POSITION")
|
---|
| 161 | .setCheck("Number")
|
---|
| 162 | .appendField("seekするバイト数");
|
---|
| 163 | this.setInputsInline(true);
|
---|
| 164 | this.setOutput(true, "Number");
|
---|
| 165 | this.setColour(160);
|
---|
| 166 | this.setTooltip("");
|
---|
| 167 | this.setHelpUrl("http://www.example.com/");
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | public class MemFileCpBlock : Block
|
---|
| 172 | {
|
---|
| 173 | public const string type_name = "memfile_cp";
|
---|
| 174 |
|
---|
| 175 | public MemFileCpBlock()
|
---|
| 176 | : base(type_name)
|
---|
| 177 | {
|
---|
| 178 | }
|
---|
| 179 | public void init()
|
---|
| 180 | {
|
---|
| 181 | this.appendDummyInput()
|
---|
| 182 | .appendField("ファイルをコピーします");
|
---|
| 183 | this.appendValueInput("SRC_FILENAME")
|
---|
| 184 | .setCheck("String")
|
---|
| 185 | .appendField("コピー元ファイル名");
|
---|
| 186 | this.appendValueInput("DST_FILENAME")
|
---|
| 187 | .setCheck("String")
|
---|
| 188 | .appendField("コピー先ファイル名");
|
---|
| 189 | this.appendDummyInput()
|
---|
| 190 | .appendField("モード")
|
---|
| 191 | .appendField(new FieldDropdown(new[] {
|
---|
| 192 | new[] { "上書きしない", "NO_OVERWRITE" },
|
---|
| 193 | new[] { "上書きする", "OVERWRITE" }
|
---|
| 194 | }), "EEP_CP_MODE");
|
---|
| 195 | this.setInputsInline(true);
|
---|
| 196 | this.setOutput(true, "Number");
|
---|
| 197 | this.setColour(160);
|
---|
| 198 | this.setTooltip("");
|
---|
| 199 | this.setHelpUrl("http://www.example.com/");
|
---|
| 200 | }
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | public class MemFileRmBlock : Block
|
---|
| 204 | {
|
---|
| 205 | public const string type_name = "memfile_rm";
|
---|
| 206 |
|
---|
| 207 | public MemFileRmBlock()
|
---|
| 208 | : base(type_name)
|
---|
| 209 | {
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | public void init()
|
---|
| 213 | {
|
---|
| 214 | this.appendDummyInput()
|
---|
| 215 | .appendField("ファイルを削除します");
|
---|
| 216 | this.appendValueInput("FILENAME")
|
---|
| 217 | .setCheck("String")
|
---|
| 218 | .appendField("削除するファイル名");
|
---|
| 219 | this.setInputsInline(true);
|
---|
| 220 | this.setOutput(true, "Number");
|
---|
| 221 | this.setColour(160);
|
---|
| 222 | this.setTooltip("");
|
---|
| 223 | this.setHelpUrl("http://www.example.com/");
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | partial class Ruby
|
---|
| 228 | {
|
---|
| 229 | public node memfile_open(MemFileOpenBlock block)
|
---|
| 230 | {
|
---|
| 231 | var dropdown_mem_file_no = block.getFieldValue("MEM_FILE_NO");
|
---|
| 232 | var value_filename = valueToCode(block, "FILENAME");
|
---|
| 233 | var dropdown_eep_open_mode = block.getFieldValue("EEP_OPEN_MODE");
|
---|
| 234 | var c = new const_node(this, intern("MemFile"));
|
---|
| 235 | var p = new node[] {
|
---|
[273] | 236 | new int_node(this, App.TargetBoard.MemFileHandlerNameToNum(dropdown_mem_file_no)),
|
---|
[270] | 237 | value_filename,
|
---|
[273] | 238 | new int_node(this, App.TargetBoard.MemOpenModeNameToNum(dropdown_eep_open_mode))
|
---|
[270] | 239 | };
|
---|
| 240 | return new call_node(this, c, intern("open"), p, null);
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 | public node memfile_close(MemFileCloseBlock block)
|
---|
| 244 | {
|
---|
| 245 | var dropdown_mem_file_no = block.getFieldValue("MEM_FILE_NO");
|
---|
| 246 | var c = new const_node(this, intern("MemFile"));
|
---|
| 247 | var p = new node[] {
|
---|
[273] | 248 | new int_node(this, App.TargetBoard.MemFileHandlerNameToNum(dropdown_mem_file_no)),
|
---|
[270] | 249 | };
|
---|
| 250 | return new call_node(this, c, intern("close"), p, null);
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | public node memfile_read(MemFileReadBlock block)
|
---|
| 254 | {
|
---|
| 255 | var dropdown_mem_file_no = block.getFieldValue("MEM_FILE_NO");
|
---|
| 256 | var c = new const_node(this, intern("MemFile"));
|
---|
| 257 | var p = new node[] {
|
---|
[273] | 258 | new int_node(this, App.TargetBoard.MemFileHandlerNameToNum(dropdown_mem_file_no)),
|
---|
[270] | 259 | };
|
---|
| 260 | return new call_node(this, c, intern("read"), p, null);
|
---|
| 261 | }
|
---|
| 262 |
|
---|
| 263 | public node memfile_write(MemFileWriteBlock block)
|
---|
| 264 | {
|
---|
| 265 | var dropdown_mem_file_no = block.getFieldValue("MEM_FILE_NO");
|
---|
| 266 | var value_data = valueToCode(block, "DATA");
|
---|
| 267 | var value_length = valueToCode(block, "LENGTH");
|
---|
| 268 | var c = new const_node(this, intern("MemFile"));
|
---|
| 269 | var p = new node[] {
|
---|
[273] | 270 | new int_node(this, App.TargetBoard.MemFileHandlerNameToNum(dropdown_mem_file_no)),
|
---|
[270] | 271 | value_data,
|
---|
| 272 | value_length,
|
---|
| 273 | };
|
---|
| 274 | return new call_node(this, c, intern("write"), p, null);
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | public node memfile_seek(MemFileSeekBlock block)
|
---|
| 278 | {
|
---|
| 279 | var dropdown_mem_file_no = block.getFieldValue("MEM_FILE_NO");
|
---|
| 280 | var value_position = valueToCode(block, "POSITION");
|
---|
| 281 | var c = new const_node(this, intern("MemFile"));
|
---|
| 282 | var p = new node[] {
|
---|
[273] | 283 | new int_node(this, App.TargetBoard.MemFileHandlerNameToNum(dropdown_mem_file_no)),
|
---|
[270] | 284 | value_position,
|
---|
| 285 | };
|
---|
| 286 | return new call_node(this, c, intern("seek"), p, null);
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | public node memfile_cp(MemFileCpBlock block)
|
---|
| 290 | {
|
---|
| 291 | var value_src_filename = valueToCode(block, "SRC_FILENAME");
|
---|
| 292 | var value_dst_filename = valueToCode(block, "DST_FILENAME");
|
---|
| 293 | var dropdown_eep_cp_mode = block.getFieldValue("EEP_CP_MODE");
|
---|
| 294 | var c = new const_node(this, intern("MemFile"));
|
---|
| 295 | var p = new node[] {
|
---|
| 296 | value_dst_filename,
|
---|
| 297 | value_dst_filename,
|
---|
[273] | 298 | new int_node(this, App.TargetBoard.MemCpModeNameToNum(dropdown_eep_cp_mode))
|
---|
[270] | 299 | };
|
---|
| 300 | return new call_node(this, c, intern("cp"), p, null);
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | public node memfile_rm(MemFileRmBlock block)
|
---|
| 304 | {
|
---|
| 305 | var value_filename = valueToCode(block, "FILENAME");
|
---|
| 306 | var c = new const_node(this, intern("MemFile"));
|
---|
| 307 | var p = new node[] {
|
---|
| 308 | value_filename,
|
---|
| 309 | };
|
---|
| 310 | return new call_node(this, c, intern("rm"), p, null);
|
---|
| 311 | }
|
---|
| 312 | }
|
---|
| 313 | }
|
---|