Add satellite in solution indicator

pull/412/head
AvSquirrel 2016-05-07 15:19:42 +00:00
rodzic 06fc9a74b6
commit d692c4d732
3 zmienionych plików z 58 dodań i 8 usunięć

Wyświetl plik

@ -48,6 +48,7 @@ type SatelliteInfo struct {
Type uint8 // Type of satellite (GPS, GLONASS, Galileo, SBAS)
TimeLastSeen time.Time // Time (system ticker) a signal was last received from this satellite
TimeLastTracked time.Time // Time (system ticker) this satellite was tracked (almanac data)
InSolution bool // True if satellite is used in the position solution (reported by GSA message or PUBX,03)
}
type SituationData struct {
@ -972,19 +973,57 @@ func processNMEALine(l string) (sentenceUsed bool) {
// 1 = no solution; 2 = 2D fix, 3 = 3D fix. WAAS status is parsed from GGA message, so no need to get here
// fields 3-14: satellites in solution
var svStr string
var svType uint8
sat := 0
for _, svtxt := range x[3:15] {
_, err := strconv.Atoi(svtxt)
sv, err := strconv.Atoi(svtxt)
if err == nil {
sat++
if sv < 33 { // indicates GPS
svType = SAT_TYPE_GPS
svStr = fmt.Sprintf("G%d", sv)
} else if sv < 65 { // indicates SBAS: WAAS, EGNOS, MSAS, etc.
svType = SAT_TYPE_SBAS
svStr = fmt.Sprintf("S%d", sv+97) // add 97 to convert from NMEA to PRN.
} else if sv < 97 { // GLONASS
svType = SAT_TYPE_GLONASS
svStr = fmt.Sprintf("R%d", sv-64) // subtract 64 to convert from NMEA to PRN.
} else { // TO-DO: GLONASS, Galileo
svType = SAT_TYPE_UNKNOWN
svStr = fmt.Sprintf("U%d", sv)
}
var thisSatellite SatelliteInfo
// START OF PROTECTED BLOCK
satelliteMutex.Lock()
// Retrieve previous information on this satellite code.
if val, ok := Satellites[svStr]; ok { // if we've already seen this satellite identifier, copy it in to do updates
thisSatellite = val
//log.Printf("Satellite %s already seen. Retrieving from 'Satellites'.\n", svStr)
} else { // this satellite isn't in the Satellites data structure, so create it
thisSatellite.SatelliteID = svStr
thisSatellite.SatelliteNMEA = uint8(sv)
thisSatellite.Type = uint8(svType)
log.Printf("Creating new satellite %s from GSA message\n", svStr) // DEBUG
}
thisSatellite.InSolution = true
thisSatellite.TimeLastSeen = stratuxClock.Time // implied, since this satellite is used in the position solution
thisSatellite.TimeLastTracked = stratuxClock.Time // implied, since this satellite is used in the position solution
Satellites[thisSatellite.SatelliteID] = thisSatellite // Update constellation with this satellite
updateConstellation()
satelliteMutex.Unlock()
// END OF PROTECTED BLOCK
}
}
tmpSituation.Satellites = uint16(sat)
// Satellites tracked / seen should be parsed from GSV message (TO-DO) ... since we don't have it, just use satellites from solution
//tmpSituation.SatellitesTracked = uint16(sat) -- moved to GPGSV parsing
//tmpSituation.SatellitesSeen = uint16(sat)
// field 16: HDOP
// Accuracy estimate
hdop, err1 := strconv.ParseFloat(x[16], 32)
@ -1071,7 +1110,7 @@ func processNMEALine(l string) (sentenceUsed bool) {
// START OF PROTECTED BLOCK
satelliteMutex.Lock()
// Retrieve previous information on this ICAO code.
// Retrieve previous information on this satellite code.
if val, ok := Satellites[svStr]; ok { // if we've already seen this satellite identifier, copy it in to do updates
thisSatellite = val
//log.Printf("Satellite %s already seen. Retrieving from 'Satellites'.\n", svStr)
@ -1103,6 +1142,17 @@ func processNMEALine(l string) (sentenceUsed bool) {
}
thisSatellite.Signal = int8(cno)
// hack workaround for GSA 12-sv limitation... if this is a SBAS satellite, we have a SBAS solution, and signal is greater than some threshold, set InSolution
if thisSatellite.Type == SAT_TYPE_SBAS {
if mySituation.Quality == 2 {
if thisSatellite.Signal > 10 {
thisSatellite.InSolution = true
}
} else { // quality == 0 or 1
thisSatellite.InSolution = false
}
}
if globalSettings.DEBUG {
log.Printf("Satellite %s at index %d. Type = %d, NMEA-ID = %d, Elev = %d, Azimuth = %d, Cno = %d\n", svStr, i, svType, sv, elev, az, cno) // remove later?
}

Wyświetl plik

@ -71,7 +71,7 @@
<div class="row" ng-repeat="satellite in data_list | orderBy: 'SatelliteNMEA'">
<div class="separator"></div>
<span class="col-xs-2">{{satellite.SatelliteID}}</span>
<span class="col-xs-2">{{satellite.SatelliteID}}<span ng-show="satellite.InSolution">&nbsp;&#x2705;</span></span>
<span class="col-xs-2 text-right">{{satellite.SatelliteNMEA}}</span>
<span class="col-xs-2 text-right">{{satellite.Elevation < -5 ? "---" : satellite.Elevation}}</span>
<span class="col-xs-2 text-right">{{satellite.Azimuth < 0 ? "---" : satellite.Azimuth}}</span>

Wyświetl plik

@ -123,7 +123,7 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) {
new_satellite.Elevation = obj.Elevation; // Angle above local horizon, -xx to +90
new_satellite.Azimuth = obj.Azimuth; // Bearing (degrees true), 0-359
new_satellite.Signal = obj.Signal; // Signal strength, 0 - 99; -99 indicates no reception
//new_satellite.Type = obj.Type;
new_satellite.InSolution = obj.InSolution; // is this satellite in the position solution
}
function loadSatellites(data) {