A generic C# template to parse all of the elements in a single view and compare it with a protocol , and pass the matched item to another script.
As this question has now been inactive for a long time, I will close it. If you still want more information, could you post a new question?
Hi,
You should be able to use Skyline's Class Library to achieve something aligned with what you describe here.
After installing the NuGet package you should be able to do something similar to the snippet below
var dms = engine.GetDms(); // or protocol.GetDms() if in a protocol QAction
var view = dms.GetView("MyViewName");
var elements = view.Elements;
foreach (var element in elements)
{
if (element.Protocol.Name == "MyProtocol" && element.Protocol.Version == "1.0.0.1")
{
// do something
}
}
Additionally, if you want to also have the elements not only in the specified view but also in child views you can repeat the process above with the following
var childViews = view.ChildViews;
References:
Method dms.GetView | DataMiner Docs
Interface IDmsView | DataMiner Docs
For calling a subscript from another script you can use an example similar to the one found on this docs page Method PrepareSubScript | DataMiner Docs together with the Method SelectScriptParam | DataMiner Docs.
Hi Joao, Thankyou so much for your answer, much appreciated , could you please explain a bit further that how would i pass parameter in the protocol.get function viewid.get function
Hi Syeda,
Not sure if I understand your follow-up question correctly but based on your other question (https://community.dataminer.services/question/c-template-a-loop-to-trigger-a-button-on-a-device-based-on-protocol/) you should be able to call your logic in a script and then from within a script use the GetScriptParam method (https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Automation.Engine.GetScriptParam.html)
With it, you would now have your input parameters as strings and could use them to replace the snippets above where I have the “MyViewName”, “MyProtocol” and “1.0.0.1” placeholders.
I see that this question has been inactive for some time. Do you still need help with this? If not, could you select the answer (using the ✓ icon) to indicate that the question is resolved?