New method to set reset bits

This commit is contained in:
Emmanuel HC
2025-10-23 22:03:58 -05:00
parent c6aaf5186e
commit 5ab69c81cc
3 changed files with 80 additions and 3 deletions

View File

@@ -105,6 +105,11 @@ RunningState<ModbusIP>::RunningState() {
tag = cb + "_V31";
addStrategy(tag, new SingleValueStrategy(0.0f, 30.0f, 1000));
}
addStrategy("Amps G", new SingleValueStrategy(0.0f, 2.0f, 1000));
addStrategy("Amps N", new SingleValueStrategy(0.0f, 3.0f, 1000));
addStrategy("kWh", new RampStrategy(5000000.0f, 1.0f, 1000));
addStrategy("PF", new SingleValueStrategy(0.0f, 1.0f, 1000));
}
/**
@@ -142,7 +147,7 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
cb_count += 1.0f;
}
}
int cb_num = 0;
for (const std::string& cb : cbs) {
std::string tag = "";
Strategy_Behavior* strategy = nullptr;
@@ -155,7 +160,13 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
float cb_load = total_load / cb_count;
if (cb_status == 1.0f){
setBitValue(equipment, "CB_Status", cb_num, true);
strategy = getStrategy("Amps G");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(65.0f);
strategy = getStrategy("Amps N");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(50.0f);
strategy = getStrategy("PF");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(90.0f);
tag = "";
tag = cb + "_V1N";
strategy = getStrategy(tag);
@@ -214,6 +225,13 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
}else{
setBitValue(equipment, "CB_Status", cb_num, false);
strategy = getStrategy("Amps G");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
strategy = getStrategy("Amps N");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
strategy = getStrategy("PF");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
tag = "";
tag = cb + "_V1N";
strategy = getStrategy(tag);
@@ -270,6 +288,7 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
tag = cb + "_L3KVar";
setPointValue(equipment, tag, total_load*0.0f);
}
cb_num++;
}
// Apply any strategies defined for the standby state
_applyStrategies(equipment);

View File

@@ -23,7 +23,7 @@
#include <ModbusIP_ESP8266.h>
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, 181); /**< @brief The static IP address for the device. */
IPAddress local_IP(172, 17, 33, 178); /**< @brief The static IP address for the device. */
IPAddress gateway(172, 17, 33, 1); /**< @brief The gateway IP address. */
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
@@ -557,6 +557,15 @@ modbusMap mb_map[] = {
{IR_LONG, 986, 0, "CB9_LN_Avg" },
{IR_LONG, 988, 0, "CB9_LL_Avg" },
{IR_LONG, 999, 0, "CB9_Status" },
{IR_FLOAT, 1068, 0, "Amps G" },
{IR_FLOAT, 1066, 0, "Amps N" },
{IR_FLOAT, 1087, 0, "kWh" },
{IR_FLOAT, 1091, 0, "PF" },
{IR, 1150, 0, "CB_Status" },
{IR, 1151, 0, "CB_Tripped" },
};
//Size of modbus map used in FOR cycles, automatically calculated.