#ifndef __GYDCG_UBCH2_H__
#define __GYDCG_UBCH2_H__
#include "com_ttySx.h"
#include "modbus_RTU.h"
#include <asm-generic/ioctls.h>  /* TIOCGRS485 + TIOCSRS485 ioctl definitions */

#include <stdint.h>
#include <math.h>

typedef struct DCGround
{
    com_ttySx_t tty;
    uint16_t salve;
    uint8_t onoff[2];

    uint16_t state[2];
    float Vol[2];
    float R_P[2];
    float R_N[2];

    pthread_mutex_t mutex;
}DCGround_t;

int ccu_DCGround_init(DCGround_t* dev, const char* devname);
void ccu_DCGround_exit(DCGround_t* dev);

void ccu_DCGroundA_set(DCGround_t* dev, int on);
void ccu_DCGroundB_set(DCGround_t* dev, int on);

float ccu_DCGroundA_readV(DCGround_t* dev);
float ccu_DCGroundA_readR_P(DCGround_t* dev);
float ccu_DCGroundA_readR_N(DCGround_t* dev);
void ccu_DCGroundA_check(DCGround_t* dev, float* VGround, float* RGround);


float ccu_DCGroundB_readV(DCGround_t* dev);
float ccu_DCGroundB_readR_P(DCGround_t* dev);
float ccu_DCGroundB_readR_N(DCGround_t* dev);
void ccu_DCGroundB_check(DCGround_t* dev, float* VGround, float* RGround);

#endif//__GYDCG_UBCH2_H__
