/*
 *========================================================================
 *
 *    : AZN_PLAZA_LANE APP
 *      : ipc_def.h
 *      : JBY
 *      : 2018.07.13
 *      :
 *        : TCS IPC(Inter Process Communication) define
 *
 *========================================================================
*/

#ifndef    _IPC_DEF
#define    _IPC_DEF

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include "def_set.h"
#include "lane_stat_info.h"

#define    CREATE_PERM      (0644 | IPC_CREAT)

/*------------------------------------------------------------------------------------------------
 *  shared memory KEY Define.
 *-----------------------------------------------------------------------------------------------*/
#define  START_SHM_KEY        0x0C00
#if 0
#define  TCS_D_ICGGMJR12_SHM       (START_SHM_KEY + 1)   /* TCS  #1   KEY */
#define  TCS_D_ICGGMJR34_SHM       (START_SHM_KEY + 2)   /* TCS  #2   KEY */
#endif

#define	AZN_LANE_STAT_SHM	(START_SHM_KEY + 1)
#define	AZN_RPR_INFO_SHM	(START_SHM_KEY + 2)
#define	AZN_CLS_THWS_SHM	(START_SHM_KEY + 3)
#define	AZN_SENS_DATA_SHM	(START_SHM_KEY + 4)
#define	AZN_WRK_STAT_SHM	(START_SHM_KEY + 5)
#define	AZN_OUT_PROC_SHM	(START_SHM_KEY + 6)
#define	AZN_PROC_VHCL_SHM	(START_SHM_KEY + 7)
#define	AZN_IN_PROC_SHM		(START_SHM_KEY + 8)
#define	AZN_IN_SPC_PROC_SHM	(START_SHM_KEY + 9)
#define	AZN_OPC_PROC_SHM	(START_SHM_KEY + 10)
#define	AZN_VIO_RCP_SHM		(START_SHM_KEY + 11)

/* TCS IPC key */
#define    KQ_RTRA    (key_t)0x1770    /* ©£                      */
#define    TB_ORAC    (key_t)0x1757    /* ORACLE                        */
#define    KM_KMST    (key_t)0x1760    /* ¥á-> MONITOR SHM.   */
#define    KM_SMON    (key_t)0x1710    /*  -> ¥á(¥ë MON)*/
#define    KS_CRIT    (key_t)0x2110    /* SEMAPHORE CRITICAL REGION JOB         */
#define    LC_SAVE    (key_t)0x3101    /* SOCKET READ                       */
#define    KQ_RTEC    (key_t)0x2770    /*  / ©£         */

struct    oracon {            /*  Connect            */
    int     flag;             /*  Connect            */
    char    contime[14+1];    /*  flag                 */
};

struct    lo_lane_ctrl_cmd { /*              */
    uchar    cmd;            /* COMMAND                      */
    unint    arg[2];         /* COMMAND ARGUMENTs          */
    uchar    wrk_year[4];    /*        */
    uchar    wrk_mon[2];     /*                            */
    uchar    wrk_day[2];     /*                            */
    uchar    wrk_no[4];      /*          */
    uchar    msg[4096];      /*    */
                             /* ,  */
                             /*                  */
                             /*  , LSAM, PSAM  */
};

struct    lo_lane_ctrl_reply { /*             */
    uchar    cmd;              /*                     */
    uchar    rsp;              /* (0: , 1: ERROR) */
    uchar    fin;              /*    ?            */
    uchar    cnt;              /*  RETRY COUNT            */
    uchar    leng;             /*  DATA LENGTH            */
    char    msg[80];           /*  MESSAGE STRING     */
};

struct    tag_lane_ctrl_reply { /*  /     */
    uchar    cmd;                /*                            */
    uchar    rsp;                /* (0: , 1: ) */
    uchar    fin;                /*    ?                   */
    unint   leng;                /*  DATA LENGTH                   */
    char    msg[1000];           /*  MESSAGE STRING            */
};

/* lo_lane_ctrl_cmd.cmd :   DESCRIPTION         arg[0]   arg[1]          */
#define LW_PROC_STRT            1          /* PROCESS START               */
#define LW_PROC_END             2          /* PROCESS             */
#define LW_RESND_NO             3          /*                   */
#define LW_TBL_DMP              4          /* TABLE DUMP              */
#define LW_TBLCMD_RQ            5          /* TABLE               */
#define LW_WRKEND_CPL           6          /*             */
#define LW_LANECOMMTEST         7          /*  TEST               */
#define LW_WARR_SND_NO          8          /*             */
#define LW_RQ_SEQ_NO            9          /*                 */

/*  shared memory */
struct sm_wrk_stat {
    uchar    lane_no;            /*  .          */
    uchar    wrk_stat;            /*  .          */
    uchar    wrk_no[4];         /*  .          */
    uchar    wrkr_no[6];         /*  .        */
    uchar    wrkr_nm[10];        /*  .        */

    ushort   wrk_year;           /*  .        */
    uchar    wrk_mon;            /*          .        */
    uchar    wrk_day;            /*          .        */

    uchar    wrk_strt_day;            /*  .        */
    uchar    wrk_strt_hr;            /*          .        */
    uchar    wrk_strt_min;            /*          .        */
    uchar    wrk_strt_sec;            /*          .        */

    uchar    wrk_end_day;            /*  .        */
    uchar    wrk_end_hr;            /*          .        */
    uchar    wrk_end_min;            /*          .        */
    uchar    wrk_end_sec;            /*          .        */
    int      cars[2][6];      /* ,  .    */
    uchar    dummy[2];         /* dummy               */
};

struct    sm_lane_info  {                  /* ¥ë SHM     */
    time_t    xtimm_lane_info;                  /*   ©£ */
    time_t    utim[MAX_LANE];        /* ¥ê  ©£     */
    struct    lane_stat_info lane_stat_info[MAX_LANE];   /* ¥ê       */
};

struct    srch_admin {            /*    */
    int    req_code;              /* REQUEST CODE         */
    char   app_nm[16];          /* ¥á           */
    int    hnd_lane_no;              /* ¥é         */
};

struct    reply_admin {          /*      */
    int    req_cd;            /* REQUEST CODE           */
    int    rsp_cd;            /* RSP 0: , -1:ERROR  */
    char   err_msg[80];        /* ERROR MESSAGE          */
    struct    {
        int     tpid;        /* PROCESS ID         */
        char    desc[32];    /* PROCESS        */
        char    appl[16];    /* ¥á         */
        time_t  call;        /*  ©£          */
        int    lane_no;         /* ¥é           */
    } proc[60];              /* PROCESS      */
};

/* c_admin.reqcd */
#define    REQ_KILL    1
#define    REQ_EXEC    2
#define    REQ_STOP    3
#define    REQ_DRUN    4
#define    REQ_INIT    5
#define    REQ_BAR     6
#define    REQ_DUMP    7
#define    SVR_KILL    9

#endif
