/** * @file config.h * @brief Main configuration file for the CRAH Unit (TCP) emulator. * @author Emmanuel Hernandez Cruz * @date 2025-09-02 * * This file contains two important configurations: WiFi network parameters * and the Modbus register map for the device. */ #ifndef CONFIG_H #define CONFIG_H #include "core.h" #include "Equipment/Equipment.h" #if defined(USE_MODBUS_IP) /** * @defgroup ModbusTCPConfig Modbus IP Configuration * @brief Parameters for Modbus TCP communication. * @{ */ #include const char *ssid = "QTS_CDR_Arduino"; /**< @brief The SSID of the WiFi network. */ const char *password = "123abc456"; /**< @brief The password for the WiFi network. */ IPAddress local_IP(172, 17, 30, 241); /**< @brief The static IP address for the device. */ IPAddress gateway(172, 17, 30, 1); /**< @brief The gateway IP address. */ IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */ ModbusIP mb; #else /** * @defgroup ModbusRTUConfig Modbus RTU Configuration * @brief Parameters for serial Modbus RTU communication. * @{ */ #include const int BAUDRATE = 19200; /**< @brief The serial communication speed in bits per second. */ const int RX_PIN = 17; /**< @brief The GPIO pin used for receiving data (RX). */ const int TX_PIN = 16; /**< @brief The GPIO pin used for transmitting data (TX). */ const int RST_PIN = 4; /**< @brief The GPIO pin connected to the RS485 driver's DE/RE pins for direction control. */ const int MODBUS_ID = 1; /**< @brief The unique slave ID for this device on the Modbus bus. */ /** @} */ /** @brief Global instance of the Modbus RTU server. */ ModbusRTU mb; #endif /** * @defgroup ModbusMapConfig Modbus Map Configuration * @brief Defines the Modbus register map and related parameters for the emulator. * @{ */ /** * @brief The Modbus map for the Equipment device. * This array defines all the Modbus points available on the emulated device. * The `description` field is crucial as it's used to look up points within the application logic. */ modbusMap mb_map[] = { {HR, 9, 0, "ATS_Source"}, //Internal to control from Modscan {HR, 10, 0, "ATS_Load"}, //Internal Fault code from Modscan {HR, 11, 0, "ATS_Input"}, //Internal Fault code from Modscan {HR, 12, 0, "ATS_Fault"}, //Internal Fault code from Modscan {DI, 999, 0, "Source 1 Available"}, {DI, 1000, 0, "Source 2 Available"}, {DI, 1001, 0, "Source 1 Active"}, {DI, 1002, 0, "Source 2 Active"}, {DI, 1003, 0, "Source 1 Preferred"}, {DI, 1004, 0, "Source 2 Preferred"}, {DI, 1013, 0, "Summary Alarm"}, {DI, 1019, 0, "Transfer Inhibit"}, {IR, 6144, 0, "Source 1 Volts AB"}, {IR, 6145, 0, "Source 1 Volts BC"}, {IR, 6146, 0, "Source 1 Volts CA"}, {IR, 6147, 0, "Source 2 Volts AB"}, {IR, 6148, 0, "Source 2 Volts BC"}, {IR, 6149, 0, "Source 2 Volts CA"}, {IR, 6151, 0, "Volts AB"}, {IR, 6152, 0, "Volts BC"}, {IR, 6153, 0, "Volts CA"}, {IR, 6154, 0, "Source 1 Frequency"}, {IR, 6155, 0, "Source 2 Frequency"}, {IR, 6158, 0, "Amps A"}, {IR, 6159, 0, "Amps B"}, {IR, 6160, 0, "Amps C"}, {IR_LONG, 6165, 0, "Total Active Power"}, {IR_LONG, 6169, 0, "Total Apparent Power"}, {IR, 6171, 0, "Power Factor"}, {IR, 6263, 0, "Number of Transfers"}, {IR, 6297, 0, "Alarm Status Bits"}, }; //Size of modbus map used in FOR cycles, automatically calculated. /** * @brief The total number of entries in the `mb_map` array. * This is calculated at compile time and used for iterating over the map. */ const int map_size = sizeof(mb_map) / sizeof(mb_map[0]); /** @brief The main loop update interval in milliseconds. */ int interval = 250; /** @} */ // End of ModbusMapConfig group #endif // CONFIG_H