TIS-B target tracking, re-send.

pull/3/head
Christopher Young 2015-08-14 23:58:53 -04:00
rodzic ef40f48017
commit 75aaea1430
2 zmienionych plików z 37 dodań i 8 usunięć

Wyświetl plik

@ -204,7 +204,7 @@ func makeOwnshipReport() bool {
}
//TODO
func makeOwnshipGeometricAltitudeReport() false {
func makeOwnshipGeometricAltitudeReport() bool {
if !isGPSValid() {
return false
}
@ -277,6 +277,8 @@ func heartBeatSender() {
makeOwnshipReport()
makeOwnshipGeometricAltitudeReport()
outConn.Write(makeInitializationMessage())
sendTrafficUpdates()
updateStatus()
time.Sleep(1 * time.Second)
}
}
@ -299,6 +301,10 @@ func updateStatus() {
MsgLog = t
globalStatus.UAT_messages_last_minute = UAT_messages_last_minute
globalStatus.ES_messages_last_minute = ES_messages_last_minute
if isGPSValid() {
globalStatus.GPS_satellites_locked = myGPS.satellites
}
}
@ -347,7 +353,6 @@ func parseInput(buf string) ([]byte, uint16) {
thisMsg.TimeReceived = time.Now()
thisMsg.Data = frame
MsgLog = append(MsgLog, thisMsg)
updateStatus()
return frame, msgtype
}
@ -365,7 +370,7 @@ type status struct {
UAT_messages_max uint
ES_messages_last_minute uint
ES_messages_max uint
GPS_satellites_locked uint
GPS_satellites_locked uint16
}
var globalSettings settings
@ -470,19 +475,21 @@ func saveSettings() {
func main() {
MsgLog = make([]msg, 0)
crcInit() // Initialize CRC16 table.
initTraffic()
globalStatus.Version = stratuxVersion
globalStatus.Devices = 123 //TODO
globalStatus.UAT_messages_last_minute = 567 //TODO
globalStatus.ES_messages_last_minute = 981 //TODO
readSettings()
if globalSettings.GPS_Enabled {
go gpsReader()
}
readSettings()
crcInit() // Initialize CRC16 table.
// Open UDP port to send out the messages.
addr, err := net.ResolveUDPAddr("udp", ipadAddr)
if err != nil {

Wyświetl plik

@ -66,6 +66,27 @@ type TrafficInfo struct {
last_seen time.Time
}
var traffic map[uint32]TrafficInfo
func cleanupOldEntries() {
for icao_addr, ti := range traffic {
if time.Since(ti.last_seen).Seconds() > float64(60) { //FIXME: 60 seconds with no update on this address - stop displaying.
delete(traffic, icao_addr)
}
}
}
func sendTrafficUpdates() {
cleanupOldEntries()
for _, ti := range traffic {
makeTrafficReport(ti)
}
}
func initTraffic() {
traffic = make(map[uint32]TrafficInfo)
}
func makeTrafficReport(ti TrafficInfo) {
msg := make([]byte, 28)
// See p.16.
@ -259,6 +280,7 @@ func parseDownlinkReport(s string) {
//OK.
// fmt.Printf("tisb_site_id %d, utc_coupled %t\n", tisb_site_id, utc_coupled)
makeTrafficReport(ti)
ti.last_seen = time.Now()
traffic[ti.icao_addr] = ti
}