package com.qaup.collision.websocket.event;

import com.qaup.collision.datacollector.model.entity.VehicleCommandEntity;
import com.qaup.collision.websocket.message.MessageTypeConstants;


import lombok.Getter;

import java.util.UUID;

/**
 * 车辆指令事件
 * 当车辆控制指令生成并处理完成后发布此事件
 */
@Getter
public class VehicleCommandEvent implements WebSocketEvent {
    
    private final String eventId;
    private final long timestamp;
    private final VehicleCommandEntity payload;
    
    public VehicleCommandEvent(VehicleCommandEntity commandEntity) {
        this.eventId = UUID.randomUUID().toString();
        this.timestamp = java.time.Instant.now().toEpochMilli() * 1000; // 微秒级绝对时间戳
        this.payload = commandEntity;
    }
    
    @Override
    public String getEventType() {
        return MessageTypeConstants.VEHICLE_COMMAND;
    }
    
    @Override
    public Object getPayload() {
        return payload;
    }
    
    /**
     * 获取车辆ID
     */
    public Long getVehicleId() {
        return payload.getVehicleId();
    }
    
    /**
     * 获取指令类型
     */
    public String getCommandType() {
        return payload.getCommandType().name();
    }
    
    /**
     * 获取指令原因
     */
    public String getCommandReason() {
        return payload.getCommandReason().name();
    }
} 