/*********************************************************************************/
/* FILE NAME  : scene_recognition.h                                                    */
/* AUTHOR     : Zhang Jingrui, ID: 11082826, Version: V0.1_Beta, Data:2019-03-28       */
/* DESCRIPTION: This header file conterns the prototype description of the external    */
/*              interface funtions of the scene recognition module and the definit-    */
/*              ion of related resources.                                              */
/* HISTORY    : (NONE)                                                                 */
/********************************************************************************/

#ifndef _PDR_SCENE_RECOGNITION_H_
#define _PDR_SCENE_RECOGNITION_H_

/* Header Files Including -----------------------------------------*/
/*=================================================================*/
#include "pdr_sensor.h"

/* Macro Declaration ----------------------------------------------*/
/*=================================================================*/

#define _TIME_BUFFER_SIZE               10      /* Buffer size for the time calculation.                   */
#define _ACCURACY_BUFFER_SIZE           9       /* Accuracy time-based buffer size.                        */
#define _GNSS_INDEX_LEN                 103     /* Structural array size in _GnssInfo.                     */

/* Extern Variable Declaration ------------------------------------*/
/*=================================================================*/
//extern int scene_recognition_debug_flag ;
//extern int scene_recognition_log_debug_flag ;

/* Status Declaration ---------------------------------------------*/
/*=================================================================*/
/* Usage: ����ʶ��ģ���ʼ�������ò������״̬��־λ                   */
typedef enum SCENE_INIT_STATE
{
    // ����ʶ��ģ���ʼ�����״̬
            INIT_SUCCESS = 0,
    INIT_NOT_PERFORMED,

    INIT_ERROR_MEMORY_OCCUPIED,     // ģ����Դδ��ǰ�ͷţ������ͷ���Դ
    INIT_ERROR_MEMORY_INIT_FAILED,  // ��ʼ���ڴ�����ʧ��
    INIT_ERROR_REDUNDANCY,          // ģ���ظ���ʼ������ʱ��ʼ����Ч������Ҫ����ģ�飬���ԣ�
    // ����1���ȹر�ģ�飬�رճɹ������³�ʼ��ģ�顣
    // ����2������ģ�飬Ч��ͬ����1��
    // ����ʶ��ģ���������״̬(for debug)
            INIT_RESET_SUCCESS = 0,
    INIT_RESET_FAILED
} SCENE_INIT_STATE;

/* Usage: ����������                                            */
typedef enum SCENE_RECOGNITION_RESULT
{
    RECOG_UNKNOWN,                  // δ��ȷ��������״̬(Ĭ��״̬)
    RECOG_OPEN_AREA,                // ����open-area
    RECOG_OTHERS,                   // ��������ȷ�����������������
    RECOG_ERROR_PARAM_INCRECT,      // �������������
    RECOG_ERROR_NMEA_INFO_MISS,     // ���������ȷ������������
    /* Ԥ�м����(���ȶ�) */
            RECOG_MULTIPATH             // ���ྶ
} SCENE_RECOGNITION_RESULT;

/* Usage: ����ʶ��ģ����Դ�ͷŲ������                             */
typedef enum SCENE_DESTROY_STATE
{
    DESTROY_SUCCESS = 0,
    DESTROY_FIALED,
    DESTROY_ERROR,
    DESTROY_INVALID     // ��Ч�ͷŲ�������ʾû�ж�Ӧ�ij�ʼ�������ò���
} SCENE_DESTROY_STATE;


/* Status Declaration--------------------------------------------*/
/*===============================================================*/

// ������ǰ����ʶ��ģ��Ĺ���״̬
typedef enum _SCENE_MODEL_WORK_STATE
{
    MODEL_OFF,
    MODEL_ON
} _SCENE_MODEL_WORK_STATE;

/* Usage: Identifier of the quality of the satellites' signal source. */
typedef enum _SIGNAL_QUALITY
{
    SIG_UNKNOWN,
    GOOD,
    BAD
} SIGNAL_QUALITY;

/* Usage: extract and save information from lct_nmea for the module. */
/*        This is the interface for the lct_nmea.                    */
typedef struct _GnssInfo
{
    int    update;                                         // GNSS���±�־λ 1������ 0��������
    double local_timestamp;                                // ����ʱ��
    float  accuracy;                                       // GPS �����Accuracy������Accuracy > 0 ����Ϊ������ʾ��Ч
    int    sat_visible_number;                             // ��ǰʱ��ɼ���������
    float  snr_list[_GNSS_INDEX_LEN];               // ��ǰʱ��ɼ����ǵ�SNR�б�
    int    sat_used_list[_GNSS_INDEX_LEN];               // ��ǰʹ�������б�
} GnssInfo;

/* Usage: ���GNSS�еĸ�������ϵͳ                                 */

/* Struct Declaration -------------------------------------------*/
/*===============================================================*/


/* Function Declaration -------------------------------------------*/
/*=================================================================*/
#ifdef __cplusplus
extern "C" {
#endif

/* Function Name: sceneRecognitionInit()                   */
/* Usage: Initialization module for configuring related resources  */
/*        and must be executed once first beforing using the scene */
/*        recognition module funcition.                            */
/* Param  @ (NONE)                                                 */
/* Return @ init_res: Result state of the initialization process.  */
SCENE_INIT_STATE initSceneRecognition(void);

/* Function Name: scene_recognition_reset()                      */
/* Usage: ��ʼ��ģ�飬���������Դ����ʹ��ģ��ǰ�������ȱ�ִ�С�      */
/* Param  @ (NONE)                                               */
/* Return @ init_res: ����ִ�н����                              */
SCENE_INIT_STATE scene_recognition_reset(void);

/**----------------------------------------------------------------------
* Function    : sceneRecognitionProc
* Description : GNSS����ʶ�������̣�
*               1����nmeaת��Ϊgnss
*               2) ͨ��accuracy��snr��������������GNSS�ź�����
*               3) ���ؽ��
* Input       : PDR��nmea�ṹ��
* Return      : ����ʶ����
* Date        : 2020/02/18  
* 
* 
* 
* 
* 
* 
*---------------------------------------------------------------------**/
SCENE_RECOGNITION_RESULT sceneRecognitionProc(const lct_nmea* nmea);

/* Function Name: scene_recognition_destroy()                    */
/* Usage: ����ʶ�������������Դ�ͷŲ�������Դ�ͷź��޷��������г�  */
/*        ��ʶ����̡�                                            */
/* Param  @ (NONE)                                               */
/* Return @ destroy_state: ��Դ�ͷŲ��������                      */
SCENE_DESTROY_STATE scene_recognition_destroy(void);

/**----------------------------------------------------------------------
* Function    : isOpenArea
* Description : GNSS�����ؼ�⣬ͨ������GNSS�źţ�������ǰ�ź��������Ӷ�ȷ��
*               Ŀ���Ƿ��ڿ������ء�
* Return      : 0 : �ǿ�����  1��������(�ź������Ϻ�)
* Author      : Zhang Jingrui, Geek ID: 11082826
* Date        : 2020/02/18  logzhan
*---------------------------------------------------------------------**/
int isOpenArea(const lct_nmea* nmea);

#ifdef __cplusplus
}
#endif
#endif  //__SCENE_RECOGNITION_H__