This commit is contained in:
Emmanuel HC
2025-10-24 13:24:59 -05:00
parent 5ab69c81cc
commit a24462e77b
7 changed files with 185 additions and 105 deletions

View File

@@ -161,6 +161,8 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
if (cb_status == 1.0f){
setBitValue(equipment, "CB_Status", cb_num, true);
setBitValue(equipment, "CB_Tripped", cb_num, false);
strategy = getStrategy("Amps G");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(65.0f);
strategy = getStrategy("Amps N");
@@ -224,7 +226,13 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
setPointValue(equipment, tag, total_load * 1715.0f * 0.9f);
}else{
}
else{
if (cb_status == 2.0f){
setBitValue(equipment, "CB_Tripped", cb_num, true);
} else {
setBitValue(equipment, "CB_Tripped", cb_num, false);
}
setBitValue(equipment, "CB_Status", cb_num, false);
strategy = getStrategy("Amps G");
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);

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, 178); /**< @brief The static IP address for the device. */
IPAddress local_IP(172, 17, 33, 181); /**< @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. */

View File

@@ -60,11 +60,12 @@ BatteryState<ModbusIP>::BatteryState() {
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("System Output Apparent Power Phs A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("Battery Time Remaining", new RampStrategy(0.0F, 0.3f, 1000));
addStrategy("Percentage Load", new RampStrategy(0.0F, 1.0f, 1000));
}
/**
@@ -120,7 +121,7 @@ State<ModbusIP>* BatteryState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
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");
ramp_strat = getStrategy("System Output Apparent Power Phs A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia * Out_PFa);
float Out_Vbn = getPointValue(equipment, "System Output RMS B-N");
@@ -128,7 +129,7 @@ State<ModbusIP>* BatteryState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
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");
ramp_strat = getStrategy("System Output Apparent Power Phs B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib * Out_PFb);
float Out_Vcn = getPointValue(equipment, "System Output RMS C-N");
@@ -136,7 +137,7 @@ State<ModbusIP>* BatteryState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
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");
ramp_strat = getStrategy("System Output Apparent Power Phs C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic * Out_PFc);
float Battery_time = getPointValue(equipment, "Battery Time Remaining");
@@ -167,23 +168,43 @@ State<ModbusIP>* BatteryState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
*/
template<>
void BatteryState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Battery State...");
// Logic to run when the equipment enters this state
Serial.println("Enter Battery State...");
setPointValue(equipment, "System Input RMS A-B", 0.0f);
setPointValue(equipment, "System Input RMS B-C", 0.0f);
setPointValue(equipment, "System Input RMS C-A", 0.0f);
setPointValue(equipment, "System Input RMS A-N", 0.0f);
setPointValue(equipment, "System Input RMS B-N", 0.0f);
setPointValue(equipment, "System Input RMS C-N", 0.0f);
setPointValue(equipment, "System Input RMS Current Phase A", 0.0f);
setPointValue(equipment, "System Input RMS Current Phase B", 0.0f);
setPointValue(equipment, "System Input RMS Current Phase C", 0.0f);
setPointValue(equipment, "System Input Frequency", 0.0f);
setPointValue(equipment, "System Input Power Factor Phs A", 0.0f);
setPointValue(equipment, "System Input Power Factor Phs B", 0.0f);
setPointValue(equipment, "System Input Power Factor Phs C", 0.0f);
setPointValue(equipment, "System Input Power Phase A", 0.0f);
setPointValue(equipment, "System Input Power Phase B", 0.0f);
setPointValue(equipment, "System Input Power Phase C", 0.0f);
setPointValue(equipment, "System Input Apparent Power Phs A", 0.0f);
setPointValue(equipment, "System Input Apparent Power Phs B", 0.0f);
setPointValue(equipment, "System Input Apparent Power Phs C", 0.0f);
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
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
}

View File

@@ -49,9 +49,9 @@ BypassState<ModbusIP>::BypassState() {
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 RMS Current Phase A", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Input RMS Current Phase B", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Input RMS Current Phase C", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Input Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
@@ -59,12 +59,12 @@ BypassState<ModbusIP>::BypassState() {
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 Input Power Phase A", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Power Phase B", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Power Phase C", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phs A", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phs B", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phs C", new RampStrategy(0.0F, 5.0f, 1000));
//Bypass System
@@ -77,9 +77,9 @@ BypassState<ModbusIP>::BypassState() {
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));
addStrategy("Bypass Input Power Phase A", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("Bypass Input Power Phase B", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("Bypass Input Power Phase C", new RampStrategy(0.0F, 1.0f, 1000));
//Output System
addStrategy("System Output RMS A-B", new SingleValueStrategy(480.0F, 5.0f, 1000));
@@ -89,9 +89,9 @@ BypassState<ModbusIP>::BypassState() {
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 RMS Current Phase A", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Output RMS Current Phase B", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Output RMS Current Phase C", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Output Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
@@ -99,12 +99,12 @@ BypassState<ModbusIP>::BypassState() {
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("System Output Power Phase A", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Output Power Phase B", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Output Power Phase C", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs A", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs B", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs C", new RampStrategy(0.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));
@@ -163,30 +163,30 @@ State<ModbusIP>* BypassState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
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");
ramp_strat = getStrategy("Bypass 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);
ramp_strat = getStrategy("System Input Apparent Power Phs A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia * 0.9f);
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");
ramp_strat = getStrategy("Bypass 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);
ramp_strat = getStrategy("System Input Apparent Power Phs B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib * 0.9f);
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");
ramp_strat = getStrategy("Bypass 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);
ramp_strat = getStrategy("System Input Apparent Power Phs C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic * 0.9f);
//Output strategies
float Out_Vab = getPointValue(equipment, "System Output RMS A-B");
@@ -204,24 +204,24 @@ State<ModbusIP>* BypassState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
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);
ramp_strat = getStrategy("System Output Apparent Power Phs A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia * 0.9f);
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);
ramp_strat = getStrategy("System Output Apparent Power Phs B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib * 0.9f);
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);
ramp_strat = getStrategy("System Output Apparent Power Phs C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic * 0.9f);
float Battery_time = getPointValue(equipment, "Battery Time Remaining");
float Bat_Percent = Battery_time /4.80f;
@@ -252,9 +252,10 @@ State<ModbusIP>* BypassState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
template<>
void BypassState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
// Logic to run when the equipment enters this state
Serial.println("Enter Battery State...");
Serial.println("Enter Bypass State...");
setPointValue(equipment, "UPS Loading Status", 4.0f);
setPointValue(equipment, "UPS Battery Status2", 3.0f);
setPointValue(equipment, "Percentage Load", 0.0f);
// You could also update a Modbus register to show the "standby" state
}

View File

@@ -47,9 +47,9 @@ RunningState<ModbusIP>::RunningState() {
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 RMS Current Phase A", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Input RMS Current Phase B", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Input RMS Current Phase C", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Input Frequency", new SingleValueStrategy(60.0F, 2.0f, 1000));
@@ -57,13 +57,12 @@ RunningState<ModbusIP>::RunningState() {
addStrategy("System Input Power Factor Phs B", new SingleValueStrategy(93.0F, 0.5f, 1000));
addStrategy("System Input Power Factor Phs C", new SingleValueStrategy(93.0F, 0.5f, 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 Input Power Phase A", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Power Phase B", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Power Phase C", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phs A", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phs B", new RampStrategy(0.0F, 5.0f, 1000));
addStrategy("System Input Apparent Power Phs C", new RampStrategy(0.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));
@@ -71,29 +70,28 @@ RunningState<ModbusIP>::RunningState() {
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 RMS Current Phase A", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Output RMS Current Phase B", new RampStrategy(0.0F, 1.0f, 1000));
addStrategy("System Output RMS Current Phase C", new RampStrategy(0.0F, 1.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("System Output Apparent Power Phs A", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs B", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("System Output Apparent Power Phs C", new RampStrategy(10.0F, 5.0f, 1000));
addStrategy("DC Bus Voltage", new SingleValueStrategy(518.0F, 5.0f, 1000));
addStrategy("Battery Time Remaining", new RampStrategy(480.0F, 1.0f, 1000));
addStrategy("Percentage Load", new RampStrategy(100.0F, 1.0f, 1000));
}
/**
@@ -149,24 +147,24 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
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));
ramp_strat = getStrategy("System Input Apparent Power Phs A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Van * In_Ia * 0.9f);
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));
ramp_strat = getStrategy("System Input Apparent Power Phs B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vbn * In_Ib * 0.9f);
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));
ramp_strat = getStrategy("System Input Apparent Power Phs C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(In_Vcn * In_Ic * 0.9f);
//Output strategies
float Out_Vab = getPointValue(equipment, "System Output RMS A-B");
@@ -184,24 +182,24 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
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));
ramp_strat = getStrategy("System Output Apparent Power Phs A");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Van * Out_Ia * 0.9f);
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));
ramp_strat = getStrategy("System Output Apparent Power Phs B");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vbn * Out_Ib * 0.9f);
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));
ramp_strat = getStrategy("System Output Apparent Power Phs C");
static_cast<RampStrategy*>(ramp_strat)->setTarget(Out_Vcn * Out_Ic * 0.9f);
float Battery_time = getPointValue(equipment, "Battery Time Remaining");
float Bat_Percent = Battery_time /4.80f;

View File

@@ -86,9 +86,60 @@ State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
*/
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);
// Logic to run when the equipment enters this state
Serial.println("Enter Standby State...");
setPointValue(equipment, "UPS Loading Status", 2.0f);
setPointValue(equipment, "System Input RMS A-B", 0.0f);
setPointValue(equipment, "System Input RMS B-C", 0.0f);
setPointValue(equipment, "System Input RMS C-A", 0.0f);
setPointValue(equipment, "System Input RMS A-N", 0.0f);
setPointValue(equipment, "System Input RMS B-N", 0.0f);
setPointValue(equipment, "System Input RMS C-N", 0.0f);
setPointValue(equipment, "System Input RMS Current Phase A", 0.0f);
setPointValue(equipment, "System Input RMS Current Phase B", 0.0f);
setPointValue(equipment, "System Input RMS Current Phase C", 0.0f);
setPointValue(equipment, "System Input Frequency", 0.0f);
setPointValue(equipment, "System Input Power Factor Phs A", 0.0f);
setPointValue(equipment, "System Input Power Factor Phs B", 0.0f);
setPointValue(equipment, "System Input Power Factor Phs C", 0.0f);
setPointValue(equipment, "System Input Power Phase A", 0.0f);
setPointValue(equipment, "System Input Power Phase B", 0.0f);
setPointValue(equipment, "System Input Power Phase C", 0.0f);
setPointValue(equipment, "System Input Apparent Power Phs A", 0.0f);
setPointValue(equipment, "System Input Apparent Power Phs B", 0.0f);
setPointValue(equipment, "System Input Apparent Power Phs C", 0.0f);
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, "System Output RMS A-B", 0.0f);
setPointValue(equipment, "System Output RMS B-C", 0.0f);
setPointValue(equipment, "System Output RMS C-A", 0.0f);
setPointValue(equipment, "System Output RMS A-N", 0.0f);
setPointValue(equipment, "System Output RMS B-N", 0.0f);
setPointValue(equipment, "System Output RMS C-N", 0.0f);
setPointValue(equipment, "System Output RMS Current Phase A", 0.0f);
setPointValue(equipment, "System Output RMS Current Phase B", 0.0f);
setPointValue(equipment, "System Output RMS Current Phase C", 0.0f);
setPointValue(equipment, "System Output Frequency", 0.0f);
setPointValue(equipment, "System Output Power Factor Phs A", 0.0f);
setPointValue(equipment, "System Output Power Factor Phs B", 0.0f);
setPointValue(equipment, "System Output Power Factor Phs C", 0.0f);
setPointValue(equipment, "System Output Power Phase A", 0.0f);
setPointValue(equipment, "System Output Power Phase B", 0.0f);
setPointValue(equipment, "System Output Power Phase C", 0.0f);
setPointValue(equipment, "System Output Apparent Power Phs A", 0.0f);
setPointValue(equipment, "System Output Apparent Power Phs B", 0.0f);
setPointValue(equipment, "System Output Apparent Power Phs C", 0.0f);
setPointValue(equipment, "System Output Power", 0.0f);
setPointValue(equipment, "System Output Apparent Power", 0.0f);
}
/**

View File

@@ -23,8 +23,8 @@
#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, 187); /**< @brief The static IP address for the device. */
IPAddress gateway(172, 17, 33, 1); /**< @brief The gateway IP address. */
IPAddress local_IP(172, 17, 3, 187); /**< @brief The static IP address for the device. */
IPAddress gateway(172, 17, 3, 1); /**< @brief The gateway IP address. */
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
ModbusIP mb;
@@ -125,7 +125,8 @@ modbusMap mb_map[] =
{IR, 60, 0, "System Output Power"},
{IR, 61, 0, "System Output Apparent Power"},
{IR, 164, 0, "UPS Loading Status"},
{IR, 175, 0, "DC Bus Voltage"},
{IR, 175, 0, "DC Bus Voltage"},
{IR, 179, 0, "Percentage Load"},
{IR, 180, 0, "Battery Time Remaining"},
{IR, 183, 0, "UPS Battery Status1"},
{IR, 184, 0, "UPS Battery Status2"},