Skip to content

Commit a28192d

Browse files
committed
huawei grid charger: revise message outputs
1 parent d330616 commit a28192d

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

src/gridcharger/huawei/Controller.cpp

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ void Controller::updateSettings()
6363
_upHardwareInterface = std::make_unique<TWAI>();
6464
break;
6565
default:
66-
MessageOutput.printf("[HuaweiCanClass::init] Unknown hardware "
66+
MessageOutput.printf("[Huawei::Controller] Unknown hardware "
6767
"interface setting %d\r\n", config.Huawei.HardwareInterface);
6868
return;
6969
break;
7070
}
7171

7272
if (!_upHardwareInterface->init()) {
73-
MessageOutput.println("[HuaweiCanClass::init] Error initializing hardware interface");
73+
MessageOutput.print("[Huawei::Controller] Error initializing hardware interface\r\n");
7474
_upHardwareInterface.reset(nullptr);
7575
return;
7676
};
@@ -86,7 +86,7 @@ void Controller::updateSettings()
8686
_mode = HUAWEI_MODE_AUTO_INT;
8787
}
8888

89-
MessageOutput.println("[HuaweiCanClass::init] Hardware Interface initialized successfully");
89+
MessageOutput.print("[Huawei::Controller] Hardware Interface initialized successfully\r\n");
9090
}
9191

9292
RectifierParameters_t * Controller::get()
@@ -126,9 +126,12 @@ void Controller::loop()
126126

127127
// Print updated data
128128
if (lastUpdate != _lastUpdateReceivedMillis && verboseLogging) {
129-
MessageOutput.printf("[HuaweiCanClass::loop] In: %.02fV, %.02fA, %.02fW\n", _rp.input_voltage, _rp.input_current, _rp.input_power);
130-
MessageOutput.printf("[HuaweiCanClass::loop] Out: %.02fV, %.02fA of %.02fA, %.02fW\n", _rp.output_voltage, _rp.output_current, _rp.max_output_current, _rp.output_power);
131-
MessageOutput.printf("[HuaweiCanClass::loop] Eff : %.01f%%, Temp in: %.01fC, Temp out: %.01fC\n", _rp.efficiency * 100, _rp.input_temp, _rp.output_temp);
129+
MessageOutput.printf("[Huawei::Controller] In: %.02fV, %.02fA, %.02fW\r\n",
130+
_rp.input_voltage, _rp.input_current, _rp.input_power);
131+
MessageOutput.printf("[Huawei::Controller] Out: %.02fV, %.02fA of %.02fA, %.02fW\r\n",
132+
_rp.output_voltage, _rp.output_current, _rp.max_output_current, _rp.output_power);
133+
MessageOutput.printf("[Huawei::Controller] Eff: %.01f%%, Temp in: %.01f°C, Temp out: %.01f°C\r\n",
134+
_rp.efficiency * 100, _rp.input_temp, _rp.output_temp);
132135
}
133136

134137
// Internal PSU power pin (slot detect) control
@@ -147,7 +150,8 @@ void Controller::loop()
147150

148151
// Set voltage limit in periodic intervals if we're in auto mode or if emergency battery charge is requested.
149152
if ( _nextAutoModePeriodicIntMillis < millis()) {
150-
MessageOutput.printf("[HuaweiCanClass::loop] Periodically setting voltage limit: %f \r\n", config.Huawei.Auto_Power_Voltage_Limit);
153+
MessageOutput.printf("[Huawei::Controller] Periodically setting "
154+
"voltage limit: %f \r\n", config.Huawei.Auto_Power_Voltage_Limit);
151155
_setParameter(config.Huawei.Auto_Power_Voltage_Limit, Setting::OnlineVoltage);
152156
_nextAutoModePeriodicIntMillis = millis() + 60000;
153157
}
@@ -163,7 +167,8 @@ void Controller::loop()
163167
// Set output current
164168
float efficiency = (_rp.efficiency > 0.5 ? _rp.efficiency : 1.0);
165169
float outputCurrent = efficiency * (config.Huawei.Auto_Power_Upper_Power_Limit / _rp.output_voltage);
166-
MessageOutput.printf("[HuaweiCanClass::loop] Emergency Charge Output current %f \r\n", outputCurrent);
170+
MessageOutput.printf("[Huawei::Controller] Emergency Charge Output "
171+
"current %.02f \r\n", outputCurrent);
167172
_setParameter(outputCurrent, Setting::OnlineCurrent);
168173
return;
169174
}
@@ -197,7 +202,7 @@ void Controller::loop()
197202
_setParameter(0.0, Setting::OnlineCurrent);
198203
// Don't run auto mode for a second now. Otherwise we may send too much over the CAN bus
199204
_autoModeBlockedTillMillis = millis() + 1000;
200-
MessageOutput.printf("[HuaweiCanClass::loop] Inverter is active, disable\r\n");
205+
MessageOutput.printf("[Huawei::Controller] Inverter is active, disable PSU\r\n");
201206
return;
202207
}
203208

@@ -216,7 +221,8 @@ void Controller::loop()
216221
newPowerLimit += _rp.output_power + config.Huawei.Auto_Power_Target_Power_Consumption / efficiency;
217222

218223
if (verboseLogging){
219-
MessageOutput.printf("[HuaweiCanClass::loop] newPowerLimit: %f, output_power: %f \r\n", newPowerLimit, _rp.output_power);
224+
MessageOutput.printf("[Huawei::Controller] newPowerLimit: %.0f, "
225+
"output_power: %.01f\r\n", newPowerLimit, _rp.output_power);
220226
}
221227

222228
// Check whether the battery SoC limit setting is enabled
@@ -226,7 +232,7 @@ void Controller::loop()
226232
if (_batterySoC >= config.Huawei.Auto_Power_Stop_BatterySoC_Threshold) {
227233
newPowerLimit = 0;
228234
if (verboseLogging) {
229-
MessageOutput.printf("[HuaweiCanClass::loop] Current battery SoC %i reached "
235+
MessageOutput.printf("[Huawei::Controller] Current battery SoC %i reached "
230236
"stop threshold %i, set newPowerLimit to %f \r\n", _batterySoC,
231237
config.Huawei.Auto_Power_Stop_BatterySoC_Threshold, newPowerLimit);
232238
}
@@ -239,7 +245,9 @@ void Controller::loop()
239245
// and if the PSU should be turned off. Also we use a simple counter mechanism here to be able
240246
// to ramp up from zero output power when starting up
241247
if (_rp.output_power < config.Huawei.Auto_Power_Lower_Power_Limit) {
242-
MessageOutput.printf("[HuaweiCanClass::loop] Power and voltage limit reached. Disabling automatic power control .... \r\n");
248+
MessageOutput.print("[Huawei::Controller] Power and "
249+
"voltage limit reached. Disabling automatic power "
250+
"control.\r\n");
243251
_autoPowerEnabledCounter--;
244252
if (_autoPowerEnabledCounter == 0) {
245253
_autoPowerEnabled = false;
@@ -264,7 +272,11 @@ void Controller::loop()
264272
outputCurrent= outputCurrent > 0 ? outputCurrent : 0;
265273

266274
if (verboseLogging) {
267-
MessageOutput.printf("[HuaweiCanClass::loop] Setting output current to %.2fA. This is the lower value of calculated %.2fA and BMS permissable %.2fA currents\r\n", outputCurrent, calculatedCurrent, permissableCurrent);
275+
MessageOutput.printf("[Huawei::Controller] Setting output "
276+
"current to %.2fA. This is the lower value of "
277+
"calculated %.2fA and BMS permissable %.2fA "
278+
"currents\r\n", outputCurrent, calculatedCurrent,
279+
permissableCurrent);
268280
}
269281
_autoPowerEnabled = true;
270282
_setParameter(outputCurrent, Setting::OnlineCurrent);
@@ -294,7 +306,7 @@ void Controller::_setParameter(float val, HardwareInterface::Setting setting)
294306
if (!_upHardwareInterface) { return; }
295307

296308
if (val < 0) {
297-
MessageOutput.printf("[HuaweiCanClass::_setParameter] Error: Tried to set "
309+
MessageOutput.printf("[Huawei::Controller] Error: Tried to set "
298310
"voltage/current to negative value %.2f\r\n", val);
299311
return;
300312
}
@@ -329,7 +341,9 @@ void Controller::setMode(uint8_t mode) {
329341
auto const& config = Configuration.get();
330342

331343
if (mode == HUAWEI_MODE_AUTO_INT && !config.Huawei.Auto_Power_Enabled ) {
332-
MessageOutput.println("[HuaweiCanClass::setMode] WARNING: Trying to setmode to internal automatic power control without being enabled in the UI. Ignoring command");
344+
MessageOutput.println("[Huawei::Controller] WARNING: Trying to set "
345+
"mode to internal automatic power control without being enabled "
346+
"in the UI. Ignoring command.");
333347
return;
334348
}
335349

0 commit comments

Comments
 (0)