Skip to content

Commit 68fabcd

Browse files
committed
added flarm status to main status page and reduced ogn-decode process spawn delay
1 parent de39ff2 commit 68fabcd

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

main/flarm.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ func handleAprsConnection(conn net.Conn) {
459459
if globalSettings.DEBUG {
460460
log.Println("FLARM APRS: Incoming connection:", conn.RemoteAddr())
461461
}
462+
globalStatus.FLARM_connected = true
462463

463464
// send initial message
464465
conn.Write([]byte(fmt.Sprintf("# %s %s\r\n", "stratux", globalStatus.Version)))
@@ -475,6 +476,11 @@ func handleAprsConnection(conn net.Conn) {
475476

476477
break
477478
}
479+
var thisMsg msg
480+
thisMsg.MessageClass = MSGCLASS_FLARM
481+
thisMsg.TimeReceived = stratuxClock.Time
482+
thisMsg.Data = message
483+
MsgLog = append(MsgLog, thisMsg)
478484

479485
// check if message is not a receiver beacon
480486
if !strings.HasPrefix(string(message), "Stratux") {
@@ -493,6 +499,7 @@ func handleAprsConnection(conn net.Conn) {
493499
}
494500
}
495501

502+
globalStatus.FLARM_connected = false
496503
// Close the connection when you're done with it.
497504
conn.Close()
498505
}
@@ -540,7 +547,7 @@ func flarmListen() {
540547
ognDecoderIsRunning = false
541548

542549
// set timer for (re-)starting decoding process (to use latest position)
543-
flarmDecoderRestartTimer := time.NewTicker(60 * time.Second)
550+
flarmDecoderRestartTimer := time.NewTicker(10 * time.Second)
544551

545552
// initialize last position
546553
var lastLon, lastLat float32 = 0.0, 0.0
@@ -560,8 +567,8 @@ func flarmListen() {
560567
break decodingLoop
561568
}
562569

563-
// check if position has changes significantly
564-
if !ognDecoderIsRunning || math.Abs(float64(mySituation.GPSLongitude-lastLon)) > 0.001 || math.Abs(float64(mySituation.GPSLatitude-lastLat)) > 0.001 {
570+
// check if position has changes significantly. 0.3 lat/lon diff is approximately 35km
571+
if !ognDecoderIsRunning || math.Abs(float64(mySituation.GPSLongitude-lastLon)) > 0.3 || math.Abs(float64(mySituation.GPSLatitude-lastLat)) > 0.3 {
565572
if globalSettings.DEBUG {
566573
if !ognDecoderIsRunning {
567574
log.Println("FLARM: Decoder is not running")

main/gen_gdl90.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ const (
7575
MSGTYPE_BASIC_REPORT = 0x1E
7676
MSGTYPE_LONG_REPORT = 0x1F
7777

78-
MSGCLASS_UAT = 0
79-
MSGCLASS_ES = 1
78+
MSGCLASS_UAT = 0
79+
MSGCLASS_ES = 1
80+
MSGCLASS_FLARM = 2
8081

8182
LON_LAT_RESOLUTION = float32(180.0 / 8388608.0)
8283
TRACK_RESOLUTION = float32(360.0 / 256.0)
@@ -810,6 +811,7 @@ func updateMessageStats() {
810811
m := len(MsgLog)
811812
UAT_messages_last_minute := uint(0)
812813
ES_messages_last_minute := uint(0)
814+
FLARM_messages_last_minute := uint(0)
813815

814816
ADSBTowerMutex.Lock()
815817
defer ADSBTowerMutex.Unlock()
@@ -849,12 +851,15 @@ func updateMessageStats() {
849851
}
850852
} else if MsgLog[i].MessageClass == MSGCLASS_ES {
851853
ES_messages_last_minute++
854+
} else if MsgLog[i].MessageClass == MSGCLASS_FLARM {
855+
FLARM_messages_last_minute++
852856
}
853857
}
854858
}
855859
MsgLog = t
856860
globalStatus.UAT_messages_last_minute = UAT_messages_last_minute
857861
globalStatus.ES_messages_last_minute = ES_messages_last_minute
862+
globalStatus.FLARM_messages_last_minute = FLARM_messages_last_minute
858863

859864
// Update "max messages/min" counters.
860865
if globalStatus.UAT_messages_max < UAT_messages_last_minute {
@@ -863,6 +868,9 @@ func updateMessageStats() {
863868
if globalStatus.ES_messages_max < ES_messages_last_minute {
864869
globalStatus.ES_messages_max = ES_messages_last_minute
865870
}
871+
if globalStatus.FLARM_messages_max < FLARM_messages_last_minute {
872+
globalStatus.FLARM_messages_max = FLARM_messages_last_minute
873+
}
866874

867875
// Update average signal strength over last minute for all ADSB towers.
868876
for t, tinf := range ADSBTowers {
@@ -1149,6 +1157,9 @@ type status struct {
11491157
UAT_messages_max uint
11501158
ES_messages_last_minute uint
11511159
ES_messages_max uint
1160+
FLARM_messages_last_minute uint
1161+
FLARM_messages_max uint
1162+
FLARM_connected bool
11521163
UAT_traffic_targets_tracking uint16
11531164
ES_traffic_targets_tracking uint16
11541165
Ping_connected bool

web/plates/js/status.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ function StatusCtrl($rootScope, $scope, $state, $http, $interval) {
5050
$scope.UAT_messages_max = status.UAT_messages_max;
5151
$scope.ES_messages_last_minute = status.ES_messages_last_minute;
5252
$scope.ES_messages_max = status.ES_messages_max;
53+
$scope.FLARM_messages_last_minute = status.FLARM_messages_last_minute;
54+
$scope.FLARM_messages_max = status.FLARM_messages_max;
55+
$scope.FLARM_connected = status.FLARM_connected;
5356
$scope.GPS_satellites_locked = status.GPS_satellites_locked;
5457
$scope.GPS_satellites_tracked = status.GPS_satellites_tracked;
5558
$scope.GPS_satellites_seen = status.GPS_satellites_seen;

web/plates/status.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
<span class="col-xs-6"><div class="bar_container"><div class="bar_display traffic-style1" ng-attr-style="width:{{ES_messages_max ? 100*ES_messages_last_minute / ES_messages_max : 0}}%;">{{ES_messages_last_minute}}</div></div></span>
4747
<span class="col-xs-2 text-right">{{ES_messages_max}}</span>
4848
</div>
49+
<div class="row" ng-class="{'section_invisible': !visible_flarm}">
50+
<span class="col-xs-1"></span>
51+
<label class="col-xs-3">FLARM{{FLARM_connected ? "" : " (disconnected)"}}:</label>
52+
<span class="col-xs-6"><div class="bar_container"><div class="bar_display traffic-style4" ng-attr-style="width:{{FLARM_messages_max ? 100*FLARM_messages_last_minute / FLARM_messages_max : 0}}%;">{{FLARM_messages_last_minute}}</div></div></span>
53+
<span class="col-xs-2 text-right">{{FLARM_messages_max}}</span>
54+
</div>
4955
<div class="row" ng-class="{ 'section_invisible': (!visible_gps && !visible_ahrs && !visible_uat)}">
5056
<span class="col-xs-1">&nbsp;</span>
5157
</div>

0 commit comments

Comments
 (0)