mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-09 06:01:37 +02:00
Redesign Statemachine
This commit is contained in:
parent
589b798f4d
commit
5afc97f7f8
4 changed files with 626 additions and 560 deletions
|
@ -235,7 +235,7 @@ void app::regularTickers(void) {
|
|||
|
||||
// Plugin ZeroExport
|
||||
#if defined(PLUGIN_ZEROEXPORT)
|
||||
everySec(std::bind(&ZeroExportType::tickerSecond, &mZeroExport), "ZeroExport");
|
||||
everySec(std::bind(&ZeroExportType::tickSecond, &mZeroExport), "ZeroExport");
|
||||
#endif
|
||||
// Plugin ZeroExport - Ende
|
||||
|
||||
|
@ -423,6 +423,10 @@ void app::tickMinute(void) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::tickMidnight(void) {
|
||||
#if defined(PLUGIN_ZEROEXPORT)
|
||||
mZeroExport.tickMidnight();
|
||||
#endif /*defined(PLUGIN_ZEROEXPORT)*/
|
||||
|
||||
uint32_t localTime = gTimezone.toLocal(mTimestamp);
|
||||
uint32_t nxtTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time
|
||||
onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2");
|
||||
|
|
|
@ -204,7 +204,6 @@ typedef struct {
|
|||
enum class zeroExportState : uint8_t {
|
||||
INIT,
|
||||
WAIT,
|
||||
PUBLISH,
|
||||
WAITREFRESH,
|
||||
GETINVERTERACKS,
|
||||
GETINVERTERDATA,
|
||||
|
@ -213,9 +212,11 @@ enum class zeroExportState : uint8_t {
|
|||
CONTROLLER,
|
||||
PROGNOSE,
|
||||
AUFTEILEN,
|
||||
SETLIMIT,
|
||||
SETPOWER,
|
||||
SETREBOOT,
|
||||
SETPOWER,
|
||||
SETLIMIT,
|
||||
PUBLISH,
|
||||
EMERGENCY,
|
||||
FINISH,
|
||||
ERROR
|
||||
};
|
||||
|
@ -271,6 +272,9 @@ typedef struct {
|
|||
unsigned long limitTsp;
|
||||
float dcVoltage;
|
||||
bool state;
|
||||
//
|
||||
bool doReboot;
|
||||
int8_t doPower;
|
||||
} zeroExportGroupInverter_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -296,12 +300,11 @@ typedef struct {
|
|||
uint16_t powerMax;
|
||||
//
|
||||
|
||||
zeroExportState stateLast;
|
||||
zeroExportState state;
|
||||
zeroExportState stateNext;
|
||||
unsigned long lastRun;
|
||||
unsigned long lastRefresh;
|
||||
// bool waitForAck;
|
||||
uint16_t sleep;
|
||||
|
||||
float eSum;
|
||||
float eSum1;
|
||||
|
@ -315,12 +318,12 @@ typedef struct {
|
|||
float Ki;
|
||||
float Kd;
|
||||
|
||||
float pm_P[5];
|
||||
float pm_P1[5];
|
||||
float pm_P2[5];
|
||||
float pm_P3[5];
|
||||
uint8_t pm_iIn = 0;
|
||||
uint8_t pm_iOut = 0;
|
||||
//float pm_P[5];
|
||||
//float pm_P1[5];
|
||||
//float pm_P2[5];
|
||||
//float pm_P3[5];
|
||||
//uint8_t pm_iIn = 0;
|
||||
//uint8_t pm_iOut = 0;
|
||||
|
||||
float pmPower;
|
||||
float pmPowerL1;
|
||||
|
@ -699,6 +702,8 @@ class settings {
|
|||
mCfg.plugin.zeroExport.groups[group].inverters[inv].waitLimitAck = false;
|
||||
mCfg.plugin.zeroExport.groups[group].inverters[inv].waitPowerAck = false;
|
||||
mCfg.plugin.zeroExport.groups[group].inverters[inv].waitRebootAck = false;
|
||||
mCfg.plugin.zeroExport.groups[group].inverters[inv].doReboot = false;
|
||||
mCfg.plugin.zeroExport.groups[group].inverters[inv].doPower = -1;
|
||||
}
|
||||
// Battery
|
||||
mCfg.plugin.zeroExport.groups[group].battEnabled = false;
|
||||
|
@ -716,6 +721,7 @@ class settings {
|
|||
mCfg.plugin.zeroExport.groups[group].state = zeroExportState::INIT;
|
||||
mCfg.plugin.zeroExport.groups[group].lastRun = 0;
|
||||
mCfg.plugin.zeroExport.groups[group].lastRefresh = 0;
|
||||
mCfg.plugin.zeroExport.groups[group].sleep = 0;
|
||||
mCfg.plugin.zeroExport.groups[group].pmPower = 0;
|
||||
mCfg.plugin.zeroExport.groups[group].pmPowerL1 = 0;
|
||||
mCfg.plugin.zeroExport.groups[group].pmPowerL2 = 0;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1158,7 +1158,6 @@ class RestApi {
|
|||
mConfig->plugin.zeroExport.groups[group].Ki = jsonIn[F("Ki")];
|
||||
mConfig->plugin.zeroExport.groups[group].Kd = jsonIn[F("Kd")];
|
||||
// Global
|
||||
mConfig->plugin.zeroExport.groups[group].stateLast = zeroExportState::INIT;
|
||||
mConfig->plugin.zeroExport.groups[group].state = zeroExportState::INIT;
|
||||
mConfig->plugin.zeroExport.groups[group].stateNext = zeroExportState::INIT;
|
||||
mApp->saveSettings(false); // without reboot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue