Hello ,
I have been trying to use the SetParamerter method in the script class to trigger a specific component of an element that has been found by the correlation rule filters.My full automation script is fully functioning but breaks in the SetParameter line ( used print statement and exceptions for checking).I believe I am having issues with the parameters used inside the () of the method.
I have tried out both SetParameter and SetParameterByPrimaryKey , using the parameterId,primaryKey,object value and IDx (depending on the method).
From my understanding of the primary key , it is unique for each component in an element ,so usually it should be hardcoded with exact value/string. But using my script , I wanted to dynamically initialize the parameter or put a part of the full string which will help to identify the exact position of the cell in the components list of the element. Could anyone please guide through where I am going wrong.
The error message:
An error occurred while setting the parameter: Set Parameter ('_117620_1711':10140/) Failed: 0x80004005 (Script 'Failure Alarm')"
Hi,
When the button is in a table, you need to provide the exact key to the SetParameter method.
In case your script does not know the exact value of the key, you can use GeTablePrimaryKeys/GetTableDisplayKeys to get the entire list of keys that are part of the table. Then, try to identify the key that you need and use it in the SetParameter method.
I want to dynamically initialize the primary key if possible, so i can feed different elements with the same parameter ID in the same driver
Just use SetParameter and it will work well (FYI, SetParameter accepts both index and display key of a table, while SetParameterByPrimaryKey will only accept the index).
I’m not sure to understand what you want to do. Do you want to use same script for different elements and therefore performing SET actions on rows having different keys , and passing the key as input argument ?
If that’s the case, then you need to extend your script with Parameters ( https://docs.dataminer.services/user-guide/Advanced_Modules/Automation_module/Designing_Automation_scripts/Script_variables.html#creating-a-parameter) , and retrieve the value of the parameter in your script ( https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Automation.Engine.GetScriptParam.html )
I have created a correlation rule with specific alarm properties , and executes a specific automation script (This one) every time those alarms are detected. Upon detection and parsing of required information, it has a restart button in the component section which needs to be triggered by the SetParameter.So yes the same script will be used to dynamically find all elements affected by the alarm and execute the action on the specific component.
If your trying to trigger a button you will need this: element.setParameter(10140,1);
try this in your code first
if it is in a Table then it would be element.setParameter(10140, *key value here * , 1);
what would be the key value – the primary key , display key or the value of column cell/button intended to be trigger
The Display key of the row
If you want to use primary key it would be element.SetParameterByPrimaryKey(10140, PrimaryKey, 1);
I tired both methods and the SetByPrimaryKey is the only one that works but it would not be ideal for me to use the primary key as it is unique for individual parameter and hence If I declare that exact string it will not allow me to catch other element alarms and trigger the button. When I use SetParameter the exception catches it
Ah I see well it depends how and what should trigger the Restart as for my automation project I use different elements and made a loop to get the Primarykey value for the able than loop again for specific value I need and than that becomes the primary key I will use.
key = elem.GetTablePrimaryKeys(14600);
string[] temp = ip_Name.Split(‘.’);
foreach (string s in key)
{
if (!string.IsNullOrEmpty(s))
{
controller.Engine.Log(elem.GetParameterDisplayByPrimaryKey(14616, s));
if (elem.GetParameterDisplayByPrimaryKey(14616, s) == “Not initialized” || elem.GetParameterDisplayByPrimaryKey(14616, s) == “(not initialized)”)
{
}
else
{
out_port_int.Add(Int32.Parse(elem.GetParameterDisplayByPrimaryKey(14616, s)));
}
}
}
int[] port_collection = out_port_int.ToArray();
int max = port_collection.Max();
int last_value = port_collection.Length;
controller.Engine.Log(“Make to assign value:” + max);
port = max + 1;
will there be a difference if i used setParameterByPrimaryKey or just SetParameter , I know the display key ( which is a better verification parameter for my case)