Skip to content

Commit

Permalink
Refactor UpdateArrayValue
Browse files Browse the repository at this point in the history
  • Loading branch information
luiscantero committed Oct 23, 2024
1 parent d3e0d78 commit 9469907
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/PluginNodes/UserDefinedPluginNodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,38 +139,6 @@ private IEnumerable<NodeWithIntervals> AddNodes(FolderState folder, ConfigFolder
}
}

private static object UpdateArrayValue(ConfigNode node, JArray jArrayValue)
{
object arrayValue = jArrayValue;

if (node.DataType == "String")
{
arrayValue = jArrayValue.ToObject<string[]>();
}

if (node.DataType == "Boolean")
{
arrayValue = jArrayValue.ToObject<bool[]>();
}

if (node.DataType == "Float")
{
arrayValue = jArrayValue.ToObject<float[]>();
}

if (node.DataType == "UInt32")
{
arrayValue = jArrayValue.ToObject<uint[]>();
}

if (node.DataType == "Int32")
{
arrayValue = jArrayValue.ToObject<int[]>();
}

return arrayValue;
}

private IEnumerable<NodeWithIntervals> AddFolders(FolderState folder, ConfigFolder cfgFolder)
{
if (cfgFolder.FolderList is null)
Expand Down Expand Up @@ -212,5 +180,37 @@ public void CreateBaseVariable(NodeState parent, ConfigNode node)
}

_plcNodeManager.CreateBaseVariable(parent, node.NodeId, node.Name, new NodeId((uint)nodeDataType), node.ValueRank, accessLevel, node.Description, NamespaceType.OpcPlcApplications, node?.Value);
}

private static object UpdateArrayValue(ConfigNode node, JArray jArrayValue)
{
object arrayValue = jArrayValue;

if (node.DataType == "String")
{
arrayValue = jArrayValue.ToObject<string[]>();
}

if (node.DataType == "Boolean")
{
arrayValue = jArrayValue.ToObject<bool[]>();
}

if (node.DataType == "Float")
{
arrayValue = jArrayValue.ToObject<float[]>();
}

if (node.DataType == "UInt32")
{
arrayValue = jArrayValue.ToObject<uint[]>();
}

if (node.DataType == "Int32")
{
arrayValue = jArrayValue.ToObject<int[]>();
}

return arrayValue;
}
}

0 comments on commit 9469907

Please sign in to comment.