PDU Maverick progam created
This commit is contained in:
@@ -11,10 +11,10 @@
|
||||
[platformio]
|
||||
|
||||
|
||||
default_envs = CH_Daikin_AWV026B_RTU ; Select here the name of the configuration you want to download
|
||||
default_envs = PDU_Maverick_Power_TCP ; Select here the name of the configuration you want to download
|
||||
|
||||
[env]
|
||||
upload_port = COM5
|
||||
upload_port = COM15
|
||||
|
||||
[common_env_options]
|
||||
framework = arduino
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
* state, such as a PID controller for the 'CW Valve Position' and totalizers
|
||||
* for the run-hours of each EC fan.
|
||||
*/
|
||||
std::string cbs[] = {"CB0", "CB1", "CB2", "CB3", "CB4", "CB5", "CB6", "CB7", "CB8", };
|
||||
template<>
|
||||
RunningState<ModbusIP>::RunningState() {
|
||||
//Example
|
||||
@@ -43,19 +44,71 @@ RunningState<ModbusIP>::RunningState() {
|
||||
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));
|
||||
|
||||
|
||||
|
||||
for (const std::string& cb : cbs) {
|
||||
std::string tag = "";
|
||||
tag = cb + "_V1N";
|
||||
addStrategy(tag, new SingleValueStrategy(0.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V2N";
|
||||
addStrategy(tag, new SingleValueStrategy(0.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V3N";
|
||||
addStrategy(tag, new SingleValueStrategy(0.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_L1PF";
|
||||
addStrategy(tag, new SingleValueStrategy(93.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_L2PF";
|
||||
addStrategy(tag, new SingleValueStrategy(93.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_L3PF";
|
||||
addStrategy(tag, new SingleValueStrategy(93.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V1THD";
|
||||
addStrategy(tag, new SingleValueStrategy(2.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V2THD";
|
||||
addStrategy(tag, new SingleValueStrategy(2.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V3THD";
|
||||
addStrategy(tag, new SingleValueStrategy(2.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I1THD";
|
||||
addStrategy(tag, new SingleValueStrategy(10.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I2THD";
|
||||
addStrategy(tag, new SingleValueStrategy(10.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I3THD";
|
||||
addStrategy(tag, new SingleValueStrategy(10.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I1Kfactor";
|
||||
addStrategy(tag, new SingleValueStrategy(3.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I2Kfactor";
|
||||
addStrategy(tag, new SingleValueStrategy(3.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I3Kfactor";
|
||||
addStrategy(tag, new SingleValueStrategy(3.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I1TDD";
|
||||
addStrategy(tag, new SingleValueStrategy(5.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I2TDD";
|
||||
addStrategy(tag, new SingleValueStrategy(5.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_I3TDD";
|
||||
addStrategy(tag, new SingleValueStrategy(5.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V12";
|
||||
addStrategy(tag, new SingleValueStrategy(0.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V23";
|
||||
addStrategy(tag, new SingleValueStrategy(0.0f, 2.0f, 1000));
|
||||
tag = "";
|
||||
tag = cb + "_V31";
|
||||
addStrategy(tag, new SingleValueStrategy(0.0f, 2.0f, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +128,153 @@ 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 Ctrl");
|
||||
switch (static_cast<int>(State_Ctrl)) {
|
||||
case 1:
|
||||
return new StandbyState<ModbusIP>();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
float cb_count = 0.0f;
|
||||
for (const std::string& cb :cbs){
|
||||
std::string tag = "";
|
||||
tag = "Px " + cb;
|
||||
if (cb == "CB0") continue;
|
||||
float cb_status = getPointValue(equipment, tag);
|
||||
if (static_cast<int>(cb_status)){
|
||||
cb_count += 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::string& cb : cbs) {
|
||||
std::string tag = "";
|
||||
Strategy_Behavior* strategy = nullptr;
|
||||
tag = "";
|
||||
tag = "Px_" + cb;
|
||||
float cb_status = getPointValue(equipment, tag);
|
||||
float percent_load = getPointValue(equipment, "Px Load");
|
||||
float Rating = getPointValue(equipment, "Px Rating");
|
||||
float total_load = Rating * (percent_load /100.0f);
|
||||
float cb_load = total_load / cb_count;
|
||||
|
||||
if (static_cast<bool>(cb_status) == 1){
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_V1N";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(270.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V2N";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(270.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V3N";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(270.0f);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_V12";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(480.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V23";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(480.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V31";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(480.0f);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_I1";
|
||||
setPointValue(equipment, tag, total_load);
|
||||
tag = "";
|
||||
tag = cb + "_I2";
|
||||
setPointValue(equipment, tag, total_load);
|
||||
tag = "";
|
||||
tag = cb + "_I3";
|
||||
setPointValue(equipment, tag, total_load);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_L1KW";
|
||||
setPointValue(equipment, tag, total_load*1.715f);
|
||||
tag = "";
|
||||
tag = cb + "_L2KW";
|
||||
setPointValue(equipment, tag, total_load*1.715f);
|
||||
tag = "";
|
||||
tag = cb + "_L3KW";
|
||||
setPointValue(equipment, tag, total_load*1.715f);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_L1KVar";
|
||||
setPointValue(equipment, tag, total_load*1.715*0.9f);
|
||||
tag = "";
|
||||
tag = cb + "_L2KVar";
|
||||
setPointValue(equipment, tag, total_load*1.715*0.9f);
|
||||
tag = "";
|
||||
tag = cb + "_L3KVar";
|
||||
setPointValue(equipment, tag, total_load*1.715*0.9f);
|
||||
|
||||
|
||||
}else{
|
||||
tag = "";
|
||||
tag = cb + "_V1N";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V2N";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V3N";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_V12";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V23";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_V31";
|
||||
strategy = getStrategy(tag);
|
||||
static_cast<SingleValueStrategy*>(strategy)->setSetpoint(0.0f);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_I1";
|
||||
setPointValue(equipment, tag, total_load);
|
||||
tag = "";
|
||||
tag = cb + "_I2";
|
||||
setPointValue(equipment, tag, total_load);
|
||||
tag = "";
|
||||
tag = cb + "_I3";
|
||||
setPointValue(equipment, tag, total_load);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_L1KW";
|
||||
setPointValue(equipment, tag, total_load*0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_L2KW";
|
||||
setPointValue(equipment, tag, total_load*0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_L3KW";
|
||||
setPointValue(equipment, tag, total_load*0.0f);
|
||||
|
||||
tag = "";
|
||||
tag = cb + "_L1KVar";
|
||||
setPointValue(equipment, tag, total_load*0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_L2KVar";
|
||||
setPointValue(equipment, tag, total_load*0.0f);
|
||||
tag = "";
|
||||
tag = cb + "_L3KVar";
|
||||
setPointValue(equipment, tag, total_load*0.0f);
|
||||
}
|
||||
}
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
return nullptr;
|
||||
|
||||
@@ -56,7 +56,14 @@ template<>
|
||||
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 Ctrl");
|
||||
switch (static_cast<int>(State_Ctrl)) {
|
||||
case 2:
|
||||
return new RunningState<ModbusIP>();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
return nullptr;
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
* @{
|
||||
*/
|
||||
#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, 16, 32, 178); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(172, 16, 32, 1); /**< @brief The gateway IP address. */
|
||||
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, 178); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(192, 168, 1, 1); /**< @brief The gateway IP address. */
|
||||
IPAddress subnet(254, 254, 254, 0); /**< @brief The subnet mask. */
|
||||
|
||||
ModbusIP mb;
|
||||
@@ -66,15 +66,15 @@ modbusMap mb_map[] = {
|
||||
{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"},
|
||||
{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, 0, 0, "CB0_V1N" },
|
||||
@@ -97,7 +97,7 @@ modbusMap mb_map[] = {
|
||||
{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, 40, 0, "CB0_V3THD" },
|
||||
{IR_FLOAT, 42, 0, "CB0_I1THD" },
|
||||
{IR_FLOAT, 44, 0, "CB0_I2THD" },
|
||||
{IR_FLOAT, 46, 0, "CB0_I3THD" },
|
||||
@@ -145,7 +145,7 @@ modbusMap mb_map[] = {
|
||||
{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, 140, 0, "CB1_V3THD" },
|
||||
{IR_FLOAT, 142, 0, "CB1_I1THD" },
|
||||
{IR_FLOAT, 144, 0, "CB1_I2THD" },
|
||||
{IR_FLOAT, 146, 0, "CB1_I3THD" },
|
||||
@@ -192,7 +192,7 @@ modbusMap mb_map[] = {
|
||||
{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, 240, 0, "CB2_V3THD" },
|
||||
{IR_FLOAT, 242, 0, "CB2_I1THD" },
|
||||
{IR_FLOAT, 244, 0, "CB2_I2THD" },
|
||||
{IR_FLOAT, 246, 0, "CB2_I3THD" },
|
||||
@@ -239,7 +239,7 @@ modbusMap mb_map[] = {
|
||||
{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, 340, 0, "CB3_V3THD" },
|
||||
{IR_FLOAT, 342, 0, "CB3_I1THD" },
|
||||
{IR_FLOAT, 344, 0, "CB3_I2THD" },
|
||||
{IR_FLOAT, 346, 0, "CB3_I3THD" },
|
||||
@@ -286,7 +286,7 @@ modbusMap mb_map[] = {
|
||||
{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, 440, 0, "CB4_V3THD" },
|
||||
{IR_FLOAT, 442, 0, "CB4_I1THD" },
|
||||
{IR_FLOAT, 444, 0, "CB4_I2THD" },
|
||||
{IR_FLOAT, 446, 0, "CB4_I3THD" },
|
||||
@@ -333,7 +333,7 @@ modbusMap mb_map[] = {
|
||||
{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, 540, 0, "CB5_V3THD" },
|
||||
{IR_FLOAT, 542, 0, "CB5_I1THD" },
|
||||
{IR_FLOAT, 544, 0, "CB5_I2THD" },
|
||||
{IR_FLOAT, 546, 0, "CB5_I3THD" },
|
||||
@@ -380,7 +380,7 @@ modbusMap mb_map[] = {
|
||||
{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, 640, 0, "CB6_V3THD" },
|
||||
{IR_FLOAT, 642, 0, "CB6_I1THD" },
|
||||
{IR_FLOAT, 644, 0, "CB6_I2THD" },
|
||||
{IR_FLOAT, 646, 0, "CB6_I3THD" },
|
||||
@@ -427,7 +427,7 @@ modbusMap mb_map[] = {
|
||||
{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, 740, 0, "CB7_V3THD" },
|
||||
{IR_FLOAT, 742, 0, "CB7_I1THD" },
|
||||
{IR_FLOAT, 744, 0, "CB7_I2THD" },
|
||||
{IR_FLOAT, 746, 0, "CB7_I3THD" },
|
||||
@@ -474,7 +474,7 @@ modbusMap mb_map[] = {
|
||||
{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, 840, 0, "CB8_V3THD" },
|
||||
{IR_FLOAT, 842, 0, "CB8_I1THD" },
|
||||
{IR_FLOAT, 844, 0, "CB8_I2THD" },
|
||||
{IR_FLOAT, 846, 0, "CB8_I3THD" },
|
||||
|
||||
Reference in New Issue
Block a user