Merge remote-tracking branch 'tbnobody/OpenDTU/master' into development
This commit is contained in:
commit
21bbed9b8e
@ -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();
|
||||
|
||||
@ -61,7 +59,7 @@ public:
|
||||
|
||||
private:
|
||||
TimeoutHelper _updateTimeout;
|
||||
SemaphoreHandle_t _xSemaphore;
|
||||
std::mutex _mutex;
|
||||
|
||||
float _totalAcYieldTotalEnabled = 0;
|
||||
float _totalAcYieldDayEnabled = 0;
|
||||
|
||||
@ -16,8 +16,7 @@ public:
|
||||
bool isQueueEmpty();
|
||||
bool isInitialized();
|
||||
|
||||
template <typename T>
|
||||
void enqueCommand(std::shared_ptr<T> cmd)
|
||||
void enqueCommand(std::shared_ptr<CommandAbstract> cmd)
|
||||
{
|
||||
_commandQueue.push(cmd);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -140,8 +140,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;
|
||||
}
|
||||
@ -170,8 +170,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;
|
||||
}
|
||||
@ -187,8 +187,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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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",
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(() => {
|
||||
|
||||
@ -355,10 +355,10 @@
|
||||
estree-walker "^2.0.2"
|
||||
picomatch "^2.3.1"
|
||||
|
||||
"@rushstack/eslint-patch@^1.3.2":
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.3.2.tgz#31b9c510d8cada9683549e1dbb4284cca5001faf"
|
||||
integrity sha512-V+MvGwaHH03hYhY+k6Ef/xKd6RYlc4q8WBx+2ANmipHJcKuktNcI/NgEsJgdSUF6Lw32njT6OnrRsKYCdgHjYw==
|
||||
"@rushstack/eslint-patch@^1.3.3":
|
||||
version "1.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.3.3.tgz#16ab6c727d8c2020a5b6e4a176a243ecd88d8d69"
|
||||
integrity sha512-0xd7qez0AQ+MbHatZTlI1gu5vkG8r7MYRUJAHPAHJBmGLs16zpkrpAVLvjQKQOqaXPDUBwOiJzNc00znHSCVBw==
|
||||
|
||||
"@tsconfig/node18@^18.2.0":
|
||||
version "18.2.0"
|
||||
@ -382,10 +382,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
|
||||
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
|
||||
|
||||
"@types/node@^20.4.6":
|
||||
version "20.4.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.6.tgz#b66b66c9bb5d49b199f03399e341c9d6036e9e88"
|
||||
integrity sha512-q0RkvNgMweWWIvSMDiXhflGUKMdIxBo2M2tYM/0kEGDueQByFzK4KZAgu5YHGFNxziTlppNpTIBcqHQAxlfHdA==
|
||||
"@types/node@^20.4.8":
|
||||
version "20.4.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.8.tgz#b5dda19adaa473a9bf0ab5cbd8f30ec7d43f5c85"
|
||||
integrity sha512-0mHckf6D2DiIAzh8fM8f3HQCvMKDpK94YQ0DSVkfWTG9BZleYIWudw9cJxX8oCk9bM+vAkDyujDV6dmKHbvQpg==
|
||||
|
||||
"@types/semver@^7.3.12":
|
||||
version "7.3.13"
|
||||
@ -2108,7 +2108,7 @@ postcss@^8.1.10:
|
||||
picocolors "^1.0.0"
|
||||
source-map-js "^1.0.2"
|
||||
|
||||
postcss@^8.4.26:
|
||||
postcss@^8.4.27:
|
||||
version "8.4.27"
|
||||
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.27.tgz#234d7e4b72e34ba5a92c29636734349e0d9c3057"
|
||||
integrity sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==
|
||||
@ -2188,10 +2188,10 @@ rimraf@^3.0.2:
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rollup@^3.25.2:
|
||||
version "3.26.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.26.2.tgz#2e76a37606cb523fc9fef43e6f59c93f86d95e7c"
|
||||
integrity sha512-6umBIGVz93er97pMgQO08LuH3m6PUb3jlDUUGFsNJB6VgTCUaDFpupf5JfU30529m/UKOgmiX+uY6Sx8cOYpLA==
|
||||
rollup@^3.27.1:
|
||||
version "3.27.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.27.2.tgz#59adc973504408289be89e5978e938ce852c9520"
|
||||
integrity sha512-YGwmHf7h2oUHkVBT248x0yt6vZkYQ3/rvE5iQuVBh3WO8GcJ6BNeOkpoX1yMHIiBm18EMLjBPIoUDkhgnyxGOQ==
|
||||
optionalDependencies:
|
||||
fsevents "~2.3.2"
|
||||
|
||||
@ -2533,19 +2533,19 @@ vite-plugin-compression@^0.5.1:
|
||||
debug "^4.3.3"
|
||||
fs-extra "^10.0.0"
|
||||
|
||||
vite-plugin-css-injected-by-js@^3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-css-injected-by-js/-/vite-plugin-css-injected-by-js-3.2.1.tgz#c23e10e28a1afb78414fa3c162ac8a253cd1a6a4"
|
||||
integrity sha512-8UQWy7tcmgwkaUKYfbj/8GOeAD0RPG2tdetAGg7WikWC8IEtNrovs8RRuLjFqdRqORT1XxchBB5tPl6xO/H95g==
|
||||
vite-plugin-css-injected-by-js@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-css-injected-by-js/-/vite-plugin-css-injected-by-js-3.3.0.tgz#c19480a9e42a95c5bced976a9dde1446f9bd91ff"
|
||||
integrity sha512-xG+jyHNCmUqi/TXp6q88wTJGeAOrNLSyUUTp4qEQ9QZLGcHWQQsCsSSKa59rPMQr8sOzfzmWDd8enGqfH/dBew==
|
||||
|
||||
vite@^4.4.8:
|
||||
version "4.4.8"
|
||||
resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.8.tgz#31e4a438f8748695c68bd57ffd262ba93540fdf7"
|
||||
integrity sha512-LONawOUUjxQridNWGQlNizfKH89qPigK36XhMI7COMGztz8KNY0JHim7/xDd71CZwGT4HtSRgI7Hy+RlhG0Gvg==
|
||||
vite@^4.4.9:
|
||||
version "4.4.9"
|
||||
resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.9.tgz#1402423f1a2f8d66fd8d15e351127c7236d29d3d"
|
||||
integrity sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==
|
||||
dependencies:
|
||||
esbuild "^0.18.10"
|
||||
postcss "^8.4.26"
|
||||
rollup "^3.25.2"
|
||||
postcss "^8.4.27"
|
||||
rollup "^3.27.1"
|
||||
optionalDependencies:
|
||||
fsevents "~2.3.2"
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user