eram

package
v0.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

TODO: 1. Fix mouse to put top box not the bottom box

Index

Constants

View Source
const (
	Line4None = iota
	Line4Destination
	Line4Type
)

Variables

View Source
var (
	ERAMPopupPaneBackgroundColor = renderer.RGB{R: 0, G: 0, B: 0}
	ERAMYellow                   = renderer.RGB{R: .894, G: .894}
)
View Source
var (
	ErrCommandFormat       = NewERAMError("FORMAT")
	ErrERAMAmbiguousACID   = NewERAMError("AMB ACID")
	ErrERAMIllegalACID     = NewERAMError("ILL CID")
	ErrERAMIllegalPosition = NewERAMError("ILLEGAL POSITION")
	ErrERAMIllegalValue    = NewERAMError("ILLEGAL VALUE")
	ErrERAMIllegalAirport  = NewERAMError("ILLEGAL AIRPORT")
	ErrIllegalUserAction   = NewERAMError("ILLEGAL USER ACTION")
	ErrERAMMapUnavailable  = NewERAMError("MAP UNAVAILABLE")
	ErrERAMMessageTooLong  = NewERAMError("MESSAGE TOO LONG")
	ErrERAMSectorNotActive = NewERAMError("SECTOR NOT ACTIVE")
)

Functions

func FullDatablockFieldSpecs added in v0.14.0

func FullDatablockFieldSpecs() map[DatablockFieldID]DatablockFieldSpec

FullDatablockFieldSpecs returns a copy of the built-in field specs map.

func InitCommands added in v0.14.1

func InitCommands()

Types

type CRRColor added in v0.13.3

type CRRColor int

CRRColor represents one of the selectable CRR colors. The palette approximates the figures provided by the user.

const (
	CRRGreen CRRColor = iota
	CRRYellow
	CRRMagenta
	CRRCyan
	CRRWhite
	CRRAmber
)

func (CRRColor) BaseRGB added in v0.13.3

func (c CRRColor) BaseRGB() renderer.RGB

BaseRGB returns the unscaled RGB for the CRR color.

func (CRRColor) BrightRGB added in v0.13.3

func (c CRRColor) BrightRGB(b radar.Brightness) renderer.RGB

BrightRGB applies an ERAM brightness to the base color.

type CRRGroup added in v0.13.3

type CRRGroup struct {
	Label    string
	Location math.Point2LL
	Color    CRRColor
	// Aircraft present in the group; value unused.
	Aircraft map[av.ADSBCallsign]struct{}
}

CRRGroup holds one CRR group definition and its aircraft membership.

type CRRLocation added in v0.14.0

type CRRLocation struct {
	Location math.Point2LL
	Token    string // Original token without // prefix (for deriving labels)
}

CRRLocation represents a parsed CRR location from //FIX, //FRD, etc.

type CommandInput added in v0.14.0

type CommandInput struct {
	// contains filtered or unexported fields
}

CommandInput holds the current state during command matching.

type CommandMode

type CommandMode int
const (
	CommandModeNone CommandMode = iota
	CommandModeDrawRoute
)

type CommandStatus

type CommandStatus struct {
	// contains filtered or unexported fields
}

type CommonPreferences

type CommonPreferences struct {
	CharSize struct {
		Line4   int // Find out what this is
		RDB     int
		LDB     int
		FDB     int
		Toolbar int
		Outage  int // Again, what is this?
		Portal  int // Same here...
	}
	Brightness struct {
		Background radar.Brightness
		Cursor     radar.Brightness
		Text       radar.Brightness
		PRTGT      radar.Brightness
		UNPTGT     radar.Brightness
		PRHST      radar.Brightness
		UNPHST     radar.Brightness
		LDB        radar.Brightness
		SLDB       radar.Brightness
		WX         radar.Brightness
		NEXRAD     radar.Brightness
		Backlight  radar.Brightness
		Button     radar.Brightness
		Border     radar.Brightness
		Toolbar    radar.Brightness
		TBBRDR     radar.Brightness
		ABBRDR     radar.Brightness
		FDB        radar.Brightness
		Portal     radar.Brightness
		Satcomm    radar.Brightness
		ONFREQ     radar.Brightness
		Line4      radar.Brightness
		Dwell      radar.Brightness
		Fence      radar.Brightness
		DBFEL      radar.Brightness
		Outage     radar.Brightness
	}

	Line4Type    int
	FDBLdrLength int // Datablock leader line length: 0=no line (W/E only), 1=normal (default), 2=2x, 3=3x

	TornOffButtons        map[string][2]float32 // button name -> screen position
	MasterToolbarPosition [2]float32            // top-left position of the master toolbar button
	// contains filtered or unexported fields
}

type DatablockFieldID added in v0.14.0

type DatablockFieldID string

DatablockFieldID identifies a datablock field for outline lookup.

const (
	DBFieldMain         DatablockFieldID = "main"
	DBFieldCallsign     DatablockFieldID = "callsign"
	DBFieldVCI          DatablockFieldID = "vci"
	DBFieldAltitude     DatablockFieldID = "altitude"
	DBFieldCID          DatablockFieldID = "cid"
	DBFieldHandoffSpeed DatablockFieldID = "handoff_speed"
	DBFieldSpeed        DatablockFieldID = "speed"
	DBFieldLine4        DatablockFieldID = "line4"
)

type DatablockFieldSpec added in v0.14.0

type DatablockFieldSpec struct {
	Line int
	Col  int
	Cols int
}

DatablockFieldSpec describes a field location in line/column space (0-based).

func FullDatablockFieldSpec added in v0.14.0

func FullDatablockFieldSpec(id DatablockFieldID) (DatablockFieldSpec, bool)

FullDatablockFieldSpec returns the built-in field spec, if defined.

type DatablockLayout added in v0.14.0

type DatablockLayout struct {
	Anchor      [2]float32
	CharWidth   float32
	LineHeight  float32
	LineSpacing float32
}

DatablockLayout captures the layout metrics for a rendered datablock.

func (DatablockLayout) FieldExtent added in v0.14.0

func (l DatablockLayout) FieldExtent(spec DatablockFieldSpec) math.Extent2D

FieldExtent returns the outline for the specified field.

func (DatablockLayout) LineExtent added in v0.14.0

func (l DatablockLayout) LineExtent(line, cols int) math.Extent2D

LineExtent returns the outline for a full line of the specified width.

type DatablockOutlines added in v0.14.0

type DatablockOutlines struct {
	Layout DatablockLayout
	Fields map[DatablockFieldID]math.Extent2D
	Lines  map[int]math.Extent2D
}

DatablockOutlines provides field and line outlines for a datablock.

type DatablockType

type DatablockType int

DatablockType enumerates the supported ERAM datablock formats. Only the general types are provided here; the specific contents are defined elsewhere.

const (
	// LimitedDatablock represents the two-line limited data block used for
	// untracked or unpaired targets.
	LimitedDatablock DatablockType = iota
	// FullDatablock represents the five line full data block.
	FullDatablock
	// EnhancedLimitedDatablock represents the optional enhanced limited data
	// block.  It behaves like LimitedDatablock with additional information.
	EnhancedLimitedDatablock
)

type ERAMError

type ERAMError struct {
	// contains filtered or unexported fields
}

func GetERAMError

func GetERAMError(e error, lg *log.Logger) *ERAMError

func NewERAMError

func NewERAMError(msg string, args ...any) *ERAMError

type ERAMMenuClickType added in v0.14.1

type ERAMMenuClickType int

ERAMMenuClickType distinguishes primary from tertiary clicks.

const (
	MenuClickPrimary ERAMMenuClickType = iota
	MenuClickTertiary
)

type ERAMMenuConfig added in v0.14.1

type ERAMMenuConfig struct {
	Title       string
	ShowMButton bool
	OnMClick    func(ERAMMenuClickType)
	OnClose     func()
	Width       float32
	Font        *renderer.Font // nil = ep.ERAMToolbarFont()
	ItemHeight  float32        // 0 = default 18px
	Rows        []ERAMMenuItem

	ShowBorder  bool
	BorderColor renderer.RGB

	DismissOnClickOutside bool

	// Escape hatch for custom drawn content (e.g. CRR color swatches).
	// Returns the new cursor position after drawing.
	CustomContent func(cursor [2]float32, width float32,
		trid *renderer.ColoredTrianglesDrawBuilder,
		ld *renderer.ColoredLinesDrawBuilder,
		td *renderer.TextDrawBuilder,
		mouse *platform.MouseState) [2]float32
}

ERAMMenuConfig holds the full configuration for a menu drawn by DrawERAMMenu.

type ERAMMenuItem added in v0.14.1

type ERAMMenuItem struct {
	Label    string
	BgColor  renderer.RGB
	Color    renderer.RGB
	Centered bool
	OnClick  func(clickType ERAMMenuClickType) bool // return true = close menu

	// If SubRows is non-nil, this row renders as a scrollable list instead of a single text row.
	SubRows     []ERAMScrollItem
	VisibleRows int                                          // Number of visible sub-rows; 0 = show all
	ScrollState *ERAMScrollState                             // Required if SubRows is non-nil
	OnSelect    func(index int, clickType ERAMMenuClickType) // Called when a sub-row is clicked
}

ERAMMenuItem describes a single row in the menu, or a scrollable list section if SubRows is set.

type ERAMMenuResult added in v0.14.1

type ERAMMenuResult struct {
	Extent     math.Extent2D
	Dismissed  bool
	RowExtents []math.Extent2D
}

ERAMMenuResult is returned by DrawERAMMenu.

type ERAMPane

type ERAMPane struct {
	ERAMPreferenceSets map[string]*PrefrenceSet `json:"PreferenceSets,omitempty"`

	TrackState map[av.ADSBCallsign]*TrackState `json:"TrackState,omitempty"`

	DisableERAMtoRadio bool `json:"-"`
	FlipNumericKeypad  bool

	InboundPointOuts  map[string]string `json:"-"`
	OutboundPointOuts map[string]string `json:"-"`

	Input inputText `json:"-"`

	VelocityTime int // 0, 1, 4, or 8 minutes

	IFPHelpers struct {
		ArrivalsColor    *[3]float32
		ApproachesColor  *[3]float32
		DeparturesColor  *[3]float32
		OverflightsColor *[3]float32
		AirspaceColor    *[3]float32
	}

	// CRR state (session)
	CRRGroups map[string]*CRRGroup `json:"CRRGroups,omitempty"`

	// ALTIM SET state (session)
	AltimSetAirports []string `json:"AltimSetAirports,omitempty"`

	// WX window state (session)
	WXReportStations []string `json:"WXReportStations,omitempty"`
	// contains filtered or unexported fields
}

func NewERAMPane

func NewERAMPane() *ERAMPane

func (*ERAMPane) Activate

func (ep *ERAMPane) Activate(r renderer.Renderer, pl platform.Platform, es *sim.EventStream, log *log.Logger)

func (*ERAMPane) CanTakeKeyboardFocus

func (ep *ERAMPane) CanTakeKeyboardFocus() bool

func (*ERAMPane) ClearTemporaryCursor added in v0.14.0

func (ep *ERAMPane) ClearTemporaryCursor()

ClearTemporaryCursor removes any temporary cursor override and rollback cursor.

func (*ERAMPane) DisplayName

func (ep *ERAMPane) DisplayName() string

func (*ERAMPane) Draw

func (ep *ERAMPane) Draw(ctx *panes.Context, cb *renderer.CommandBuffer)

func (*ERAMPane) DrawERAMMenu added in v0.14.1

func (ep *ERAMPane) DrawERAMMenu(ctx *panes.Context, transforms radar.ScopeTransformations,
	cb *renderer.CommandBuffer, origin [2]float32, cfg ERAMMenuConfig) ERAMMenuResult

DrawERAMMenu renders a floating popup menu and handles clicks.

func (*ERAMPane) DrawInfo

func (ep *ERAMPane) DrawInfo(c *client.ControlClient, p platform.Platform, lg *log.Logger)

func (*ERAMPane) DrawUI

func (ep *ERAMPane) DrawUI(p platform.Platform, config *platform.Config)

func (*ERAMPane) ERAMFont

func (ep *ERAMPane) ERAMFont(size int) *renderer.Font

func (*ERAMPane) ERAMInputFont

func (ep *ERAMPane) ERAMInputFont() *renderer.Font

func (*ERAMPane) ERAMToolbarFont

func (ep *ERAMPane) ERAMToolbarFont() *renderer.Font

func (*ERAMPane) FullDatablockOutlines added in v0.14.0

func (ep *ERAMPane) FullDatablockOutlines(ctx *panes.Context, trk sim.Track,
	transforms radar.ScopeTransformations) (DatablockOutlines, bool)

FullDatablockOutlines returns outlines for the ERAM full datablock fields.

func (*ERAMPane) LoadedSim

func (ep *ERAMPane) LoadedSim(client *client.ControlClient, pl platform.Platform, lg *log.Logger)

func (*ERAMPane) ResetSim

func (ep *ERAMPane) ResetSim(client *client.ControlClient, pl platform.Platform, lg *log.Logger)

func (*ERAMPane) ScaledRGBFromColorPickerRGB

func (ep *ERAMPane) ScaledRGBFromColorPickerRGB(input [3]float32) renderer.RGB

func (*ERAMPane) SetTemporaryCursor added in v0.14.0

func (ep *ERAMPane) SetTemporaryCursor(cursorType string, seconds float64, rollbackCursor string)

SetTemporaryCursor displays a cursor type for the given number of seconds.

type ERAMScrollItem added in v0.14.1

type ERAMScrollItem struct {
	Label string
	Color renderer.RGB
}

ERAMScrollItem describes one item in a scrollable list.

type ERAMScrollState added in v0.14.1

type ERAMScrollState struct {
	Offset      int // first visible item index
	SelectedIdx int // -1 = none
}

ERAMScrollState is caller-owned persistent state for a scrollable list.

type InterimAltitude added in v0.14.0

type InterimAltitude struct {
	Altitude int    // Altitude in feet
	Type     string // "" for none, "P" for pilot, "L" for local
}

InterimAltitude holds an interim altitude value with optional type (P for pilot, L for local)

type Preferences

type Preferences struct {
	CommonPreferences

	Name string

	// ARTCC facility identifier for which this preference set applies (e.g., ZNY)
	ARTCC string

	Center math.Point2LL
	Range  float32

	CurrentCenter math.Point2LL

	VideoMapGroup string // ZNYMAP, AREAA, AREAB, etc

	AltitudeFilters []float32 // find out the different targets

	VideoMapVisible map[string]interface{}

	DisplayToolbar bool

	Line4Size   int
	FDBSize     int
	PoralSize   int
	ToolbarSize int
	RDBSize     int // CRR datablocks
	LDBSize     int
	OutageSize  int
	CursorSize  int

	VideoMapBrightness map[string]int
	HistoryLength      int

	UseRightClick bool

	// CRR view preferences and configuration
	CRR struct {
		Visible       bool
		ListMode      bool // true: list, false: panel
		Opaque        bool
		ShowBorder    bool
		Lines         int
		Font          int
		Bright        int
		SelectedColor CRRColor
		ColorBright   map[CRRColor]int
		Position      [2]float32
		DisplayFixes  bool // ATC TOOLS overlay of CRR fixes
	}

	// ALTIM SET view preferences
	AltimSet struct {
		Visible        bool
		Position       [2]float32
		Opaque         bool
		ShowBorder     bool
		ShowIndicators bool
		Lines          int
		Col            int // 1-4 columns
		Font           int // 1-3
		Bright         int // 0-100
	}

	// WX view preferences
	WX struct {
		Visible        bool
		Position       [2]float32
		Opaque         bool
		ShowBorder     bool
		ShowIndicators bool
		Lines          int
		Font           int // 1-3
		Bright         int // 0-100
	}
	// contains filtered or unexported fields
}

type PrefrenceSet

type PrefrenceSet struct {
	Current  Preferences
	Selected *int
	// Saved preference slots (10). Some slots may be nil. Each stored
	// Preferences includes ARTCC and VideoMapGroup so we can filter rows.
	Saved [numSavedPreferenceSets]*Preferences
}

type TrackState

type TrackState struct {
	Track             av.RadarTrack
	PreviousTrack     av.RadarTrack
	PreviousAltitude  float32 // for seeing if the track is climbing or descending. This may need to be moved someplace else later
	PreviousTrackTime time.Time
	TrackTime         time.Time
	CID               int

	HistoryTracks     [6]historyTrack // I think it's six?
	HistoryTrackIndex int

	DatablockType DatablockType

	LeaderLineDirection *math.CardinalOrdinalDirection
	LeaderLineLength    int // 0=no line (W/E only), 1=normal (default), 2=2x, 3=3x

	ELDB bool
	EFDB bool

	DisplayJRing        bool
	DisplayReducedJRing bool

	DisplayVCI bool

	OSectorEndTime sim.Time

	ReachedAltitude bool

	HoverVCI bool // if the user is hovering over the VCI field

	HSFHide bool
}

func (*TrackState) Climbing

func (ts *TrackState) Climbing() bool

func (*TrackState) Descending

func (ts *TrackState) Descending() bool

func (*TrackState) HaveHeading

func (ts *TrackState) HaveHeading() bool

func (*TrackState) HeadingVector

func (ts *TrackState) HeadingVector(nmPerLongitude, magneticVariation float32) math.Point2LL

func (*TrackState) IsLevel

func (ts *TrackState) IsLevel() bool

func (*TrackState) TrackDeltaAltitude

func (ts *TrackState) TrackDeltaAltitude() int

func (*TrackState) TrackHeading

func (ts *TrackState) TrackHeading(nmPerLongitude float32) math.TrueHeading

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL