Skip to content
Snippets Groups Projects

DEPFET Q2M1 Power Procedure

Merged Cyril Danilevski requested to merge q2m1_test into main
5 files
+ 85
20
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 37
3
@@ -35,7 +35,7 @@ SNMP::Message *MPOD::read(uint16_t channel) {
}
// Create an SNMP SETREQUEST message to switch on or off the specified channel
SNMP::Message *MPOD::output(const uint16_t channel, const bool on) {
SNMP::Message *MPOD::setChannelState(const uint16_t channel, const bool on) {
SNMP::Message *message = new SNMP::Message(SNMP::Version::V2C, "guru", SNMP::Type::SetRequest);
// In SETREQUEST, use node type and set the value.
// OUTPUT SWITCH, integer type, 0 is OFF and 1 is ON.
@@ -45,6 +45,17 @@ SNMP::Message *MPOD::output(const uint16_t channel, const bool on) {
return message;
}
// Create an SNMP SETREQUEST message to set the channel voltage
SNMP::Message *MPOD::setTargetVoltage(const uint16_t channel, const float targetVoltage) {
SNMP::Message *message = new SNMP::Message(SNMP::Version::V2C, "guru", SNMP::Type::SetRequest);
// In SETREQUEST, use node type and set the value.
// OUTPUT VOLTAGE, float type.
String snmp_cmd = OID::NAMES[OID::OUTPUTVOLTAGE];
snmp_cmd += channel;
message->add(snmp_cmd.c_str(), new OpaqueBER(new OpaqueFloatBER(targetVoltage)));
return message;
}
// Parse incoming message
bool MPOD::message(const SNMP::Message *message) {
unsigned int found = 0;
@@ -194,9 +205,9 @@ void initializeSNMP() {
/* setChannelAndWait
* Set a channel's parameters and wait until it's settled.
*/
void setChannelAndWait(const IPAddress *ipAddr, const uint16_t channel, const uint8_t output) {
void setChannelStateAndWait(const IPAddress *ipAddr, const uint16_t channel, const uint8_t output) {
// Send set command
SNMP::Message *snmp_msg = mpod.output(channel, output);
SNMP::Message *snmp_msg = mpod.setChannelState(channel, output);
snmp.send(snmp_msg, *ipAddr, SNMP::Port::SNMP);
delete snmp_msg;
@@ -213,3 +224,26 @@ void setChannelAndWait(const IPAddress *ipAddr, const uint16_t channel, const ui
snmp.loop();
} while (mpod.isOn() != (bool)output || mpod.isRampingDown() || mpod.isRampingUp());
}
void setChannelVoltageAndWait(const IPAddress *ipAddr, const uint16_t channel,
const float targetVoltage) {
// Send set command
SNMP::Message *snmp_msg = mpod.setTargetVoltage(channel, targetVoltage);
snmp.send(snmp_msg, *ipAddr, SNMP::Port::SNMP);
delete snmp_msg;
// wait for channel reply
delay(MPOD_UPDATE_LATENCY);
snmp.loop();
// Poll channel until it's settled
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.isRampingDown() ||
mpod.isRampingUp()); // TODO check applied voltage close to target voltage
}
Loading