OK. I finally finish the reverse engineering of the speedcam plugin, and I can explain what is happening :
The speedcam icon visibility is triggered by PropLayer.ShowSpeedCam (speedcam_mods.ui)
PropLayer.ShowSpeedCam is linked to MODEL.lua.Speedcam_FirstClick.
MODEL.lua.Speedcam_FirstClick is changed by sc_ResetFirstSpeedcamClick() in speedcam.lua.
sc_ResetFirstSpeedcamClick() is called by sc_ResetFirstSpeedcamClick_new()
sc_ResetFirstSpeedcamClick_new() is called on events when speedcam starts and speedcam ends.
By pressing on speedcam icon on cockpit to mute it, function sc_SpeedcamClick() in speedcam.lua is called.
sc_SpeedcamClick() is calling twice, with a delay, the function sc_ToggleSpeedcamSound(). Twice with a delay, because it's acting like off/on actions.
In sc_ToggleSpeedcamSound() the current speedcam id is saved in the local data gSkippedSpeedcamID of speedcam.lua.
So, when the speedcam "A" has been muted previously, if this speedcam "A" raises again, the speedcam icon in cockpit will not be displayed again. This is voluntary done and I don't understand the reason, because notification, alarm, approach sound, overspeed of this speedcam will work.
And important to notice : when this speedcam "A" will be "on back" phase, the speedcam icon will be displayed !! It has no sense to display it now and not before.
Could be that this code is a rest of an old part of code when the functionnality was completed. Or if PONGO can explain why this code is always existing, I'm curious to know.
In case of an average speedcam : When doing the manual stop of the average speedcam alert, the speedcam id is always 0.
This is because MODEL.navigation.curr_speedcam.id() is only known at section begin and end positions. Outside of the speedcam position, id is 0. So, id 0 is saved in gSkippedSpeedcamID.
On the next average speedcam zone, the beginning of the speedcam is detected and the icon is displayed at this moment because MODEL.navigation.curr_speedcam.id() exists and is different than gSkippedSpeedcamID = 0.
But few meters later, when the speedcam is on back, MODEL.navigation.curr_speedcam.id() is 0 again, and now is equal to gSkippedSpeedcamID. Then, the speedcam icon disappears, even if the average zone is always correctly detected and sounded.
On speedcam end position, if the end of the section is correctly detected, function sc_ToggleSpeedcamSound() is called twice by function sc_SetLastSpeedcamSpeedLimit(). Because we are at a speedcam position, MODEL.navigation.curr_speedcam.id() is valid and is saved in gSkippedSpeedcamID
This is explaining why the icon of speedcam section will appear again in the next section if the section end is correctly detected, and why not if the section end is not detected.
I would propose to apply the following changes in speedcam.lua to delete this weird reaction. It's just deleting some few parts of the code.
Spoiler: +
I also made some other corrections in speedcam.lua :
- Avoid the speedcam icon in cockpit blinking when an average speedcam section is starting
- Detecting the average speedcam end, even if the speed of the end point is not 5km/h (it works with 5 or without).
If you are interresting of this changes, please let me know.
I'm also working on the case of speedcam without speed. Problem is, especially in town, that the speed at the beginning of the alarm can be different than the speed at the speedcam position. It's bad to announce "50 km/h" to the driver if 10m later, it's 30km/h. I think it's better to announce a speedcam without speed information in that case.



Likes: 




Reply With Quote

Bookmarks