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')"
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);
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;
what would be the key value – the primary key , display key or the value of column cell/button intended to be trigger