YoloWingPixie / lsobot

A log scrapper for DCS World that checks for new carrier landing grades made by humans and sends them to Discord.
MIT License
11 stars 8 forks source link

[BUG] Duplicate Grade Sent to Discord #14

Open DCAFOC opened 3 years ago

DCAFOC commented 3 years ago

Please attach your dcs.log for when the bug is experienced

dcs.log

2021-05-26 17:40:06.323 INFO Scripting: event:type=land,initiatorPilotName=200 Rebound,place=CVN-71,t=2422.683,initiatorMissionID=976, 2021-05-26 17:40:07.684 INFO Scripting: event:type=landing quality mark,initiatorPilotName=200 Rebound,place=CVN-71,t=2424.04,comment=LSO: GRADE:C : WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 EGIW [BC],initiatorMissionID=976,

Event Log lsobot-debug.txt

2021-05-26 12:39:51:783 | INFO | JOB | Begin cycle 8 of 40 2021-05-26 12:39:52:264 | INFO | DETECT | Landing detected at 2021-05-26 17:34:20 UTC 2021-05-26 12:39:52:266 | INFO | TIMING | Time diference from the start of the loop is 00:05:31.7830000 2021-05-26 12:39:52:269 | INFO | Raw Grade is GRADE:--- : WIRE# 2 EGIW [BC] 2021-05-26 12:39:52:278 | INFO | REGEX | Found no deviations and a #2 or #4 WIRE. Graded as OK. 2021-05-26 12:39:52:281 | INFO | REGEX | Regraded Grade: OK (Acceptable): WIRE# 2 2021-05-26 12:39:52:289 | WARNING | TIMING | Landing detected at 2021-05-26 17:34:20 is too old. Excepted interval was 00:00:15.7500000. Discarding. 2021-05-26 12:39:52:291 | INFO | JOB | LSO BOT loop duration was 00:00:00.5080000 2021-05-26 12:39:52:293 | INFO | TIMING | Sleep duration is now 15242 based on 00:00:15.7500000 - 00:00:00.5080000 2021-05-26 12:39:52:294 | INFO | TIMING | LSO BOT Cycle Ran. Sleeping for 15242 milliseconds 2021-05-26 12:40:07:549 | INFO | JOB | Begin cycle 9 of 40 2021-05-26 12:40:07:986 | INFO | DETECT | Landing detected at 2021-05-26 17:40:07 UTC 2021-05-26 12:40:07:986 | INFO | TIMING | Time diference from the start of the loop is 00:00:00.5510000 2021-05-26 12:40:07:986 | INFO | Raw Grade is GRADE:C : WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 EGIW [BC] 2021-05-26 12:40:07:986 | INFO | REGEX | Regraded Grade: C (CUT): WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 2021-05-26 12:40:08:658 | INFO | DISCORD | A landing event was detected and sent successfully via Discord. 2021-05-26 12:40:08:674 | INFO | JOB | LSO BOT loop duration was 00:00:01.1230000 2021-05-26 12:40:08:674 | INFO | TIMING | Sleep duration is now 14893 based on 00:00:16.0160000 - 00:00:01.1230000 2021-05-26 12:40:08:674 | INFO | TIMING | LSO BOT Cycle Ran. Sleeping for 14893 milliseconds 2021-05-26 12:40:23:582 | INFO | JOB | Begin cycle 10 of 40 2021-05-26 12:40:24:048 | INFO | DETECT | Landing detected at 2021-05-26 17:40:07 UTC 2021-05-26 12:40:24:057 | INFO | TIMING | Time diference from the start of the loop is 00:00:16.5860000 2021-05-26 12:40:24:059 | INFO | Raw Grade is GRADE:C : WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 EGIW [BC] 2021-05-26 12:40:24:061 | INFO | REGEX | Regraded Grade: C (CUT): WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 2021-05-26 12:40:24:295 | INFO | DISCORD | A landing event was detected and sent successfully via Discord. 2021-05-26 12:40:24:297 | INFO | JOB | LSO BOT loop duration was 00:00:00.7100000 2021-05-26 12:40:24:298 | INFO | TIMING | Sleep duration is now 16536 based on 00:00:17.2460000 - 00:00:00.7100000 2021-05-26 12:40:24:302 | INFO | TIMING | LSO BOT Cycle Ran. Sleeping for 16536 milliseconds 2021-05-26 12:40:40:846 | INFO | JOB | Begin cycle 11 of 40 2021-05-26 12:40:41:174 | INFO | DETECT | Landing detected at 2021-05-26 17:40:07 UTC 2021-05-26 12:40:41:174 | INFO | TIMING | Time diference from the start of the loop is 00:00:33.8460000 2021-05-26 12:40:41:174 | INFO | Raw Grade is GRADE:C : WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 EGIW [BC] 2021-05-26 12:40:41:174 | INFO | REGEX | Regraded Grade: C (CUT): WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 2021-05-26 12:40:41:197 | WARNING | TIMING | Landing detected at 2021-05-26 17:40:07 is too old. Excepted interval was 00:00:16.4200000. Discarding. 2021-05-26 12:40:41:199 | INFO | JOB | LSO BOT loop duration was 00:00:00.3530000 2021-05-26 12:40:41:200 | INFO | TIMING | Sleep duration is now 16067 based on 00:00:16.4200000 - 00:00:00.3530000 2021-05-26 12:40:41:202 | INFO | TIMING | LSO BOT Cycle Ran. Sleeping for 16067 milliseconds 2021-05-26 12:40:57:283 | INFO | JOB | Begin cycle 12 of 40

lsoBot-rawGrades.txt

2021-05-26 12:34:28:353 GRADE:--- : WIRE# 2 EGIW [BC] 2021-05-26 12:40:08:079 GRADE:C : WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 EGIW [BC] 2021-05-26 12:40:24:068 GRADE:C : WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 EGIW [BC] 2021-05-26 12:45:25:905 GRADE:--- : FX WIRE# 3 EGIW [BC]

lsoBot-reGrades.txt

2021-05-26 12:34:28:355 OK (Acceptable): WIRE# 2 2021-05-26 12:40:08:088 C (CUT): WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 2021-05-26 12:40:24:071 C (CUT): WX FX DRX (LURIM) DRIM DLIC LULIC TMRDAR WIRE# 2 2021-05-26 12:45:25:905 OK (Acceptable): FX WIRE# 3

Describe the bug Lsobot will send a duplicate grade for the same trap to discord. See Cycle 9 and 10 in lsobot-debug.txt

To Reproduce Random and rare; dependent on timing.

Environment Info:

YoloWingPixie commented 3 years ago

Thanks for adding a report.

I am aware of this issue although it is increasingly rarer. When I started this project I made a bad decision to make the bot stateless and have no record of what it did in previous cycles. I worked to get the timing controls just so, even to account for the execution time of the script itself, however, there are still overlaps between each cycle, or in some rarer cases gaps.

To fix this, I'm going to need to refactor the bot to consider if it has acted on a particular trap before. I don't have a fix yet, but I am aware. I will hopefully have some time in the next week or two to sit down and iron out the current wave of bugs and improvements.

DCAFOC commented 3 years ago

I've been tinkering with the main loop, and I think I may have found a method to have the bot rely on comparing log times instead while disregarding previously logged traps in rawGrades. I have a working example if you'd like to see it.

YoloWingPixie commented 3 years ago

I've been tinkering with the main loop, and I think I may have found a method to have the bot rely on comparing log times instead while disregarding previously logged traps in rawGrades. I have a working example if you'd like to see it.

Sure, I'd love to

DCAFOC commented 3 years ago

It's been uploaded on my fork.

YoloWingPixie commented 3 years ago

It's been uploaded on my fork.

I like it.

This:

($null -eq $landingEvent -or $null -eq $lastTrapTime)

should read

($null -eq $landingEvent -or $landingEvent -eq $lastTrapTime)

As your 2nd condition isn't comparing if the landingEvent is $null, it's comparing if it's the same as the lastTrapTime. $null is on the left here because it's a best practice. Other than that, if you can make the Points feature optional and configurable via the config file I'll be happy to merge into the dev build. If not, I know I intend to sit down and change the bot over to using an index after I finish my group's current campaign which will be sometime in the next few weeks.

YoloWingPixie commented 3 years ago

Merged request. Going to iron out some smaller things, test for a bit in my group and I'll release.

Thank you for the assistance, I really appreciate it.