#ifndef __CCU_PORT_H__
#define __CCU_PORT_H__
#include <stdio.h>
#include <stdint.h>
#include "mtimer.h"
#include "mthread.h"
#include "msystem.h"
#include "ccu_config.h"

typedef struct ccu_port
{
    void    *priv;

    ccu_config_t *config;

    void    *qttcu;
    void    *ocpp0;
    void    *ocpp1;

    void    *pcuA;
    void    *pcuB;
    
    void    *seccA;
    void    *seccB;

    float   BOX_Temp;

    mthread_t threadIO;
    mthread_t threadCmd;
    int fd[2];

    uint16_t resv0;
    uint16_t transID;
    uint8_t rxbuff[1024];
    int rxbyte;

    int quit;

    float limit_CPMaxPowerKW;
    float limit_CPMaxCurrent;

    void (*report_GUN_information)(void *self, void* secc);
}ccu_port_t;


extern ccu_port_t ccu_port;

void ccu_send_GUN_error_state(void* self, int connectorId, uint32_t GUN_Error, uint32_t GUN_State);

void ccu_send_GUN_MeterValues(void* self, int connectorId);

void ccu_send_TransactionStart(void* self, int connectorId);

void ccu_send_TransactionStop(void* self, int connectorId, int transactionId);


int ccu_BSP_init(void);

void ccu_BSP_exit(void);

int ccu_SYS_init(void);

void ccu_SYS_exit(void);

void* ccu_SYS_loop(void* argv);

#endif//__CCU_PORT_H__
