refactor: Add DLA message parsing logic to BodyParser

This commit is contained in:
windyboy
2024-07-24 17:38:39 +08:00
parent e58fa3bb36
commit 5d62b8dc77
6 changed files with 964 additions and 30 deletions
+11
View File
@@ -100,6 +100,8 @@ const (
fplPatternString = `\((?P<category>[A-Z]{3})-(?P<number>[A-Z]+\d+)-(?P<indicator>[A-Z]{2})\n-(?P<aircraft>[A-Z]+\d+\/?[A-Z]?)\n?-(?P<surve>.*)\n?-(?P<departure>[A-Z]{4})(?P<departure_time>\d{4})\n?-(?P<speed>[A-Z]+\d+)(?P<level>[A-Z0-9]+)\s+(?P<route>(.|\n)+)\n-(?P<destination>[A-Z]{4})(?P<estt>\d{4})\s?(?P<alter>(\s[A-Z]{4})+)\n?-([A-Z]{3}\/(?:[A-Z]{4}\d{4}\s?)+)?(?P<other>(?m)[A-Z]{3}\/(.|\n)*)\)$`
cnlPatternString = `^\((?P<category>[A-Z]{3})-(?P<number>\w+\d+)-?(?P<departure>[A-Z]{4})?-?(?<destination>[A-Z]{4})\)$`
dlaPatternString = `^\((?P<category>[A-Z]{3})-(?P<number>\w+\d+)-?(?P<departure>[A-Z]{4})(?P<departure_time>\d{4})?-?(?<arrival>[A-Z]{4})(?<arrival_time>\d{4})?\)$`
)
// Initialize the bodyPatterns map
@@ -140,6 +142,15 @@ var bodyPatterns = map[string]BodyConfig{
},
},
},
"DLA": {
Patterns: []PatternConfig{
{
Pattern: dlaPatternString,
Comments: "Pattern for DLA message",
Expression: regexp.MustCompile(dlaPatternString),
},
},
},
}
func GetBodyPatterns() map[string]BodyConfig {