Skip to content

Commit 40727ae

Browse files
authored
Merge pull request #27 from OpenDDS/minor-improve
Minor console output changes
2 parents 9765040 + bb8d8a2 commit 40727ae

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

tactical-microgrid-standard/cli/CLIClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void CLIClient::display_controllers() const
599599
size_t i = 1;
600600
const auto now = Clock::now();
601601
for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
602-
std::cout << i << ". Controller Id: " << it->first << " (" <<
602+
std::cout << i++ << ". Controller Id: " << it->first << " (" <<
603603
(controller_status(now, it->second.last_hb) == ControllerStatus::AVAILABLE ? "available)" : "unavailable)")
604604
<< std::endl;
605605
}

tactical-microgrid-standard/power_devices/Distribution.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,23 @@ void ElectricCurrentDataReaderListenerImpl::on_data_available(DDS::DataReader_pt
189189
continue;
190190
}
191191

192+
// For simulation purpose, we just split the amperage evenly over all output ports
193+
const auto out_amps = ec.amperage() / connected_devices_out.size();
194+
192195
// Relay to all devices connected to the output power ports
193196
for (const auto& out_dev : connected_devices_out) {
194197
powersim::ElectricCurrent relay_ec = ec;
195198
relay_ec.power_path().push_back(out_dev.id());
199+
relay_ec.amperage() = out_amps;
196200
const DDS::ReturnCode_t rc = dist_dev_.get_electric_current_data_writer()->write(relay_ec, DDS::HANDLE_NIL);
197201
if (rc != DDS::RETCODE_OK) {
198202
ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: ElectricCurrentDataReaderListenerImpl::on_data_available: "
199203
"write ElectricCurrent failed: %C\n", OpenDDS::DCPS::retcode_to_string(rc)));
200204
}
201205

202206
if (dist_dev_.verbose()) {
203-
std::cout << "=== Relaying power from device \"" << from << "\" to device \""
204-
<< out_dev.id() << "\" -- " << ec.amperage() << "Amps ..." << std::endl;
207+
ACE_DEBUG((LM_DEBUG, "=== (%T) Relaying power from device \"%C\" to device \"%C\" -- %f Amps...\n",
208+
from.c_str(), out_dev.id().c_str(), out_amps));
205209
}
206210
}
207211
}

tactical-microgrid-standard/power_devices/Load.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void ElectricCurrentDataReaderListenerImpl::on_data_available(DDS::DataReader_pt
146146

147147
if (from == load_dev_.connected_dev_id() && to == load_dev_.get_device_id()) {
148148
if (load_dev_.verbose()) {
149-
ACE_DEBUG((LM_INFO, "=== Receiving power from \"%C\" -- %f Amps ...\n", from.c_str(), ec.amperage()));
149+
ACE_DEBUG((LM_INFO, "=== (%T) Receiving power from \"%C\" -- %f Amps...\n", from.c_str(), ec.amperage()));
150150
}
151151
break;
152152
}

tactical-microgrid-standard/power_devices/Source.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,16 @@ class SourceDevice : public PowerDevice {
120120
powersim::ElectricCurrent ec;
121121
ec.power_path().push_back(get_device_id());
122122
ec.power_path().push_back(connected_devs[0].id());
123-
ec.amperage() = 1.0f;
123+
ec.amperage() = 10.0f;
124124
const DDS::ReturnCode_t rc = ec_dw_->write(ec, DDS::HANDLE_NIL);
125125
if (rc != DDS::RETCODE_OK) {
126126
ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: SourceDevice::simulate_power_flow: "
127127
"write ElectricCurrent failed: %C\n", OpenDDS::DCPS::retcode_to_string(rc)));
128128
}
129129

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

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

0 commit comments

Comments
 (0)