kopia lustrzana https://github.com/cyoung/stratux
Improved demo traffic
rodzic
878747e633
commit
48b5127af6
|
@ -606,23 +606,25 @@ func heartBeatSender() {
|
||||||
sendGDL90(makeStratuxStatus(), false)
|
sendGDL90(makeStratuxStatus(), false)
|
||||||
makeOwnshipReport()
|
makeOwnshipReport()
|
||||||
makeOwnshipGeometricAltitudeReport()
|
makeOwnshipGeometricAltitudeReport()
|
||||||
/* --- debug code: traffic demo* --- /
|
|
||||||
/* Uncomment and compile to display huge number of artificial traffic targets
|
|
||||||
numTargets := uint32(1000)
|
|
||||||
hexCode := uint32(0xFF0000)
|
|
||||||
|
|
||||||
for i := uint32(0); i < numTargets; i++ {
|
// --- debug code: traffic demo ---
|
||||||
tail := fmt.Sprintf("DEMO%d", i)
|
// Uncomment and compile to display large number of artificial traffic targets
|
||||||
alt := float32((i*117%2000)*25 + 2000)
|
/*
|
||||||
hdg := float64((i * 37) % 360)
|
numTargets := uint32(40)
|
||||||
spd := float64(100 + ((i*7)%61)*13)
|
hexCode := uint32(0xFF0000)
|
||||||
|
|
||||||
updateDemoTraffic(i|hexCode, tail, alt, spd, hdg)
|
for i := uint32(0); i < numTargets; i++ {
|
||||||
|
tail := fmt.Sprintf("DEMO%d", i)
|
||||||
|
alt := float32((i*117%2000)*25 + 2000)
|
||||||
|
hdg := int32((i * 149) % 360)
|
||||||
|
spd := float64(50 + ((i*23)%13)*17)
|
||||||
|
|
||||||
}
|
updateDemoTraffic(i|hexCode, tail, alt, spd, hdg)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/* ---end traffic demo code ---*/
|
// ---end traffic demo code ---
|
||||||
sendTrafficUpdates()
|
sendTrafficUpdates()
|
||||||
updateStatus()
|
updateStatus()
|
||||||
case <-timerMessageStats.C:
|
case <-timerMessageStats.C:
|
||||||
|
|
|
@ -589,10 +589,10 @@ KOSH, once every five minutes.
|
||||||
Inputs are ICAO 24-bit hex code, tail number (8 chars max), relative altitude in feet,
|
Inputs are ICAO 24-bit hex code, tail number (8 chars max), relative altitude in feet,
|
||||||
groundspeed in knots, and bearing offset from 0 deg initial position.
|
groundspeed in knots, and bearing offset from 0 deg initial position.
|
||||||
*/
|
*/
|
||||||
func updateDemoTraffic(icao uint32, tail string, relAlt float32, gs float64, offset float64) {
|
func updateDemoTraffic(icao uint32, tail string, relAlt float32, gs float64, offset int32) {
|
||||||
var ti TrafficInfo
|
var ti TrafficInfo
|
||||||
|
|
||||||
hdg := float64((stratuxClock.Milliseconds/1000)%360) + offset
|
hdg := float64((int32(stratuxClock.Milliseconds/1000) + offset) % 360)
|
||||||
// gs := float64(220) // knots
|
// gs := float64(220) // knots
|
||||||
radius := gs * 0.1 / (2 * math.Pi)
|
radius := gs * 0.1 / (2 * math.Pi)
|
||||||
x := radius * math.Cos(hdg*math.Pi/180.0)
|
x := radius * math.Cos(hdg*math.Pi/180.0)
|
||||||
|
@ -617,12 +617,19 @@ func updateDemoTraffic(icao uint32, tail string, relAlt float32, gs float64, off
|
||||||
ti.Alt = int32(mySituation.Alt + relAlt)
|
ti.Alt = int32(mySituation.Alt + relAlt)
|
||||||
ti.Track = uint16(hdg)
|
ti.Track = uint16(hdg)
|
||||||
ti.Speed = uint16(gs)
|
ti.Speed = uint16(gs)
|
||||||
ti.Speed_valid = false
|
if hdg > 180 && hdg < 195 {
|
||||||
|
ti.Speed_valid = false
|
||||||
|
} else {
|
||||||
|
ti.Speed_valid = true
|
||||||
|
}
|
||||||
ti.Vvel = 0
|
ti.Vvel = 0
|
||||||
ti.Tail = tail // "DEMO1234"
|
ti.Tail = tail // "DEMO1234"
|
||||||
ti.Timestamp = time.Now()
|
ti.Timestamp = time.Now()
|
||||||
ti.Last_seen = stratuxClock.Time
|
ti.Last_seen = stratuxClock.Time
|
||||||
ti.Last_source = 1
|
ti.Last_source = 1
|
||||||
|
if icao%7 == 1 { // make some of the traffic UAT sourced
|
||||||
|
ti.Last_source = 2
|
||||||
|
}
|
||||||
|
|
||||||
// now insert this into the traffic map...
|
// now insert this into the traffic map...
|
||||||
trafficMutex.Lock()
|
trafficMutex.Lock()
|
||||||
|
|
Ładowanie…
Reference in New Issue