I've used OpenCPN this summer during two months of sailing. My VHF with AIS is connected to my PC.
The AISalarm is set to 2 miles and 30 minutes. I'v found a little problem (really not blocking).

When the CPA/TCPA is inside the limit an alarm window appears which can be aknoledged, and the window doesn't re-appear again...

EXCEPT, if the CPA/TCPA is close to the limit (2 miles / 30 minutes) and go inside then outside then inside again of this limit.

- going inside, the target becomes red, the alarm appears : acknoledge
- going outside, the target becomes green, and I think is removed from a table or list of dangerous targets.
- going inside again, the target becomes red again, and the alarm re-appears although it has been acknoledged a few seconds before.

It can occurs many many times, because each time a target becomes dangerous, OpenCPN has forgotten it has been already acknoledged.

Tricky one. Whilst someone has reported this issue as a feature request they haven't asked for it to be implemented in any specific way.

Calling it an alarm loop surely is not correct. OpenCPN is merely working perfectly as configured & providing alarm to individual instrusions into the user defined limits. The exact same issue can happen with a guard zone alarm on radar.

Any mod to avoid this happening regularly would remove or reduce the defined safety margin either with an individual target or any at all, albeit for maybe a short period.

I guess you could have an "ignore repeat marginal target alarm" option. A database could be built for each target intrusion recording the distance/time the intrusion alarm was canceled. Only further instrusions into this new reduced limit would cause the alarm to trigger for that particular target. The user would need to be vigilant of the reduced time/distance limits though. There would also have to be a timeout beyond which a particular targets data was flushed.

I can't see a totally safe software answer to this issue. I would suggest the user take control & change the alarm trigger to suit. This puts the responsibility quite rightly on his/her shoulders rather than the programmers.

What you are looking for is hysteresis. That is, after an alarm has been acknowledged, the CPA/TCPA limits for that target is reduced by X% of the original limits.

One way to implement this is to use an acknowledgement count. Where each count equals a 10% reduction in the CPA/TCPA limits. Thus, if the acknowledgement count is limited to 5 then the original CPA/TCPA of 2 miles and 30 minutes would dynamically change to 1 miles and 15 minutes. This particular implementation results in a maximum of 5 acknowledgements and a 50% reduction in the CPA/TCPA limits. There are of course many other possible implementations.