Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.18.3 #14

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
Fixed -- for any bug fixes.
Security -- in case of vulnerabilities.
-->
## [0.18.3]

### Added
- support dynamically creating enums for configured nodes

## [0.18.2]

Expand Down Expand Up @@ -49,7 +53,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
- workflow has been added for generaing json artifacts.

<!--Version Comparison Links-->
[Unreleased]: https://github.com/tektronix/tsp-toolkit-webhelp-to-json/compare/v0.18.2...HEAD
[Unreleased]: https://github.com/tektronix/tsp-toolkit-webhelp-to-json/compare/v0.18.3...HEAD
[0.18.3]: https://github.com/tektronix/tsp-toolkit-webhelp-to-json/releases/tag/v0.18.3
[0.18.2]: https://github.com/tektronix/tsp-toolkit-webhelp-to-json/releases/tag/v0.18.2
[0.18.1]: https://github.com/tektronix/tsp-toolkit-webhelp-to-json/releases/tag/v0.18.1
[0.18.0]: https://github.com/tektronix/tsp-toolkit-webhelp-to-json/releases/tag/v0.18.0
Expand Down
5 changes: 4 additions & 1 deletion Configuration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Folder path of webhelp file
import os

class Confiurations:
class Configuration:
HELP_FILE_FOLDER_PATH = ""

MANUALLY_EXTRACTED_COMMANDS = {}
PARAMS_TYPES_DETAILS = {}

# model number
MODEL_NUMBER = ""

Expand Down
71 changes: 12 additions & 59 deletions Json_parser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)
Console.WriteLine(cmdList.First());
var outStr = "---@meta\n\n";
int MAX_DEPT = 10;
var nodeTable = new HashSet<string>();
Dictionary<string, Dictionary<string, CommandInfo>>[] instrTable = new Dictionary<string, Dictionary<string, CommandInfo>>[MAX_DEPT];
for (int i = 0; i < MAX_DEPT; i++)
{
Expand All @@ -71,35 +70,20 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)

var triggerModelLoadCommands = cmdList.Where(cmd => cmd.name.Contains("trigger.model.load()")).ToList(); // get trigger.model.load() commands

var bufferMathCommand = cmdList.Where(cmd => cmd.name.Contains("buffer.math()")).ToList();

var triggerBlockConstants = cmdList.Where(cmd => cmd.name.Contains("trigger.BLOCK_")).ToList();
cmdList = cmdList.Except(triggerBlockConstants).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

cmdList = cmdList.Except(bufferMathCommand).ToList(); // remove "buffer.math()" commands and handle it speratley


foreach (var cmd in cmdList)
{
string s = cmd.name;
var tSplit = s.Contains(".") ? s.Trim().Split('.') : s.Trim().Split(':');
if (cmd.tsplink_supported.Contains("Yes"))
{
//if (tSplit[0] == "bufferVar")
//continue;
if (tSplit.Length > 1)
{
nodeTable.Add(tSplit[0] + " = " + tSplit[0]);
}
else
{
nodeTable.Add(s.Contains('(') ? s.Split('(')[0] + " = " + s.Split('(')[0] : s + " = " + s);
}
}



for (int i = 0; i < tSplit.Length - 1; i++)
{//ignore functions
string attr = null;
Expand All @@ -121,15 +105,16 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)

outStr += "---@class io_object\nlocal io_object={}\n---@class scriptVar\nlocal scriptVar={}\n---@class eventID\n\n---@class file_object\nlocal file_object ={}\n\n"; //PRIV
outStr += "---@class bufferVar\nlocal bufferVar={}\n";
outStr += "---@class digio\n digio = {}\n\n---@class tsplink\n tsplink = {}\n\n---@class lan\n lan = {}\n\n---@class tspnetConnectionID\nlocal tspnetConnectionID = {}\n\n ---@class promptID\nlocal promptID = {}\n\n";
outStr += "---@class digio\n local digio = {}\n\n---@class tsplink\n local tsplink = {}\n\n---@class lan\n local lan = {}\n\n---@class tspnetConnectionID\nlocal tspnetConnectionID = {}\n\n ---@class promptID\nlocal promptID = {}\n\n";

var tsplinkStr = "";
string[] arrlist = { };
tsplinkStr = outStr;
Utility.PrintFields(MAX_DEPT, file_name, ref instrTable, ref outStr, ref tsplinkStr, ref arrlist, "null");
tsplinkStr += Utility.PrintFields(MAX_DEPT, file_name, instrTable, true);
outStr += Utility.PrintFields(MAX_DEPT, file_name, instrTable, false);
foreach (var cmd in directFunctioncommands)
{
Utility.HelpContent(cmd, file_name, ref outStr, ref tsplinkStr, "", true, "", "", true);
var cmd_info = new KeyValuePair<string, CommandInfo>(cmd.name, cmd);
outStr += Utility.HelpContent(cmd_info, file_name, "", true);
}

if (triggerModelLoadCommands.Count > 0)
Expand All @@ -138,18 +123,13 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)
outStr += defStr;
tsplinkStr += defStr;

// IList<string> aliasTypes = new List<string>();

foreach (var cmd in triggerModelLoadCommands)
{
// aliasTypes.Add(cmd.name.Split('-')[1].Trim());
var header = Utility.get_command_header(cmd, file_name);
outStr += header;
tsplinkStr += header;
}

//outStr+= Utility.create_alias_type("loadFunConstParam", aliasTypes);
//tsplinkStr += Utility.create_alias_type("loadFunConstParam", aliasTypes);
var sig = "\n" + @"---@param loadFunConst loadFunConstParam
function trigger.model.load(loadFunConst,...) end";
outStr += sig;
Expand All @@ -158,24 +138,7 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)

}

if (bufferMathCommand.Count > 0)
{
var alias = Utility.create_enum_alias_type(bufferMathCommand[0].param_info[1]);
var header = Utility.get_command_header(bufferMathCommand[0], file_name);

outStr += alias + header;
tsplinkStr += alias + header;

Utility.append_buffermath_signature(ref outStr);
Utility.append_buffermath_signature(ref tsplinkStr);

}

nodeTable.Remove("node[N] = node[N]"); // for now removing this command from nodeTable because its creating problem in lua definitions
nodeTable.Remove("slot[slot] = slot[slot]"); // for now removing this command from nodeTable because its creating problem in lua definition




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

Expand All @@ -187,35 +150,25 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)
else // for tti models
{

nodeTable.Add("defbuffer1 = defbuffer1");
nodeTable.Add("defbuffer2 = defbuffer2");

}

var nodeTable_str = @"{" + string.Join(",\n ", nodeTable) + "\n}";
var node_class_name = Regex.Replace(file_name, @"[^a-zA-Z0-9_]", "");
var nodeTableDetails = $"---@meta\n\n---@class model{node_class_name}\nmodel{node_class_name} = {nodeTable_str}" +
$"\n--#region node details\n--#endregion";

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 nodeTableFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/nodeTable.lua";
var AllTspCommandsFilePath = $"{base_lib_dir}/{model}/AllTspCommands/" + file_name + ".lua";
var tspLinkSupportedCommandsFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/" + file_name + "_TSPLink.lua";
var AllTspCommandsFilePath = $"{base_lib_dir}/{model}/AllTspCommands/definitions.lua";
var tspLinkSupportedCommandsFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/definitions.txt";

var static_folder_Path = Path.Combine(base_lib_dir, model, "Helper");

Utility.CopyStaticFiles(model, static_folder_Path);

Utility.write_to_file(nodeTableFilePath, nodeTableDetails);
Utility.write_to_file(AllTspCommandsFilePath, outStr);
Utility.write_to_file(tspLinkSupportedCommandsFilePath, tsplinkStr);

Utility.SetFileReadOnly(nodeTableFilePath);
Utility.SetFileReadOnly(AllTspCommandsFilePath);
Utility.SetFileReadOnly(tspLinkSupportedCommandsFilePath);

Expand Down
8 changes: 8 additions & 0 deletions Json_parser/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"jsonToLuaParser": {
"commandName": "Project",
"commandLineArgs": "C:\\Users\\rjha\\source\\repos\\GitHub\\tsp-toolkit-webhelp-to-json\\data"
}
}
}
10 changes: 0 additions & 10 deletions Json_parser/StaticLuaDefinations/2450/bufferCustomUnit.lua

This file was deleted.

61 changes: 0 additions & 61 deletions Json_parser/StaticLuaDefinations/2450/bufferFileSaveDetails.lua

This file was deleted.

21 changes: 0 additions & 21 deletions Json_parser/StaticLuaDefinations/2450/bufferVarstatuses.lua

This file was deleted.

13 changes: 0 additions & 13 deletions Json_parser/StaticLuaDefinations/2450/buttonPressAlias.lua

This file was deleted.

16 changes: 0 additions & 16 deletions Json_parser/StaticLuaDefinations/2450/channelMatchType.lua

This file was deleted.

8 changes: 0 additions & 8 deletions Json_parser/StaticLuaDefinations/2450/displayText.lua

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions Json_parser/StaticLuaDefinations/2450/functionality.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---@meta
channel = {}
digio = {}
gpib = {}
serial = {}
tsplink = {}
local channel = {}
local digio = {}
local gpib = {}
local serial = {}
local tsplink = {}
---@alias functionality
---| `channel`
---| `digio`
Expand Down
Loading
Loading