#ifndef MINE_H
#define MINE_H

/**
 * @brief 矿井里相关的业务
 * @author 戴月腾
 * @date 2018-09-24
 */

#include <unordered_map>
#include <log.h>
#include <chrono>
#include "common.h"
#include <memory>

struct card_location_base;
struct mine_tool
{
    mine_tool()
		:m_over_speed_count(0)
		,m_normal_speed_count(0)
		,m_status_call(0)
        ,m_is_attendance(false)
		,m_attendance_start_time(std::chrono::seconds(0))
		,m_is_overtime(false)
		,m_overtime(std::chrono::seconds(0))
    {

    }

    int    m_over_speed_count;
    int    m_normal_speed_count;
    ///CALL_NONE(0):没有呼叫，CALL_ING（2）：正在呼叫，CALL_SUCCESSED（1）：呼叫成功
    int m_status_call;

    ///考勤状态  0初始状态 1 没在考勤 2 考勤;参看ATTENDANCE_STATUS
    bool m_is_attendance;
    ///考勤开始时间
    std::chrono::system_clock::time_point m_attendance_start_time;
    //井下是否超时
    bool m_is_overtime;
    //井下超时时间
    std::chrono::system_clock::time_point m_overtime;

    void on_point(uint32_t card_id, int32_t type, int vehicle_category_id);

    //检查井下超时
    void on_check_overtime(uint32_t card_id, int32_t type);
	uint64_t get_down_time();
	uint64_t get_work_time();
	int32_t is_on_duty();

};
#endif // MINE_H
