
#ifndef ETHERCAT_UTILS_DARRA_ENI_H
#define ETHERCAT_UTILS_DARRA_ENI_H

#pragma once

#include "../ethercat_types.h"
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

#define ENI_MAX_NAME       128
#define ENI_MAX_SLAVES     256

typedef struct {
    char     name[ENI_MAX_NAME];
    int      cycleTimeUs;
    int      dcCycleTimeUs;
    int      expectedSlaveCount;
} DarraEniMasterConfig;

typedef struct {
    int      physicalAddress;
    int      autoIncAddress;
    uint32_t vendorId;
    uint32_t productCode;
    uint32_t revisionNumber;
    char     name[ENI_MAX_NAME];
    int      dcAssignActivate;
    int      sm2Offset;
    int      sm2Length;
    int      sm3Offset;
    int      sm3Length;
} DarraEniSlaveConfig;

typedef struct {
    DarraEniMasterConfig master;
    DarraEniSlaveConfig  slaves[ENI_MAX_SLAVES];
    int                  slaveCount;
    char                 version[16];
} DarraEniConfiguration;

int eni_config_load(const char* filePath, DarraEniConfiguration* config);

int eni_config_save(const char* filePath, const DarraEniConfiguration* config);

#ifdef __cplusplus
}
#endif

#endif
