Merge pull request #27 from emmanuelsrlok/ecruz/UPS_Vertiv

Ecruz/ups vertiv
This commit is contained in:
Emmanuel HC
2025-10-20 09:44:02 -05:00
committed by GitHub
23 changed files with 2017 additions and 737 deletions

View File

@@ -0,0 +1,59 @@
/**
* @file State_Battery.h
* @brief Defines the BatteryState class for the device.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the definition for the BatteryState, which represents
* the state where the equipment is actively performing its primary function.
*/
#ifndef Battery_State_h
#define Battery_State_h
#include "State.h" // Include the base class header
template<typename T> class Equipment;
/**
* @class BatteryState
* @brief Represents the active Battery state of the equipment.
*
* In this state, the equipment is fully operational and performing its main
* tasks. It applies a set of predefined strategies to its Modbus points to
* simulate active behavior (e.g., fans Battery at various speeds) and waits
* for a command to transition to another state.
*/
template<typename T>
class BatteryState : public State<T> {
public:
/**
* @brief Constructs a new BatteryState object.
* Initializes the strategies for various Modbus points that are active
* during the Battery state, such as setting fan speed behaviors.
*/
BatteryState();
/**
* @brief Executes the Battery state's logic for one update cycle.
* This method applies all active strategies (e.g., for fan speeds, temperatures)
* and checks for conditions that would trigger a state transition, such as a
* command to stop or a fault condition.
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
State<T>* update(Equipment<T>* equipment) override;
/**
* @brief Logic to execute once when entering the Battery state.
* Typically sets status bits to indicate the equipment is active (e.g.,
* setting an "On/Off" point to 1).
* @param equipment Pointer to the Equipment instance.
*/
void enterState(Equipment<T>* equipment) override;
/**
* @brief Logic to execute once when exiting the Battery state.
* Typically resets status bits to indicate the equipment is no longer
* active before transitioning to the next state.
* @param equipment Pointer to the Equipment instance.
*/
void exitState(Equipment<T>* equipment) override;
};
#endif

View File

@@ -0,0 +1,59 @@
/**
* @file State_Bypass.h
* @brief Defines the BypassState class for the device.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the definition for the BypassState, which represents
* the state where the equipment is actively performing its primary function.
*/
#ifndef Bypass_State_h
#define Bypass_State_h
#include "State.h" // Include the base class header
template<typename T> class Equipment;
/**
* @class BypassState
* @brief Represents the active Bypass state of the equipment.
*
* In this state, the equipment is fully operational and performing its main
* tasks. It applies a set of predefined strategies to its Modbus points to
* simulate active behavior (e.g., fans Bypass at various speeds) and waits
* for a command to transition to another state.
*/
template<typename T>
class BypassState : public State<T> {
public:
/**
* @brief Constructs a new BypassState object.
* Initializes the strategies for various Modbus points that are active
* during the Bypass state, such as setting fan speed behaviors.
*/
BypassState();
/**
* @brief Executes the Bypass state's logic for one update cycle.
* This method applies all active strategies (e.g., for fan speeds, temperatures)
* and checks for conditions that would trigger a state transition, such as a
* command to stop or a fault condition.
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
State<T>* update(Equipment<T>* equipment) override;
/**
* @brief Logic to execute once when entering the Bypass state.
* Typically sets status bits to indicate the equipment is active (e.g.,
* setting an "On/Off" point to 1).
* @param equipment Pointer to the Equipment instance.
*/
void enterState(Equipment<T>* equipment) override;
/**
* @brief Logic to execute once when exiting the Bypass state.
* Typically resets status bits to indicate the equipment is no longer
* active before transitioning to the next state.
* @param equipment Pointer to the Equipment instance.
*/
void exitState(Equipment<T>* equipment) override;
};
#endif

View File

@@ -9,7 +9,8 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = CRAH_UMAS_TCP ; Select here the name of the configuration you want to download
default_envs = UPS_Vertiv_APM2_TCP ; Select here the name of the configuration you want to download
[env]
upload_port = COM5
@@ -187,9 +188,9 @@ extends = common_env_options
build_flags = -D USE_MODBUS_IP
build_src_filter = -<*> +<EPMS/ATS/ATS_Woodward_DTSC200A_TCP>
[env:CRAH_UMAS_TCP]
[env:UPS_Vertiv_APM2_TCP]
platform = espressif32
board = dfrobot_firebeetle2_esp32e
extends = common_env_options
build_flags = -D USE_MODBUS_IP ;Importat configuration, this flags is used to configure the program
build_src_filter = -<*> +<BMS/CRAH/CRAH_UMAS_TCP> ;Add the specific folder path here
build_flags = -D USE_MODBUS_IP
build_src_filter = -<*> +<EPMS/UPS/UPS_Vertiv_APM2_TCP>

View File

@@ -54,7 +54,7 @@ template<>
State<ModbusRTU>* FailState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Fail update function");
Modbus_Point<ModbusRTU>* clearAlm = equipment->getModbus_Point("Clear Alm");
Modbus_Point<ModbusRTU>* clearAlm = equipment->getModbus_Point("Clear Alarms");
int nextStateId = clearAlm ? clearAlm->getValue() : 0;
if (nextStateId == 1){
return new StandbyState<ModbusRTU>();

View File

@@ -0,0 +1,88 @@
/**
* @file State_Fail.cpp
* @brief Implementation of the FailState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the FailState, which defines
* the behavior of the equipment when it has entered a fault condition.
*/
#include "States/State_Standby.h"
#include "States/State_Fail.h"
#include "ModbusPoints/Modbus_Point.h"
#include "Equipment/Equipment.h"
#include "Strategies/Strategy_SingleValue.h"
#include "Strategies/Strategy_PID.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new FailState object.
*
* This constructor receives a list of alarm descriptions and creates strategies
* to set the corresponding Modbus points to a value of 1, indicating an
* active alarm. It also initializes a PID strategy for the valve position.
*/
template<>
FailState<ModbusRTU>::FailState(const std::vector<std::string>& activeAlarms) {
// Simulate a failure: set common alarm and a specific fan alarm.
for (const auto& alarmName : activeAlarms){
addStrategy(alarmName, new SingleValueStrategy(1.0f, 0.0f, 1000));
}
addStrategy("CW Valve Position", new PIDStrategy("RAT Setpoint", 1000, "RAT"));
}
/**
* @brief Executes the fail state's logic for one update cycle.
*
* This method checks the "Clear Alm" Modbus point for a command to transition
* back to Standby, which would typically happen after a fault is cleared by a
* user. If no transition is requested, it continues to apply the failure strategies.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusRTU>* FailState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Fail update function");
Modbus_Point<ModbusRTU>* clearAlm = equipment->getModbus_Point("Clear Alm");
int nextStateId = clearAlm ? clearAlm->getValue() : 0;
if (nextStateId == 1){
return new StandbyState<ModbusRTU>();
}
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the fail state. Sets the main alarm bit.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void FailState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Fail State...");
Modbus_Point<ModbusRTU>* alarm_common = equipment->getModbus_Point("Alarm Common");
alarm_common->setValue(1);
}
/**
* @brief Logic to execute once when exiting the fail state. Clears the main alarm bit.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void FailState<ModbusRTU>::exitState(Equipment<ModbusRTU>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Fail State...");
Modbus_Point<ModbusRTU>* alarm_common = equipment->getModbus_Point("Alarm Common");
alarm_common->setValue(0);
}

View File

@@ -38,10 +38,11 @@
*/
template<>
RunningState<ModbusRTU>::RunningState() {
addStrategy("Actual Capacity", new PIDStrategy("Active SP", 1000, "Supply Temp"));
addStrategy("Comp1 Percent RLA", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("Comp2 Percent RLA", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("Return Temp", new SingleValueStrategy(85,3.0f, 1000));
addStrategy("Actual Capacity", new PIDStrategy("Chiller Local Setpoint", 1000, "PICs Supply Temp"));
addStrategy("C1 Comp 1 Motor Percent (RLA)", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("C2 Comp 1 Motor Percent (RLA)", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("C3 Comp 1 Motor Percent (RLA)", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("PICs Return Temp", new SingleValueStrategy(85,3.0f, 1000));
}
/**
@@ -75,25 +76,27 @@ State<ModbusRTU>* RunningState<ModbusRTU>::update(Equipment<ModbusRTU>* equipmen
// Determine the correct setpoint based on the current operating mode.
switch(currentMode){
case 1:
currentSP = getPointValue(equipment, "Ice SP");
currentSP = getPointValue(equipment, "Ice Setpoint");
currentSP = currentSP - 20;
break; // Added break to prevent fall-through
case 2:
currentSP = getPointValue(equipment, "Cool SP");
currentSP = getPointValue(equipment, "Cooling Active Setpoint");
currentSP = currentSP + 20;
break; // Added break
default:
// The default value is already set.
break;
}
Strategy_Behavior* ramp_strategy1 = getStrategy("Comp1 Percent RLA");
Strategy_Behavior* ramp_strategy2 = getStrategy("Comp2 Percent RLA");
Strategy_Behavior* ramp_strategy1 = getStrategy("C1 Comp 1 Motor Percent (RLA)");
Strategy_Behavior* ramp_strategy2 = getStrategy("C2 Comp 1 Motor Percent (RLA)");
Strategy_Behavior* ramp_strategy3 = getStrategy("C3 Comp 1 Motor Percent (RLA)");
int actualCapacity = getPointValue(equipment, "Actual Capacity");
if (actualCapacity < 50){
actualCapacity = actualCapacity * 2;
if (actualCapacity > 100) actualCapacity = 100;
static_cast<RampStrategy*>(ramp_strategy1)->setTarget(actualCapacity);
static_cast<RampStrategy*>(ramp_strategy2)->setTarget(0);
static_cast<RampStrategy*>(ramp_strategy3)->setTarget(0);
} else {
if (actualCapacity > 100) actualCapacity = 100;
static_cast<RampStrategy*>(ramp_strategy1)->setTarget(actualCapacity);
@@ -110,7 +113,7 @@ State<ModbusRTU>* RunningState<ModbusRTU>::update(Equipment<ModbusRTU>* equipmen
static_cast<PIDStrategy*>(strategy)->setSetpoint(currentSP);
}
float OutdoorTemp = getPointValue(equipment, "Outdoor Air Temp");
float OutdoorTemp = getPointValue(equipment, "Ambient Temperature");
Serial.printf("Outdoor Temp: %f\n", OutdoorTemp);
if (OutdoorTemp >50.0f) {
setPointValue(equipment, "Chiller Mode SP", 1.0f);
@@ -120,10 +123,10 @@ State<ModbusRTU>* RunningState<ModbusRTU>::update(Equipment<ModbusRTU>* equipmen
setPointValue(equipment, "Chiller Mode Output", 2.0f);
}
float SupplyTemp = getPointValue(equipment, "Supply Temp");
setPointValue(equipment, "Return Temp", SupplyTemp + 14.0f);
float SupplyTemp = getPointValue(equipment, "PICs Supply Temp");
setPointValue(equipment, "PICs Return Temp", SupplyTemp + 14.0f);
setPointValue(equipment, "Active SP", currentSP);
setPointValue(equipment, "Chiller Local Setpoint", currentSP);
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
@@ -139,7 +142,7 @@ void RunningState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Running State...");
// You could also update a Modbus register to show the "standby" state
setPointValue(equipment, "Run Enabled", 1);
setPointValue(equipment, "Run Enable", 1);
setPointValue(equipment, "Flow Switch", 1);
}

View File

@@ -0,0 +1,156 @@
/**
* @file State_Running.cpp
* @brief Implementation of the RunningState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the RunningState, which defines
* the behavior of the equipment when it is actively running.
*/
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "Strategies/Strategy_Behavior.h"
#include "Strategies/Strategy_PID.h"
#include "Strategies/Strategy_Ramp.h"
#include "Strategies/Strategy_Totalizer.h"
#include "Strategies/Strategy_SingleValue.h"
#include "Equipment/Equipment.h"
#include "ModbusPoints/Modbus_Point.h"
#include "ModbusPoints/Modbus_FloatDecorator.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new RunningState object.
*
* This constructor initializes behavior strategies active during the running
* state, such as a PID controller for the 'CW Valve Position' and totalizers
* for the run-hours of each EC fan.
*/
template<>
RunningState<ModbusRTU>::RunningState() {
addStrategy("Actual Capacity", new PIDStrategy("Active SP", 1000, "Supply Temp"));
addStrategy("Comp1 Percent RLA", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("Comp2 Percent RLA", new RampStrategy(0.0f, 5.0f, 1000));
addStrategy("Return Temp", new SingleValueStrategy(85,3.0f, 1000));
}
/**
* @brief Executes the running state's logic for one update cycle.
*
* This method first checks for state transition commands:
* 1. It reads the "ON/OFF Command By BMS" point. If it's 0, it transitions to StandbyState.
* 2. It reads the "Fault Code" point. If it's non-zero, it transitions to FailState,
* passing the corresponding alarm description.
*
* If no transition occurs, it applies the strategies defined for the running state.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusRTU>* RunningState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Running update function");
int CH_Enable_SP = getPointValue(equipment, "Chiller Enable SP");
if (CH_Enable_SP == 0){
return new StandbyState<ModbusRTU>();
}
// Declare currentSP outside the switch so it's accessible later.
float highCapacityLimit = getPointValue(equipment, "Active Capacity Limit");
Strategy_Behavior* PID_Strat = getStrategy("Actual Capacity");
static_cast<PIDStrategy*>(PID_Strat)->setLimits(0.0f, highCapacityLimit);
float currentSP = 50.0f; // Default value
int currentMode = getPointValue(equipment, "Chiller Mode Output");
// Determine the correct setpoint based on the current operating mode.
switch(currentMode){
case 1:
currentSP = getPointValue(equipment, "Ice SP");
currentSP = currentSP - 20;
break; // Added break to prevent fall-through
case 2:
currentSP = getPointValue(equipment, "Cool SP");
currentSP = currentSP + 20;
break; // Added break
default:
// The default value is already set.
break;
}
Strategy_Behavior* ramp_strategy1 = getStrategy("Comp1 Percent RLA");
Strategy_Behavior* ramp_strategy2 = getStrategy("Comp2 Percent RLA");
int actualCapacity = getPointValue(equipment, "Actual Capacity");
if (actualCapacity < 50){
actualCapacity = actualCapacity * 2;
if (actualCapacity > 100) actualCapacity = 100;
static_cast<RampStrategy*>(ramp_strategy1)->setTarget(actualCapacity);
static_cast<RampStrategy*>(ramp_strategy2)->setTarget(0);
} else {
if (actualCapacity > 100) actualCapacity = 100;
static_cast<RampStrategy*>(ramp_strategy1)->setTarget(actualCapacity);
int actualCapacity2 = (actualCapacity - 50)*4;
if (actualCapacity2 > 100) actualCapacity2 = 100;
static_cast<RampStrategy*>(ramp_strategy2)->setTarget(actualCapacity2);
}
// 1. Get the strategy by its name.
Strategy_Behavior* strategy = getStrategy("Actual Capacity");
// 2. Check if the strategy exists and is a PID type.
if (strategy && strategy->isPID()) {
// 3. Cast it to a PIDStrategy pointer and call setSetpoint.
static_cast<PIDStrategy*>(strategy)->setSetpoint(currentSP);
}
float OutdoorTemp = getPointValue(equipment, "Outdoor Air Temp");
Serial.printf("Outdoor Temp: %f\n", OutdoorTemp);
if (OutdoorTemp >50.0f) {
setPointValue(equipment, "Chiller Mode SP", 1.0f);
setPointValue(equipment, "Chiller Mode Output", 1.0f);
}else {
setPointValue(equipment, "Chiller Mode SP", 2.0f);
setPointValue(equipment, "Chiller Mode Output", 2.0f);
}
float SupplyTemp = getPointValue(equipment, "Supply Temp");
setPointValue(equipment, "Return Temp", SupplyTemp + 14.0f);
setPointValue(equipment, "Active SP", currentSP);
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the running state.
* Sets the "Chiller Sts" point to indicate the unit is running.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void RunningState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Running State...");
// You could also update a Modbus register to show the "standby" state
setPointValue(equipment, "Run Enabled", 1);
setPointValue(equipment, "Flow Switch", 1);
}
/**
* @brief Logic to execute once when exiting the running state.
* Sets the "Chiller Sts" point to indicate the unit is no longer running.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void RunningState<ModbusRTU>::exitState(Equipment<ModbusRTU>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Running State...");
}

View File

@@ -32,9 +32,10 @@
*/
template<>
StandbyState<ModbusRTU>::StandbyState() {
addStrategy("Comp1 Percent RLA", new RampStrategy(0,5,1000));
addStrategy("Comp2 Percent RLA", new RampStrategy(0,5,1000));
addStrategy("Return Temp", new SingleValueStrategy(85,3.0f, 1000));
addStrategy("C1 Comp 1 Motor Percent (RLA)", new RampStrategy(0,5,1000));
addStrategy("C2 Comp 1 Motor Percent (RLA)", new RampStrategy(0,5,1000));
addStrategy("C3 Comp 1 Motor Percent (RLA)", new RampStrategy(0,5,1000));
addStrategy("PICs Return Temp", new SingleValueStrategy(85,3.0f, 1000));
}
/**
@@ -55,7 +56,7 @@ State<ModbusRTU>* StandbyState<ModbusRTU>::update(Equipment<ModbusRTU>* equipmen
if (CH_Enable_SP == 1){
return new RunningState<ModbusRTU>();
}
float OutdoorTemp = getPointValue(equipment, "Outdoor Air Temp");
float OutdoorTemp = getPointValue(equipment, "Ambient Temperature");
Serial.printf("Outdoor Temp: %f\n", OutdoorTemp);
if (OutdoorTemp >50.0f) {
setPointValue(equipment, "Chiller Mode SP", 1);
@@ -76,7 +77,7 @@ template<>
void StandbyState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Standby State...");
setPointValue(equipment, "Run Enabled", 0);
setPointValue(equipment, "Run Enable", 0);
setPointValue(equipment, "Flow Switch", 0);
}

View File

@@ -0,0 +1,91 @@
/**
* @file State_Standby.cpp
* @brief Implementation of the StandbyState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the StandbyState, which defines
* the behavior of the equipment when it is in an idle or standby mode.
*/
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "ModbusPoints/Modbus_Point.h"
#include "ModbusPoints/Modbus_FloatDecorator.h"
#include "Equipment/Equipment.h"
#include "Strategies/Strategy_Ramp.h"
#include "Strategies/Strategy_SingleValue.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new StandbyState object.
*
* In this state, the equipment is idle. This constructor initializes several
* strategies to generate random values for various status points, simulating
* a live but non-operational unit.
*/
template<>
StandbyState<ModbusRTU>::StandbyState() {
addStrategy("Comp1 Percent RLA", new RampStrategy(0,5,1000));
addStrategy("Comp2 Percent RLA", new RampStrategy(0,5,1000));
addStrategy("Return Temp", new SingleValueStrategy(85,3.0f, 1000));
}
/**
* @brief Executes the standby state's logic for one update cycle.
*
* This method checks the "Chiller On-Off" Modbus point for a command to
* transition to the Running state. If no transition is requested, it applies
* the strategies defined for the standby state.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusRTU>* StandbyState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Standby update function");
int CH_Enable_SP = getPointValue(equipment, "Chiller Enable SP");
if (CH_Enable_SP == 1){
return new RunningState<ModbusRTU>();
}
float OutdoorTemp = getPointValue(equipment, "Outdoor Air Temp");
Serial.printf("Outdoor Temp: %f\n", OutdoorTemp);
if (OutdoorTemp >50.0f) {
setPointValue(equipment, "Chiller Mode SP", 1);
}else {
setPointValue(equipment, "Chiller Mode SP", 2);
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the standby state.
* Sets the "Chiller Sts" point to indicate the unit is not running.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void StandbyState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Standby State...");
setPointValue(equipment, "Run Enabled", 0);
setPointValue(equipment, "Flow Switch", 0);
}
/**
* @brief Logic to execute once when exiting the standby state.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void StandbyState<ModbusRTU>::exitState(Equipment<ModbusRTU>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Standby State...");
}

View File

@@ -22,10 +22,10 @@
* @{
*/
#include <ModbusIP_ESP8266.h>
const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */
const char *password = "wifi_password"; /**< @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. */
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, 33, 78); /**< @brief The static IP address for the device. */
IPAddress gateway(192, 17, 33, 1); /**< @brief The gateway IP address. */
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
ModbusIP mb;
@@ -54,67 +54,51 @@
*/
modbusMap mb_map[] =
{
{HR, 100, 0, "State Control"}, //Internal to control from Modscan
{HR, 101, 0, "Fault Code"},
{HR_FLOAT, 102, 0, "Supply Temp"},
{HR_FLOAT, 103, 0, "Return Temp"}, //+14
{HR_FLOAT, 104, 0, "Flow Switch"},
{HR, 0, 0, "Chiller Local-Network"},
{HR, 1, 0, "Chiller Enable Output"},
{HR, 2, 0, "Run Enabled"},
{HR, 3, 0, "Chiller Capacity Limited"},
{HR, 4, 0, "Alm Digital Output"},
{HR, 6, 0, "Evap Flow Switch Sts"},
{HR, 7, 0, "Cond Flow Switch Sts"},
{HR, 8, 0, "Chiller On-Off"},
{HR, 9, 0, "Chiller Enable SP"},
{HR, 10, 0, "Clear Alm"},
{HR, 11, 0, "Chiller Mode Output"},
{HR_10x, 12, 0, "Active SP"},
{HR_10x, 13, 0, "Actual Capacity"},
{HR_10x, 14, 0, "Active Capacity Limit"},
{HR, 15, 0, "Chiller Sts"},
{HR_10x, 16, 0, "Evap Entering Fluid Temp"},
{HR_10x, 17, 0, "Evap Leaving Fluid Temp"},
{HR, 18, 0, "Evap Fluid Flow Rate"},
{HR_10x, 19, 0, "Cond Entering Fluid Temp"},
{HR_10x, 20, 0, "Cond Leaving Fluid Temp"},
{HR, 21, 0, "Cond Fluid Flow Rate"},
{HR_10x, 24, 0, "Outdoor Air Temp"},
{HR, 25, 0, "Chiller Current"},
{HR, 27, 0, "Total Kw"},
{HR, 28, 0, "Warning Alm Idx"},
{HR, 29, 0, "Problem Alm Idx"},
{HR, 30, 0, "Fault Alm Idx"},
{HR, 31, 0, "Warning Alm Code"},
{HR, 32, 0, "Problem Alm Code"},
{HR, 33, 0, "Fault Alm Code"},
{HR, 34, 0, "Chiller Mode SP"},
{HR_10x, 35, 0, "Cool SP"},
{HR_10x, 36, 0, "Ice SP"},
{HR_10x, 38, 0, "Capacity Limit SP"},
{HR_10x, 39, 0, "Cond Refrig Pressure"},
{HR_10x, 40, 0, "Cond Saturated Refrig Temp"},
{HR_10x, 41, 0, "Evap Refrig Pressure"},
{HR_10x, 42, 0, "Evap Saturated Refrig Temp"},
{HR, 65, 0, "Comp Suction Refrig Temp"},
{HR_10x, 68, 0, "Comp Discharge Refrig Temp"},
{HR, 69, 0, "Comp1 Percent RLA"},
{HR, 70, 0, "Comp1 Current"},
{HR, 71, 0, "Comp Voltage"},
{HR, 72, 0, "Comp Power"},
{HR, 73, 0, "Comp Starts"},
{HR, 74, 0, "Comp Run Hours"},
{HR, 75, 0, "Comp Run Hours"},
{HR, 82, 0, "Comp2 Percent RLA"},
{HR, 303, 0, "Evap Pump Run Hours"},
{HR, 304, 0, "Evap Pump Run Hours"},
{HR, 305, 0, "Evap Pump Sts"},
{HR, 316, 0, "Units"},
{HR, 317, 0, "Chiller Model"},
{HR, 1849, 0, "Oil Feed Pessure"},
{HR, 1854, 0, "Wtrside Econo State"},
{HR, 1855, 0, "Wtrside Econo En SP"},
{HR_FLOAT, 8100, 0, "PICs Supply Temp"}, //Internal to control from Modscan
{COIL, 8102, 0, "PICs Chiller Enable"},
{HR_FLOAT, 8104, 0, "PICs Chiller Flow"},
{HR_FLOAT, 8106, 0, "PICs Return Temp"},
{HR, 3, 0, "Run Enable"},
{HR, 9, 0, "Chiller Enable SP"},
{HR, 10, 0, "Clear Alarms"},
{HR, 11, 0, "Chiller Mode Output"},
{HR_10x, 12, 0, "Chiller Local Setpoint"},
{HR_10x, 13, 0, "Actual Capacity"},
{HR_10x, 14, 0, "Active Capacity Limit"},
{HR_10x, 16, 0, "System Chill Water In Temp"},
{HR_10x, 17, 0, "System Chill Water Out Temp"},
{HR_10x, 24, 0, "Ambient Temperature"},
{HR, 27, 0, "Chiller Total Power"},
{HR, 34, 0, "Chiller Mode SP"},
{HR_10x, 35, 0, "Cooling Active Setpoint"},
{HR_10x, 36, 0, "Ice Setpoint"},
{HR_10x, 39, 0, "C1 Cond Refrig Pres"},
{HR_10x, 41, 0, "C1 Evap Refrig Pres"},
{HR_10x, 43, 0, "C2 Cond Refrig Pres"},
{HR_10x, 45, 0, "C2 Evap Refrig Pres"},
{HR_10x, 47, 0, "C3 Cond Refrig Pres"},
{HR_10x, 49, 0, "C3 Evap Refrig Pres"},
{HR_10x, 51, 0, "C4 Cond Refrig Pres"},
{HR_10x, 53, 0, "C4 Evap Refrig Pres"},
{HR_10x, 63, 0, "C1 Comp Suction Refrig Pres"},
{HR_10x, 66, 0, "C1 Comp 1 Discharge Refrig Pres"},
{HR, 69, 0, "C1 Comp 1 Motor Percent (RLA)"},
{HR, 70, 0, "C1 Comp Current"},
{HR, 72, 0, "C1 Comp 1 Power"},
{HR_10x, 76, 0, "C1 Comp 2 Suction Refrig Pres"},
{HR_10x, 79, 0, "C1 Comp 2 Discharge Refrig Pres"},
{HR, 108, 0, "C2 Comp 1 Current"},
{HR, 109, 0, "C2 Comp 1 Current"},
{HR, 111, 0, "C2 Comp 1 Power"},
{HR, 147, 0, "C3 Comp 1 Motor Percent (RLA)"},
{HR, 148, 0, "C3 Comp 1 Current"},
{HR, 150, 0, "C3 Comp 1 Power"},
{HR, 592, 0, "Alarm Freeze Protection Evap 1"},
{HR, 593, 0, "Alarm Freeze Protection Evap 2"},
{HR_10x, 1731, 0, "C4 Comp 1 Oil Pres"},
{HR_10x, 1770, 0, "C3 Comp 1 Oil Pres"},
{HR_10x, 1809, 0, "C2 Comp 1 Oil Pres"},
{HR_10x, 1849, 0, "C1 Comp 1 Oil Pres"},
};
//Size of modbus map used in FOR cycles, automatically calculated.

View File

@@ -0,0 +1,132 @@
/**
* @file config.h
* @brief Main configuration file for the Daikin Chiller (RTU) emulator.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-02
*
* This file contains important configurations for the Modbus RTU communication
* and the specific register map for the emulated device.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <ModbusRTU.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 = "wifi_name"; /**< @brief The SSID of the WiFi network. */
const char *password = "wifi_password"; /**< @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
/**
* @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, 100, 0, "State Control"}, //Internal to control from Modscan
{HR, 101, 0, "Fault Code"},
{HR_FLOAT, 102, 0, "Supply Temp"},
{HR_FLOAT, 103, 0, "Return Temp"}, //+14
{HR_FLOAT, 104, 0, "Flow Switch"},
{HR, 0, 0, "Chiller Local-Network"},
{HR, 1, 0, "Chiller Enable Output"},
{HR, 2, 0, "Run Enabled"},
{HR, 3, 0, "Chiller Capacity Limited"},
{HR, 4, 0, "Alm Digital Output"},
{HR, 6, 0, "Evap Flow Switch Sts"},
{HR, 7, 0, "Cond Flow Switch Sts"},
{HR, 8, 0, "Chiller On-Off"},
{HR, 9, 0, "Chiller Enable SP"},
{HR, 10, 0, "Clear Alm"},
{HR, 11, 0, "Chiller Mode Output"},
{HR_10x, 12, 0, "Active SP"},
{HR_10x, 13, 0, "Actual Capacity"},
{HR_10x, 14, 0, "Active Capacity Limit"},
{HR, 15, 0, "Chiller Sts"},
{HR_10x, 16, 0, "Evap Entering Fluid Temp"},
{HR_10x, 17, 0, "Evap Leaving Fluid Temp"},
{HR, 18, 0, "Evap Fluid Flow Rate"},
{HR_10x, 19, 0, "Cond Entering Fluid Temp"},
{HR_10x, 20, 0, "Cond Leaving Fluid Temp"},
{HR, 21, 0, "Cond Fluid Flow Rate"},
{HR_10x, 24, 0, "Outdoor Air Temp"},
{HR, 25, 0, "Chiller Current"},
{HR, 27, 0, "Total Kw"},
{HR, 28, 0, "Warning Alm Idx"},
{HR, 29, 0, "Problem Alm Idx"},
{HR, 30, 0, "Fault Alm Idx"},
{HR, 31, 0, "Warning Alm Code"},
{HR, 32, 0, "Problem Alm Code"},
{HR, 33, 0, "Fault Alm Code"},
{HR, 34, 0, "Chiller Mode SP"},
{HR_10x, 35, 0, "Cool SP"},
{HR_10x, 36, 0, "Ice SP"},
{HR_10x, 38, 0, "Capacity Limit SP"},
{HR_10x, 39, 0, "Cond Refrig Pressure"},
{HR_10x, 40, 0, "Cond Saturated Refrig Temp"},
{HR_10x, 41, 0, "Evap Refrig Pressure"},
{HR_10x, 42, 0, "Evap Saturated Refrig Temp"},
{HR, 65, 0, "Comp Suction Refrig Temp"},
{HR_10x, 68, 0, "Comp Discharge Refrig Temp"},
{HR, 69, 0, "Comp1 Percent RLA"},
{HR, 70, 0, "Comp1 Current"},
{HR, 71, 0, "Comp Voltage"},
{HR, 72, 0, "Comp Power"},
{HR, 73, 0, "Comp Starts"},
{HR, 74, 0, "Comp Run Hours"},
{HR, 75, 0, "Comp Run Hours"},
{HR, 82, 0, "Comp2 Percent RLA"},
{HR, 303, 0, "Evap Pump Run Hours"},
{HR, 304, 0, "Evap Pump Run Hours"},
{HR, 305, 0, "Evap Pump Sts"},
{HR, 316, 0, "Units"},
{HR, 317, 0, "Chiller Model"},
{HR, 1849, 0, "Oil Feed Pessure"},
{HR, 1854, 0, "Wtrside Econo State"},
{HR, 1855, 0, "Wtrside Econo En SP"},
};
//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;
#endif // CONFIG_H

View File

@@ -38,6 +38,24 @@
*/
template<>
RunningState<ModbusIP>::RunningState() {
//Example
addStrategy("System Input RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase A", new RampStrategy(10.0F, 5.0f, 1000));
//
addStrategy("CB0_V1N", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_V2N", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_V3N", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_V12", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_V23", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_V31", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_I1", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_I2", new SingleValueStrategy(0.0F, 1.0f, 1000));
addStrategy("CB0_I3", new SingleValueStrategy(0.0F, 1.0f, 1000));
}
/**
@@ -86,4 +104,5 @@ void RunningState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Running State...");
}
}

View File

@@ -21,11 +21,11 @@
* @{
*/
#include <ModbusIP_ESP8266.h>
const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */
const char *password = "wifi_password"; /**< @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. */
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, 16, 32, 178); /**< @brief The static IP address for the device. */
IPAddress gateway(172, 16, 32, 1); /**< @brief The gateway IP address. */
IPAddress subnet(254, 254, 254, 0); /**< @brief The subnet mask. */
ModbusIP mb;
#else
@@ -63,429 +63,442 @@ modbusMap mb_map[] = {
//***************************************
// Write Registers (as Input Registers - 3X)
//***************************************
{HR, 9, 0, "Px Ctrl"},
{HR, 10, 0, "Px Rating"}, //Watts
{HR, 11, 0, "Px Load"}, //%load
{COIL, 9, 0, "Px CB0"},
{COIL, 10, 0, "Px CB1"},
{COIL, 11, 0, "Px CB2"},
{COIL, 12, 0, "Px CB3"},
{COIL, 13, 0, "Px CB4"},
{COIL, 14, 0, "Px CB5"},
{COIL, 15, 0, "Px CB6"},
{COIL, 16, 0, "Px CB7"},
{COIL, 17, 0, "Px CB8"},
// System Status
{IR_FLOAT, 1, 0, "CB0_V1N" },
{IR_FLOAT, 3, 0, "CB0_V2N" },
{IR_FLOAT, 5, 0, "CB0_V3N" },
{IR_FLOAT, 7, 0, "CB0_I1" },
{IR_FLOAT, 9, 0, "CB0_I2" },
{IR_FLOAT, 11, 0, "CB0_I3" },
{IR_FLOAT, 13, 0, "CB0_L1KW" },
{IR_FLOAT, 15, 0, "CB0_L2KW" },
{IR_FLOAT, 17, 0, "CB0_L3KW" },
{IR_FLOAT, 19, 0, "CB0_L1KVar" },
{IR_FLOAT, 21, 0, "CB0_L2KVar" },
{IR_FLOAT, 23, 0, "CB0_L3KVar" },
{IR_FLOAT, 25, 0, "CB0_L1KVA" },
{IR_FLOAT, 27, 0, "CB0_L2KVA" },
{IR_FLOAT, 29, 0, "CB0_L3KVA" },
{IR_FLOAT, 31, 0, "CB0_L1PF" },
{IR_FLOAT, 33, 0, "CB0_L2PF" },
{IR_FLOAT, 35, 0, "CB0_L3PF" },
{IR_FLOAT, 37, 0, "CB0_V1THD" },
{IR_FLOAT, 39, 0, "CB0_V2THD" },
{IR_FLOAT, 41, 0, "CB0_V3THD" },
{IR_FLOAT, 43, 0, "CB0_I1THD" },
{IR_FLOAT, 45, 0, "CB0_I2THD" },
{IR_FLOAT, 47, 0, "CB0_I3THD" },
{IR_FLOAT, 49, 0, "CB0_I1Kfactor" },
{IR_FLOAT, 51, 0, "CB0_I2Kfactor" },
{IR_FLOAT, 53, 0, "CB0_I3Kfactor" },
{IR_FLOAT, 55, 0, "CB0_I1TDD" },
{IR_FLOAT, 57, 0, "CB0_I2TDD" },
{IR_FLOAT, 59, 0, "CB0_I3TDD" },
{IR_FLOAT, 61, 0, "CB0_V12" },
{IR_FLOAT, 63, 0, "CB0_V23" },
{IR_FLOAT, 65, 0, "CB0_V31" },
{IR_FLOAT, 67, 0, "CB0_TotalKW" },
{IR_FLOAT, 69, 0, "CB0_TotalKVar" },
{IR_FLOAT, 71, 0, "CB0_TotalKVA" },
{IR_FLOAT, 73, 0, "CB0_TotalPF" },
{IR_FLOAT, 75, 0, "CB0_TotalPFLag" },
{IR_FLOAT, 77, 0, "CB0_TotalPFLead" },
{IR_FLOAT, 79, 0, "CB0_TotalKWImport" },
{IR_FLOAT, 81, 0, "CB0_TotalKWExport" },
{IR_FLOAT, 83, 0, "CB0_TotalKVarImport" },
{IR_FLOAT, 85, 0, "CB0_TotalKVarExport" },
{IR_FLOAT, 87, 0, "CB0_LN_Avg" },
{IR_FLOAT, 89, 0, "CB0_LL_Avg" },
{IR_FLOAT, 0, 0, "CB0_V1N" },
{IR_FLOAT, 2, 0, "CB0_V2N" },
{IR_FLOAT, 4, 0, "CB0_V3N" },
{IR_FLOAT, 6, 0, "CB0_I1" },
{IR_FLOAT, 8, 0, "CB0_I2" },
{IR_FLOAT, 10, 0, "CB0_I3" },
{IR_FLOAT, 12, 0, "CB0_L1KW" },
{IR_FLOAT, 14, 0, "CB0_L2KW" },
{IR_FLOAT, 16, 0, "CB0_L3KW" },
{IR_FLOAT, 18, 0, "CB0_L1KVar" },
{IR_FLOAT, 20, 0, "CB0_L2KVar" },
{IR_FLOAT, 22, 0, "CB0_L3KVar" },
{IR_FLOAT, 24, 0, "CB0_L1KVA" },
{IR_FLOAT, 26, 0, "CB0_L2KVA" },
{IR_FLOAT, 28, 0, "CB0_L3KVA" },
{IR_FLOAT, 30, 0, "CB0_L1PF" },
{IR_FLOAT, 32, 0, "CB0_L2PF" },
{IR_FLOAT, 34, 0, "CB0_L3PF" },
{IR_FLOAT, 36, 0, "CB0_V1THD" },
{IR_FLOAT, 38, 0, "CB0_V2THD" },
{IR_FLOAT, 30, 0, "CB0_V3THD" },
{IR_FLOAT, 42, 0, "CB0_I1THD" },
{IR_FLOAT, 44, 0, "CB0_I2THD" },
{IR_FLOAT, 46, 0, "CB0_I3THD" },
{IR_FLOAT, 48, 0, "CB0_I1Kfactor" },
{IR_FLOAT, 50, 0, "CB0_I2Kfactor" },
{IR_FLOAT, 52, 0, "CB0_I3Kfactor" },
{IR_FLOAT, 54, 0, "CB0_I1TDD" },
{IR_FLOAT, 56, 0, "CB0_I2TDD" },
{IR_FLOAT, 58, 0, "CB0_I3TDD" },
{IR_FLOAT, 60, 0, "CB0_V12" },
{IR_FLOAT, 62, 0, "CB0_V23" },
{IR_FLOAT, 64, 0, "CB0_V31" },
{IR_FLOAT, 66, 0, "CB0_TotalKW" },
{IR_FLOAT, 68, 0, "CB0_TotalKVar" },
{IR_FLOAT, 70, 0, "CB0_TotalKVA" },
{IR_FLOAT, 72, 0, "CB0_TotalPF" },
{IR_FLOAT, 74, 0, "CB0_TotalPFLag" },
{IR_FLOAT, 76, 0, "CB0_TotalPFLead" },
{IR_FLOAT, 78, 0, "CB0_TotalKWImport" },
{IR_FLOAT, 80, 0, "CB0_TotalKWExport" },
{IR_FLOAT, 82, 0, "CB0_TotalKVarImport" },
{IR_FLOAT, 84, 0, "CB0_TotalKVarExport" },
{IR_FLOAT, 86, 0, "CB0_LN_Avg" },
{IR_FLOAT, 88, 0, "CB0_LL_Avg" },
{IR_FLOAT, 92, 0, "CB0_TotalKWh" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 101, 0, "CB1_V1N" },
{IR_FLOAT, 103, 0, "CB1_V2N" },
{IR_FLOAT, 105, 0, "CB1_V3N" },
{IR_FLOAT, 107, 0, "CB1_I1" },
{IR_FLOAT, 109, 0, "CB1_I2" },
{IR_FLOAT, 111, 0, "CB1_I3" },
{IR_FLOAT, 113, 0, "CB1_L1KW" },
{IR_FLOAT, 115, 0, "CB1_L2KW" },
{IR_FLOAT, 117, 0, "CB1_L3KW" },
{IR_FLOAT, 119, 0, "CB1_L1KVar" },
{IR_FLOAT, 121, 0, "CB1_L2KVar" },
{IR_FLOAT, 123, 0, "CB1_L3KVar" },
{IR_FLOAT, 125, 0, "CB1_L1KVA" },
{IR_FLOAT, 127, 0, "CB1_L2KVA" },
{IR_FLOAT, 129, 0, "CB1_L3KVA" },
{IR_FLOAT, 131, 0, "CB1_L1PF" },
{IR_FLOAT, 133, 0, "CB1_L2PF" },
{IR_FLOAT, 135, 0, "CB1_L3PF" },
{IR_FLOAT, 137, 0, "CB1_V1THD" },
{IR_FLOAT, 139, 0, "CB1_V2THD" },
{IR_FLOAT, 141, 0, "CB1_V3THD" },
{IR_FLOAT, 143, 0, "CB1_I1THD" },
{IR_FLOAT, 145, 0, "CB1_I2THD" },
{IR_FLOAT, 147, 0, "CB1_I3THD" },
{IR_FLOAT, 149, 0, "CB1_I1Kfactor" },
{IR_FLOAT, 151, 0, "CB1_I2Kfactor" },
{IR_FLOAT, 153, 0, "CB1_I3Kfactor" },
{IR_FLOAT, 155, 0, "CB1_I1TDD" },
{IR_FLOAT, 157, 0, "CB1_I2TDD" },
{IR_FLOAT, 159, 0, "CB1_I3TDD" },
{IR_FLOAT, 161, 0, "CB1_V12" },
{IR_FLOAT, 163, 0, "CB1_V23" },
{IR_FLOAT, 165, 0, "CB1_V31" },
{IR_FLOAT, 167, 0, "CB1_TotalKW" },
{IR_FLOAT, 169, 0, "CB1_TotalKVar" },
{IR_FLOAT, 171, 0, "CB1_TotalKVA" },
{IR_FLOAT, 173, 0, "CB1_TotalPF" },
{IR_FLOAT, 175, 0, "CB1_TotalPFLag" },
{IR_FLOAT, 177, 0, "CB1_TotalPFLead" },
{IR_FLOAT, 179, 0, "CB1_TotalKWImport" },
{IR_FLOAT, 181, 0, "CB1_TotalKWExport" },
{IR_FLOAT, 183, 0, "CB1_TotalKVarImport" },
{IR_FLOAT, 185, 0, "CB1_TotalKVarExport" },
{IR_FLOAT, 187, 0, "CB1_LN_Avg" },
{IR_FLOAT, 189, 0, "CB1_LL_Avg" },
{IR_FLOAT, 100, 0, "CB1_V1N" },
{IR_FLOAT, 102, 0, "CB1_V2N" },
{IR_FLOAT, 104, 0, "CB1_V3N" },
{IR_FLOAT, 106, 0, "CB1_I1" },
{IR_FLOAT, 108, 0, "CB1_I2" },
{IR_FLOAT, 110, 0, "CB1_I3" },
{IR_FLOAT, 112, 0, "CB1_L1KW" },
{IR_FLOAT, 114, 0, "CB1_L2KW" },
{IR_FLOAT, 116, 0, "CB1_L3KW" },
{IR_FLOAT, 118, 0, "CB1_L1KVar" },
{IR_FLOAT, 120, 0, "CB1_L2KVar" },
{IR_FLOAT, 122, 0, "CB1_L3KVar" },
{IR_FLOAT, 124, 0, "CB1_L1KVA" },
{IR_FLOAT, 126, 0, "CB1_L2KVA" },
{IR_FLOAT, 128, 0, "CB1_L3KVA" },
{IR_FLOAT, 130, 0, "CB1_L1PF" },
{IR_FLOAT, 132, 0, "CB1_L2PF" },
{IR_FLOAT, 134, 0, "CB1_L3PF" },
{IR_FLOAT, 136, 0, "CB1_V1THD" },
{IR_FLOAT, 138, 0, "CB1_V2THD" },
{IR_FLOAT, 130, 0, "CB1_V3THD" },
{IR_FLOAT, 142, 0, "CB1_I1THD" },
{IR_FLOAT, 144, 0, "CB1_I2THD" },
{IR_FLOAT, 146, 0, "CB1_I3THD" },
{IR_FLOAT, 148, 0, "CB1_I1Kfactor" },
{IR_FLOAT, 150, 0, "CB1_I2Kfactor" },
{IR_FLOAT, 152, 0, "CB1_I3Kfactor" },
{IR_FLOAT, 154, 0, "CB1_I1TDD" },
{IR_FLOAT, 156, 0, "CB1_I2TDD" },
{IR_FLOAT, 158, 0, "CB1_I3TDD" },
{IR_FLOAT, 160, 0, "CB1_V12" },
{IR_FLOAT, 162, 0, "CB1_V23" },
{IR_FLOAT, 164, 0, "CB1_V31" },
{IR_FLOAT, 166, 0, "CB1_TotalKW" },
{IR_FLOAT, 168, 0, "CB1_TotalKVar" },
{IR_FLOAT, 170, 0, "CB1_TotalKVA" },
{IR_FLOAT, 172, 0, "CB1_TotalPF" },
{IR_FLOAT, 174, 0, "CB1_TotalPFLag" },
{IR_FLOAT, 176, 0, "CB1_TotalPFLead" },
{IR_FLOAT, 178, 0, "CB1_TotalKWImport" },
{IR_FLOAT, 180, 0, "CB1_TotalKWExport" },
{IR_FLOAT, 182, 0, "CB1_TotalKVarImport" },
{IR_FLOAT, 184, 0, "CB1_TotalKVarExport" },
{IR_FLOAT, 186, 0, "CB1_LN_Avg" },
{IR_FLOAT, 188, 0, "CB1_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 201, 0, "CB2_V1N" },
{IR_FLOAT, 203, 0, "CB2_V2N" },
{IR_FLOAT, 205, 0, "CB2_V3N" },
{IR_FLOAT, 207, 0, "CB2_I1" },
{IR_FLOAT, 209, 0, "CB2_I2" },
{IR_FLOAT, 211, 0, "CB2_I3" },
{IR_FLOAT, 213, 0, "CB2_L1KW" },
{IR_FLOAT, 215, 0, "CB2_L2KW" },
{IR_FLOAT, 217, 0, "CB2_L3KW" },
{IR_FLOAT, 219, 0, "CB2_L1KVar" },
{IR_FLOAT, 221, 0, "CB2_L2KVar" },
{IR_FLOAT, 223, 0, "CB2_L3KVar" },
{IR_FLOAT, 225, 0, "CB2_L1KVA" },
{IR_FLOAT, 227, 0, "CB2_L2KVA" },
{IR_FLOAT, 229, 0, "CB2_L3KVA" },
{IR_FLOAT, 231, 0, "CB2_L1PF" },
{IR_FLOAT, 233, 0, "CB2_L2PF" },
{IR_FLOAT, 235, 0, "CB2_L3PF" },
{IR_FLOAT, 237, 0, "CB2_V1THD" },
{IR_FLOAT, 239, 0, "CB2_V2THD" },
{IR_FLOAT, 241, 0, "CB2_V3THD" },
{IR_FLOAT, 243, 0, "CB2_I1THD" },
{IR_FLOAT, 245, 0, "CB2_I2THD" },
{IR_FLOAT, 247, 0, "CB2_I3THD" },
{IR_FLOAT, 249, 0, "CB2_I1Kfactor" },
{IR_FLOAT, 251, 0, "CB2_I2Kfactor" },
{IR_FLOAT, 253, 0, "CB2_I3Kfactor" },
{IR_FLOAT, 255, 0, "CB2_I1TDD" },
{IR_FLOAT, 257, 0, "CB2_I2TDD" },
{IR_FLOAT, 259, 0, "CB2_I3TDD" },
{IR_FLOAT, 261, 0, "CB2_V12" },
{IR_FLOAT, 263, 0, "CB2_V23" },
{IR_FLOAT, 265, 0, "CB2_V31" },
{IR_FLOAT, 267, 0, "CB2_TotalKW" },
{IR_FLOAT, 269, 0, "CB2_TotalKVar" },
{IR_FLOAT, 271, 0, "CB2_TotalKVA" },
{IR_FLOAT, 273, 0, "CB2_TotalPF" },
{IR_FLOAT, 275, 0, "CB2_TotalPFLag" },
{IR_FLOAT, 277, 0, "CB2_TotalPFLead" },
{IR_FLOAT, 279, 0, "CB2_TotalKWImport" },
{IR_FLOAT, 281, 0, "CB2_TotalKWExport" },
{IR_FLOAT, 283, 0, "CB2_TotalKVarImport" },
{IR_FLOAT, 285, 0, "CB2_TotalKVarExport" },
{IR_FLOAT, 287, 0, "CB2_LN_Avg" },
{IR_FLOAT, 289, 0, "CB2_LL_Avg" },
// Circuit Breaker 2 (OB02)
{IR_FLOAT, 200, 0, "CB2_V1N" },
{IR_FLOAT, 202, 0, "CB2_V2N" },
{IR_FLOAT, 204, 0, "CB2_V3N" },
{IR_FLOAT, 206, 0, "CB2_I1" },
{IR_FLOAT, 208, 0, "CB2_I2" },
{IR_FLOAT, 210, 0, "CB2_I3" },
{IR_FLOAT, 212, 0, "CB2_L1KW" },
{IR_FLOAT, 214, 0, "CB2_L2KW" },
{IR_FLOAT, 216, 0, "CB2_L3KW" },
{IR_FLOAT, 218, 0, "CB2_L1KVar" },
{IR_FLOAT, 220, 0, "CB2_L2KVar" },
{IR_FLOAT, 222, 0, "CB2_L3KVar" },
{IR_FLOAT, 224, 0, "CB2_L1KVA" },
{IR_FLOAT, 226, 0, "CB2_L2KVA" },
{IR_FLOAT, 228, 0, "CB2_L3KVA" },
{IR_FLOAT, 230, 0, "CB2_L1PF" },
{IR_FLOAT, 232, 0, "CB2_L2PF" },
{IR_FLOAT, 234, 0, "CB2_L3PF" },
{IR_FLOAT, 236, 0, "CB2_V1THD" },
{IR_FLOAT, 238, 0, "CB2_V2THD" },
{IR_FLOAT, 230, 0, "CB2_V3THD" },
{IR_FLOAT, 242, 0, "CB2_I1THD" },
{IR_FLOAT, 244, 0, "CB2_I2THD" },
{IR_FLOAT, 246, 0, "CB2_I3THD" },
{IR_FLOAT, 248, 0, "CB2_I1Kfactor" },
{IR_FLOAT, 250, 0, "CB2_I2Kfactor" },
{IR_FLOAT, 252, 0, "CB2_I3Kfactor" },
{IR_FLOAT, 254, 0, "CB2_I1TDD" },
{IR_FLOAT, 256, 0, "CB2_I2TDD" },
{IR_FLOAT, 258, 0, "CB2_I3TDD" },
{IR_FLOAT, 260, 0, "CB2_V12" },
{IR_FLOAT, 262, 0, "CB2_V23" },
{IR_FLOAT, 264, 0, "CB2_V31" },
{IR_FLOAT, 266, 0, "CB2_TotalKW" },
{IR_FLOAT, 268, 0, "CB2_TotalKVar" },
{IR_FLOAT, 270, 0, "CB2_TotalKVA" },
{IR_FLOAT, 272, 0, "CB2_TotalPF" },
{IR_FLOAT, 274, 0, "CB2_TotalPFLag" },
{IR_FLOAT, 276, 0, "CB2_TotalPFLead" },
{IR_FLOAT, 278, 0, "CB2_TotalKWImport" },
{IR_FLOAT, 280, 0, "CB2_TotalKWExport" },
{IR_FLOAT, 282, 0, "CB2_TotalKVarImport" },
{IR_FLOAT, 284, 0, "CB2_TotalKVarExport" },
{IR_FLOAT, 286, 0, "CB2_LN_Avg" },
{IR_FLOAT, 288, 0, "CB2_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 301, 0, "CB3_V1N" },
{IR_FLOAT, 303, 0, "CB3_V2N" },
{IR_FLOAT, 305, 0, "CB3_V3N" },
{IR_FLOAT, 307, 0, "CB3_I1" },
{IR_FLOAT, 309, 0, "CB3_I2" },
{IR_FLOAT, 311, 0, "CB3_I3" },
{IR_FLOAT, 313, 0, "CB3_L1KW" },
{IR_FLOAT, 315, 0, "CB3_L2KW" },
{IR_FLOAT, 317, 0, "CB3_L3KW" },
{IR_FLOAT, 319, 0, "CB3_L1KVar" },
{IR_FLOAT, 321, 0, "CB3_L2KVar" },
{IR_FLOAT, 323, 0, "CB3_L3KVar" },
{IR_FLOAT, 325, 0, "CB3_L1KVA" },
{IR_FLOAT, 327, 0, "CB3_L2KVA" },
{IR_FLOAT, 329, 0, "CB3_L3KVA" },
{IR_FLOAT, 331, 0, "CB3_L1PF" },
{IR_FLOAT, 333, 0, "CB3_L2PF" },
{IR_FLOAT, 335, 0, "CB3_L3PF" },
{IR_FLOAT, 337, 0, "CB3_V1THD" },
{IR_FLOAT, 339, 0, "CB3_V2THD" },
{IR_FLOAT, 341, 0, "CB3_V3THD" },
{IR_FLOAT, 343, 0, "CB3_I1THD" },
{IR_FLOAT, 345, 0, "CB3_I2THD" },
{IR_FLOAT, 347, 0, "CB3_I3THD" },
{IR_FLOAT, 349, 0, "CB3_I1Kfactor" },
{IR_FLOAT, 351, 0, "CB3_I2Kfactor" },
{IR_FLOAT, 353, 0, "CB3_I3Kfactor" },
{IR_FLOAT, 355, 0, "CB3_I1TDD" },
{IR_FLOAT, 357, 0, "CB3_I2TDD" },
{IR_FLOAT, 359, 0, "CB3_I3TDD" },
{IR_FLOAT, 361, 0, "CB3_V12" },
{IR_FLOAT, 363, 0, "CB3_V23" },
{IR_FLOAT, 365, 0, "CB3_V31" },
{IR_FLOAT, 367, 0, "CB3_TotalKW" },
{IR_FLOAT, 369, 0, "CB3_TotalKVar" },
{IR_FLOAT, 371, 0, "CB3_TotalKVA" },
{IR_FLOAT, 373, 0, "CB3_TotalPF" },
{IR_FLOAT, 375, 0, "CB3_TotalPFLag" },
{IR_FLOAT, 377, 0, "CB3_TotalPFLead" },
{IR_FLOAT, 379, 0, "CB3_TotalKWImport" },
{IR_FLOAT, 381, 0, "CB3_TotalKWExport" },
{IR_FLOAT, 383, 0, "CB3_TotalKVarImport" },
{IR_FLOAT, 385, 0, "CB3_TotalKVarExport" },
{IR_FLOAT, 387, 0, "CB3_LN_Avg" },
{IR_FLOAT, 389, 0, "CB3_LL_Avg" },
// Circuit Breaker 3 (OB03)
{IR_FLOAT, 300, 0, "CB3_V1N" },
{IR_FLOAT, 302, 0, "CB3_V2N" },
{IR_FLOAT, 304, 0, "CB3_V3N" },
{IR_FLOAT, 306, 0, "CB3_I1" },
{IR_FLOAT, 308, 0, "CB3_I2" },
{IR_FLOAT, 310, 0, "CB3_I3" },
{IR_FLOAT, 312, 0, "CB3_L1KW" },
{IR_FLOAT, 314, 0, "CB3_L2KW" },
{IR_FLOAT, 316, 0, "CB3_L3KW" },
{IR_FLOAT, 318, 0, "CB3_L1KVar" },
{IR_FLOAT, 320, 0, "CB3_L2KVar" },
{IR_FLOAT, 322, 0, "CB3_L3KVar" },
{IR_FLOAT, 324, 0, "CB3_L1KVA" },
{IR_FLOAT, 326, 0, "CB3_L2KVA" },
{IR_FLOAT, 328, 0, "CB3_L3KVA" },
{IR_FLOAT, 330, 0, "CB3_L1PF" },
{IR_FLOAT, 332, 0, "CB3_L2PF" },
{IR_FLOAT, 334, 0, "CB3_L3PF" },
{IR_FLOAT, 336, 0, "CB3_V1THD" },
{IR_FLOAT, 338, 0, "CB3_V2THD" },
{IR_FLOAT, 330, 0, "CB3_V3THD" },
{IR_FLOAT, 342, 0, "CB3_I1THD" },
{IR_FLOAT, 344, 0, "CB3_I2THD" },
{IR_FLOAT, 346, 0, "CB3_I3THD" },
{IR_FLOAT, 348, 0, "CB3_I1Kfactor" },
{IR_FLOAT, 350, 0, "CB3_I2Kfactor" },
{IR_FLOAT, 352, 0, "CB3_I3Kfactor" },
{IR_FLOAT, 354, 0, "CB3_I1TDD" },
{IR_FLOAT, 356, 0, "CB3_I2TDD" },
{IR_FLOAT, 358, 0, "CB3_I3TDD" },
{IR_FLOAT, 360, 0, "CB3_V12" },
{IR_FLOAT, 362, 0, "CB3_V23" },
{IR_FLOAT, 364, 0, "CB3_V31" },
{IR_FLOAT, 366, 0, "CB3_TotalKW" },
{IR_FLOAT, 368, 0, "CB3_TotalKVar" },
{IR_FLOAT, 370, 0, "CB3_TotalKVA" },
{IR_FLOAT, 372, 0, "CB3_TotalPF" },
{IR_FLOAT, 374, 0, "CB3_TotalPFLag" },
{IR_FLOAT, 376, 0, "CB3_TotalPFLead" },
{IR_FLOAT, 378, 0, "CB3_TotalKWImport" },
{IR_FLOAT, 380, 0, "CB3_TotalKWExport" },
{IR_FLOAT, 382, 0, "CB3_TotalKVarImport" },
{IR_FLOAT, 384, 0, "CB3_TotalKVarExport" },
{IR_FLOAT, 386, 0, "CB3_LN_Avg" },
{IR_FLOAT, 388, 0, "CB3_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 401, 0, "CB4_V1N" },
{IR_FLOAT, 403, 0, "CB4_V2N" },
{IR_FLOAT, 405, 0, "CB4_V3N" },
{IR_FLOAT, 407, 0, "CB4_I1" },
{IR_FLOAT, 409, 0, "CB4_I2" },
{IR_FLOAT, 411, 0, "CB4_I3" },
{IR_FLOAT, 413, 0, "CB4_L1KW" },
{IR_FLOAT, 415, 0, "CB4_L2KW" },
{IR_FLOAT, 417, 0, "CB4_L3KW" },
{IR_FLOAT, 419, 0, "CB4_L1KVar" },
{IR_FLOAT, 421, 0, "CB4_L2KVar" },
{IR_FLOAT, 423, 0, "CB4_L3KVar" },
{IR_FLOAT, 425, 0, "CB4_L1KVA" },
{IR_FLOAT, 427, 0, "CB4_L2KVA" },
{IR_FLOAT, 429, 0, "CB4_L3KVA" },
{IR_FLOAT, 431, 0, "CB4_L1PF" },
{IR_FLOAT, 433, 0, "CB4_L2PF" },
{IR_FLOAT, 435, 0, "CB4_L3PF" },
{IR_FLOAT, 437, 0, "CB4_V1THD" },
{IR_FLOAT, 439, 0, "CB4_V2THD" },
{IR_FLOAT, 441, 0, "CB4_V3THD" },
{IR_FLOAT, 443, 0, "CB4_I1THD" },
{IR_FLOAT, 445, 0, "CB4_I2THD" },
{IR_FLOAT, 447, 0, "CB4_I3THD" },
{IR_FLOAT, 449, 0, "CB4_I1Kfactor" },
{IR_FLOAT, 451, 0, "CB4_I2Kfactor" },
{IR_FLOAT, 453, 0, "CB4_I3Kfactor" },
{IR_FLOAT, 455, 0, "CB4_I1TDD" },
{IR_FLOAT, 457, 0, "CB4_I2TDD" },
{IR_FLOAT, 459, 0, "CB4_I3TDD" },
{IR_FLOAT, 461, 0, "CB4_V12" },
{IR_FLOAT, 463, 0, "CB4_V23" },
{IR_FLOAT, 465, 0, "CB4_V31" },
{IR_FLOAT, 467, 0, "CB4_TotalKW" },
{IR_FLOAT, 469, 0, "CB4_TotalKVar" },
{IR_FLOAT, 471, 0, "CB4_TotalKVA" },
{IR_FLOAT, 473, 0, "CB4_TotalPF" },
{IR_FLOAT, 475, 0, "CB4_TotalPFLag" },
{IR_FLOAT, 477, 0, "CB4_TotalPFLead" },
{IR_FLOAT, 479, 0, "CB4_TotalKWImport" },
{IR_FLOAT, 481, 0, "CB4_TotalKWExport" },
{IR_FLOAT, 483, 0, "CB4_TotalKVarImport" },
{IR_FLOAT, 485, 0, "CB4_TotalKVarExport" },
{IR_FLOAT, 487, 0, "CB4_LN_Avg" },
{IR_FLOAT, 489, 0, "CB4_LL_Avg" },
// Circuit Breaker 4 (OB04)
{IR_FLOAT, 400, 0, "CB4_V1N" },
{IR_FLOAT, 402, 0, "CB4_V2N" },
{IR_FLOAT, 404, 0, "CB4_V3N" },
{IR_FLOAT, 406, 0, "CB4_I1" },
{IR_FLOAT, 408, 0, "CB4_I2" },
{IR_FLOAT, 410, 0, "CB4_I3" },
{IR_FLOAT, 412, 0, "CB4_L1KW" },
{IR_FLOAT, 414, 0, "CB4_L2KW" },
{IR_FLOAT, 416, 0, "CB4_L3KW" },
{IR_FLOAT, 418, 0, "CB4_L1KVar" },
{IR_FLOAT, 420, 0, "CB4_L2KVar" },
{IR_FLOAT, 422, 0, "CB4_L3KVar" },
{IR_FLOAT, 424, 0, "CB4_L1KVA" },
{IR_FLOAT, 426, 0, "CB4_L2KVA" },
{IR_FLOAT, 428, 0, "CB4_L3KVA" },
{IR_FLOAT, 430, 0, "CB4_L1PF" },
{IR_FLOAT, 432, 0, "CB4_L2PF" },
{IR_FLOAT, 434, 0, "CB4_L3PF" },
{IR_FLOAT, 436, 0, "CB4_V1THD" },
{IR_FLOAT, 438, 0, "CB4_V2THD" },
{IR_FLOAT, 430, 0, "CB4_V3THD" },
{IR_FLOAT, 442, 0, "CB4_I1THD" },
{IR_FLOAT, 444, 0, "CB4_I2THD" },
{IR_FLOAT, 446, 0, "CB4_I3THD" },
{IR_FLOAT, 448, 0, "CB4_I1Kfactor" },
{IR_FLOAT, 450, 0, "CB4_I2Kfactor" },
{IR_FLOAT, 452, 0, "CB4_I3Kfactor" },
{IR_FLOAT, 454, 0, "CB4_I1TDD" },
{IR_FLOAT, 456, 0, "CB4_I2TDD" },
{IR_FLOAT, 458, 0, "CB4_I3TDD" },
{IR_FLOAT, 460, 0, "CB4_V12" },
{IR_FLOAT, 462, 0, "CB4_V23" },
{IR_FLOAT, 464, 0, "CB4_V31" },
{IR_FLOAT, 466, 0, "CB4_TotalKW" },
{IR_FLOAT, 468, 0, "CB4_TotalKVar" },
{IR_FLOAT, 470, 0, "CB4_TotalKVA" },
{IR_FLOAT, 472, 0, "CB4_TotalPF" },
{IR_FLOAT, 474, 0, "CB4_TotalPFLag" },
{IR_FLOAT, 476, 0, "CB4_TotalPFLead" },
{IR_FLOAT, 478, 0, "CB4_TotalKWImport" },
{IR_FLOAT, 480, 0, "CB4_TotalKWExport" },
{IR_FLOAT, 482, 0, "CB4_TotalKVarImport" },
{IR_FLOAT, 484, 0, "CB4_TotalKVarExport" },
{IR_FLOAT, 486, 0, "CB4_LN_Avg" },
{IR_FLOAT, 488, 0, "CB4_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 501, 0, "CB5_V1N" },
{IR_FLOAT, 503, 0, "CB5_V2N" },
{IR_FLOAT, 505, 0, "CB5_V3N" },
{IR_FLOAT, 507, 0, "CB5_I1" },
{IR_FLOAT, 509, 0, "CB5_I2" },
{IR_FLOAT, 511, 0, "CB5_I3" },
{IR_FLOAT, 513, 0, "CB5_L1KW" },
{IR_FLOAT, 515, 0, "CB5_L2KW" },
{IR_FLOAT, 517, 0, "CB5_L3KW" },
{IR_FLOAT, 519, 0, "CB5_L1KVar" },
{IR_FLOAT, 521, 0, "CB5_L2KVar" },
{IR_FLOAT, 523, 0, "CB5_L3KVar" },
{IR_FLOAT, 525, 0, "CB5_L1KVA" },
{IR_FLOAT, 527, 0, "CB5_L2KVA" },
{IR_FLOAT, 529, 0, "CB5_L3KVA" },
{IR_FLOAT, 531, 0, "CB5_L1PF" },
{IR_FLOAT, 533, 0, "CB5_L2PF" },
{IR_FLOAT, 535, 0, "CB5_L3PF" },
{IR_FLOAT, 537, 0, "CB5_V1THD" },
{IR_FLOAT, 539, 0, "CB5_V2THD" },
{IR_FLOAT, 541, 0, "CB5_V3THD" },
{IR_FLOAT, 543, 0, "CB5_I1THD" },
{IR_FLOAT, 545, 0, "CB5_I2THD" },
{IR_FLOAT, 547, 0, "CB5_I3THD" },
{IR_FLOAT, 549, 0, "CB5_I1Kfactor" },
{IR_FLOAT, 551, 0, "CB5_I2Kfactor" },
{IR_FLOAT, 553, 0, "CB5_I3Kfactor" },
{IR_FLOAT, 555, 0, "CB5_I1TDD" },
{IR_FLOAT, 557, 0, "CB5_I2TDD" },
{IR_FLOAT, 559, 0, "CB5_I3TDD" },
{IR_FLOAT, 561, 0, "CB5_V12" },
{IR_FLOAT, 563, 0, "CB5_V23" },
{IR_FLOAT, 565, 0, "CB5_V31" },
{IR_FLOAT, 567, 0, "CB5_TotalKW" },
{IR_FLOAT, 569, 0, "CB5_TotalKVar" },
{IR_FLOAT, 571, 0, "CB5_TotalKVA" },
{IR_FLOAT, 573, 0, "CB5_TotalPF" },
{IR_FLOAT, 575, 0, "CB5_TotalPFLag" },
{IR_FLOAT, 577, 0, "CB5_TotalPFLead" },
{IR_FLOAT, 579, 0, "CB5_TotalKWImport" },
{IR_FLOAT, 581, 0, "CB5_TotalKWExport" },
{IR_FLOAT, 583, 0, "CB5_TotalKVarImport" },
{IR_FLOAT, 585, 0, "CB5_TotalKVarExport" },
{IR_FLOAT, 587, 0, "CB5_LN_Avg" },
{IR_FLOAT, 589, 0, "CB5_LL_Avg" },
// Circuit Breaker 5 (OB05)
{IR_FLOAT, 500, 0, "CB5_V1N" },
{IR_FLOAT, 502, 0, "CB5_V2N" },
{IR_FLOAT, 504, 0, "CB5_V3N" },
{IR_FLOAT, 506, 0, "CB5_I1" },
{IR_FLOAT, 508, 0, "CB5_I2" },
{IR_FLOAT, 510, 0, "CB5_I3" },
{IR_FLOAT, 512, 0, "CB5_L1KW" },
{IR_FLOAT, 514, 0, "CB5_L2KW" },
{IR_FLOAT, 516, 0, "CB5_L3KW" },
{IR_FLOAT, 518, 0, "CB5_L1KVar" },
{IR_FLOAT, 520, 0, "CB5_L2KVar" },
{IR_FLOAT, 522, 0, "CB5_L3KVar" },
{IR_FLOAT, 524, 0, "CB5_L1KVA" },
{IR_FLOAT, 526, 0, "CB5_L2KVA" },
{IR_FLOAT, 528, 0, "CB5_L3KVA" },
{IR_FLOAT, 530, 0, "CB5_L1PF" },
{IR_FLOAT, 532, 0, "CB5_L2PF" },
{IR_FLOAT, 534, 0, "CB5_L3PF" },
{IR_FLOAT, 536, 0, "CB5_V1THD" },
{IR_FLOAT, 538, 0, "CB5_V2THD" },
{IR_FLOAT, 530, 0, "CB5_V3THD" },
{IR_FLOAT, 542, 0, "CB5_I1THD" },
{IR_FLOAT, 544, 0, "CB5_I2THD" },
{IR_FLOAT, 546, 0, "CB5_I3THD" },
{IR_FLOAT, 548, 0, "CB5_I1Kfactor" },
{IR_FLOAT, 550, 0, "CB5_I2Kfactor" },
{IR_FLOAT, 552, 0, "CB5_I3Kfactor" },
{IR_FLOAT, 554, 0, "CB5_I1TDD" },
{IR_FLOAT, 556, 0, "CB5_I2TDD" },
{IR_FLOAT, 558, 0, "CB5_I3TDD" },
{IR_FLOAT, 560, 0, "CB5_V12" },
{IR_FLOAT, 562, 0, "CB5_V23" },
{IR_FLOAT, 564, 0, "CB5_V31" },
{IR_FLOAT, 566, 0, "CB5_TotalKW" },
{IR_FLOAT, 568, 0, "CB5_TotalKVar" },
{IR_FLOAT, 570, 0, "CB5_TotalKVA" },
{IR_FLOAT, 572, 0, "CB5_TotalPF" },
{IR_FLOAT, 574, 0, "CB5_TotalPFLag" },
{IR_FLOAT, 576, 0, "CB5_TotalPFLead" },
{IR_FLOAT, 578, 0, "CB5_TotalKWImport" },
{IR_FLOAT, 580, 0, "CB5_TotalKWExport" },
{IR_FLOAT, 582, 0, "CB5_TotalKVarImport" },
{IR_FLOAT, 584, 0, "CB5_TotalKVarExport" },
{IR_FLOAT, 586, 0, "CB5_LN_Avg" },
{IR_FLOAT, 588, 0, "CB5_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 601, 0, "CB6_V1N" },
{IR_FLOAT, 603, 0, "CB6_V2N" },
{IR_FLOAT, 605, 0, "CB6_V3N" },
{IR_FLOAT, 607, 0, "CB6_I1" },
{IR_FLOAT, 609, 0, "CB6_I2" },
{IR_FLOAT, 611, 0, "CB6_I3" },
{IR_FLOAT, 613, 0, "CB6_L1KW" },
{IR_FLOAT, 615, 0, "CB6_L2KW" },
{IR_FLOAT, 617, 0, "CB6_L3KW" },
{IR_FLOAT, 619, 0, "CB6_L1KVar" },
{IR_FLOAT, 621, 0, "CB6_L2KVar" },
{IR_FLOAT, 623, 0, "CB6_L3KVar" },
{IR_FLOAT, 625, 0, "CB6_L1KVA" },
{IR_FLOAT, 627, 0, "CB6_L2KVA" },
{IR_FLOAT, 629, 0, "CB6_L3KVA" },
{IR_FLOAT, 631, 0, "CB6_L1PF" },
{IR_FLOAT, 633, 0, "CB6_L2PF" },
{IR_FLOAT, 635, 0, "CB6_L3PF" },
{IR_FLOAT, 637, 0, "CB6_V1THD" },
{IR_FLOAT, 639, 0, "CB6_V2THD" },
{IR_FLOAT, 641, 0, "CB6_V3THD" },
{IR_FLOAT, 643, 0, "CB6_I1THD" },
{IR_FLOAT, 645, 0, "CB6_I2THD" },
{IR_FLOAT, 647, 0, "CB6_I3THD" },
{IR_FLOAT, 649, 0, "CB6_I1Kfactor" },
{IR_FLOAT, 651, 0, "CB6_I2Kfactor" },
{IR_FLOAT, 653, 0, "CB6_I3Kfactor" },
{IR_FLOAT, 655, 0, "CB6_I1TDD" },
{IR_FLOAT, 657, 0, "CB6_I2TDD" },
{IR_FLOAT, 659, 0, "CB6_I3TDD" },
{IR_FLOAT, 661, 0, "CB6_V12" },
{IR_FLOAT, 663, 0, "CB6_V23" },
{IR_FLOAT, 665, 0, "CB6_V31" },
{IR_FLOAT, 667, 0, "CB6_TotalKW" },
{IR_FLOAT, 669, 0, "CB6_TotalKVar" },
{IR_FLOAT, 671, 0, "CB6_TotalKVA" },
{IR_FLOAT, 673, 0, "CB6_TotalPF" },
{IR_FLOAT, 675, 0, "CB6_TotalPFLag" },
{IR_FLOAT, 677, 0, "CB6_TotalPFLead" },
{IR_FLOAT, 679, 0, "CB6_TotalKWImport" },
{IR_FLOAT, 681, 0, "CB6_TotalKWExport" },
{IR_FLOAT, 683, 0, "CB6_TotalKVarImport" },
{IR_FLOAT, 685, 0, "CB6_TotalKVarExport" },
{IR_FLOAT, 687, 0, "CB6_LN_Avg" },
{IR_FLOAT, 689, 0, "CB6_LL_Avg" },
// Circuit Breaker 6 (OB06)
{IR_FLOAT, 600, 0, "CB6_V1N" },
{IR_FLOAT, 602, 0, "CB6_V2N" },
{IR_FLOAT, 604, 0, "CB6_V3N" },
{IR_FLOAT, 606, 0, "CB6_I1" },
{IR_FLOAT, 608, 0, "CB6_I2" },
{IR_FLOAT, 610, 0, "CB6_I3" },
{IR_FLOAT, 612, 0, "CB6_L1KW" },
{IR_FLOAT, 614, 0, "CB6_L2KW" },
{IR_FLOAT, 616, 0, "CB6_L3KW" },
{IR_FLOAT, 618, 0, "CB6_L1KVar" },
{IR_FLOAT, 620, 0, "CB6_L2KVar" },
{IR_FLOAT, 622, 0, "CB6_L3KVar" },
{IR_FLOAT, 624, 0, "CB6_L1KVA" },
{IR_FLOAT, 626, 0, "CB6_L2KVA" },
{IR_FLOAT, 628, 0, "CB6_L3KVA" },
{IR_FLOAT, 630, 0, "CB6_L1PF" },
{IR_FLOAT, 632, 0, "CB6_L2PF" },
{IR_FLOAT, 634, 0, "CB6_L3PF" },
{IR_FLOAT, 636, 0, "CB6_V1THD" },
{IR_FLOAT, 638, 0, "CB6_V2THD" },
{IR_FLOAT, 630, 0, "CB6_V3THD" },
{IR_FLOAT, 642, 0, "CB6_I1THD" },
{IR_FLOAT, 644, 0, "CB6_I2THD" },
{IR_FLOAT, 646, 0, "CB6_I3THD" },
{IR_FLOAT, 648, 0, "CB6_I1Kfactor" },
{IR_FLOAT, 650, 0, "CB6_I2Kfactor" },
{IR_FLOAT, 652, 0, "CB6_I3Kfactor" },
{IR_FLOAT, 654, 0, "CB6_I1TDD" },
{IR_FLOAT, 656, 0, "CB6_I2TDD" },
{IR_FLOAT, 658, 0, "CB6_I3TDD" },
{IR_FLOAT, 660, 0, "CB6_V12" },
{IR_FLOAT, 662, 0, "CB6_V23" },
{IR_FLOAT, 664, 0, "CB6_V31" },
{IR_FLOAT, 666, 0, "CB6_TotalKW" },
{IR_FLOAT, 668, 0, "CB6_TotalKVar" },
{IR_FLOAT, 670, 0, "CB6_TotalKVA" },
{IR_FLOAT, 672, 0, "CB6_TotalPF" },
{IR_FLOAT, 674, 0, "CB6_TotalPFLag" },
{IR_FLOAT, 676, 0, "CB6_TotalPFLead" },
{IR_FLOAT, 678, 0, "CB6_TotalKWImport" },
{IR_FLOAT, 680, 0, "CB6_TotalKWExport" },
{IR_FLOAT, 682, 0, "CB6_TotalKVarImport" },
{IR_FLOAT, 684, 0, "CB6_TotalKVarExport" },
{IR_FLOAT, 686, 0, "CB6_LN_Avg" },
{IR_FLOAT, 688, 0, "CB6_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 701, 0, "CB7_V1N" },
{IR_FLOAT, 703, 0, "CB7_V2N" },
{IR_FLOAT, 705, 0, "CB7_V3N" },
{IR_FLOAT, 707, 0, "CB7_I1" },
{IR_FLOAT, 709, 0, "CB7_I2" },
{IR_FLOAT, 711, 0, "CB7_I3" },
{IR_FLOAT, 713, 0, "CB7_L1KW" },
{IR_FLOAT, 715, 0, "CB7_L2KW" },
{IR_FLOAT, 717, 0, "CB7_L3KW" },
{IR_FLOAT, 719, 0, "CB7_L1KVar" },
{IR_FLOAT, 721, 0, "CB7_L2KVar" },
{IR_FLOAT, 723, 0, "CB7_L3KVar" },
{IR_FLOAT, 725, 0, "CB7_L1KVA" },
{IR_FLOAT, 727, 0, "CB7_L2KVA" },
{IR_FLOAT, 729, 0, "CB7_L3KVA" },
{IR_FLOAT, 731, 0, "CB7_L1PF" },
{IR_FLOAT, 733, 0, "CB7_L2PF" },
{IR_FLOAT, 735, 0, "CB7_L3PF" },
{IR_FLOAT, 737, 0, "CB7_V1THD" },
{IR_FLOAT, 739, 0, "CB7_V2THD" },
{IR_FLOAT, 741, 0, "CB7_V3THD" },
{IR_FLOAT, 743, 0, "CB7_I1THD" },
{IR_FLOAT, 745, 0, "CB7_I2THD" },
{IR_FLOAT, 747, 0, "CB7_I3THD" },
{IR_FLOAT, 749, 0, "CB7_I1Kfactor" },
{IR_FLOAT, 751, 0, "CB7_I2Kfactor" },
{IR_FLOAT, 753, 0, "CB7_I3Kfactor" },
{IR_FLOAT, 755, 0, "CB7_I1TDD" },
{IR_FLOAT, 757, 0, "CB7_I2TDD" },
{IR_FLOAT, 759, 0, "CB7_I3TDD" },
{IR_FLOAT, 761, 0, "CB7_V12" },
{IR_FLOAT, 763, 0, "CB7_V23" },
{IR_FLOAT, 765, 0, "CB7_V31" },
{IR_FLOAT, 767, 0, "CB7_TotalKW" },
{IR_FLOAT, 769, 0, "CB7_TotalKVar" },
{IR_FLOAT, 771, 0, "CB7_TotalKVA" },
{IR_FLOAT, 773, 0, "CB7_TotalPF" },
{IR_FLOAT, 775, 0, "CB7_TotalPFLag" },
{IR_FLOAT, 777, 0, "CB7_TotalPFLead" },
{IR_FLOAT, 779, 0, "CB7_TotalKWImport" },
{IR_FLOAT, 781, 0, "CB7_TotalKWExport" },
{IR_FLOAT, 783, 0, "CB7_TotalKVarImport" },
{IR_FLOAT, 785, 0, "CB7_TotalKVarExport" },
{IR_FLOAT, 787, 0, "CB7_LN_Avg" },
{IR_FLOAT, 789, 0, "CB7_LL_Avg" },
// Circuit Breaker 7 (OB07)
{IR_FLOAT, 700, 0, "CB7_V1N" },
{IR_FLOAT, 702, 0, "CB7_V2N" },
{IR_FLOAT, 704, 0, "CB7_V3N" },
{IR_FLOAT, 706, 0, "CB7_I1" },
{IR_FLOAT, 708, 0, "CB7_I2" },
{IR_FLOAT, 710, 0, "CB7_I3" },
{IR_FLOAT, 712, 0, "CB7_L1KW" },
{IR_FLOAT, 714, 0, "CB7_L2KW" },
{IR_FLOAT, 716, 0, "CB7_L3KW" },
{IR_FLOAT, 718, 0, "CB7_L1KVar" },
{IR_FLOAT, 720, 0, "CB7_L2KVar" },
{IR_FLOAT, 722, 0, "CB7_L3KVar" },
{IR_FLOAT, 724, 0, "CB7_L1KVA" },
{IR_FLOAT, 726, 0, "CB7_L2KVA" },
{IR_FLOAT, 728, 0, "CB7_L3KVA" },
{IR_FLOAT, 730, 0, "CB7_L1PF" },
{IR_FLOAT, 732, 0, "CB7_L2PF" },
{IR_FLOAT, 734, 0, "CB7_L3PF" },
{IR_FLOAT, 736, 0, "CB7_V1THD" },
{IR_FLOAT, 738, 0, "CB7_V2THD" },
{IR_FLOAT, 730, 0, "CB7_V3THD" },
{IR_FLOAT, 742, 0, "CB7_I1THD" },
{IR_FLOAT, 744, 0, "CB7_I2THD" },
{IR_FLOAT, 746, 0, "CB7_I3THD" },
{IR_FLOAT, 748, 0, "CB7_I1Kfactor" },
{IR_FLOAT, 750, 0, "CB7_I2Kfactor" },
{IR_FLOAT, 752, 0, "CB7_I3Kfactor" },
{IR_FLOAT, 754, 0, "CB7_I1TDD" },
{IR_FLOAT, 756, 0, "CB7_I2TDD" },
{IR_FLOAT, 758, 0, "CB7_I3TDD" },
{IR_FLOAT, 760, 0, "CB7_V12" },
{IR_FLOAT, 762, 0, "CB7_V23" },
{IR_FLOAT, 764, 0, "CB7_V31" },
{IR_FLOAT, 766, 0, "CB7_TotalKW" },
{IR_FLOAT, 768, 0, "CB7_TotalKVar" },
{IR_FLOAT, 770, 0, "CB7_TotalKVA" },
{IR_FLOAT, 772, 0, "CB7_TotalPF" },
{IR_FLOAT, 774, 0, "CB7_TotalPFLag" },
{IR_FLOAT, 776, 0, "CB7_TotalPFLead" },
{IR_FLOAT, 778, 0, "CB7_TotalKWImport" },
{IR_FLOAT, 780, 0, "CB7_TotalKWExport" },
{IR_FLOAT, 782, 0, "CB7_TotalKVarImport" },
{IR_FLOAT, 784, 0, "CB7_TotalKVarExport" },
{IR_FLOAT, 786, 0, "CB7_LN_Avg" },
{IR_FLOAT, 788, 0, "CB7_LL_Avg" },
// Circuit Breaker 1 (OB01)
{IR_FLOAT, 801, 0, "CB8_V1N" },
{IR_FLOAT, 803, 0, "CB8_V2N" },
{IR_FLOAT, 805, 0, "CB8_V3N" },
{IR_FLOAT, 807, 0, "CB8_I1" },
{IR_FLOAT, 809, 0, "CB8_I2" },
{IR_FLOAT, 811, 0, "CB8_I3" },
{IR_FLOAT, 813, 0, "CB8_L1KW" },
{IR_FLOAT, 815, 0, "CB8_L2KW" },
{IR_FLOAT, 817, 0, "CB8_L3KW" },
{IR_FLOAT, 819, 0, "CB8_L1KVar" },
{IR_FLOAT, 821, 0, "CB8_L2KVar" },
{IR_FLOAT, 823, 0, "CB8_L3KVar" },
{IR_FLOAT, 825, 0, "CB8_L1KVA" },
{IR_FLOAT, 827, 0, "CB8_L2KVA" },
{IR_FLOAT, 829, 0, "CB8_L3KVA" },
{IR_FLOAT, 831, 0, "CB8_L1PF" },
{IR_FLOAT, 833, 0, "CB8_L2PF" },
{IR_FLOAT, 835, 0, "CB8_L3PF" },
{IR_FLOAT, 837, 0, "CB8_V1THD" },
{IR_FLOAT, 839, 0, "CB8_V2THD" },
{IR_FLOAT, 841, 0, "CB8_V3THD" },
{IR_FLOAT, 843, 0, "CB8_I1THD" },
{IR_FLOAT, 845, 0, "CB8_I2THD" },
{IR_FLOAT, 847, 0, "CB8_I3THD" },
{IR_FLOAT, 849, 0, "CB8_I1Kfactor" },
{IR_FLOAT, 851, 0, "CB8_I2Kfactor" },
{IR_FLOAT, 853, 0, "CB8_I3Kfactor" },
{IR_FLOAT, 855, 0, "CB8_I1TDD" },
{IR_FLOAT, 857, 0, "CB8_I2TDD" },
{IR_FLOAT, 859, 0, "CB8_I3TDD" },
{IR_FLOAT, 861, 0, "CB8_V12" },
{IR_FLOAT, 863, 0, "CB8_V23" },
{IR_FLOAT, 865, 0, "CB8_V31" },
{IR_FLOAT, 867, 0, "CB8_TotalKW" },
{IR_FLOAT, 869, 0, "CB8_TotalKVar" },
{IR_FLOAT, 871, 0, "CB8_TotalKVA" },
{IR_FLOAT, 873, 0, "CB8_TotalPF" },
{IR_FLOAT, 875, 0, "CB8_TotalPFLag" },
{IR_FLOAT, 877, 0, "CB8_TotalPFLead" },
{IR_FLOAT, 879, 0, "CB8_TotalKWImport" },
{IR_FLOAT, 881, 0, "CB8_TotalKWExport" },
{IR_FLOAT, 883, 0, "CB8_TotalKVarImport" },
{IR_FLOAT, 885, 0, "CB8_TotalKVarExport" },
{IR_FLOAT, 887, 0, "CB8_LN_Avg" },
{IR_FLOAT, 889, 0, "CB8_LL_Avg" },
// Circuit Breaker 8 (OB08)
{IR_FLOAT, 800, 0, "CB8_V1N" },
{IR_FLOAT, 802, 0, "CB8_V2N" },
{IR_FLOAT, 804, 0, "CB8_V3N" },
{IR_FLOAT, 806, 0, "CB8_I1" },
{IR_FLOAT, 808, 0, "CB8_I2" },
{IR_FLOAT, 810, 0, "CB8_I3" },
{IR_FLOAT, 812, 0, "CB8_L1KW" },
{IR_FLOAT, 814, 0, "CB8_L2KW" },
{IR_FLOAT, 816, 0, "CB8_L3KW" },
{IR_FLOAT, 818, 0, "CB8_L1KVar" },
{IR_FLOAT, 820, 0, "CB8_L2KVar" },
{IR_FLOAT, 822, 0, "CB8_L3KVar" },
{IR_FLOAT, 824, 0, "CB8_L1KVA" },
{IR_FLOAT, 826, 0, "CB8_L2KVA" },
{IR_FLOAT, 828, 0, "CB8_L3KVA" },
{IR_FLOAT, 830, 0, "CB8_L1PF" },
{IR_FLOAT, 832, 0, "CB8_L2PF" },
{IR_FLOAT, 834, 0, "CB8_L3PF" },
{IR_FLOAT, 836, 0, "CB8_V1THD" },
{IR_FLOAT, 838, 0, "CB8_V2THD" },
{IR_FLOAT, 830, 0, "CB8_V3THD" },
{IR_FLOAT, 842, 0, "CB8_I1THD" },
{IR_FLOAT, 844, 0, "CB8_I2THD" },
{IR_FLOAT, 846, 0, "CB8_I3THD" },
{IR_FLOAT, 848, 0, "CB8_I1Kfactor" },
{IR_FLOAT, 850, 0, "CB8_I2Kfactor" },
{IR_FLOAT, 852, 0, "CB8_I3Kfactor" },
{IR_FLOAT, 854, 0, "CB8_I1TDD" },
{IR_FLOAT, 856, 0, "CB8_I2TDD" },
{IR_FLOAT, 858, 0, "CB8_I3TDD" },
{IR_FLOAT, 860, 0, "CB8_V12" },
{IR_FLOAT, 862, 0, "CB8_V23" },
{IR_FLOAT, 864, 0, "CB8_V31" },
{IR_FLOAT, 866, 0, "CB8_TotalKW" },
{IR_FLOAT, 868, 0, "CB8_TotalKVar" },
{IR_FLOAT, 870, 0, "CB8_TotalKVA" },
{IR_FLOAT, 872, 0, "CB8_TotalPF" },
{IR_FLOAT, 874, 0, "CB8_TotalPFLag" },
{IR_FLOAT, 876, 0, "CB8_TotalPFLead" },
{IR_FLOAT, 878, 0, "CB8_TotalKWImport" },
{IR_FLOAT, 880, 0, "CB8_TotalKWExport" },
{IR_FLOAT, 882, 0, "CB8_TotalKVarImport" },
{IR_FLOAT, 884, 0, "CB8_TotalKVarExport" },
{IR_FLOAT, 886, 0, "CB8_LN_Avg" },
{IR_FLOAT, 888, 0, "CB8_LL_Avg" },
};
//Size of modbus map used in FOR cycles, automatically calculated.

View File

@@ -1,89 +0,0 @@
/**
* @file State_Running.cpp
* @brief Implementation of the RunningState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the RunningState, which defines
* the behavior of the equipment when it is actively running.
*/
#include "ModbusPoints/Modbus_Point.h"
#include "ModbusPoints/Modbus_FloatDecorator.h"
#include "Equipment/Equipment.h"
#include "Strategies/Strategy_Ramp.h"
#include "Strategies/Strategy_Random.h"
#include "Strategies/Strategy_Saw.h"
#include "Strategies/Strategy_SingleValue.h"
#include "Strategies/Strategy_Square.h"
#include "Strategies/Strategy_PID.h"
#include "Strategies/Strategy_Totalizer.h"
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "States/State.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new RunningState object.
*
* This constructor initializes behavior strategies active during the running
* state, such as a PID controller for the 'CW Valve Position' and totalizers
* for the run-hours of each EC fan.
*/
template<>
RunningState<ModbusIP>::RunningState() {
}
/**
* @brief Executes the running state's logic for one update cycle.
*
* This method first checks for state transition commands:
* 1. It reads the "ON/OFF Command By BMS" point. If it's 0, it transitions to StandbyState.
* 2. It reads the "Fault Code" point. If it's non-zero, it transitions to FailState,
* passing the corresponding alarm description.
*
* If no transition occurs, it applies the strategies defined for the running state.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Running update function");
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the running state.
* Sets the "Run Status" for all EC fans to 1 to indicate they are active.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void RunningState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Running State...");
// You could also update a Modbus register to show the "standby" state
}
/**
* @brief Logic to execute once when exiting the running state.
* Sets the "Run Status" for all EC fans to 0 before transitioning to the next state.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void RunningState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Running State...");
}

View File

@@ -1,141 +0,0 @@
/**
* @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 <ModbusIP_ESP8266.h>
const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */
const char *password = "wifi_password"; /**< @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[] =
{
{HR, 15, 0, "State Control"}, //Internal to control from Modscan
{HR, 16, 0, "Fault Code"}, //Internal Fault code from Modscan
{DI, 20, 0, "Bypass Not Ready"},
{DI, 244, 0, "System Shutdown-EPO"},
{DI, 247, 0, "System Fan Failure"},
{DI, 245, 0, "Fuse Failure"},
{DI, 239, 0, "Internal Comms Failure"},
{DI, 254, 0, "UPS Output on Bypass"},
{DI, 249, 0, "System Output Off"},
{DI, 11, 0, "Output Overload"},
{DI, 263, 0, "Battery Low"},
{IR, 183, 0, "UPS Battery Status"},
{IR, 180, 0, "Battery Time Remaining"},
{IR, 29, 0, "Bypass Input Frequency"},
{IR, 30, 0, "Bypass Power Phase A"},
{IR, 31, 0, "Bypass Power Phase B"},
{IR, 32, 0, "Bypass Power Phase C"},
{IR, 23, 0, "Bypass Input Voltage RMS A-B"},
{IR, 26, 0, "Bypass Input Voltage RMS A-N"},
{IR, 24, 0, "Bypass Input Voltage RMS B-C"},
{IR, 27, 0, "Bypass Input Voltage RMS B-N"},
{IR, 25, 0, "Bypass Input Voltage RMS C-A"},
{IR, 28, 0, "Bypass Input Voltage RMS C-N"},
{IR, 175, 0, "DC Bus Voltage"},
{IR, 7, 0, "System Input RMS Current Phase A"},
{IR, 8, 0, "System Input RMS Current Phase B"},
{IR, 9, 0, "System Input RMS Current Phase C"},
{IR, 10, 0, "System Input Frequency"},
{IR, 17, 0, "System Input Apparent Power Phs A"},
{IR, 18, 0, "System Input Apparent Power Phs B"},
{IR, 19, 0, "System Input Apparent Power Phs C"},
{IR, 14, 0, "System Input Power Phase A"},
{IR, 15, 0, "System Input Power Phase B"},
{IR, 16, 0, "System Input Power Phase C"},
{IR, 11, 0, "System Input Power Factor Phs A"},
{IR, 12, 0, "System Input Power Factor Phs B"},
{IR, 13, 0, "System Input Power Factor Phs C"},
{IR, 1, 0, "System Input RMS A-B"},
{IR, 4, 0, "System Input RMS A-N"},
{IR, 2, 0, "System Input RMS B-C"},
{IR, 5, 0, "System Input RMS B-N"},
{IR, 3, 0, "System Input RMS C-A"},
{IR, 6, 0, "System Input RMS C-N"},
{IR, 50, 0, "System Output Frequency"},
{IR, 44, 0, "System Output RMS Current Phase A"},
{IR, 45, 0, "System Output RMS Current Phase B"},
{IR, 46, 0, "System Output RMS Current Phase C"},
{IR, 61, 0, "System Output Apparent Power"},
{IR, 57, 0, "System Output Apparent Power Phs A"},
{IR, 58, 0, "System Output Apparent Power Phs B"},
{IR, 59, 0, "System Output Apparent Power Phs C"},
{IR, 60, 0, "System Output Power"},
{IR, 54, 0, "System Output Power Phase A"},
{IR, 55, 0, "System Output Power Phase B"},
{IR, 56, 0, "System Output Power Phase C"},
{IR, 51, 0, "System Output Power Factor Phs A"},
{IR, 52, 0, "System Output Power Factor Phs B"},
{IR, 53, 0, "System Output Power Factor Phs C"},
{IR, 38, 0, "System Output Voltage RMS A-B"},
{IR, 41, 0, "System Output Voltage RMS A-N"},
{IR, 39, 0, "System Output Voltage RMS B-C"},
{IR, 42, 0, "System Output Voltage RMS B-N"},
{IR, 40, 0, "System Output Voltage RMS C-A"},
{IR, 43, 0, "System Output Voltage RMS C-N"},
{IR, 164, 0, "UPS Loading Status"},
};
//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

View File

@@ -0,0 +1,200 @@
/**
* @file State_Battery.cpp
* @brief Implementation of the BatteryState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the BatteryState, which defines
* the behavior of the equipment when it is actively Battery.
*/
#include "ModbusPoints/Modbus_Point.h"
#include "ModbusPoints/Modbus_FloatDecorator.h"
#include "Equipment/Equipment.h"
#include "Strategies/Strategy_Ramp.h"
#include "Strategies/Strategy_Random.h"
#include "Strategies/Strategy_Saw.h"
#include "Strategies/Strategy_SingleValue.h"
#include "Strategies/Strategy_Square.h"
#include "Strategies/Strategy_PID.h"
#include "Strategies/Strategy_Totalizer.h"
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "States/State_Battery.h"
#include "States/State_Bypass.h"
#include "States/State.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new BatteryState object.
*
* This constructor initializes behavior strategies active during the Battery
* state, such as a PID controller for the 'CW Valve Position' and totalizers
* for the run-hours of each EC fan.
*/
template<>
BatteryState<ModbusIP>::BatteryState() {
addStrategy("System Output RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS B-C", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS C-A", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS A-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS B-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
addStrategy("System Output Power Factor Phs A", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Factor Phs B", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Factor Phs C", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("Battery Time Remaining", new RampStrategy(0.0F, 0.3f, 1000));
}
/**
* @brief Executes the Battery state's logic for one update cycle.
*
* This method first checks for state transition commands:
* 1. It reads the "ON/OFF Command By BMS" point. If it's 0, it transitions to StandbyState.
* 2. It reads the "Fault Code" point. If it's non-zero, it transitions to FailState,
* passing the corresponding alarm description.
*
* If no transition occurs, it applies the strategies defined for the Battery state.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusIP>* BatteryState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Battery update function");
float State_Ctrl = getPointValue(equipment, "Px State");
switch (static_cast<int>(State_Ctrl)) {
case 1:
return new StandbyState<ModbusIP>();
break;
case 2:
return new RunningState<ModbusIP>();
break;
case 4:
return new BypassState<ModbusIP>();
break;
default:
break;
}
float rating = getPointValue(equipment, "Px Rating");
float load = getPointValue(equipment, "Px Load");
float real_load = rating * (load/100.f);
Strategy_Behavior* ramp_strat = nullptr;
//Output strategies
float Out_Vab = getPointValue(equipment, "System Output RMS A-B");
ramp_strat = getStrategy("System Output RMS Current Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vab);
float Out_Vbc = getPointValue(equipment, "System Output RMS B-C");
ramp_strat = getStrategy("System Output RMS Current Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vbc);
float Out_Vca = getPointValue(equipment, "System Output RMS C-A");
ramp_strat = getStrategy("System Output RMS Current Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vca);
float Out_Van = getPointValue(equipment, "System Output RMS A-N");
float Out_Ia = getPointValue(equipment, "System Output RMS Current Phase A");
float Out_PFa = getPointValue(equipment, "System Output Power Factor Phs A");
ramp_strat = getStrategy("System Output Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia);
ramp_strat = getStrategy("System Output Apparent Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia * Out_PFa);
float Out_Vbn = getPointValue(equipment, "System Output RMS B-N");
float Out_Ib = getPointValue(equipment, "System Output RMS Current Phase B");
float Out_PFb = getPointValue(equipment, "System Output Power Factor Phs B");
ramp_strat = getStrategy("System Output Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib);
ramp_strat = getStrategy("System Output Apparent Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib * Out_PFb);
float Out_Vcn = getPointValue(equipment, "System Output RMS C-N");
float Out_Ic = getPointValue(equipment, "System Output RMS Current Phase C");
float Out_PFc = getPointValue(equipment, "System Output Power Factor Phs C");
ramp_strat = getStrategy("System Output Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic);
ramp_strat = getStrategy("System Output Apparent Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic * Out_PFc);
float Battery_time = getPointValue(equipment, "Battery Time Remaining");
float Bat_Percent = Battery_time /4.80f;
if (Bat_Percent > 98.0f){
setPointValue(equipment, "UPS Battery Status2", 0.0f);
}
if (Bat_Percent > 20.0f) {
setPointValue(equipment, "UPS Battery Status1", 2.0f);
setPointValue(equipment, "Battery Low", 0.0f);
}
if (Bat_Percent <= 20.0f && Bat_Percent >= 5.0f){
setPointValue(equipment, "UPS Battery Status1", 3.0f);
setPointValue(equipment, "Battery Low", 1.0f);
}
if (Bat_Percent < 5.0f){
setPointValue(equipment, "UPS Battery Status1", 4.0f);
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the Battery state.
* Sets the "Run Status" for all EC fans to 1 to indicate they are active.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void BatteryState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Battery State...");
setPointValue(equipment, "Bypass Input Voltage RMS A-B", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS B-C", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS C-A", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS A-N", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS B-N", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS C-N", 0.0f);
setPointValue(equipment, "Bypass Input Frequency", 0.0f);
setPointValue(equipment, "Bypass Power Phase A", 0.0f);
setPointValue(equipment, "Bypass Power Phase B", 0.0f);
setPointValue(equipment, "Bypass Power Phase C", 0.0f);
setPointValue(equipment, "UPS Loading Status", 6.0f);
setPointValue(equipment, "UPS Battery Status2", 2.0f);
// You could also update a Modbus register to show the "standby" state
}
/**
* @brief Logic to execute once when exiting the Battery state.
* Sets the "Run Status" for all EC fans to 0 before transitioning to the next state.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void BatteryState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Battery State...");
}

View File

@@ -0,0 +1,271 @@
/**
* @file State_Bypass.cpp
* @brief Implementation of the BypassState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the BypassState, which defines
* the behavior of the equipment when it is actively Bypass.
*/
#include "ModbusPoints/Modbus_Point.h"
#include "ModbusPoints/Modbus_FloatDecorator.h"
#include "Equipment/Equipment.h"
#include "Strategies/Strategy_Ramp.h"
#include "Strategies/Strategy_Random.h"
#include "Strategies/Strategy_Saw.h"
#include "Strategies/Strategy_SingleValue.h"
#include "Strategies/Strategy_Square.h"
#include "Strategies/Strategy_PID.h"
#include "Strategies/Strategy_Totalizer.h"
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "States/State_Bypass.h"
#include "States/State_Battery.h"
#include "States/State.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new BypassState object.
*
* This constructor initializes behavior strategies active during the Bypass
* state, such as a PID controller for the 'CW Valve Position' and totalizers
* for the run-hours of each EC fan.
*/
template<>
BypassState<ModbusIP>::BypassState() {
//Input System
addStrategy("System Input RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Input RMS B-C", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Input RMS C-A", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Input RMS A-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS B-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
addStrategy("System Input Power Factor Phs A", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Input Power Factor Phs B", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Input Power Factor Phs C", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Input Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
//Bypass System
addStrategy("Bypass Input Voltage RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("Bypass Input Voltage RMS B-C", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("Bypass Input Voltage RMS C-A", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("Bypass Input Voltage RMS A-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("Bypass Input Voltage RMS B-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("Bypass Input Voltage RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("Bypass Input Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
addStrategy("Bypass Input Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("Bypass Input Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("Bypass Input Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
//Output System
addStrategy("System Output RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS B-C", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS C-A", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS A-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS B-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
addStrategy("System Output Power Factor Phs A", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Factor Phs B", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Factor Phs C", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("Battery Time Remaining", new RampStrategy(480.0F, 0.3f, 1000));
addStrategy("DC Bus Voltage", new SingleValueStrategy(518.0F, 5.0f, 1000));
}
/**
* @brief Executes the Bypass state's logic for one update cycle.
*
* This method first checks for state transition commands:
* 1. It reads the "ON/OFF Command By BMS" point. If it's 0, it transitions to StandbyState.
* 2. It reads the "Fault Code" point. If it's non-zero, it transitions to FailState,
* passing the corresponding alarm description.
*
* If no transition occurs, it applies the strategies defined for the Bypass state.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusIP>* BypassState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Bypass update function");
float State_Ctrl = getPointValue(equipment, "Px State");
switch (static_cast<int>(State_Ctrl)) {
case 1:
return new StandbyState<ModbusIP>();
break;
case 2:
return new RunningState<ModbusIP>();
break;
case 3:
return new BatteryState<ModbusIP>();
break;
default:
break;
}
float rating = getPointValue(equipment, "Px Rating");
float load = getPointValue(equipment, "Px Load");
float real_load = rating * (load/100.f);
Strategy_Behavior* ramp_strat = nullptr;
//Input strategies
float In_Vab = getPointValue(equipment, "System Input RMS A-B");
ramp_strat = getStrategy("System Input RMS Current Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/In_Vab);
float In_Vbc = getPointValue(equipment, "System Input RMS B-C");
ramp_strat = getStrategy("System Input RMS Current Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/In_Vbc);
float In_Vca = getPointValue(equipment, "System Input RMS C-A");
ramp_strat = getStrategy("System Input RMS Current Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/In_Vca);
float In_Van = getPointValue(equipment, "System Input RMS A-N");
float In_Ia = getPointValue(equipment, "System Input RMS Current Phase A");
float In_PFa = getPointValue(equipment, "System Input Power Factor Phs A");
ramp_strat = getStrategy("System Input Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia);
ramp_strat = getStrategy("Bypass Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia);
ramp_strat = getStrategy("System Input Apparent Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia * In_PFa);
float In_Vbn = getPointValue(equipment, "System Input RMS B-N");
float In_Ib = getPointValue(equipment, "System Input RMS Current Phase B");
float In_PFb = getPointValue(equipment, "System Input Power Factor Phs B");
ramp_strat = getStrategy("System Input Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib);
ramp_strat = getStrategy("Bypass Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib);
ramp_strat = getStrategy("System Input Apparent Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib * In_PFb);
float In_Vcn = getPointValue(equipment, "System Input RMS C-N");
float In_Ic = getPointValue(equipment, "System Input RMS Current Phase C");
float In_PFc = getPointValue(equipment, "System Input Power Factor Phs C");
ramp_strat = getStrategy("System Input Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic);
ramp_strat = getStrategy("Bypass Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic);
ramp_strat = getStrategy("System Input Apparent Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic * In_PFc);
//Output strategies
float Out_Vab = getPointValue(equipment, "System Output RMS A-B");
ramp_strat = getStrategy("System Output RMS Current Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vab);
float Out_Vbc = getPointValue(equipment, "System Output RMS B-C");
ramp_strat = getStrategy("System Output RMS Current Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vbc);
float Out_Vca = getPointValue(equipment, "System Output RMS C-A");
ramp_strat = getStrategy("System Output RMS Current Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vca);
float Out_Van = getPointValue(equipment, "System Output RMS A-N");
float Out_Ia = getPointValue(equipment, "System Output RMS Current Phase A");
float Out_PFa = getPointValue(equipment, "System Output Power Factor Phs A");
ramp_strat = getStrategy("System Output Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia);
ramp_strat = getStrategy("System Output Apparent Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia * Out_PFa);
float Out_Vbn = getPointValue(equipment, "System Output RMS B-N");
float Out_Ib = getPointValue(equipment, "System Output RMS Current Phase B");
float Out_PFb = getPointValue(equipment, "System Output Power Factor Phs B");
ramp_strat = getStrategy("System Output Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib);
ramp_strat = getStrategy("System Output Apparent Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib * Out_PFb);
float Out_Vcn = getPointValue(equipment, "System Output RMS C-N");
float Out_Ic = getPointValue(equipment, "System Output RMS Current Phase C");
float Out_PFc = getPointValue(equipment, "System Output Power Factor Phs C");
ramp_strat = getStrategy("System Output Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic);
ramp_strat = getStrategy("System Output Apparent Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic * Out_PFc);
float Battery_time = getPointValue(equipment, "Battery Time Remaining");
float Bat_Percent = Battery_time /4.80f;
if (Bat_Percent > 98.0f){
setPointValue(equipment, "UPS Battery Status2", 0.0f);
}
if (Bat_Percent > 20.0f) {
setPointValue(equipment, "UPS Battery Status1", 2.0f);
setPointValue(equipment, "Battery Low", 0.0f);
}
if (Bat_Percent <= 20.0f && Bat_Percent >= 5.0f){
setPointValue(equipment, "UPS Battery Status1", 3.0f);
setPointValue(equipment, "Battery Low", 1.0f);
}
if (Bat_Percent < 5.0f){
setPointValue(equipment, "UPS Battery Status1", 4.0f);
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the Bypass state.
* Sets the "Run Status" for all EC fans to 1 to indicate they are active.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void BypassState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Battery State...");
setPointValue(equipment, "UPS Loading Status", 4.0f);
setPointValue(equipment, "UPS Battery Status2", 3.0f);
// You could also update a Modbus register to show the "standby" state
}
/**
* @brief Logic to execute once when exiting the Bypass state.
* Sets the "Run Status" for all EC fans to 0 before transitioning to the next state.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void BypassState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Bypass State...");
}

View File

@@ -14,6 +14,7 @@
#include "Strategies/Strategy_PID.h"
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Battery.h"
#include "States/State_Fail.h"
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
@@ -53,7 +54,13 @@ template<>
State<ModbusIP>* FailState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Fail update function");
float State_Ctrl = getPointValue(equipment, "Px State");
if (State_Ctrl == 2){
return new RunningState<ModbusIP>();
}
if (State_Ctrl == 1){
return new StandbyState<ModbusIP>();
}
_applyStrategies(equipment);
return nullptr;
}

View File

@@ -0,0 +1,264 @@
/**
* @file State_Running.cpp
* @brief Implementation of the RunningState class.
* @author Emmanuel Hernandez Cruz
* @date 2025-09-05
*
* This file contains the implementation for the RunningState, which defines
* the behavior of the equipment when it is actively running.
*/
#include "ModbusPoints/Modbus_Point.h"
#include "ModbusPoints/Modbus_FloatDecorator.h"
#include "Equipment/Equipment.h"
#include "Strategies/Strategy_Ramp.h"
#include "Strategies/Strategy_Random.h"
#include "Strategies/Strategy_Saw.h"
#include "Strategies/Strategy_SingleValue.h"
#include "Strategies/Strategy_Square.h"
#include "Strategies/Strategy_PID.h"
#include "Strategies/Strategy_Totalizer.h"
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "States/State_Battery.h"
#include "States/State_Bypass.h"
#include "States/State.h"
#include <vector>
#include <string>
#if defined(USE_MODBUS_IP)
#include <ModbusIP_ESP8266.h>
#else
#include <ModbusRTU.h>
#endif
/**
* @brief Constructs a new RunningState object.
*
* This constructor initializes behavior strategies active during the running
* state, such as a PID controller for the 'CW Valve Position' and totalizers
* for the run-hours of each EC fan.
*/
template<>
RunningState<ModbusIP>::RunningState() {
addStrategy("System Input RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Input RMS B-C", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Input RMS C-A", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Input RMS A-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS B-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input RMS Current Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
addStrategy("System Input Power Factor Phs A", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Input Power Factor Phs B", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Input Power Factor Phs C", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Input Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS B-C", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS C-A", new SingleValueStrategy(480.0F, 5.0f, 1000));
addStrategy("System Output RMS A-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS B-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS C-N", new SingleValueStrategy(270.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output RMS Current Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
addStrategy("System Output Power Factor Phs A", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Factor Phs B", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Factor Phs C", new SingleValueStrategy(93.0F, 5.0f, 1000));
addStrategy("System Output Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phase C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("Battery Time Remaining", new RampStrategy(480.0F, 1.0f, 1000));
addStrategy("DC Bus Voltage", new SingleValueStrategy(518.0F, 5.0f, 1000));
}
/**
* @brief Executes the running state's logic for one update cycle.
*
* This method first checks for state transition commands:
* 1. It reads the "ON/OFF Command By BMS" point. If it's 0, it transitions to StandbyState.
* 2. It reads the "Fault Code" point. If it's non-zero, it transitions to FailState,
* passing the corresponding alarm description.
*
* If no transition occurs, it applies the strategies defined for the running state.
*
* @param equipment Pointer to the Equipment instance.
* @return A pointer to a new State if a transition should occur, otherwise nullptr.
*/
template<>
State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
// STATE control, add conditions if change to a different state is needed
Serial.println("Running update function");
float State_Ctrl = getPointValue(equipment, "Px State");
switch (static_cast<int>(State_Ctrl)) {
case 1:
return new StandbyState<ModbusIP>();
break;
case 3:
return new BatteryState<ModbusIP>();
break;
case 4:
return new BypassState<ModbusIP>();
break;
default:
break;
}
float rating = getPointValue(equipment, "Px Rating");
float load = getPointValue(equipment, "Px Load");
float real_load = (rating*1000.0f) * (load/100.f);
Strategy_Behavior* ramp_strat = nullptr;
//Input strategies
float In_Vab = getPointValue(equipment, "System Input RMS A-B");
ramp_strat = getStrategy("System Input RMS Current Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/In_Vab);
float In_Vbc = getPointValue(equipment, "System Input RMS B-C");
ramp_strat = getStrategy("System Input RMS Current Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/In_Vbc);
float In_Vca = getPointValue(equipment, "System Input RMS C-A");
ramp_strat = getStrategy("System Input RMS Current Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/In_Vca);
float In_Van = getPointValue(equipment, "System Input RMS A-N");
float In_Ia = getPointValue(equipment, "System Input RMS Current Phase A");
float In_PFa = getPointValue(equipment, "System Input Power Factor Phs A");
ramp_strat = getStrategy("System Input Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia);
ramp_strat = getStrategy("System Input Apparent Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia * (In_PFa/100.0f));
float In_Vbn = getPointValue(equipment, "System Input RMS B-N");
float In_Ib = getPointValue(equipment, "System Input RMS Current Phase B");
float In_PFb = getPointValue(equipment, "System Input Power Factor Phs B");
ramp_strat = getStrategy("System Input Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib);
ramp_strat = getStrategy("System Input Apparent Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib * (In_PFb/100.0f));
float In_Vcn = getPointValue(equipment, "System Input RMS C-N");
float In_Ic = getPointValue(equipment, "System Input RMS Current Phase C");
float In_PFc = getPointValue(equipment, "System Input Power Factor Phs C");
ramp_strat = getStrategy("System Input Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic);
ramp_strat = getStrategy("System Input Apparent Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic * (In_PFc/100.0f));
//Output strategies
float Out_Vab = getPointValue(equipment, "System Output RMS A-B");
ramp_strat = getStrategy("System Output RMS Current Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vab);
float Out_Vbc = getPointValue(equipment, "System Output RMS B-C");
ramp_strat = getStrategy("System Output RMS Current Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vbc);
float Out_Vca = getPointValue(equipment, "System Output RMS C-A");
ramp_strat = getStrategy("System Output RMS Current Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(real_load/Out_Vca);
float Out_Van = getPointValue(equipment, "System Output RMS A-N");
float Out_Ia = getPointValue(equipment, "System Output RMS Current Phase A");
float Out_PFa = getPointValue(equipment, "System Output Power Factor Phs A");
ramp_strat = getStrategy("System Output Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia);
ramp_strat = getStrategy("System Output Apparent Power Phase A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia * (Out_PFa/100.0f));
float Out_Vbn = getPointValue(equipment, "System Output RMS B-N");
float Out_Ib = getPointValue(equipment, "System Output RMS Current Phase B");
float Out_PFb = getPointValue(equipment, "System Output Power Factor Phs B");
ramp_strat = getStrategy("System Output Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib);
ramp_strat = getStrategy("System Output Apparent Power Phase B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib * (Out_PFb/100.0f));
float Out_Vcn = getPointValue(equipment, "System Output RMS C-N");
float Out_Ic = getPointValue(equipment, "System Output RMS Current Phase C");
float Out_PFc = getPointValue(equipment, "System Output Power Factor Phs C");
ramp_strat = getStrategy("System Output Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic);
ramp_strat = getStrategy("System Output Apparent Power Phase C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic * (Out_PFc/100.0f));
float Battery_time = getPointValue(equipment, "Battery Time Remaining");
float Bat_Percent = Battery_time /4.80f;
if (Bat_Percent > 98.0f){
setPointValue(equipment, "UPS Battery Status2", 0.0f);
}
if (Bat_Percent > 20.0f) {
setPointValue(equipment, "UPS Battery Status1", 2.0f);
setPointValue(equipment, "Battery Low", 0.0f);
}
if (Bat_Percent <= 20.0f && Bat_Percent >= 5.0f){
setPointValue(equipment, "UPS Battery Status1", 3.0f);
setPointValue(equipment, "Battery Low", 1.0f);
}
if (Bat_Percent < 5.0f){
setPointValue(equipment, "UPS Battery Status1", 4.0f);
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
}
/**
* @brief Logic to execute once when entering the running state.
* Sets the "Run Status" for all EC fans to 1 to indicate they are active.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void RunningState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Running State...");
// You could also update a Modbus register to show the "standby" state
setPointValue(equipment, "Bypass Input Voltage RMS A-B", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS B-C", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS C-A", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS A-N", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS B-N", 0.0f);
setPointValue(equipment, "Bypass Input Voltage RMS C-N", 0.0f);
setPointValue(equipment, "Bypass Input Frequency", 0.0f);
setPointValue(equipment, "Bypass Power Phase A", 0.0f);
setPointValue(equipment, "Bypass Power Phase B", 0.0f);
setPointValue(equipment, "Bypass Power Phase C", 0.0f);
setPointValue(equipment, "UPS Loading Status", 3.0f);
setPointValue(equipment, "UPS Battery Status2", 1.0f);
}
/**
* @brief Logic to execute once when exiting the running state.
* Sets the "Run Status" for all EC fans to 0 before transitioning to the next state.
* @param equipment Pointer to the Equipment instance.
*/
template<>
void RunningState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
// Cleanup logic to run when the equipment leaves this state
Serial.println("Exit Running State...");
}

View File

@@ -19,6 +19,8 @@
#include "States/State_Standby.h"
#include "States/State_Running.h"
#include "States/State_Fail.h"
#include "States/State_Battery.h"
#include "States/State_Bypass.h"
#include "States/State.h"
#include <vector>
#include <string>
@@ -57,6 +59,20 @@ State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
// STATE control, add conditions if change to a different state is needed
Serial.println("Standby update function");
float State_Ctrl = getPointValue(equipment, "Px State");
switch (static_cast<int>(State_Ctrl)) {
case 2:
return new RunningState<ModbusIP>();
break;
case 3:
return new BatteryState<ModbusIP>();
break;
case 4:
return new BypassState<ModbusIP>();
break;
default:
break;
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);
return nullptr;
@@ -72,6 +88,7 @@ template<>
void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Standby State...");
setPointValue(equipment, "UPS Loading Status", 2.0f);
}
/**

View File

@@ -0,0 +1,145 @@
/**
* @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 <ModbusIP_ESP8266.h>
const char *ssid = "esrlok_portable"; /**< @brief The SSID of the WiFi network. */
const char *password = "m7g6eNMe?cy8S@z"; /**< @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[] =
{
{HR, 9, 0, "Px State"}, //1-standby, 2 Running (Normal - charging), 3 Battery, 4 Bypass
{HR, 10, 0, "Px Load"}, //% Internal Fault code from Modscan
{HR, 11, 0, "Px Rating"}, //kVA Internal Fault code from Modscan
{DI, 11, 0, "Output Overload"},
{DI, 20, 0, "Bypass Not Ready"},
{DI, 239, 0, "Internal Comms Failure"},
{DI, 244, 0, "System Shutdown-EPO"},
{DI, 245, 0, "Fuse Failure"},
{DI, 247, 0, "System Fan Failure"},
{DI, 249, 0, "System Output Off"},
{DI, 254, 0, "UPS Output on Bypass"},
{DI, 263, 0, "Battery Low"},
{IR_10x, 1, 0, "System Input RMS A-B"},
{IR_10x, 2, 0, "System Input RMS B-C"},
{IR_10x, 3, 0, "System Input RMS C-A"},
{IR_10x, 4, 0, "System Input RMS A-N"},
{IR_10x, 5, 0, "System Input RMS B-N"},
{IR_10x, 6, 0, "System Input RMS C-N"},
{IR_10x, 7, 0, "System Input RMS Current Phase A"},
{IR_10x, 8, 0, "System Input RMS Current Phase B"},
{IR_10x, 9, 0, "System Input RMS Current Phase C"},
{IR_10x, 10, 0, "System Input Frequency"},
{IR_10x, 11, 0, "System Input Power Factor Phs A"},
{IR_10x, 12, 0, "System Input Power Factor Phs B"},
{IR_10x, 13, 0, "System Input Power Factor Phs C"},
{IR_10x, 14, 0, "System Input Power Phase A"},
{IR_10x, 15, 0, "System Input Power Phase B"},
{IR_10x, 16, 0, "System Input Power Phase C"},
{IR_10x, 17, 0, "System Input Apparent Power Phs A"},
{IR_10x, 18, 0, "System Input Apparent Power Phs B"},
{IR_10x, 19, 0, "System Input Apparent Power Phs C"},
{IR_10x, 23, 0, "Bypass Input Voltage RMS A-B"},
{IR_10x, 24, 0, "Bypass Input Voltage RMS B-C"},
{IR_10x, 25, 0, "Bypass Input Voltage RMS C-A"},
{IR_10x, 26, 0, "Bypass Input Voltage RMS A-N"},
{IR_10x, 27, 0, "Bypass Input Voltage RMS B-N"},
{IR_10x, 28, 0, "Bypass Input Voltage RMS C-N"},
{IR_10x, 29, 0, "Bypass Input Frequency"},
{IR_10x, 30, 0, "Bypass Power Phase A"},
{IR_10x, 31, 0, "Bypass Power Phase B"},
{IR_10x, 32, 0, "Bypass Power Phase C"},
{IR_10x, 38, 0, "System Output RMS A-B"},
{IR_10x, 39, 0, "System Output RMS B-C"},
{IR_10x, 40, 0, "System Output RMS C-A"},
{IR_10x, 41, 0, "System Output RMS A-N"},
{IR_10x, 42, 0, "System Output RMS B-N"},
{IR_10x, 43, 0, "System Output RMS C-N"},
{IR_10x, 44, 0, "System Output RMS Current Phase A"},
{IR_10x, 45, 0, "System Output RMS Current Phase B"},
{IR_10x, 46, 0, "System Output RMS Current Phase C"},
{IR_10x, 50, 0, "System Output Frequency"},
{IR_10x, 51, 0, "System Output Power Factor Phs A"},
{IR_10x, 52, 0, "System Output Power Factor Phs B"},
{IR_10x, 53, 0, "System Output Power Factor Phs C"},
{IR_10x, 54, 0, "System Output Power Phase A"},
{IR_10x, 55, 0, "System Output Power Phase B"},
{IR_10x, 56, 0, "System Output Power Phase C"},
{IR_10x, 57, 0, "System Output Apparent Power Phs A"},
{IR_10x, 58, 0, "System Output Apparent Power Phs B"},
{IR_10x, 59, 0, "System Output Apparent Power Phs C"},
{IR_10x, 60, 0, "System Output Power"},
{IR_10x, 61, 0, "System Output Apparent Power"},
{IR, 164, 0, "UPS Loading Status"},
{IR_10x, 175, 0, "DC Bus Voltage"},
{IR, 180, 0, "Battery Time Remaining"},
{IR, 183, 0, "UPS Battery Status1"},
{IR, 184, 0, "UPS Battery Status2"},
};
//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