I'm trying to create some reports based on information events. However in the dashboards and low-codes apps i can't access those. So i was looking in fetching the through an automation script. I found the following example on dojo: https://community.dataminer.services/question/paging-when-using-getalarmdetailsfromdbmessage-and-sendslnetmessage-calls/ and it takes a long time to retrieve the information events, if i use it to retrieve alarms it is very quick. I'm i using this wrong?
This takes around 40 seconds to retrieve one information events:
AlarmFilter af = new AlarmFilter();
AlarmFilterItem afi = new AlarmFilterItemString(
AlarmFilterField.ParameterDescription,
AlarmFilterCompareType.WildcardEquality,
new string[] { "Connected Input (Virtual Outputs)*" }
);
af.FilterItems = new AlarmFilterItem[] { afi };
DateTime startTime = new DateTime(2023, 12, 07, 00, 00, 00);
DateTime endTime = new DateTime(2023, 12, 08, 23, 59, 59);
var repostoryRegistery = SLDataGateway.API.Repositories.Registry.DatabaseRepositoryRegistryBuilder.Default
.WithConnection(Engine.SLNetRaw)
.Build();
var alarmRepository = repostoryRegistery.Get<IInfoRepository>();
var alarmsfromDB = alarmRepository.Read(af, startTime, endTime)
.Cast<AlarmEventMessage>()
.ToList();
engine.GenerateInformation($" count {alarmsfromDB.Count()}");
foreach( var alarm in alarmsfromDB )
{
engine.GenerateInformation($"Source {alarm.DisplayValue} {alarm.Severity} desti {alarm.ParameterName}");
}
With a few checks most of the time is spend in the
var alarmsfromDB = alarmRepository.Read(af, startTime, endTime)
.Cast<AlarmEventMessage>()
.ToList();
Is there an option to speed this up a bit? (increasing the amount of information messages doesn't seems to influence the timing at all, so if there is no other option i think it would work.
Hello Gerwin,
In the filters that you can pass along, filters that will help in pre-filtering and limiting the result of the database are of type ParameterID. Basically limiting the set of information events to either 1 element (by leaving the Parameter ID to -1 and Instance an empty string). 1 parameter (by adding the parameter ID value) of 1 cell (by adding the Instance value).
All the rest is done in post filtering hence the reason why the performance is similar. The reason the alarms might go faster than the information events are probably due to the amount you receive back.
An example to fetch the information events for an element with DMAID 1047 and element ID 7:
var elementFilter = new AlarmFilterItemString(AlarmFilterField.ElementID, AlarmFilterCompareType.Equality, new string[] { “1047/7” });
AlarmFilter AF = new AlarmFilter(elementFilter);
Hi Davy,
Would you have an example of such a filter?