Hello
Is posible in a protocol service get parameters value from the child elements to make some operation?
Thanks
Juan
Hi Juan,
If I understood your question correctly, it can be done if the child element is known.
The documented approach is to use the DataMinerSystem library to retrieve that element and then retrieve the parameter from it.
For a standalone parameter in a QAction, this can be done, for example, as follows:
IDms dms = protocol.GetDms();
IDmsElement childElement = dms.GetElement(new DmsElementId(346, 530006));
IDmsStandaloneParameter<string> parameter = childElement.GetStandaloneParameter<string>(10);
string value = parameter.GetValue();
For table data, retrieve the table through GetTable(...) and then use GetRow(...) or GetData(...), depending on whether a single row or multiple rows are needed.
Hi Juan, you can try retrieving the service with IDms (IDms.GetService).
From the service returned access, you can get the list of included parameters as shown below.
IDmsService.ParameterSettings.IncludedParameters, which contains the ID of the element, but also ServiceParamSettings.ParameterFilters that contain the ID of the parameter.
Please find below a quick example:
public class Script
{
public void Run(IEngine engine)
{
var dms = engine.GetDms();
// Retrieve the service by its ID
int serviceId = 1234; // Replace with your actual service ID
var service = dms.GetService(serviceId);
// Access the included parameters of the service
var includedParameters = service.ParameterSettings.IncludedParameters;
// Iterate through the included parameters to find parameter filters
foreach (var paramSetting in includedParameters)
{
var parameterFilters = paramSetting.ParameterFilters;
// Check if there are any parameter filters
if (parameterFilters != null && parameterFilters.Any())
{
// Retrieve the first parameter ID from the filters
var firstParameterId = parameterFilters.First().ParameterId;
// Output the parameter ID
engine.GenerateInformation($"First Parameter ID from Filter: {firstParameterId}");
break; // Exit after finding the first parameter ID
}
}
}
}
Hi Vasco
I thought about using direct querying to each element, but it requires having the service parameters in the code. Is there any way to query the service for the elements that are already filtered?
Thanks