diff --git a/mpod.cpp b/mpod.cpp index 86030b73e0f2e4ab59f7c7ec25c4d00c5e58c31c..1190c9c592313c7d3edd9ae3fae4e7a3679bd364 100644 --- a/mpod.cpp +++ b/mpod.cpp @@ -221,13 +221,34 @@ void setChannelStateAndWait(const IPAddress *ipAddr, const uint16_t channel, con snmp.loop(); // Poll channel until it's settled + uint8_t loopCount = 0; + bool ramping = true; + bool settingChannelState = true; do { SNMP::Message *snmp_msg = mpod.read(channel); snmp.send(snmp_msg, *ipAddr, SNMP::Port::SNMP); delete snmp_msg; + delay(MPOD_UPDATE_LATENCY); snmp.loop(); - } while (mpod.isOn() != (bool)output || mpod.isRampingDown() || mpod.isRampingUp()); + loopCount += 1; + ramping = (mpod.isRampingUp() || mpod.isRampingDown()); + if (!ramping) { + if (mpod.isOn() == (bool)output) { + settingChannelState = false; + } else if (loopCount >= 5) { + // Resend set command + Serial.print("!Resend command to "); + Serial.println(channel); + SNMP::Message *snmp_msg = mpod.setChannelState(channel, output); + snmp.send(snmp_msg, *ipAddr, SNMP::Port::SNMP); + delete snmp_msg; + delay(MPOD_UPDATE_LATENCY); + snmp.loop(); + loopCount = 0; + } + } + } while (settingChannelState); } void setChannelVoltageAndWait(const IPAddress *ipAddr, const uint16_t channel, diff --git a/mpod.hpp b/mpod.hpp index 639d993f1525f2fdba331cfe683ec71d68980ccb..8ecd78f17ddca1c1f65409a0f27da26575fd3e2b 100644 --- a/mpod.hpp +++ b/mpod.hpp @@ -59,7 +59,6 @@ class MPOD { } }; - // Create an SNMP SETREQUEST message to setup MPOD MPOD(); SNMP::Message* read(const uint16_t); SNMP::Message* setChannelState(const uint16_t, const bool); diff --git a/powerproc.cpp b/powerproc.cpp index 3264c4ca5ef38ebbb8b964700aa70463e3f596c7..aa5fc68450e60d67dbe5c462a65dab52cd0e4705 100644 --- a/powerproc.cpp +++ b/powerproc.cpp @@ -8,25 +8,55 @@ PowerProcedure::PowerProcedure(const IPAddress& ipAddr) stages[0].name = "ASICS"; stages[0].type = SWITCH; - stages[0].size = 9; - stages[0].channels = new int[stages[0].size]{508, 708, 502, 503, 504, 501, 507, 607, 608}; + stages[0].size = 15; + stages[0].channels = new int[stages[0].size]{ + 508, 708, // MBJT + 503, 504, // AM, RB + 502, 506, 602, 606, // RB + 501, 505, 601, 605, // IOB + 507, 607, 608 // IOBA + }; stages[1].name = "HV"; stages[1].type = SWITCH; - stages[1].size = 10; - stages[1].channels = new int[stages[1].size]{1, 2, 101, 103, 102, 104, 105, 106, 107, 108}; + stages[1].size = 40; + stages[1].channels = new int[stages[1].size]{ + 1, 2, 3, 4, 5, 6, 7, 8, // IS + 101, 103, 102, 104, // M1 RING1 + 113, 114, 115, 116, // M2 RING1 + 213, 214, 215, 216, // M3 RING1 + 201, 202, 203, 204, // M4 RING1 + 105, 106, 107, 108, // M1 BACK + 109, 110, 111, 112, // M2 BACK + 209, 210, 211, 212, // M3 BACK + 205, 206, 207, 208, // M4 BACK + }; stages[2].name = "ISVOLTAGE"; stages[2].type = VOLTAGE; - stages[2].size = 2; - stages[2].channels = new int[stages[2].size]{1, 2}; - stages[2].onValue = new float[stages[2].size]{10, 10}; - stages[2].offValue = new float[stages[2].size]{2.5, 2.5}; + stages[2].size = 8; + stages[2].channels = new int[stages[2].size]{ + 1, 2, // M1 + 3, 4, // M2 + 5, 6, // M3 + 7, 8 // M4 + }; + stages[2].onValue = new float[stages[2].size]{10, 10, 10, 10, 10, 10, 10, 10}; + stages[2].offValue = new float[stages[2].size]{2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5}; stages[3].name = "PLCSOURCE"; stages[3].type = SWITCH; - stages[3].size = 9; - stages[3].channels = new int[stages[3].size]{701, 801, 802, 803, 804, 301, 302, 303, 304}; + stages[3].size = 36; + stages[3].channels = new int[stages[3].size]{ + 701, 801, 802, 803, 804, // M1 PLC + 702, 805, 806, 807, 808, // M2 PLC + 703, 901, 902, 903, 904, // M3 PLC + 704, 905, 906, 907, 908, // M4 PLC + 301, 302, 303, 304, // M1 SG + 305, 306, 307, 308, // M2 SG + 401, 402, 403, 404, // M3 SG + 405, 406, 407, 408, // M4 SG + }; } PowerProcedure::~PowerProcedure() { diff --git a/rest.cpp b/rest.cpp index 61af9a28636a2a313a394284e57ef2763a402c7b..2f1b0aef913d5460618ed72a54d48bf336c2c6bc 100644 --- a/rest.cpp +++ b/rest.cpp @@ -241,7 +241,7 @@ void powerAllOff() { if (success) { PINS.ramping = true; - for (uint8_t groupIdx = pproc.stagesCount - 1; groupIdx >= 0; groupIdx--) { + for (int8_t groupIdx = pproc.stagesCount - 1; groupIdx >= 0; groupIdx--) { group = pproc.stages[groupIdx].name; groups += group; groups += ",";