using System; using System.Collections.Generic; using System.Linq; namespace WebMrbc { public class SdExistsBlock : Block { public const string type_name = "sd_exists"; public SdExistsBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルが存在するかどうか調べる"); this.appendValueInput("FILENAME") .setCheck("String"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdMkdirBlock : Block { public const string type_name = "sd_mkdir"; public SdMkdirBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ディレクトリを作成する"); this.appendValueInput("DIRNAME") .setCheck("String"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdRemoveBlock : Block { public const string type_name = "sd_remove"; public SdRemoveBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルを削除する"); this.appendValueInput("FILENAME") .setCheck("String"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdCopyBlock : Block { public const string type_name = "sd_copy"; public SdCopyBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルをコピーする"); this.appendValueInput("SRC_FILENAME") .setCheck("String") .appendField("コピー元ファイル名"); this.appendValueInput("DST_FILENAME") .setCheck("String") .appendField("コピー先ファイル名"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdRmdirBlock : Block { public const string type_name = "sd_rmdir"; public SdRmdirBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ディレクトリを削除する"); this.appendValueInput("DIRNAME") .setCheck("String"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdOpenBlock : Block { public const string type_name = "sd_open"; public SdOpenBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルをオープンします") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.appendValueInput("FILENAME") .setCheck("String") .appendField("ファイル名"); this.appendDummyInput() .appendField("モード") .appendField(new FieldDropdown(new[] { new[] { "Read", "READ" }, new[] { "Append", "APPEND" }, new[] { "New Create", "NEW_CREATE" } }), "SD_OPEN_MODE"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdCloseBlock : Block { public const string type_name = "sd_close"; public SdCloseBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルをクローズします") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdReadBlock : Block { public const string type_name = "sd_read"; public SdReadBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルから1バイト読み込みます") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.setInputsInline(true); this.setOutput(true, "Number"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdSeekBlock : Block { public const string type_name = "sd_seek"; public SdSeekBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルの読み出し位置を移動する") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.appendValueInput("POSITION") .setCheck("Number") .appendField("バイト数"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdWriteBlock : Block { public const string type_name = "sd_write"; public SdWriteBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルにバイナリデータを書き込む") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.appendValueInput("DATA") .setCheck("String") .appendField("データ"); this.appendValueInput("LENGTH") .setCheck("Number") .appendField("データサイズ"); this.setInputsInline(true); this.setOutput(true, "Boolean"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdFlushBlock : Block { public const string type_name = "sd_flush"; public SdFlushBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルの書き込みをフラッシュします") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.setPreviousStatement(true, null); this.setNextStatement(true, null); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdSizeBlock : Block { public const string type_name = "sd_size"; public SdSizeBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルのサイズを取得します") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.setOutput(true, "Number"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } public class SdPositionBlock : Block { public const string type_name = "sd_position"; public SdPositionBlock() : base(type_name) { } public void init() { this.appendDummyInput() .appendField("ファイルのseek位置を取得します") .appendField(App.TargetBoard.SdFileHandles(), "SD_FILE_NO"); this.setOutput(true, "Number"); this.setColour(160); this.setTooltip(""); this.setHelpUrl("http://www.example.com/"); } } partial class Ruby { public node sd_exists(SdExistsBlock block) { var value_filename = valueToCode(block, "FILENAME"); var c = new const_node(this, intern("SD")); var p = new node[] { value_filename, }; return new call_node(this, c, intern("exists"), p, null); } public node sd_mkdir(SdMkdirBlock block) { var value_filename = valueToCode(block, "DIRNAME"); var c = new const_node(this, intern("SD")); var p = new node[] { value_filename, }; return new call_node(this, c, intern("mkdir"), p, null); } public node sd_remove(SdRemoveBlock block) { var value_filename = valueToCode(block, "FILENAME"); var c = new const_node(this, intern("SD")); var p = new node[] { value_filename, }; return new call_node(this, c, intern("remove"), p, null); } public node sd_copy(SdCopyBlock block) { var value_src_filename = valueToCode(block, "SRC_FILENAME"); var value_dst_filename = valueToCode(block, "DST_FILENAME"); var c = new const_node(this, intern("SD")); var p = new node[] { value_src_filename, value_dst_filename, }; return new call_node(this, c, intern("copy"), p, null); } public node sd_rmdir(SdRmdirBlock block) { var value_filename = valueToCode(block, "DIRNAME"); var c = new const_node(this, intern("SD")); var p = new node[] { value_filename, }; return new call_node(this, c, intern("rmdir"), p, null); } public node sd_open(SdOpenBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var value_filename = valueToCode(block, "FILENAME"); var dropdown_sd_open_mode = block.getFieldValue("SD_OPEN_MODE"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), value_filename, new int_node(this, App.TargetBoard.SdOpenModeNameToNum(dropdown_sd_open_mode)), }; return new call_node(this, c, intern("open"), p, null); } public node sd_close(SdCloseBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), }; return new call_node(this, c, intern("close"), p, null); } public node sd_read(SdReadBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), }; return new call_node(this, c, intern("read"), p, null); } public node sd_seek(SdSeekBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var value_position = valueToCode(block, "POSITION"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), value_position, }; return new call_node(this, c, intern("seek"), p, null); } public node sd_write(SdWriteBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var value_data = valueToCode(block, "DATA"); var value_length = valueToCode(block, "LENGTH"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), value_data, value_length, }; return new call_node(this, c, intern("write"), p, null); } public node sd_flush(SdFlushBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), }; return new call_node(this, c, intern("flush"), p, null); } public node sd_size(SdSizeBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), }; return new call_node(this, c, intern("size"), p, null); } public node sd_position(SdPositionBlock block) { var dropdown_sd_file_no = block.getFieldValue("SD_FILE_NO"); var c = new const_node(this, intern("SD")); var p = new node[] { new int_node(this, App.TargetBoard.SdFileHandlerNameToNum(dropdown_sd_file_no)), }; return new call_node(this, c, intern("position"), p, null); } } }