Hi Dojo,
I'm working on http driver which has services which can have multiple channels. Every channel can have multiple alarms on it. Driver has implemented buffer logic because we can poll only alarms on specified channels.
The problem is that we don't get any unique field from alarms request.
First there was problem with huge "Channel Alarms" table which is filled with FillArrayNoDelete (there is mechanism for deleting rows based on date). But that was odd because in web UI user see only 6 alarms and in driver there was 700 multiplicated alarms that are filled every time we poll for channel that have alarms on it.
Solution was to create unique primary key in following format serviceId/channelId/randomNumber (randomNumber is there to have something unique). Every time we poll alarms for channelId with serviceId we will delete those rows and then fillArrayNoDelete with new rows that we received. So now user can see only 6 alarms in driver like it see it on Web Interface.
But when user create alarm template it will again see 700 multiplicated alarms per day because we fill table with "new" alarms from last poll. Is there any solution for this case (driver based or alarm template based)?
Hi Dario,
There is one potential solution that comes to my mind that is similar to what I had to implement once.
You will need to have that "randomNumber" be deterministic so that for the same alarm the value will always be the same no matter if you polled it now or yesterday. In the past, I used things like creation time or if nothing like that is available I hashed the entire content of the alarm object to achieve a smaller key.
By having the deterministic ID you can now do a FillArray without the need to delete rows first.
Alternatively, you could read the existing rows and compare them with the incoming data to determine which rows need to be either added, updated, or deleted.
But the main thing here to not have new alarms being generated daily is that you should not clear the table first.