41 lines
1.1 KiB
GDScript
41 lines
1.1 KiB
GDScript
extends BaseWidgetNode
|
|
class_name SatelliteWidgetNode
|
|
|
|
@export_enum("Total", "BeiDou", "Galileo", "GLONASS", "GNSS", "GPS", "NavIC", "QZSS") var sat_category: String = "Total"
|
|
#[ga, gb, gi, gl, gp, gq, gn]
|
|
var sat_idx_map = {
|
|
"Galileo": 0,
|
|
"BeiDou": 1,
|
|
"NavIC": 2,
|
|
"GLONASS": 3,
|
|
"GPS": 4,
|
|
"QZSS": 5,
|
|
"GNSS": 6,
|
|
}
|
|
|
|
var label_node: Label
|
|
|
|
var prev_num_connections: int = 0
|
|
var num_connections: int = 0
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
super._ready()
|
|
sensor_class = "PNT"
|
|
label_node = get_node("Label")
|
|
Signals.sat_count_updated.connect(_on_sat_count_updated)
|
|
label_node.text = sat_category + ": 0"
|
|
|
|
func _on_sat_count_updated(sensor_ip: String, sat_count_array: Array):
|
|
if sat_category == "Total":
|
|
var sat_sum = 0
|
|
for val in sat_count_array:
|
|
sat_sum += val
|
|
num_connections = sat_sum
|
|
else:
|
|
num_connections = sat_count_array[sat_idx_map[sat_category]]
|
|
if num_connections == prev_num_connections:
|
|
return
|
|
label_node.text = sat_category + ": " + str(num_connections)
|
|
prev_num_connections = num_connections
|