Пример #1
0
func (a *Airspace) thisIsNewContent(msg *adsb.CompositeMsg) (wasNew bool) {
	// Lazy init
	if a.RollAfter == time.Minute*0 {
		a.RollAfter = DefaultRollAfter
	}
	if a.Aircraft == nil {
		a.Aircraft = make(map[adsb.IcaoId]AircraftData)
	}

	sig := msg.GetSignature()
	if _, existsCurr := a.CurrMsgs[sig]; !existsCurr {
		// Add it into Curr in all cases
		a.CurrMsgs[sig] = true

		existsPrev := false
		if a.PrevMsgs != nil {
			_, existsPrev = a.PrevMsgs[sig]
		}

		// If the thing was already in prev, then it isn't new; else it is
		return !existsPrev
	}

	return false
}
Пример #2
0
// If this message has new position info, *and* we have good backfill, then craft a CompositeMsg.
// Note, we don't wait for squawk info.
func (s *ADSBSender) maybeCreateComposite(m *adsb.Msg) *adsb.CompositeMsg {
	if !m.HasPosition() {
		return nil
	}

	//if s.LastGroundSpeed == 0 || s.LastTrack == 0 || s.LastCallsign == "" { return nil }

	cm := adsb.CompositeMsg{Msg: *m} // Clone the input into the embedded struct

	// Overwrite with cached info (from previous packets), if we don't have it in this packet
	if cm.GroundSpeed == 0 {
		cm.GroundSpeed = s.LastGroundSpeed
	}
	if cm.VerticalRate == 0 {
		cm.VerticalRate = s.LastVerticalSpeed
	}
	if cm.Track == 0 {
		cm.Track = s.LastTrack
	}
	if cm.Callsign == "" {
		cm.Callsign = s.LastCallsign
	}
	if cm.Squawk == "" {
		cm.Squawk = s.LastSquawk
	}

	return &cm
}