#ifndef __MONKEYCAR_PERSON__	
#define __MONKEYCAR_PERSON__

#include "base_card.h"
#include "base_area.h"
#include "base_data.h"
#include "linear_fit.h"
#include "fp_path.h"
#include "cacti/util/Timestamp.h"
#include "cacti/kernel/Mutex.h"
#include "monkey_fit.h"
struct monkey_bus;
struct monkey_area;

#define MAX_POINT_V 30
#define MAX_GETOFF_NUM 5
#define ZERO_  1E-5
extern const int num_fit_point[4];

struct monkey_person:position_interface 
{
	typedef cacti::RecursiveMutex::ScopedLock ScopedLock;
	std::weak_ptr<monkey_bus> m_bus;
	std::shared_ptr<person> m_person;
	//µ÷¼ä¾àµÄµã
	std::deque<st_coord> m_fit_point;


	monkey_person(std::shared_ptr<Card> ptr,monkey_area* pma);

	~monkey_person();
	void GetOnTheBus(std::shared_ptr<monkey_bus> bus,double speed);
	void GetOffTheBus();
	bool Judge_OffIndex();
	void resetOffIndex();
	std::string & getCardId();
	bool is_on_bus() const;
	bool on_step_map(POS_21::fp_path & fppath);

	bool fit_speed(double*ret_speed);
	bool get_num_point(int * p);
	bool init_another_list(size_t index);
	void updata_position() ;
	virtual point_2 get_position();
	virtual bool save_point();

	
	
	inline void setCompensationSpeed(double v)
	{
		debug_print_syslog(0,"[framework adjust speed] :%s,v:%f",getCardId().c_str(),v);
		m_compensation_speed = v;
	}

	bool screen_Point(u16 ct,double dis);
	void reset(double speed);
	void Set_AverageSpeed();
	void handle_monkeycar_fit(double);
public:
	int m_getOffIndex;
	uint16_t m_ori_ct;
	double m_cur_distance;   //curTime distance
	u16 m_longTime_NoRecvData_Index ;
	double m_compensation_speed;
	u64    m_timeval;
	u64    m_adjustDis_timeval;
	uint64_t m_timestamp;

	st_coord  m_go_up_point; // go on point
	comp_linear_fit* m_linear_fit;
	cacti::RecursiveMutex m_monitor;
	std::array<monkey_fit*,2> mp_monkey_fit;
};

#endif