/*******************************************************************************
*                                   ZMC
*                       ----------------------------
*                          ZHIYUAN Machine Control
*
* Copyright (c) 2001-2020 Guangzhou ZHIYUAN Electronics Co., Ltd.
* All rights reserved.
*
* Contact information:
* web site:    http://www.zlg.cn/
*******************************************************************************/
 
/*----------------------------------------------------------------------------*/
/**
 * @file
 * @brief 错误码
 *
 * @internal
 * @par Modification history
 * - 1.00 2023-5-29  ZBL, 初次实现
 * @endinternal
 */
/*----------------------------------------------------------------------------*/
#ifndef ZMC_PCI_ERRNO_H_
#define ZMC_PCI_ERRNO_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

#define ECAT_TEXT(text) text
typedef int ECAT_RESULT;

typedef enum
{
    ECAT_S_OK = 0,
    ECAT_S_SIZE_LIMIT = 1,
    ECAT_S_NOITEMS = 2,
    ECAT_S_PI_ALREADY_SYNC = 3,
    ECAT_S_NOITEMS_MAILBOX_WAIT = 4,
    ECAT_S_TIMEOUT = 5,
    ECAT_S_THREAD_EXIT = 6,
    ECAT_S_SYNC_CALL = 7,
    ECAT_S_REDUNDANCY = 8,
    ECAT_S_AGAIN = 9,
    ECAT_S_OBJECT = 10,
    ECAT_S_INVALID_LICENSE = 256,
    ECAT_S_DEMO_TIME_EXPIRED = 257,
    ECAT_S_PI_SYNC_LATE = 528,
    ECAT_S_PI_SYNC_FAST = 544,
    ECAT_E_OUTOFMEMORY = 32769,
    ECAT_E_INVALIDARG = 32770,
    ECAT_E_FAIL = 32771,
    ECAT_E_NOTIMPL = 32772,
    ECAT_E_XML_OPEN = 32773,
    ECAT_E_XML_PARSE = 32774,
    ECAT_E_MASTER_NOT_CONFIGURED = 32775,
    ECAT_E_MASTER_NOT_CONNECTED = 32776,
    ECAT_E_MASTER_ALREADY_CONNECTED = 32777,
    ECAT_E_INVALID_SLAVE_INDEX = 32778,
    ECAT_E_INVALID_TRANSITION = 32779,
    ECAT_E_DRIVER_LOAD = 32780,
    ECAT_E_DRIVER_INIT = 32781,
    ECAT_E_DRIVER_NOT_SUPPORTED = 32782,
    ECAT_E_DRIVER_NOT_LOADED = 32783,
    ECAT_E_SEND_FRAME_FAILED = 32784,
    ECAT_E_RECV_FRAME_FAILED = 32785,
    ECAT_E_TRACE_BUFFER_OVERFLOW = 32786,
    ECAT_E_NOTAVIABLE_TRANSITION = 32787,
    ECAT_E_TRANSITION_ERROR = 32788,
    ECAT_E_INVALID_POINTER = 32789,
    ECAT_E_INVALID_COMMAND_TYPE = 32790,
    ECAT_E_TRANSITION_FORBIDDEN = 32791,
    ECAT_E_SYNC_CALL_TIMEOUT = 32792,
    ECAT_E_MB_COE_TRANSITION_ABORTED = 32793,
    ECAT_E_INVALID_WC = 32794,
    ECAT_E_INVALID_SLAVE_STATE = 32795,
    ECAT_E_SNAPSHOT_DATA_LOSE = 32796,
    ECAT_E_XML_LICENSE_OPEN = 32797,
    ECAT_E_XML_LICENSE_PARSE = 32798,
    ECAT_E_XML_LICENSE_PRODUCT_NAME = 32799,
    ECAT_E_XML_LICENSE_LICENSED_TO = 32800,
    ECAT_E_XML_LICENSE_EXP_DATE = 32801,
    ECAT_E_XML_LICENSE_DEMO_MODE = 32802,
    ECAT_E_XML_LICENSE_HW_BINDING = 32803,
    ECAT_E_XML_LICENSE_PRODUCT_KEY = 32804,
    ECAT_E_CMD_ACYCLIC_SET_DATA = 32805,
    ECAT_E_CMD_CONTAINER_ADD_RES_CMD = 32806,
    ECAT_E_BUFFER_SIZE_LIMIT = 32807,
    ECAT_E_TELEGRAM_BUILD = 32808,
    ECAT_E_FRAME_BUILD = 32809,
    ECAT_E_LOAD_FORBIDDEN = 32810,
    ECAT_E_INVALID_CONFIGURATION = 32811,
    ECAT_E_READ_SLAVE_STATES = 32812,
    ECAT_E_TRANSIT_SLAVES = 32813,
    ECAT_E_SEND_MASTER_CMDS = 32814,
    ECAT_E_MASTER_ALREADY_STARTED = 32815,
    ECAT_E_THREAD_INITIALISE = 32816,
    ECAT_E_READ_EEPROM = 32817,
    ECAT_E_MB_NOT_SUPPORTED = 32818,
    ECAT_E_MB_COE_NOT_SUPPORTED = 32819,
    ECAT_E_PI_ALREADY_UNLOCKED = 32820,
    ECAT_E_INVALID_FRAME_SIZE = 32821,
    ECAT_E_INVALID_FRAME_TYPE = 32822,
    ECAT_E_INVALID_COMMAND_SIZE = 32823,
    ECAT_E_INVALID_COMMAND_DATA = 32824,
    ECAT_E_WRITE_EEPROM = 32825,
    ECAT_E_MASTER_NOT_STARTED = 32826,
    ECAT_E_ARRAY_BOUNDS_EXCEEDED = 32827,
    ECAT_E_INVALID_LICENSE = 32828,
    ECAT_E_RECV_FRAME_TIMEOUT = 32829,
    ECAT_E_EEPROM_ACCESS_DENIED = 32830,
    ECAT_E_EEPROM_ACCESS_DENIDED = 32830,
    ECAT_E_BUSY = 32831,
    ECAT_E_TIME = 32832,
    ECAT_E_ABORTED = 32833,
    ECAT_E_SLAVE_PI_NOT_EXIST = 32834,
    ECAT_E_DC_SYNC = 32835,
    ECAT_E_BAD_CONTEXT = 32836,
    ECAT_E_NOT_PERMITTED = 32837,
    ECAT_E_INI_BAD_CONTENT = 32838,
    ECAT_E_OBJECT = 32839,
    ECAT_E_CHANNEL_TRANSFER = 32840,
    ECAT_E_OPEN_FILE = 32848,
    ECAT_E_WRITE_FILE = 32849,
    ECAT_E_READ_FILE = 32850,
    ECAT_E_CANT_GET_HW_KEY = 32851,
    ECAT_E_CANT_ENCODE_DATA = 32852,
    ECAT_E_CANT_DECODE_DATA = 32853,
    ECAT_E_DRIVER_INVALID_NIC = 32864,
    ECAT_E_QUEUE_RESOURCE_LACK = 32880,
    ECAT_E_QUEUE_NO_ITEMS = 32881,
    ECAT_E_MB_COE_UNSUPPORTED_DATA_TYPE = 33024,
    ECAT_E_MB_COE_OBJECT_IS_READ_ONLY = 33025,
    ECAT_E_MB_COE_OBJECT_IS_WRITE_ONLY = 33026,
    ECAT_E_MB_COE_INCOMPLETE_ENTRY_DESC = 33027,
    ECAT_E_MB_COE_SDOINFO_ERROR = 33028,
    ECAT_E_MB_VOE_NOT_SUPPORTED = 33104,
    ECAT_E_MASTER_IS_LOCKED = 33280,
    ECAT_E_MASTER_NO_RIGHTS = 33281,
    ECAT_E_MASTER_USER_NOT_FOUND = 33282,
    ECAT_E_MASTER_NAME_CANNOT_BE_FOUND = 33283,
    ECAT_E_TASK_CANNOT_BE_FOUND = 33284,
    ECAT_E_AOE_ERROR_CODE = 33536,
    ECAT_E_AOE_CMD_ERROR = 33537,
    ECAT_E_AOE_INVALID_HEADER = 33538,
    ECAT_E_MB_AOE_NOT_SUPPORTED = 33539,
    ECAT_E_AOE_INVALID_ROUTE = 33540,
    ECAT_E_MB_SOE_NOT_SUPPORTED = 33552,
    ECAT_E_SOE_ERROR_CODE = 33553,
    ECAT_E_SOE_INVALID_HEADER = 33554,
    ECAT_E_SOE_FRAGMENT_LEFT = 33555,
    ECAT_E_MB_EOE_NOT_SUPPORTED = 33568,
    ECAT_E_MB_FOE_NOT_SUPPORTED = 33584,
    ECAT_E_OD_OBJECT_NOTFOUND = 33792,
    ECAT_E_OD_OBJECT_ALREADY_EXISTS = 33793,
    ECAT_E_OD_ENTRY_DESCRIPTION_ALREADY_EXISTS = 33794,
    ECAT_E_OD_ENTRY_DESCRIPTION_FAILED = 33795,
    ECAT_E_OD_INVALID_OBJECT_TYPE = 33796,
    ECAT_E_OD_INVALID_ACCESS_TYPE = 33797,
    ECAT_E_OD_INVALID_DATA_TYPE = 33798,
    ECAT_E_OD_ACCESS_DENIED = 33799,
    ECAT_E_OD_NOT_CREATED = 33800,
    ECAT_E_OD_SDO_SERVICE_NOT_SUPORTED = 33801,
    ECAT_E_OD_SDO_SIZE_INVALID_HEADER = 33802,
    ECAT_E_OD_SDO_SIZE_TOO_SHORT = 33803,
    ECAT_E_OD_SDO_INVALID_SIZE = 33804,
    ECAT_E_OD_SUB_OBJ_NOTFOUND = 33805,
    ECAT_E_OD_MORE_MAXIMUM_VALUE = 33806,
    ECAT_E_OD_LESS_MINIMUM_VALUE = 33807,
    ECAT_E_LICENSE_INIT = 34050,
    ECAT_E_LICENSE_LOAD = 34051,
    ECAT_E_LICENSE_INVALID_TARGET = 34052,
    ECAT_E_LICENSE_EXPIRED = 34053,
    ECAT_E_LICENSE_INVALID_HW = 34054,
    ECAT_E_NO_CONFIG = 34055,
    ECAT_E_INVALID_MASTER_CONFIGURATION = 34056,
    ECAT_E_ALREADY_INITIALIZED = 34057,
    ECAT_E_PI_MAP_OUT_OF_IMAGE = 34058,
    ECAT_E_PI_MAP_REJECTED = 34059,
    ECAT_E_NOT_INITIALIZED = 34060,
    ECAT_E_FRAME_GENERAL = 34305,
    ECAT_E_FRAME_QUEUE = 34306,
    ECAT_E_FRAME_TRANSFER = 34307,
    ECAT_E_FRAME_SEND = 34308,
    ECAT_E_FRAME_WAIT_TIMEOUT = 34309,
    ECAT_E_FRAME_SEND_TIMEOUT = 34310,
    ECAT_E_FRAME_SCHEDULER_DESTROY = 34311,
    ECAT_E_FRAME_CANCEL = 34312,
    ECAT_E_FRAME_TOO_LONG = 34313,
    ECAT_E_MBXREQ_NOT_STARTED = 34336,
    ECAT_E_MBXREQ_RESPONSE = 34337,
    ECAT_E_MBXREQ_NO_RESPONSE_DATA = 34338,
    ECAT_E_MBXREQ_FINISHED = 34339,
    ECAT_E_MB_FAIL = 34352,
    ECAT_E_MB_INVALID_SYNTAX = 34353,
    ECAT_E_MB_INVALID_CHANNEL = 34355,
    ECAT_E_MB_SERVICE_NOT_SUPPORTED = 34356,
    ECAT_E_MB_INVALID_PROTOCOL_HEADER = 34357,
    ECAT_E_MB_SIZE_TOO_SHORT = 34358,
    ECAT_E_MB_NO_MORE_MEMORY = 34359,
    ECAT_E_MB_INVALID_SIZE = 34360,
    ECAT_E_INIT_MODULE = 34560,
    ECAT_E_CONNECTION = 34817,
    ECAT_E_RPC_RESPOND = 34818,
    ECAT_E_RPC_INIT = 34819,
    ECAT_E_LIBRARY = 34820,
    ECAT_E_NOITEMS = 34821,
    ECAT_E_SYS = 34822,

    ECAT_E_FILL_NAME_TOO_LONG = 80000,
    ECAT_E_QUEUE_FULL = 80001,
    ECAT_E_RECV_BUFF_TOO_SMALL = 80002,
    ECAT_E_RECV_TIMEOUT = 80003,
    ECAT_E_NOT_FIND_DEVICE = 80004,
    ECAT_E_INVALID_CHANNEL = 80005,
    ECAT_E_API_NOT_SUPPORT = 80006,
    ECAT_E_BOARD_FILE_SIZE = 80007,
    ECAT_E_ENI_FILE_SIZE = 80008,
    ECAT_E_FOE_FILE_SIZE = 80009,
    ECAT_E_UPDATE_FILE_SIZE = 80010,
    ECAT_E_SEND_TIMEOUT = 80011,
    ECAT_E_VERSION = 80012,
    ECAT_E_INVALID_HANDLE = 80013,
    ECAT_E_SLAVE_DISCONNECT = 80014,
    ECAT_E_SLAVE_NOT_READY = 80015,
    ECAT_E_LOGIC_ADDR_MAP_FORMAT_ERROR = 80016,
    ECAT_E_INVALID_PARAM = 80017,
    ECAT_E_ENI_FILE_MISMATCH = 80018,
    ECAT_E_BOARDCAST_NON_EXISTENT = 80019,
    
    ECAT_E_WATCHDOG_SIZE_ERR = 90000,
    ECAT_E_WATCHDOG_DATA_ERR = 90001,
    ECAT_E_WATCHDOG_CMD_ERR = 90002,
    ECAT_E_WATCHDOG_MALLOC_ERR = 90003,
    ECAT_E_WATCHDOG_FUNC_ERR = 90004,
    ECAT_E_WATCHDOG_OFFSET_ERR = 90005,
    ECAT_E_WATCHDOG_SLAVE_ID_ERR = 90006,
    ECAT_E_WATCHDOG_SLAVE_BUFF_SIZE_ERR = 90007,
} ECAT_ERROR_CODE;

typedef enum
{
    ECAT_AL_STATUS_CODE_SOK                                     = 0x0000, 
    ECAT_AL_STATUS_CODE_ERROR_UNSPECIFIED_ERROR                 = 0x0001, 
    ECAT_AL_STATUS_CODE_ERROR_NO_MEMORY                         = 0x0002, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_REQUESTED_STATE_CHANGE    = 0x0011, 
    ECAT_AL_STATUS_CODE_ERROR_UNKNOWN_REQUESTED_STATE           = 0x0012, 
    ECAT_AL_STATUS_CODE_ERROR_BOOTSTRAP_NOT_SUPPORTED           = 0x0013, 
    ECAT_AL_STATUS_CODE_ERROR_NO_VALID_FIRMWARE                 = 0x0014, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_MAILBOX_CONFIGURATION_IB  = 0x0015, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_MAILBOX_CONFIGURATION_IP  = 0x0016, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_SYNC_MANAGER_CONFIGURAT   = 0x0017, 
    ECAT_AL_STATUS_CODE_ERROR_NO_VALID_INPUTS_AVAILABLE         = 0x0018, 
    ECAT_AL_STATUS_CODE_ERROR_NO_VALID_OUTPUTS                  = 0x0019, 
    ECAT_AL_STATUS_CODE_ERROR_SYNCHRONIZATION_ERROR             = 0x001A, 
    ECAT_AL_STATUS_CODE_ERROR_SYNC_MANAGER_WATCHDOG             = 0x001B, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_SYNC_MANAGER_TYPES        = 0x001C, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_OUTPUT_CONFIGURATION      = 0x001D, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_INPUT_CONFIGURATION       = 0x001E, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_WATCHDOG_CONFIGURATION    = 0x001F, 
    ECAT_AL_STATUS_CODE_ERROR_SLAVE_NEEDS_COLD_START            = 0x0020, 
    ECAT_AL_STATUS_CODE_ERROR_SLAVE_NEEDS_INIT                  = 0x0021, 
    ECAT_AL_STATUS_CODE_ERROR_SLAVE_NEEDS_PREOP                 = 0x0022, 
    ECAT_AL_STATUS_CODE_ERROR_SLAVE_NEEDS_SAFEOP                = 0x0023, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_INPUT_MAPPING             = 0x0024, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_OUTPUT_MAPPING            = 0x0025, 
    ECAT_AL_STATUS_CODE_ERROR_INCONSISTENT_SETTINGS             = 0x0026, 
    ECAT_AL_STATUS_CODE_ERROR_FREE_RUN_NOT_SUPPORTED            = 0x0027, 
    ECAT_AL_STATUS_CODE_ERROR_SYNCHRONIZATION_NOT_SUPPORTED     = 0x0028, 
    ECAT_AL_STATUS_CODE_ERROR_FREE_RUN_NEEDS_3_BUFFER_MODE      = 0x0029, 
    ECAT_AL_STATUS_CODE_ERROR_BACKGROUND_WATCHDOG               = 0x002A, 
    ECAT_AL_STATUS_CODE_ERROR_NO_VALID_INPUTS_AND_OUTPUTS       = 0x002B, 
    ECAT_AL_STATUS_CODE_ERROR_FATAL_SYNC_ERROR                  = 0x002C, 
    ECAT_AL_STATUS_CODE_ERROR_NO_SYNC_ERROR                     = 0x002D, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_DC_SYNCH_CONFIGURATION    = 0x0030, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_DC_LATCH_CONFIGURATION    = 0x0031, 
    ECAT_AL_STATUS_CODE_ERROR_PLL_ERROR                         = 0x0032, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_DC_IO_ERROR               = 0x0033, 
    ECAT_AL_STATUS_CODE_ERROR_INVALID_DC_TIMEOUT_ERROR          = 0x0034, 
    ECAT_AL_STATUS_CODE_ERROR_DC_INVALID_SYNC_CYCLE_TIME        = 0x0035, 
    ECAT_AL_STATUS_CODE_ERROR_DC_SYNC0_CYCLE_TIME               = 0x0036, 
    ECAT_AL_STATUS_CODE_ERROR_DC_SYNC1_CYCLE_TIME               = 0x0037, 
    ECAT_AL_STATUS_CODE_ERROR_MBX_AOE                           = 0x0041, 
    ECAT_AL_STATUS_CODE_ERROR_MBX_EOE                           = 0x0042, 
    ECAT_AL_STATUS_CODE_ERROR_MBX_COE                           = 0x0043, 
    ECAT_AL_STATUS_CODE_ERROR_MBX_FOE                           = 0x0044, 
    ECAT_AL_STATUS_CODE_ERROR_MBX_SOE                           = 0x0045, 
    ECAT_AL_STATUS_CODE_ERROR_MBX_VOE                           = 0x004F, 
    ECAT_AL_STATUS_CODE_ERROR_EEPROM_NO_ACCESS                  = 0x0050, 
    ECAT_AL_STATUS_CODE_ERROR_EEPROM_ERROR                      = 0x0051, 
    ECAT_AL_STATUS_CODE_ERROR_SLAVE_RESTARTED_LOCALLY           = 0x0060, 
} ECAT_AL_STATUS_CODE;

const char* EcatErrorGetErrorMessage(ECAT_RESULT nError);
const char* EcatGetAlStatusCodeMessage(uint16_t u16AlStatusCode);

#ifdef __cplusplus
}
#endif

#endif  // ZMC_PCI_ERRNO_H_
/* end of file */
