Skip to content

Commit

Permalink
Merge pull request #4 from tbnobody/master
Browse files Browse the repository at this point in the history
merge v23.8.8
  • Loading branch information
AloisKlingler authored Aug 9, 2023
2 parents 99100b7 + b71106c commit 423b33e
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 117 deletions.
6 changes: 2 additions & 4 deletions include/Datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#pragma once

#include <TimeoutHelper.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <mutex>

class DatastoreClass {
public:
DatastoreClass();
void init();
void loop();

Expand Down Expand Up @@ -61,7 +59,7 @@ class DatastoreClass {

private:
TimeoutHelper _updateTimeout;
SemaphoreHandle_t _xSemaphore;
std::mutex _mutex;

float _totalAcYieldTotalEnabled = 0;
float _totalAcYieldDayEnabled = 0;
Expand Down
3 changes: 1 addition & 2 deletions lib/Hoymiles/src/HoymilesRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class HoymilesRadio {
bool isQueueEmpty();
bool isInitialized();

template <typename T>
void enqueCommand(std::shared_ptr<T> cmd)
void enqueCommand(std::shared_ptr<CommandAbstract> cmd)
{
_commandQueue.push(cmd);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Hoymiles/src/inverters/HM_Abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ bool HM_Abstract::sendAlarmLogRequest(bool force)
auto cmd = _radio->prepareCommand<AlarmDataCommand>();
cmd->setTime(now);
cmd->setTargetAddress(serial());
_radio->enqueCommand(cmd);
EventLog()->setLastAlarmRequestSuccess(CMD_PENDING);
_radio->enqueCommand(cmd);

return true;
}
Expand Down Expand Up @@ -114,8 +114,8 @@ bool HM_Abstract::sendSystemConfigParaRequest()
auto cmd = _radio->prepareCommand<SystemConfigParaCommand>();
cmd->setTime(now);
cmd->setTargetAddress(serial());
_radio->enqueCommand(cmd);
SystemConfigPara()->setLastLimitRequestSuccess(CMD_PENDING);
_radio->enqueCommand(cmd);

return true;
}
Expand All @@ -136,8 +136,8 @@ bool HM_Abstract::sendActivePowerControlRequest(float limit, PowerLimitControlTy
auto cmd = _radio->prepareCommand<ActivePowerControlCommand>();
cmd->setActivePowerLimit(limit, type);
cmd->setTargetAddress(serial());
_radio->enqueCommand(cmd);
SystemConfigPara()->setLastLimitCommandSuccess(CMD_PENDING);
_radio->enqueCommand(cmd);

return true;
}
Expand All @@ -162,8 +162,8 @@ bool HM_Abstract::sendPowerControlRequest(bool turnOn)
auto cmd = _radio->prepareCommand<PowerControlCommand>();
cmd->setPowerOn(turnOn);
cmd->setTargetAddress(serial());
_radio->enqueCommand(cmd);
PowerCommand()->setLastPowerCommandSuccess(CMD_PENDING);
_radio->enqueCommand(cmd);

return true;
}
Expand All @@ -179,8 +179,8 @@ bool HM_Abstract::sendRestartControlRequest()
auto cmd = _radio->prepareCommand<PowerControlCommand>();
cmd->setRestart();
cmd->setTargetAddress(serial());
_radio->enqueCommand(cmd);
PowerCommand()->setLastPowerCommandSuccess(CMD_PENDING);
_radio->enqueCommand(cmd);

return true;
}
Expand Down
111 changes: 33 additions & 78 deletions src/Datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@
#include "Configuration.h"
#include <Hoymiles.h>

#define DAT_SEMAPHORE_TAKE() \
do { \
} while (xSemaphoreTake(_xSemaphore, portMAX_DELAY) != pdPASS)
#define DAT_SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore)

DatastoreClass Datastore;

DatastoreClass::DatastoreClass()
{
_xSemaphore = xSemaphoreCreateMutex();
DAT_SEMAPHORE_GIVE(); // release before first use
}

void DatastoreClass::init()
{
_updateTimeout.set(1000);
Expand All @@ -32,7 +21,7 @@ void DatastoreClass::loop()
uint8_t isReachable = 0;
uint8_t pollEnabledCount = 0;

DAT_SEMAPHORE_TAKE();
std::lock_guard<std::mutex> lock(_mutex);

_totalAcYieldTotalEnabled = 0;
_totalAcYieldTotalDigits = 0;
Expand Down Expand Up @@ -116,136 +105,102 @@ void DatastoreClass::loop()

_totalDcIrradiation = _totalDcIrradiationInstalled > 0 ? _totalDcPowerIrradiation / _totalDcIrradiationInstalled * 100.0f : 0;

DAT_SEMAPHORE_GIVE();

_updateTimeout.reset();
}
}

float DatastoreClass::getTotalAcYieldTotalEnabled()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalAcYieldTotalEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldTotalEnabled;
}

float DatastoreClass::getTotalAcYieldDayEnabled()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalAcYieldDayEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldDayEnabled;
}

float DatastoreClass::getTotalAcPowerEnabled()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalAcPowerEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcPowerEnabled;
}

float DatastoreClass::getTotalDcPowerEnabled()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalDcPowerEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalDcPowerEnabled;
}

float DatastoreClass::getTotalDcPowerIrradiation()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalDcPowerIrradiation;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalDcPowerIrradiation;
}

float DatastoreClass::getTotalDcIrradiationInstalled()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalDcIrradiationInstalled;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalDcIrradiationInstalled;
}

float DatastoreClass::getTotalDcIrradiation()
{
DAT_SEMAPHORE_TAKE();
float retval = _totalDcIrradiation;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalDcIrradiation;
}

unsigned int DatastoreClass::getTotalAcYieldTotalDigits()
{
DAT_SEMAPHORE_TAKE();
unsigned int retval = _totalAcYieldTotalDigits;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldTotalDigits;
}

unsigned int DatastoreClass::getTotalAcYieldDayDigits()
{
DAT_SEMAPHORE_TAKE();
unsigned int retval = _totalAcYieldDayDigits;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldDayDigits;
}

unsigned int DatastoreClass::getTotalAcPowerDigits()
{
DAT_SEMAPHORE_TAKE();
unsigned int retval = _totalAcPowerDigits;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcPowerDigits;
}

unsigned int DatastoreClass::getTotalDcPowerDigits()
{
DAT_SEMAPHORE_TAKE();
unsigned int retval = _totalDcPowerDigits;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _totalDcPowerDigits;
}

bool DatastoreClass::getIsAtLeastOneReachable()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAtLeastOneReachable;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _isAtLeastOneReachable;
}

bool DatastoreClass::getIsAtLeastOneProducing()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAtLeastOneProducing;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _isAtLeastOneProducing;
}

bool DatastoreClass::getIsAllEnabledProducing()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAllEnabledProducing;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _isAllEnabledProducing;
}

bool DatastoreClass::getIsAllEnabledReachable()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAllEnabledReachable;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _isAllEnabledReachable;
}

bool DatastoreClass::getIsAtLeastOnePollEnabled()
{
DAT_SEMAPHORE_TAKE();
bool retval = _isAtLeastOnePollEnabled;
DAT_SEMAPHORE_GIVE();
return retval;
std::lock_guard<std::mutex> lock(_mutex);
return _isAtLeastOnePollEnabled;
}
8 changes: 4 additions & 4 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
},
"devDependencies": {
"@intlify/unplugin-vue-i18n": "^0.12.2",
"@rushstack/eslint-patch": "^1.3.2",
"@rushstack/eslint-patch": "^1.3.3",
"@tsconfig/node18": "^18.2.0",
"@types/bootstrap": "^5.2.6",
"@types/node": "^20.4.6",
"@types/node": "^20.4.8",
"@types/sortablejs": "^1.15.1",
"@types/spark-md5": "^3.0.2",
"@vitejs/plugin-vue": "^4.2.3",
Expand All @@ -38,9 +38,9 @@
"sass": "^1.64.2",
"terser": "^5.19.2",
"typescript": "^5.1.6",
"vite": "^4.4.8",
"vite": "^4.4.9",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^3.2.1",
"vite-plugin-css-injected-by-js": "^3.3.0",
"vue-tsc": "^1.8.8"
}
}
6 changes: 5 additions & 1 deletion webapp/src/components/BootstrapAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export default defineComponent({
_countDownTimeout = undefined;
};
const countDown = ref(parseCountDown(props.modelValue));
var countDown = ref();
watch(() => props.modelValue, () => {
countDown.value = parseCountDown(props.modelValue);
});
const isAlertVisible = computed(() => props.modelValue || props.show);
onBeforeUnmount(() => {
Expand Down
Loading

0 comments on commit 423b33e

Please sign in to comment.