#ifndef module_traffic_light_common_h
#define module_traffic_light_common_h
#include <string>
#include <list>
#include "point.h"

enum device_type{
    DT_BIG_READER = 1,      // 大分站
    DT_SMALL_READER = 2,    // 小分站
    DT_CARD_READER = 3,     // 读卡分站
    DT_CTRL_READER = 4,     // 通信分站
    DT_LIGHT = 5,           // 红绿灯
    DT_SPEAKER = 6,         // 告警器
    DT_TURNOUT = 7,         // 道岔
    DT_LED = 8,             // 显示屏
};

// 灯的颜色和形状表
enum light_shape{
    init_shape          = 0,
    red_circle_solid    = 1,    // 红色实心圆
    red_circle          = 2,    // 红色空心圆
    red_cross           = 3,    // 红色叉型
    green_up            = 4,    // 绿色上箭头
    green_down          = 5,    // 绿色下箭头
    green_left          = 6,    // 绿色左箭头
    green_right         = 7,    // 绿色右箭头
    red_spark           = 8,    // 红色闪烁
    green_spark         = 9,    // 绿色闪烁
    green_all_on        = 10,   // 绿色全亮
    green_all_off       = 11,   // 绿色全灭
    red_all_on          = 12,   // 红色全亮
    red_all_off         = 13    // 红色全灭
};

//优先级
enum priority{
    priority_init           = 0,      // 初始值
    priority_crossing       = 1,      // 路口控制
    priority_avoidance      = 2,      // 避让控制
    priority_manual_ctrl    = 3,      // 手动控制
};

//web对应的
enum light_color{
    init = 1,   // 初始值
    red,        // 红灯
    green,      // 绿灯
    spark       // 闪烁
};

enum light_cmd{
    cmd_reload      = 0,    // 重新加载红绿灯信息
    cmd_manual_ctrl,     // 手动控制红绿灯信息
    cmd_card_data,          // 卡数据
};

struct pos_data: point{
    uint64_t m_card_id;     // 卡id
    uint8_t  m_type;        // 1-add,2-del,3-update
    bool m_bigger;          // 大小车标记
    int32_t m_area_id;      // 区域id
    double m_speed;         // 速度
    std::list<int> m_light_group;   // 红绿灯id

    pos_data(): m_card_id(0), m_type(0), m_bigger(false), m_area_id(0), m_speed(0.0)
    {
        m_light_group.clear();
    }
};

struct light_message{
    uint16_t m_cmd;             // 命令
    int m_group_id;             // 信号灯组id
    int m_light_id;             // 信号灯id
    int m_light_status;         // 信号灯形状
    std::string m_ctrl_name;    // 控制用户
    pos_data m_pos;             // 卡数据

    light_message(): m_cmd(0), m_group_id(0), m_light_id(0), m_light_status(0), m_ctrl_name("")
    {}

    light_message(const uint16_t cmd, const int gid, const int lid, const int ls, const std::string name, const pos_data& p): m_cmd(cmd), m_group_id(gid), m_light_id(lid), m_light_status(ls), m_ctrl_name(name), m_pos(p)
    {}
};

const double g_max_scope = 100.0;
const double g_mid_vehicle_length_group = 30.0;

#endif