extends BaseSensorNode
class_name SatelliteSensorNode


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	super._ready()
	DataSignals.sat_data_received.connect(_on_data_received)
	
func _on_data_received(source_ip: String, timestamp_list: Array, sat_counts: Array, sat_positions: Array):
	if source_ip != ip_address:
		return
	var msg_timestamp = timestamp_list[0] * 3600 + timestamp_list[1] * 60 + timestamp_list[2] + timestamp_list[3]
	if not Constants.is_timestamp_newer(timestamp, msg_timestamp):
		return
	timestamp = msg_timestamp
	var sat_ids = []
	for sat_data in sat_positions:
		sat_ids.append(sat_data[0])
		#sat_position = _calc_sat_position(sat_data[1], sat_data[2])
	Signals.sensor_sats_updated.emit(ip_address, self)
	Signals.sat_count_updated.emit(ip_address, sat_counts)
	#Signals.sat_position_updated.emit(ip_address, sat_positions)
