// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include "external_energy_limitsImpl.hpp"

namespace module {
namespace external_limits {

void external_energy_limitsImpl::init() {
}

void external_energy_limitsImpl::ready() {
    // special case: phase_count could be configured as zero for historic reason,
    // so let's just use voltage and current for power calculation
    types::energy::CapabilityLimits capabilities{
        static_cast<float>(mod->config.fuse_limit_A), mod->config.phase_count,
        static_cast<float>(mod->config.nominal_voltage_V),
        static_cast<float>(mod->config.nominal_voltage_V * mod->config.fuse_limit_A *
                           (mod->config.phase_count ? mod->config.phase_count : 1))};

    this->publish_capabilities(capabilities);
}

void external_energy_limitsImpl::handle_set_external_limits(types::energy::ExternalLimits& value) {
    // your code for cmd set_external_limits goes here
    mod->signalExternalLimit(value);
};

} // namespace external_limits
} // namespace module
