/**
* @file
* @brief    
* @details  
* @author   Junlong Cheng. Email: chengjunlong@whu.edu.cn
* @date     2021/10/19
* @version  1.0
* @par      Copyright(c) 2012-2021 School of Geodesy and Geomatics, University of Wuhan. All Rights Reserved.
* @par      History:
*           2021/10/19,Junlong Cheng, new \n
*/

#ifndef __X_DEFINE_INTERNAL_H__
#define __X_DEFINE_INTERNAL_H__

#define GLOBAL_ROS_NAMESPACE    "planet_smartpnt"

#define DEVICE_TYPE_NONE        0x00
#define DEVICE_TYPE_MCS_TCP     0x01
#define DEVICE_TYPE_MCS_UDP     0x02
#define DEVICE_TYPE_CAM_UDP     0x03
#define DEVICE_TYPE_IMU_UDP     0x04
#define DEVICE_TYPE_CAM         0x05
#define DEVICE_TYPE_IMU         0x06
#define DEVICE_TYPE_LID         0x07
#define DEVICE_TYPE_ODO         0x08
#define DEVICE_TYPE_GPS         0x09
#define DEVICE_TYPE_ALL         0xFF

#define DEVICE_STATUS_ROS_TOPIC "/device_status_ros_msg"

#define DEVICE_STATUS_UNKNOWN   0   // not open or timeout
#define DEVICE_STATUS_START     1   // has already started
#define DEVICE_STATUS_ACTIVE    2   // active
#define DEVICE_STATUS_TIMEOUT   3   // timeout
#define DEVICE_STATUS_STOP      4   // timeout

#define DEVICE_COMMAND_ROS_TOPIC "/device_command_ros_msg"
#define DEVICE_COMMAND_UNKNOWN  0   // unknown
#define DEVICE_COMMAND_START    1   // start
#define DEVICE_COMMAND_ACTIVE   2   // stop
#define DEVICE_COMMAND_STATUS   3   // status

#define MAX_CAM_COUNT        8
#define CAM_SYNC_ROS_TOPIC      "/cam_sync_ros_msg"
#define CAM_SYNC_MSG_QUE_PREFIX "cam_sync_msg_que"
#define CAM_SYNC_MSG_QUE_FORMAT "%02d"

#define MAX_IMU_COUNT           3
#define MAX_GPS_COUNT           4
#define MAX_LID_COUNT           1

#define DEVICE_START_REQUEST_SRV_NAME   "device_start_req_ros_srv"
#define DEVICE_STATUS_QUERY_SRV_NAME    "device_status_query_srv"

#define DATA_SAVE_PATH_SRV_NAME   "/device_manager/data_save_path_srv"

typedef struct CAM_SYNC_MSG
{
    long                seq;
    double              systime;
    double              gpstime;
    
    CAM_SYNC_MSG()
    {
        seq = 0;
        systime = 0.0;
        gpstime = 0.0;
    }   
} CAM_SYNC_MSG;

typedef struct CAM_SYNC_MSG_QUE
{  
    long int msg_type; 
    CAM_SYNC_MSG    msg;
    
    CAM_SYNC_MSG_QUE()
    {
        msg_type = -1;
    }
} CAM_SYNC_MSG_QUE;

typedef struct DEVICE_STATUS_MSG
{
    int         type;   // device type
    int         id;     // device id
    int         status; // device status
    
    DEVICE_STATUS_MSG()
    {
        type =  DEVICE_TYPE_NONE;
        id   = -1;
        status = DEVICE_STATUS_UNKNOWN;
    }   
} DEVICE_STATUS_MSG;


// Linux消息队列相关，发送和接收方必须使用同一个，定义在这儿
/*
 i = 0, msgStrKey = cam_sync_msg_que_00, msgQueKey = 48071, msgQueId = 262148
 i = 1, msgStrKey = cam_sync_msg_que_01, msgQueKey = 44006, msgQueId = 294917
 i = 2, msgStrKey = cam_sync_msg_que_02, msgQueKey = 39813, msgQueId = 327686
 i = 3, msgStrKey = cam_sync_msg_que_03, msgQueKey = 35748, msgQueId = 360455
 i = 4, msgStrKey = cam_sync_msg_que_04, msgQueKey = 64323, msgQueId = 393224
 i = 5, msgStrKey = cam_sync_msg_que_05, msgQueKey = 60258, msgQueId = 425993
 i = 6, msgStrKey = cam_sync_msg_que_06, msgQueKey = 56065, msgQueId = 458762
 i = 7, msgStrKey = cam_sync_msg_que_07, msgQueKey = 52000, msgQueId = 491531
*/
static int CAM_SYNC_MSG_QUE_KRY[MAX_CAM_COUNT+1] = {
    48071, /* cam_sync_msg_que_00 */
    44006, /* cam_sync_msg_que_01 */
    39813, /* cam_sync_msg_que_02 */
    35748, /* cam_sync_msg_que_03 */
    64323, /* cam_sync_msg_que_04 */
    60258, /* cam_sync_msg_que_05 */
    56065, /* cam_sync_msg_que_06 */
    52000, /* cam_sync_msg_que_07 */
    00000
};


#endif // __X_DEFINE_INTERNAL_H__