LargeScreen/main_perspectiveinfo.gd
2025-01-13 17:53:01 +08:00

39 lines
1.2 KiB
GDScript

extends Panel
func _ready() -> void:
Websocket.connected_to_server.connect(connected_to_server)
Websocket.message_received.connect(message_received)
func _physics_process(delta: float) -> void:
var current_time = Time.get_datetime_dict_from_system()
%Time.text = str(current_time.hour)+":"+str(current_time.minute)
%Date.text = str(current_time.month)+""+str(current_time.day) + ""
func connected_to_server():
vehicle_info()
pass
func message_received(data:Dictionary):
if data.is_empty():return
if !data.has("topic"):return
match data.topic:
"/hmi_input/app/cloud_control_platform/vehicle_info":
if (data.msg.seatbelt == 0):
%SeatBeltTexture.texture = preload("res://res/icon/icon_safebelt_yes.png")
%SeatBeltText.text = "已系好"
%AnimationPlayer.play("RESET")
pass
else:
%SeatBeltTexture.texture = preload("res://res/icon/icon_safebelt_no.png")
%SeatBeltText.text = "未系好"
%AnimationPlayer.play("1")
pass
%Speed.text = str(data.msg.spd)
pass
func vehicle_info():#所有车辆信息
var send_data = {
"op": "subscribe",
"topic": "/hmi_input/app/cloud_control_platform/vehicle_info",
"type": "pixmoving_hmi_msgs/msg/VehicleInfo"
}
Websocket.send_msg(str(send_data))