mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-09 14:11:39 +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
|
// Plugin ZeroExport
|
||||||
#if defined(PLUGIN_ZEROEXPORT)
|
#if defined(PLUGIN_ZEROEXPORT)
|
||||||
everySec(std::bind(&ZeroExportType::tickerSecond, &mZeroExport), "ZeroExport");
|
everySec(std::bind(&ZeroExportType::tickSecond, &mZeroExport), "ZeroExport");
|
||||||
#endif
|
#endif
|
||||||
// Plugin ZeroExport - Ende
|
// Plugin ZeroExport - Ende
|
||||||
|
|
||||||
|
@ -423,6 +423,10 @@ void app::tickMinute(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::tickMidnight(void) {
|
void app::tickMidnight(void) {
|
||||||
|
#if defined(PLUGIN_ZEROEXPORT)
|
||||||
|
mZeroExport.tickMidnight();
|
||||||
|
#endif /*defined(PLUGIN_ZEROEXPORT)*/
|
||||||
|
|
||||||
uint32_t localTime = gTimezone.toLocal(mTimestamp);
|
uint32_t localTime = gTimezone.toLocal(mTimestamp);
|
||||||
uint32_t nxtTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time
|
uint32_t nxtTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time
|
||||||
onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2");
|
onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2");
|
||||||
|
|
|
@ -204,7 +204,6 @@ typedef struct {
|
||||||
enum class zeroExportState : uint8_t {
|
enum class zeroExportState : uint8_t {
|
||||||
INIT,
|
INIT,
|
||||||
WAIT,
|
WAIT,
|
||||||
PUBLISH,
|
|
||||||
WAITREFRESH,
|
WAITREFRESH,
|
||||||
GETINVERTERACKS,
|
GETINVERTERACKS,
|
||||||
GETINVERTERDATA,
|
GETINVERTERDATA,
|
||||||
|
@ -213,9 +212,11 @@ enum class zeroExportState : uint8_t {
|
||||||
CONTROLLER,
|
CONTROLLER,
|
||||||
PROGNOSE,
|
PROGNOSE,
|
||||||
AUFTEILEN,
|
AUFTEILEN,
|
||||||
SETLIMIT,
|
|
||||||
SETPOWER,
|
|
||||||
SETREBOOT,
|
SETREBOOT,
|
||||||
|
SETPOWER,
|
||||||
|
SETLIMIT,
|
||||||
|
PUBLISH,
|
||||||
|
EMERGENCY,
|
||||||
FINISH,
|
FINISH,
|
||||||
ERROR
|
ERROR
|
||||||
};
|
};
|
||||||
|
@ -271,6 +272,9 @@ typedef struct {
|
||||||
unsigned long limitTsp;
|
unsigned long limitTsp;
|
||||||
float dcVoltage;
|
float dcVoltage;
|
||||||
bool state;
|
bool state;
|
||||||
|
//
|
||||||
|
bool doReboot;
|
||||||
|
int8_t doPower;
|
||||||
} zeroExportGroupInverter_t;
|
} zeroExportGroupInverter_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -296,12 +300,11 @@ typedef struct {
|
||||||
uint16_t powerMax;
|
uint16_t powerMax;
|
||||||
//
|
//
|
||||||
|
|
||||||
zeroExportState stateLast;
|
|
||||||
zeroExportState state;
|
zeroExportState state;
|
||||||
zeroExportState stateNext;
|
zeroExportState stateNext;
|
||||||
unsigned long lastRun;
|
unsigned long lastRun;
|
||||||
unsigned long lastRefresh;
|
unsigned long lastRefresh;
|
||||||
// bool waitForAck;
|
uint16_t sleep;
|
||||||
|
|
||||||
float eSum;
|
float eSum;
|
||||||
float eSum1;
|
float eSum1;
|
||||||
|
@ -315,12 +318,12 @@ typedef struct {
|
||||||
float Ki;
|
float Ki;
|
||||||
float Kd;
|
float Kd;
|
||||||
|
|
||||||
float pm_P[5];
|
//float pm_P[5];
|
||||||
float pm_P1[5];
|
//float pm_P1[5];
|
||||||
float pm_P2[5];
|
//float pm_P2[5];
|
||||||
float pm_P3[5];
|
//float pm_P3[5];
|
||||||
uint8_t pm_iIn = 0;
|
//uint8_t pm_iIn = 0;
|
||||||
uint8_t pm_iOut = 0;
|
//uint8_t pm_iOut = 0;
|
||||||
|
|
||||||
float pmPower;
|
float pmPower;
|
||||||
float pmPowerL1;
|
float pmPowerL1;
|
||||||
|
@ -699,6 +702,8 @@ class settings {
|
||||||
mCfg.plugin.zeroExport.groups[group].inverters[inv].waitLimitAck = false;
|
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].waitPowerAck = false;
|
||||||
mCfg.plugin.zeroExport.groups[group].inverters[inv].waitRebootAck = 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
|
// Battery
|
||||||
mCfg.plugin.zeroExport.groups[group].battEnabled = false;
|
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].state = zeroExportState::INIT;
|
||||||
mCfg.plugin.zeroExport.groups[group].lastRun = 0;
|
mCfg.plugin.zeroExport.groups[group].lastRun = 0;
|
||||||
mCfg.plugin.zeroExport.groups[group].lastRefresh = 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].pmPower = 0;
|
||||||
mCfg.plugin.zeroExport.groups[group].pmPowerL1 = 0;
|
mCfg.plugin.zeroExport.groups[group].pmPowerL1 = 0;
|
||||||
mCfg.plugin.zeroExport.groups[group].pmPowerL2 = 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].Ki = jsonIn[F("Ki")];
|
||||||
mConfig->plugin.zeroExport.groups[group].Kd = jsonIn[F("Kd")];
|
mConfig->plugin.zeroExport.groups[group].Kd = jsonIn[F("Kd")];
|
||||||
// Global
|
// Global
|
||||||
mConfig->plugin.zeroExport.groups[group].stateLast = zeroExportState::INIT;
|
|
||||||
mConfig->plugin.zeroExport.groups[group].state = zeroExportState::INIT;
|
mConfig->plugin.zeroExport.groups[group].state = zeroExportState::INIT;
|
||||||
mConfig->plugin.zeroExport.groups[group].stateNext = zeroExportState::INIT;
|
mConfig->plugin.zeroExport.groups[group].stateNext = zeroExportState::INIT;
|
||||||
mApp->saveSettings(false); // without reboot
|
mApp->saveSettings(false); // without reboot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue