#ifndef RM_ARM_DRIVER_HPP
#define RM_ARM_DRIVER_HPP

#include "arm_driver.hpp"
#include "rm_service.h"
#include "rm_define.h"

enum {
    RM_DRIVER_UNINIT = 0,
    RM_DRIVER_INIT_OK,
    RM_DRIVER_INIT_ERR
};

class RmArmDriver
{
public:
    RmArmDriver();
    ~RmArmDriver();

    int Init();
    static int ArmMove(const float points[USED_ARM_DOF], int armId);

    using ApiLogFunc = void(*)(const char* message, va_list args);
    void SetCustomApiLog(ApiLogFunc logFunc) {customApiLog_ = logFunc;}

    using RmArmStatusCallbackFun = void(*)(ArmStatusCallbackData *data);
    void RegArmStatusCallback(RmArmStatusCallbackFun callback) {
        armStatusCallback_ = callback;
    }

    static RM_Service *rmService_;

private:
    int initFlag_;
    static ApiLogFunc customApiLog_;
    static RmArmStatusCallbackFun armStatusCallback_;
    static rm_robot_handle *leftRobotHandle_;
    static rm_robot_handle *rightRobotHandle_;

    static void CallbackRmRealtimeArmJointState(rm_realtime_arm_joint_state_t data);
    int InitHandle(rm_robot_handle **robotHandle_, const char *robot_ip_address, int robot_port, rm_realtime_push_config_t *config);
    static void api_log(const char* format, ...);
};

#endif // RM_ARM_DRIVER_HPP