#pragma once

#include <cstdint>
#include <string>
#include <vector>
#include <chrono>

int64_t getCurrentTimestampMs()
{
    using namespace std::chrono;
    return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}

struct GeneralMsg
{
    float power = 0.0f;        // 电量 %
    bool chargeStatus = false; // 是否在充电
    int gear = 0;              // 档位
    float speed = 0.0f;        // 当前速度 km/h
    int waterLevel = 0;        // 水位
    int motorTemp = 0;         // 电机温度 °C
    int64_t timestamp = 0;     // 时间戳
};

struct BMSFault
{
    uint8_t TemHighF;
    uint8_t TemLowF;
    uint8_t TemDevBigF;
    uint8_t CVHighF;

    uint8_t CVLowF;
    uint8_t CVDevBigF;
    uint8_t ChaCurrBigF;
    uint8_t DisCurrBigF;

    uint8_t InsuFadeF;
    uint8_t ChaPowOverLimF;
    uint8_t DisPowOverLimF;
    uint8_t SOCLowF;

    uint8_t ContactorAdhesion;
    uint8_t ContactorInvalid;
    uint8_t PrechaFailF;
    uint8_t InterComErrF;

    uint8_t ExterComErrF;
    uint8_t DisSysVolLowF;
    uint8_t ChaSysVolLowF;
    uint8_t ErrLevelF;

    uint8_t ChargeUTF;
    uint8_t WiresF;
    uint8_t TempSensorF;
    uint8_t SOHLowF;

    uint8_t InternalFanF;
    uint8_t HeatingModuleF;
    uint8_t ChargerStatus;
    uint8_t HaLLZeroRefF;
};
