diff --git a/src/device/power_switch.cpp b/src/device/power_switch.cpp index 4cefc26..2ca5518 100644 --- a/src/device/power_switch.cpp +++ b/src/device/power_switch.cpp @@ -56,6 +56,8 @@ TMFeResult powerSwitch::HandleInit(const std::vector &args) { midas::odb to_watch(this->equipmentPath + SLASH + VARIABLES_DIR + SLASH + COMMAND_VARNAME); + updateOutletNumber(); + to_watch.watch( [&](midas::odb &arg) { this->sendCommand(arg.get_last_index()); }); return TMFeOk(); @@ -118,10 +120,10 @@ void powerSwitch::updateOutletNumber() { } void powerSwitch::sendCommand(int index) { - if (index < 0 || index >= (int)outlets.size()) { + if (index < 0 || index >= static_cast(outlets.size())) { fMfe->Msg(MERROR, __FUNCTION__, "Command received for outlet %d but only %d outlet(s) ready", - index, (int)outlets.size()); + index, static_cast(outlets.size())); return; } midas::odb o(this->equipmentPath);