final testing before publishing
This commit is contained in:
160
src/BMS/CRAH/CRAH_UMAS_TCP/config.h
Normal file
160
src/BMS/CRAH/CRAH_UMAS_TCP/config.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* @file config.h
|
||||
* @brief Main configuration file for the UMAS CRAH Unit (TCP) emulator.
|
||||
* @author Robert J Davis
|
||||
* @date 2025-10-01
|
||||
*
|
||||
* 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 <ModbusIP_ESP8266.h>
|
||||
const char *ssid = "TP-Link_D91A"; /**< @brief The SSID of the WiFi network. */
|
||||
const char *password = "52761492"; /**< @brief The password for the WiFi network. */
|
||||
IPAddress local_IP(192, 168, 1, 234); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(192, 168, 1, 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 <ModbusRTU.h>
|
||||
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[] =
|
||||
{
|
||||
{COIL, 0, 0, "ON/OFF Command By BMS"}, // Receive signal from PLC
|
||||
{COIL, 1, 0, "Alarm Fan 1 ON"}, // Just for Arduino testing. Sets Alarm Fan 1 to 1.
|
||||
{COIL, 2, 0, "Alarm Fan 2 ON"}, // Just for Arduino testing. Sets Alarm Fan 2 to 1.
|
||||
{COIL, 3, 0, "Alarm Dirty Filter ON"}, // Just for Arduino testing. Sets Alarm Dirty Filter to 1.
|
||||
{COIL, 4, 0, "Alarm Leak Detect ON"}, // Just for Arduino testing. Sets Alarm Fan 1 to 1.
|
||||
{COIL, 5, 0, "RA Temp Low Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 68F (low alarm)
|
||||
{COIL, 6, 0, "RA Temp High Alarm ON"}, // Just for Arduino testing. Sets RA Temp to 104F (high alarm)
|
||||
{COIL, 7, 0, "RA Humidity Low Alarm ON"}, // Just for Arduino testing. Sets RA Humidity to 15% (low alarm)
|
||||
{COIL, 8, 0, "RA Humidity High Alarm ON"}, // Just for Arduino testing. Sets RA Humidity to 65% (high alarm)
|
||||
{COIL, 9, 0, "Alarm Fan 3 ON"}, // Just for Arduino testing. Sets Alarm Fan 3 to 1.
|
||||
{COIL, 10, 0, "Alarm Fan 4 ON"}, // Just for Arduino testing. Sets Alarm Fan 4 to 1.
|
||||
{COIL, 11, 0, "Alarm Fan 5 ON"}, // Just for Arduino testing. Sets Alarm Fan 5 to 1.
|
||||
{COIL, 12, 0, "Alarm Fan 6 ON"}, // Just for Arduino testing. Sets Alarm Fan 6 to 1.
|
||||
{COIL, 13, 0, "Alarm Fan 7 ON"}, // Just for Arduino testing. Sets Alarm Fan 7 to 1.
|
||||
{COIL, 14, 0, "Alarm Fan 8 ON"}, // Just for Arduino testing. Sets Alarm Fan 8 to 1.
|
||||
{COIL, 15, 0, "Alarm Fan 9 ON"}, // Just for Arduino testing. Sets Alarm Fan 9 to 1.
|
||||
{COIL, 16, 0, "Alarm Condensate Pump ON"}, // Just for Arduino testing. Sets Alarm Condensate Pump to 1.
|
||||
{COIL, 17, 0, "Alarm Fire ON"}, // Just for Arduino testing. Sets Alarm Fire to 1.
|
||||
{COIL, 18, 0, "Alarm Smoke ON"}, // Just for Arduino testing. Sets Alarm Smoke to 1.
|
||||
|
||||
{DI, 4, 0, "Alarm Leak Detect"},
|
||||
{DI, 5, 0, "Alarm Dirty Filter"},
|
||||
{DI, 12, 0, "Common Alarm"}, // Send to PLC
|
||||
{DI, 14, 0, "Alarm Condensate Pump"},
|
||||
{DI, 15, 0, "Alarm Smoke"},
|
||||
{DI, 16, 0, "Alarm Fire"},
|
||||
|
||||
{IR_FLOAT, 1, 0, "Supply Air Temp"},
|
||||
{IR_FLOAT, 3, 0, "Return Air Humidity"}, // Ignition visual only
|
||||
{IR_FLOAT, 5, 0, "Return Air Temp"}, // Send to PLC
|
||||
{IR_FLOAT, 7, 0, "Filter Differential Pressure"}, // sawStrategy between 0 and 5
|
||||
{IR_FLOAT, 9, 0, "CW Valve Position"},
|
||||
{IR, 26, 0, "Alarm Fan 1"},
|
||||
{IR, 30, 0, "Alarm Fan 2"},
|
||||
{IR, 34, 0, "Alarm Fan 3"},
|
||||
{IR, 38, 0, "Alarm Fan 4"},
|
||||
{IR, 42, 0, "Alarm Fan 5"},
|
||||
{IR, 46, 0, "Alarm Fan 6"},
|
||||
{IR, 50, 0, "Alarm Fan 7"},
|
||||
{IR, 54, 0, "Alarm Fan 8"},
|
||||
{IR, 58, 0, "Alarm Fan 9"},
|
||||
{IR, 27, 0, "Run Status Fan 1"}, // Send to PLC
|
||||
{IR, 31, 0, "Run Status Fan 2"}, // Send to PLC
|
||||
{IR, 35, 0, "Run Status Fan 3"}, // Send to PLC
|
||||
{IR, 39, 0, "Run Status Fan 4"}, // Send to PLC
|
||||
{IR, 43, 0, "Run Status Fan 5"}, // Send to PLC
|
||||
{IR, 47, 0, "Run Status Fan 6"}, // Send to PLC
|
||||
{IR, 51, 0, "Run Status Fan 7"}, // Send to PLC
|
||||
{IR, 55, 0, "Run Status Fan 8"}, // Send to PLC
|
||||
{IR, 59, 0, "Run Status Fan 9"}, // Send to PLC
|
||||
{IR, 25, 0, "Speed Fan 1"},
|
||||
{IR, 29, 0, "Speed Fan 2"},
|
||||
{IR, 33, 0, "Speed Fan 3"},
|
||||
{IR, 37, 0, "Speed Fan 4"},
|
||||
{IR, 41, 0, "Speed Fan 5"},
|
||||
{IR, 45, 0, "Speed Fan 6"},
|
||||
{IR, 49, 0, "Speed Fan 7"},
|
||||
{IR, 53, 0, "Speed Fan 8"},
|
||||
{IR, 57, 0, "Speed Fan 9"},
|
||||
{IR, 28, 0, "Operating Hours Fan 1"},
|
||||
{IR, 32, 0, "Operating Hours Fan 2"},
|
||||
{IR, 36, 0, "Operating Hours Fan 3"},
|
||||
{IR, 40, 0, "Operating Hours Fan 4"},
|
||||
{IR, 44, 0, "Operating Hours Fan 5"},
|
||||
{IR, 48, 0, "Operating Hours Fan 6"},
|
||||
{IR, 52, 0, "Operating Hours Fan 7"},
|
||||
{IR, 56, 0, "Operating Hours Fan 8"},
|
||||
{IR, 60, 0, "Operating Hours Fan 9"},
|
||||
{IR, 61, 0, "Control Mode Selected"},
|
||||
{IR_FLOAT, 63, 0, "Amps Fan 1"},
|
||||
{IR_FLOAT, 65, 0, "Amps Fan 2"},
|
||||
{IR_FLOAT, 67, 0, "Amps Fan 3"},
|
||||
{IR_FLOAT, 69, 0, "Amps Fan 4"},
|
||||
{IR_FLOAT, 71, 0, "Amps Fan 5"},
|
||||
{IR_FLOAT, 73, 0, "Amps Fan 6"},
|
||||
{IR_FLOAT, 75, 0, "Amps Fan 7"},
|
||||
{IR_FLOAT, 77, 0, "Amps Fan 8"},
|
||||
{IR_FLOAT, 79, 0, "Amps Fan 9"},
|
||||
|
||||
{HR_FLOAT, 13, 0, "Fan Speed Setpoint"}, // Receive signal from PLC
|
||||
{HR_FLOAT, 17, 0, "Supply Air Temp Setpoint"}, // Receive signal from PLC
|
||||
{HR_FLOAT, 21, 0, "Fan Min Speed"}, // Send to PLC
|
||||
{HR_FLOAT, 23, 0, "Fan Max Speed"}, // Send to PLC
|
||||
{HR, 25, 0, "BMS Control Source"}, // Receive signal from PLC
|
||||
{HR, 26, 0, "BMS Enable Source"}, // Receive signal from PLC
|
||||
|
||||
};
|
||||
//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
|
||||
Reference in New Issue
Block a user