Skip to content

Commit

Permalink
handeling blockType parameter for setblock() command
Browse files Browse the repository at this point in the history
fixing node[N].defbuffer1 and  node[N].defbuffer2 not available in node configurations

making sure that node[N].execute(), node[N].getglobal() and
node[N].setglobal() is only available with node
  • Loading branch information
jharajeev55 committed Dec 11, 2024
1 parent f977f37 commit bee6e53
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 255 deletions.
59 changes: 44 additions & 15 deletions Json_parser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,24 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)
}

var factoryScriptCommands = cmdList.Where(cmd => cmd.description.Contains("factory script")).ToList(); // get factoryScriptCommands and remove it, its there for 26xx models

cmdList = cmdList.Except(factoryScriptCommands).ToList(); // remove all factoryScriptCommands commands

var directFunctioncommands = cmdList.Where(cmd => !cmd.name.Contains('.')).ToList();
cmdList = cmdList.Except(directFunctioncommands).ToList(); // remove all directFunctioncommands commands and handle it speratley


var triggerModelLoadCommands = cmdList.Where(cmd => cmd.name.Contains("trigger.model.load()")).ToList(); // get trigger.model.load() commands
cmdList = cmdList.Except(triggerModelLoadCommands).ToList(); // remove all trigger.model.load() commands and handle it speratley

var triggerBlockConstants = cmdList.Where(cmd => cmd.name.Contains("trigger.BLOCK_")).ToList();
cmdList = cmdList.Except(triggerBlockConstants).ToList();
var triggerModelSetblockCommands = cmdList.Where(cmd => cmd.name.Contains("trigger.model.setblock()")).ToList();
cmdList = cmdList.Except(triggerModelSetblockCommands).ToList();

var commad_only_for_tspLinkNodes = cmdList.Where(cmd => cmd.name.Contains("node[N].")).ToList();
cmdList = cmdList.Except(commad_only_for_tspLinkNodes).ToList();

cmdList = cmdList.Except(directFunctioncommands).ToList(); // remove all directFunctioncommands commands and handle it speratley

cmdList = cmdList.Except(triggerModelLoadCommands).ToList(); // remove all trigger.model.load() commands and handle it speratley




foreach (var cmd in cmdList)
Expand Down Expand Up @@ -129,36 +133,61 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)
outStr += header;
tsplinkStr += header;
}
outStr += "\n" + get_trigger_load_cmd_signature();
tsplinkStr += "\n" + get_trigger_load_cmd_signature(true);
}

if (triggerModelSetblockCommands.Count > 0)
{
var defStr = @"
---This is generic function to define trigger model setblock.
---Signature of this function depends on the BlockType.
---For more details, please keep scrolling to find the required function signature for specific BlockType
---";
outStr += $"{get_BlockType_alias()}"+defStr;
tsplinkStr += $"{get_BlockType_alias(true)}" + defStr;

foreach (var cmd in triggerModelSetblockCommands)
{
var header = Utility.get_command_header(cmd, file_name);
outStr += header;
tsplinkStr += header;
}

var sig = "\n" + @"---@param loadFunConst loadFunConstParam
function trigger.model.load(loadFunConst,...) end";
outStr += sig;
tsplinkStr += sig;

outStr += get_trigger_model_setBlock_cmd_signature();
tsplinkStr += get_trigger_model_setBlock_cmd_signature(true);
}

if (commad_only_for_tspLinkNodes.Count > 0)
{
foreach (var cmd in commad_only_for_tspLinkNodes)
{
var cmd_info = new KeyValuePair<string, CommandInfo>(cmd.name.Split('.')[1], cmd);
tsplinkStr += Utility.HelpContent(cmd_info, file_name, "", false, true);
}
}


if (file_name.Contains("26"))
{

// Add specific handling for 26 models if needed
}

else if (file_name.Contains("37"))
{
// Add specific handling for 37 models if needed
}
else // for tti models
{


outStr += get_def_buffer_definations();
tsplinkStr += get_def_buffer_definations(true);
}

Directory.CreateDirectory(Path.Combine(base_lib_dir, model));
Directory.CreateDirectory(Path.Combine(base_lib_dir, model, "tspLinkSupportedCommands"));
Directory.CreateDirectory(Path.Combine(base_lib_dir, model, "AllTspCommands"));
Directory.CreateDirectory(Path.Combine(base_lib_dir, model, "Helper"));


var AllTspCommandsFilePath = $"{base_lib_dir}/{model}/AllTspCommands/definitions.lua";
var tspLinkSupportedCommandsFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/definitions.txt";

Expand Down
5 changes: 0 additions & 5 deletions Json_parser/StaticLuaDefinations/2450/defbuffers.lua

This file was deleted.

6 changes: 0 additions & 6 deletions Json_parser/StaticLuaDefinations/2450/setBlock.lua

This file was deleted.

47 changes: 0 additions & 47 deletions Json_parser/StaticLuaDefinations/2450/triggerBlockBranch.lua

This file was deleted.

5 changes: 0 additions & 5 deletions Json_parser/StaticLuaDefinations/2460/defbuffers.lua

This file was deleted.

6 changes: 0 additions & 6 deletions Json_parser/StaticLuaDefinations/2460/setBlock.lua

This file was deleted.

47 changes: 0 additions & 47 deletions Json_parser/StaticLuaDefinations/2460/triggerBlockBranch.lua

This file was deleted.

5 changes: 0 additions & 5 deletions Json_parser/StaticLuaDefinations/2461/defbuffers.lua

This file was deleted.

6 changes: 0 additions & 6 deletions Json_parser/StaticLuaDefinations/2461/setBlock.lua

This file was deleted.

47 changes: 0 additions & 47 deletions Json_parser/StaticLuaDefinations/2461/triggerBlockBranch.lua

This file was deleted.

5 changes: 0 additions & 5 deletions Json_parser/StaticLuaDefinations/2470/defbuffers.lua

This file was deleted.

6 changes: 0 additions & 6 deletions Json_parser/StaticLuaDefinations/2470/setBlock.lua

This file was deleted.

47 changes: 0 additions & 47 deletions Json_parser/StaticLuaDefinations/2470/triggerBlockBranch.lua

This file was deleted.

Loading

0 comments on commit bee6e53

Please sign in to comment.