Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tactical-microgrid-standard/cli/CLIClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ void CLIClient::display_controllers() const
size_t i = 1;
const auto now = Clock::now();
for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
std::cout << i << ". Controller Id: " << it->first << " (" <<
std::cout << i++ << ". Controller Id: " << it->first << " (" <<
(controller_status(now, it->second.last_hb) == ControllerStatus::AVAILABLE ? "available)" : "unavailable)")
<< std::endl;
}
Expand Down
8 changes: 6 additions & 2 deletions tactical-microgrid-standard/power_devices/Distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,23 @@ void ElectricCurrentDataReaderListenerImpl::on_data_available(DDS::DataReader_pt
continue;
}

// For simulation purpose, we just split the amperage evenly over all output ports
const auto out_amps = ec.amperage() / connected_devices_out.size();

// Relay to all devices connected to the output power ports
for (const auto& out_dev : connected_devices_out) {
powersim::ElectricCurrent relay_ec = ec;
relay_ec.power_path().push_back(out_dev.id());
relay_ec.amperage() = out_amps;
const DDS::ReturnCode_t rc = dist_dev_.get_electric_current_data_writer()->write(relay_ec, DDS::HANDLE_NIL);
if (rc != DDS::RETCODE_OK) {
ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: ElectricCurrentDataReaderListenerImpl::on_data_available: "
"write ElectricCurrent failed: %C\n", OpenDDS::DCPS::retcode_to_string(rc)));
}

if (dist_dev_.verbose()) {
std::cout << "=== Relaying power from device \"" << from << "\" to device \""
<< out_dev.id() << "\" -- " << ec.amperage() << "Amps ..." << std::endl;
ACE_DEBUG((LM_DEBUG, "=== (%T) Relaying power from device \"%C\" to device \"%C\" -- %f Amps...\n",
from.c_str(), out_dev.id().c_str(), out_amps));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tactical-microgrid-standard/power_devices/Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void ElectricCurrentDataReaderListenerImpl::on_data_available(DDS::DataReader_pt

if (from == load_dev_.connected_dev_id() && to == load_dev_.get_device_id()) {
if (load_dev_.verbose()) {
ACE_DEBUG((LM_INFO, "=== Receiving power from \"%C\" -- %f Amps ...\n", from.c_str(), ec.amperage()));
ACE_DEBUG((LM_INFO, "=== (%T) Receiving power from \"%C\" -- %f Amps...\n", from.c_str(), ec.amperage()));
}
break;
}
Expand Down
5 changes: 3 additions & 2 deletions tactical-microgrid-standard/power_devices/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ class SourceDevice : public PowerDevice {
powersim::ElectricCurrent ec;
ec.power_path().push_back(get_device_id());
ec.power_path().push_back(connected_devs[0].id());
ec.amperage() = 1.0f;
ec.amperage() = 10.0f;
const DDS::ReturnCode_t rc = ec_dw_->write(ec, DDS::HANDLE_NIL);
if (rc != DDS::RETCODE_OK) {
ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: SourceDevice::simulate_power_flow: "
"write ElectricCurrent failed: %C\n", OpenDDS::DCPS::retcode_to_string(rc)));
}

if (verbose_) {
std::cout << "=== Sending power to device \"" << connected_devs[0].id() << "\"..." << std::endl;
ACE_DEBUG((LM_DEBUG, "=== (%T) Sending power to device \"%C\" -- %f Amps...\n",
connected_devs[0].id().c_str(), ec.amperage()));
}

// Frequency of messages can be proportional to the power measure?
Expand Down