I have two tables, inputs and outputs. The output table contains a column "connected inputs" which contains PKs from the input table.
I want to get all the display keys for outputs connected to a few selected inputs (also based on display keys). At the moment I need to get all the table display keys from from the input table, filter based on the display keys I want, then FindPrimaryKey for those rows. Then I get all the display keys for the output table and since we can't fetch an entire table or a column which isn't PK or DK column I need to do GetParameter on each row in the output table (1700+ rows) to get the Connected Input for each output which is taking a looong time so that I can then filter the outputs to the ones using a specific input.
This is a script that runs when opening the visual overview; right now it takes 20+ seconds to load the visual overview since the script blocks the screen until finished. Is there a way to speed this up?
var prefix = (string) engine.GetScriptParam("Prefix").Value;
var dummy = engine.GetDummy("dummy");// inputs we want
string[] sourceKeys = dummy.GetTableDisplayKeys(1400)
.Where(dk => dk.StartsWith(prefix + " AUX "))
.OrderBy(dk => dk)
.Select(dk => dummy.FindPrimaryKey(1400, dk))
.ToArray<string>();// populate dict to speed up filtering
var destinations = new Dictionary<string, List<string>>();foreach(var dk in dummy.GetTableDisplayKeys(1500))
{
var connectedInput = (string) dummy.GetParameter(1506, dk);
if (!String.IsNullOrEmpty(connectedInput) && Array.Exists(sourceKeys, key => key.Equals(connectedInput))) {
if(!destinations.ContainsKey(connectedInput))
destinations[connectedInput] = new List<string>();
destinations[connectedInput].Add(dk);
}
}// return outputs connected to each input
for(var i = 0; i< sourceKeys.Length; i++)
{
if (destinations.ContainsKey(sourceKeys[i]))
engine.AddScriptOutput(UIVariables.VisualOverview.CreateKey($"Aux{i+1}"), string.Join(", ", destinations[sourceKeys[i]]));
}
Hi,
If you have DIS then you can create the automation script solution through DIS and make use of the class library.
The start point for the class library help can be found here .
You'll need to retrieve the IDmsTable object and on that object call the QueryData method with the ColumnFilter that you're trying to filter on (see method info here)
To summarize it will be something like below (note that I didn't verify the syntax) :
-Add the needed references:
using Skyline.DataMiner.Library.Automation;
using Skyline.DataMiner.Library.Common;
-Access the dms object (IDms dms = engine.GetDms(); )
-Get the element (IDmsElement element = dms.GetElement("elementName"); )
-Get the table (IDmsTable table = element.GetTable(tablePid); )
-Construct the filter (List<ColumnFilter> filter = new List<ColumnFilter>
{
new ColumnFilter {Pid=columnPid, Value="filterValue"}
}; )
-Query the table (IEnumerable<object[]> result = table.QueryData(filter); )
Thank you! That sped up things significantly.