Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERAM Framework #375

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
9bdd3a4
Change the way `STARSComputer` and `ERAMComputer` work
checkandmate1 Sep 16, 2024
53d8604
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 17, 2024
b122f21
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 18, 2024
9ae4f61
Revert changing STARS/ERAMComputer because I did it wrong .-.
checkandmate1 Sep 18, 2024
8460c43
Merge branch 'improve-stars' of https://github.com/checkandmate1/vice…
checkandmate1 Sep 18, 2024
d904616
Add squawks to IC
checkandmate1 Sep 19, 2024
623eabf
Seperate ERAM and STARS ICs
checkandmate1 Sep 19, 2024
eae3a11
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 20, 2024
d28d5f7
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 24, 2024
d215828
starting to get there...
checkandmate1 Sep 26, 2024
148eab7
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 26, 2024
b5afb98
gofmt
checkandmate1 Sep 26, 2024
e21791e
Delete unncessesary funcs and update autotrack
checkandmate1 Sep 26, 2024
5469d4f
Refactor handling of automated acceptance of aircraft.
checkandmate1 Sep 27, 2024
b856bd4
Minor changes
checkandmate1 Sep 27, 2024
26166fe
Lots of work...
checkandmate1 Sep 27, 2024
7c4f851
Reduced even more reliance on `Aircraft`
checkandmate1 Sep 27, 2024
e0a39f0
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 27, 2024
98c83fa
Temp altitude
checkandmate1 Sep 28, 2024
35b260d
Fix the issue of some handoffs not going through and keep LDB
checkandmate1 Sep 28, 2024
f6c898e
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 28, 2024
b6a911b
gofmt
checkandmate1 Sep 28, 2024
bccc414
Scratchpad fix
checkandmate1 Sep 28, 2024
8b6d658
Delete print
checkandmate1 Sep 28, 2024
7fcfa0c
Verify controlller facility.
checkandmate1 Sep 28, 2024
bace83a
gofmt
checkandmate1 Sep 28, 2024
6512180
Use track info for `ControlClient AcceptHandoff`
checkandmate1 Sep 28, 2024
1fb93ca
Merge branch 'master' into improve-stars
checkandmate1 Sep 28, 2024
305a0cd
Nextcontroller in STARSPane
checkandmate1 Sep 28, 2024
79c5791
CMD to see facility track info
checkandmate1 Sep 28, 2024
b8f7ec5
bug-fix accepted handoffs
checkandmate1 Sep 28, 2024
e5b267c
Fix intra-facility handoffs
checkandmate1 Sep 28, 2024
373ab72
Fix handoffs fully.
checkandmate1 Sep 28, 2024
25c1001
Added facilities to LIB
checkandmate1 Sep 28, 2024
fa1ce52
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 29, 2024
bf5b0d1
Change `NextControllers` to the server and fix `Sim CancelHandoff`
checkandmate1 Sep 29, 2024
ceee030
Merge branch 'improve-stars' of https://github.com/checkandmate1/vice…
checkandmate1 Sep 29, 2024
595a17d
Fix automatically accepting handoffs
checkandmate1 Sep 29, 2024
3e71255
Edited some scenario files (A80, C90, COS, CPR)
checkandmate1 Sep 29, 2024
a103bd7
Merge pull request #4 from checkandmate1:update-facility-files
checkandmate1 Sep 29, 2024
b6d2f53
Fix scratchpads
checkandmate1 Sep 29, 2024
0af528a
some commenting out + gofmt
checkandmate1 Sep 29, 2024
35137e8
Request FP & Fix virtual departure controllers
checkandmate1 Sep 29, 2024
8758ab9
Fix issue with initiating track for weird flights
checkandmate1 Sep 29, 2024
ce45855
gofmt
checkandmate1 Sep 29, 2024
fa7ea10
Merge branch 'master' into improve-stars
checkandmate1 Sep 29, 2024
0dfabb0
Tweak go arounds
checkandmate1 Sep 29, 2024
46ae73a
ERAMComputers are able to assign a new coordination fix.
checkandmate1 Sep 29, 2024
f621c17
Slight changes
checkandmate1 Sep 29, 2024
5adccb5
Merge branch 'mmp:master' into improve-stars
checkandmate1 Sep 29, 2024
c7f7358
Minor tweaks
checkandmate1 Sep 29, 2024
85df3cd
Remove scope_char from lib.json
checkandmate1 Sep 30, 2024
35a207f
Change facility ID handling in ERAMAdaptation and STARSFacilityAdapta…
checkandmate1 Sep 30, 2024
85181ee
Start of unsupported tracks
checkandmate1 Sep 30, 2024
6144f2f
Change unsupported track handling and visualization + leader lines
checkandmate1 Sep 30, 2024
b3c5fa7
DropUnassociatedTrack && auto association for unassociated tracks
checkandmate1 Sep 30, 2024
3c660d9
Minor changes
checkandmate1 Sep 30, 2024
3804450
HandoffUnsupportedTrack
checkandmate1 Sep 30, 2024
6928343
Merge branch 'mmp:master' into improve-stars
checkandmate1 Oct 1, 2024
44a884d
Update ewr.json
checkandmate1 Oct 1, 2024
6731ce4
Merge branch 'improve-stars' of https://github.com/checkandmate1/vice…
checkandmate1 Oct 1, 2024
234c6e3
Minor touches
checkandmate1 Oct 1, 2024
8a5eb1d
AcceptUnsupportedTrack, unsupported track selection, better unsupport…
checkandmate1 Oct 2, 2024
c08f5e9
More unsupported track stuff
checkandmate1 Oct 2, 2024
e16a2ac
Use correct ERAM identifiers for requestFP
checkandmate1 Oct 2, 2024
7c9d948
Unsupported track handoff updates and cancel unsupported handoff
checkandmate1 Oct 3, 2024
9aaa6ca
Removed unnecessary print statements
checkandmate1 Oct 3, 2024
9f3cffd
Better unsupported DB formatting, handoffs, commands, etc
checkandmate1 Oct 3, 2024
95f26c9
gofmt
checkandmate1 Oct 3, 2024
4f840e9
Callsign parameters
checkandmate1 Oct 3, 2024
efb3801
Delete from ContainedPlans after an unsupported track is made
checkandmate1 Oct 3, 2024
607ce68
More unsupported DB formatting
checkandmate1 Oct 4, 2024
1ebebf5
Minor tweaks/ fixes
checkandmate1 Oct 5, 2024
3d14cb6
Merge branch 'master' into improve-stars
checkandmate1 Oct 5, 2024
2dbe146
Fix crash while slewing aircraft
checkandmate1 Oct 7, 2024
623ab32
Add back `nav.FlightState.Summary` and gofmt
checkandmate1 Oct 7, 2024
92acdf6
Add `ERAMComputer AcceptHandoff`
checkandmate1 Oct 7, 2024
7f5d85f
Some error handling
checkandmate1 Oct 7, 2024
516a9c0
Remove redudant `Unassign()` method
checkandmate1 Oct 8, 2024
2d37a56
Organize `Sim` code into `NAS` methods
checkandmate1 Oct 8, 2024
9da997f
gofmt
checkandmate1 Oct 8, 2024
93f647b
Merge branch 'master' into improve-stars
checkandmate1 Oct 9, 2024
92b9e75
Merge branch 'master' into improve-stars
checkandmate1 Oct 9, 2024
d47828f
Merge branch 'mmp:master' into improve-stars
checkandmate1 Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/aviation/aviation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,17 @@ func (p *SquawkCodePool) IsAssigned(code Squawk) bool {
return false
}

func (p *SquawkCodePool) Unassign(code Squawk) error {
checkandmate1 marked this conversation as resolved.
Show resolved Hide resolved
if idx, bit, err := p.indices(code); err == nil {
if p.AssignedBits[idx]&(1<<bit) != 0 {
p.AssignedBits[idx] &^= (1 << bit) // Clear the bit
return nil
}
return fmt.Errorf("squawk code %d is not assigned", code)
checkandmate1 marked this conversation as resolved.
Show resolved Hide resolved
}
return fmt.Errorf("invalid squawk code %d", code)
checkandmate1 marked this conversation as resolved.
Show resolved Hide resolved
}

func (p *SquawkCodePool) Return(code Squawk) error {
if !p.IsAssigned(code) {
return ErrSquawkCodeUnassigned
Expand Down
1 change: 1 addition & 0 deletions pkg/aviation/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ func (ea ERAMAdaptation) FixForRouteAndAltitude(route string, altitude string) *
}
}
}

return nil
}

Expand Down
17 changes: 12 additions & 5 deletions pkg/panes/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ type MessagesPane struct {
messages []Message

// Command-input-related
input CLIInput
history []CLIInput
historyOffset int // for up arrow / downarrow. Note: counts from the end! 0 when not in history
savedInput CLIInput
input CLIInput
history []CLIInput
historyOffset int // for up arrow / downarrow. Note: counts from the end! 0 when not in history
savedInput CLIInput
nextController map[string]string // Callsign -> NextController
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that this is information that should be managed purely on the server; it seems unnecessarily complicated for client-side code to have to pay attention to this and then feed back information back to the server.

}

func init() {
Expand Down Expand Up @@ -75,6 +76,7 @@ func (mp *MessagesPane) Activate(r renderer.Renderer, p platform.Platform, event
mp.scrollbar = NewVerticalScrollBar(4, true)
}
mp.events = eventStream.Subscribe()
mp.nextController = make(map[string]string)
}

func (mp *MessagesPane) LoadedSim(ss sim.State, pl platform.Platform, lg *log.Logger) {}
Expand Down Expand Up @@ -280,7 +282,8 @@ func (mp *MessagesPane) runCommands(ctx *Context) {

if ok {
if ac := ctx.ControlClient.AircraftFromPartialCallsign(callsign); ac != nil {
ctx.ControlClient.RunAircraftCommands(ac.Callsign, cmd,

ctx.ControlClient.RunAircraftCommands(ac.Callsign, cmd, mp.nextController[ac.Callsign],
func(errorString string, remainingCommands string) {
if errorString != "" {
mp.messages = append(mp.messages, Message{contents: errorString, error: true})
Expand Down Expand Up @@ -412,6 +415,10 @@ func (mp *MessagesPane) processEvents(ctx *Context) {
ctx.KeyboardFocus.Take(mp)
}
}
case sim.AcceptedHandoffEvent:
mp.nextController[event.Callsign] = event.ToController
case sim.HandoffControllEvent:
delete(mp.nextController, event.Callsign) // clear the next controller
}
}

Expand Down
62 changes: 42 additions & 20 deletions pkg/panes/stars/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (sp *STARSPane) executeSTARSCommand(cmd string, ctx *panes.Context) (status
return ctx.ControlClient.Aircraft[sp.TabListAircraft[idx]]
}

if trk := ctx.ControlClient.STARSComputer().LookupTrackIndex(idx); trk != nil {
if trk := ctx.ControlClient.STARSComputer(ctx.ControlClient.Callsign).LookupTrackIndex(idx); trk != nil {
// May be nil, but this is our last option
return ctx.ControlClient.Aircraft[trk.Identifier]
}
Expand Down Expand Up @@ -510,7 +510,7 @@ func (sp *STARSPane) executeSTARSCommand(cmd string, ctx *panes.Context) (status
return
} else {
// Is it an abbreviated flight plan?
fp, err := sim.MakeSTARSFlightPlanFromAbbreviated(cmd, ctx.ControlClient.STARSComputer(),
fp, err := sim.MakeSTARSFlightPlanFromAbbreviated(cmd, ctx.ControlClient.STARSComputer(ctx.ControlClient.Callsign),
ctx.ControlClient.STARSFacilityAdaptation)
if fp != nil {
ctx.ControlClient.UploadFlightPlan(fp, sim.LocalNonEnroute, nil,
Expand All @@ -529,7 +529,13 @@ func (sp *STARSPane) executeSTARSCommand(cmd string, ctx *panes.Context) (status
if ac := lookupAircraft(cmd); ac == nil {
status.err = ErrSTARSCommandFormat
} else {
sp.initiateTrack(ctx, ac.Callsign)
fp, err := ctx.ControlClient.STARSComputer(ctx.ControlClient.Callsign).GetFlightPlan(ac.Callsign) // TODO: change this so that it's the inputted squawk/ callsign.
if err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is logging the error the right thing to do in this case? i.e. is it expected that there may not always be a flight plan, or does this case mean there's an error in the code elsewhere? If it's valid that there may be no flight plan then I assume a STARS error should be displayed to the user instead?

ctx.Lg.Errorf("Error getting flight plan for %s: %v", ac.Callsign, err)
return
}

sp.initiateTrack(ctx, ac.Callsign, fp)
status.clear = true
}
return
Expand Down Expand Up @@ -2309,7 +2315,7 @@ func (sp *STARSPane) setScratchpad(ctx *panes.Context, callsign string, contents
}

trk := sp.getTrack(ctx, ac)
if trk != nil && trk.TrackOwner == "" {
if trk == nil || trk.TrackOwner == "" {
// This is because /OK can be used for associated tracks that are
// not owned by this TCP. But /OK cannot be used for unassociated
// tracks. So might as well weed them out now.
Expand Down Expand Up @@ -2386,12 +2392,19 @@ func (sp *STARSPane) setGlobalLeaderLine(ctx *panes.Context, callsign string, di
func(err error) { sp.displayError(err, ctx) })
}

func (sp *STARSPane) initiateTrack(ctx *panes.Context, callsign string) {
// TODO: should we actually be looking up the flight plan on the server
// side anyway?
fp, err := ctx.ControlClient.STARSComputer().GetFlightPlan(callsign)
if err != nil {
// TODO: do what here?
func (sp *STARSPane) initiateTrack(ctx *panes.Context, callsign string, fp *sim.STARSFlightPlan) {

checkandmate1 marked this conversation as resolved.
Show resolved Hide resolved
comp := ctx.ControlClient.STARSComputer(ctx.ControlClient.Callsign)
// Do the checking here as well as in pkg/sim/sim.go so that we can assure that the sim side sucseeds and the local calls can be made before.

if comp.TrackInformation[callsign] != nil {
// This is a track that is already being tracked
sp.previewAreaOutput = ErrSTARSIllegalTrack.Error()
return
}
comp.TrackInformation[callsign] = &sim.TrackInformation{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with limited reading of globals out of the computers structs (similar to what's done elsewhere for e.g., sim.State.Aircraft, but setting them should probably be done through a method they provide, since the STARS code shouldn't have to potentially worry about any additional housekeeping with changing them.

Also, same question as above about whether it's valid to be setting this value here since I think a sim state update will clobber it.

TrackOwner: ctx.ControlClient.Callsign,
FlightPlan: fp,
}
ctx.ControlClient.InitiateTrack(callsign, fp,
func(any) {
Expand Down Expand Up @@ -2613,7 +2626,12 @@ func (sp *STARSPane) executeSTARSClickedCommand(ctx *panes.Context, cmd string,
if ctrl && shift {
// initiate track, CRC style
status.clear = true
sp.initiateTrack(ctx, ac.Callsign)
fp, err := ctx.ControlClient.STARSComputer(ctx.ControlClient.Callsign).GetFlightPlan(ac.Callsign)
if err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same questions as above about what an error return value implies here.

ctx.Lg.Errorf("Error getting flight plan for %s: %v", ac.Callsign, err)
return
}
sp.initiateTrack(ctx, ac.Callsign, fp)
return
}
}
Expand Down Expand Up @@ -2662,7 +2680,9 @@ func (sp *STARSPane) executeSTARSClickedCommand(ctx *panes.Context, cmd string,
} else if cmd == "?" {
ctx.Lg.Info("print aircraft", slog.String("callsign", ac.Callsign),
slog.Any("aircraft", ac))
fmt.Println(spew.Sdump(ac) + "\n" + ac.Nav.FlightState.Summary())
comp := ctx.ControlClient.ERAMComputer(ctx.ControlClient.Callsign)
fmt.Println(spew.Sdump(ac)+"\n"+comp.FlightPlans[ac.Squawk].CoordinationFix, ac.FlightPlan.ArrivalAirport)
checkandmate1 marked this conversation as resolved.
Show resolved Hide resolved
// fmt.Println(spew.Sdump(ac), )
status.clear = true
return
} else if cmd == "*F" {
Expand Down Expand Up @@ -2881,12 +2901,6 @@ func (sp *STARSPane) executeSTARSClickedCommand(ctx *panes.Context, cmd string,
return

} else if len(cmd) > 0 {
// If it matches the callsign, attempt to initiate track.
if cmd == ac.Callsign {
status.clear = true
sp.initiateTrack(ctx, ac.Callsign)
return
}

// See if cmd works as a sector id; if so, make it a handoff.
control := sp.lookupControllerForId(ctx, cmd, ac.Callsign)
Expand Down Expand Up @@ -2916,11 +2930,19 @@ func (sp *STARSPane) executeSTARSClickedCommand(ctx *panes.Context, cmd string,
}

case CommandModeInitiateControl:
if cmd != ac.Callsign {
_, err := av.ParseSquawk(cmd)
if cmd != ac.Callsign && err != nil || len(cmd) <= 1 {
status.err = ErrSTARSCommandFormat
} else {
status.clear = true
sp.initiateTrack(ctx, ac.Callsign)
fp, err := ctx.ControlClient.STARSComputer(ctx.ControlClient.Callsign).GetFlightPlan(cmd)

if err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above about the error case here.

ctx.Lg.Errorf("Error getting flight plan for %s: %v", ac.Callsign, err)
return
}

sp.initiateTrack(ctx, ac.Callsign, fp)
}
return

Expand Down
Loading
Loading