#pragma once
#include <cmath>
#include <stdlib.h>

enum ErrorCode
{
	SUCCESS = 0,
	CLASS_OBJ_NULL = 30000,


	FUN_UNSUPPORT = 31000,

	//文件相关错误
	FILE_ERR_EXIST = 32000,
	FILE_ERR_NOEXIST,
	FILE_ERR_READ,
	FILE_ERR_WRITE,
	FILE_ERR_FORMAT,
	FILE_ERR_DEL,

	//数据错误
	DATA_ERR_LEN = 33000,
	DATA_ERR_INVALID,
	DATA_ERR_MD5,
	DATA_ERR_KEY,
	DATA_ERR_RANGE,

	//功能执行失败
	APP_ERR_EXEC = 34000,
	APP_ERR_ACK,

	//相关加密内容
	ENCRYPT_ERROR_BASE = 37000,

	// 运行加密算法
	RUN_ENCRYPT_SUCCESS = 0,
	RUN_ENCRYPT_LOAD = 39000,
	RUN_ENCRYPT_NOT_LOAD,
	RUN_ENCRYPT_RELEASE,
	RUN_ENCRYPT_NO_FUN,
	RUN_ENCRYPT_ARG,

	//网络错误
	NET_SUCCESS = 0,
	NET_ERR_CREAT_INIT = 40000,
	NET_ERR_CREAT_BIND,
	NET_ERR_CREAT_LISTEN,
	NET_ERR_CONNECT,
	NET_ERR_ACCEPT,
	NET_ERR_IP_INVALID,
	NET_ERR_NOTINIT,

	NET_ERR_SEND_DATA = 40100,
	NET_ERR_RECV_CMD,
	NET_ERR_RECV_DATA,
	NET_ERR_RECV_DATA_LACK,
	NET_ERR_ARG,
	NET_ERR_CONFIG,

	NET_ERR_CONFIG_GET_IP,
	NET_ERR_REMOVE_FD_FAILED,
	NET_ERR_GET,

	NET_DEV_NOT_FIND = 40300,
	NET_DEV_NOT_RIGHT,

	NET_DEV_CLIENT_LINK = 41000,
	NET_DEV_CLIENT_SENDLEN,
	NET_DEV_CLIENT_RECV,

	// 设备类型
	DEV_TYPE_ERR		= 50000,
	DEV_NOT_FIND,
    DEV_NO_OPEN,
    DEV_ID_ERR,
    DEV_OPEN_ERR,
    DEV_CLOSE_ERR,
    DEV_CTRL_ERR,
    DEV_SEND_ERR,
    DEV_RECV_ERR,
    DEV_CTRL_TIMEOUT,
    DEV_UNSUPPORT,
    DEV_ARG_INVAILD,
    DEV_BUSY,
	DEV_CONFIG_ERR,


};

#define ERR_CODE(nCode) -std::abs((int)nCode)
#define ERR_CODE_RETURN(nCode) do{ if(SUCCESS != (nCode)) return ERR_CODE(nCode); }while(0)

#define ERRCODE(nCode) -std::abs((int)nCode)
