#pragma once
#include "HIKBase.h"

#define PTZ_LEFT 1 // 云台向左
#define PTZ_RIGHT 2 // 云台向右
#define PTZ_UP 3 // 云台向上
#define PTZ_DOWN 4 // 云台向下
#define PTZ_UP_LEFT 5 // 云台左上
#define PTZ_UP_RIGHT 6 // 云台右上
#define PTZ_DOWN_LEFT 7 // 云台左下
#define PTZ_DOWN_RIGHT 8 // 云台右下
#define PTZ_ZOOM_IN 9 // 云台放大
#define PTZ_ZOOM_OUT 10 // 云台缩小
#define PTZ_Focus_Far 11 // 云台聚焦+
#define PTZ_Focus_Near 12 // 云台聚焦-

class HIKBallCamera : public HIKBase
{
public:
    HIKBallCamera();
    bool InitBallCamera(std::string ip, std::string port, std::string username, std::string password, std::string BallMachineType);
    bool PtzGotoPut(int Action, float P, float T, float Z = 0);
    bool PtzGet(float *posP, float *posT, float *posZ);
    bool StopBus(int direction);
    bool StartBus(int direction,int speed);

private:
    LONG lTranHandle;
    std::string BallMachineType;
    int m_Channel;

private:
    bool PtzControlUp(int speed,int state);
    bool PtzControlDown(int speed,int state);
    bool PtzControlLeft(int speed,int state);
    bool PtzControlRight(int speed,int state);
    bool PtzControlUpLeft(int speed,int state);
    bool PtzControlUpRight(int speed,int state);
    bool PtzControlDownLeft(int speed,int state);
    bool PtzControlDownRight(int speed,int state);
    bool PtzControlZoomIn(int speed,int state);
    bool PtzControlZoomOut(int speed,int state);
    bool PtzControlFocusAdd(int speed,int state);
    bool PtzControlFocusSub(int speed,int state);
private:
    /**
     * @brief 使用海康485透传接口发送透传数据
     *
     * @param hex 十六进制透传数据字符串
    **/
    bool SerialSend(const std::string& hex);
private:
    /**
     * @brief PTZ 控制相关的 Switch 集合
     *
     * @param direction PTZ 方向
     * @param speed PTZ 速度
     * @param state PTZ 启停状态
    **/
    bool CmdSwitch(int direction,int speed,int state);
    bool PtzControl(int command, int stop, int speed);
    bool PtzControlStop();
    void static CALLBACK g_fSerialDataCallBack(LONG lSerialHandle,	LONG lChannel, char *pRecvDataBuffer, DWORD dwBufSize, void *pUser);

};
