LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
out_sprinkler.h
Go to the documentation of this file.
1
2#pragma once
3#include "options.h"
4#ifdef SPRINKLER_ENABLE
5
6#include <abstractout.h>
7#include <item.h>
8
10#define DRENAGE_ON_TIME 10000
12#define VIN_MAX_TIME 1200000UL
14#define DRENAGE_MAX_TIME 4000000UL
15
17#define LASTWCTRLSTATE 1
18#define LASTWCTRLSTATE_ALL 2
19#define LASTWMAXSTATE 4
20#define LASTWMINSTATE 8
21#define LASTFBDRENSTATE 16
22#define LASTFBPUMPSTATE 32
23#define LASTPUMPSTATE 64
24#define LASTDRENSTATE 128
25#define LASTVINSTATE 256
26#define LASTFAULTSTATE 512
27#define LASTSTATE_MASK 0x3FF
28#define LASTSTATE_INVALID 1024
29
33enum sprinklerState {
34 SP_UNKNOWN = 0,
35 SP_OFF = 1,
36 SP_DREN_ON = 2,
37 SP_DREN_OPERATE = 3,
38 SP_DREN_EMPTY = 4,
39 SP_VIN = 5,
40 SP_FULL = 6,
41 SP_DRYING = 7,
42 SP_FAULT_VIN = -1,
43 SP_FAULT_DREN = -2
44};
45
89class out_sprinkler : public abstractOut {
90public:
91
92 //out_sprinkler(){ /*NO getConfig() here due Poll() optimization*/ };
94 bool getConfig();
96 void link(Item * _item){abstractOut::link(_item); if (_item) getConfig();};
98 int Setup() override;
100 int Poll(short cause) override;
102 int Stop() override;
103 //int Status() override;
105 int getChanType() override;
107 int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
108
109protected:
110 aJsonObject * gatesObj;
111 short vinPin, drenPin, pumpPin;
112 short wMaxPin, wMinPin, fbDrenPin, fbPumpPin, wCtrPin;
113
114
116 void pump(bool state);
118 void dren(bool state);
120 void vin(bool state);
122 void setOutput(short pin, bool value);
124 bool isNeedPump(bool steelNeed=false);
126 void turnOffValves();
128 void turnOffAllZones();
130 aJsonObject * getZone(const char * name);
132 aJsonObject * findNextZone();
134 void setZoneActive(aJsonObject * zone, bool active);
136 void updateZoneValue(aJsonObject * zone, long value);
138 bool publishBooleanState(const char * subItem, bool state);
140 void publishNumericState(const char * subItem, long value);
142 bool publishBooleanStateIfChanged(const char * subItem, bool state, uint32_t flag, uint32_t & lastState, bool forcePublish=false);
144 bool isFreeze();
146 void notifyState(short state);
148 int moveToState(sprinklerState nextState);
150 void updateCounterValue();
152 void getAndNotifyStatus();
153};
154#endif
Base class of output driver modules (one per channel type).
Definition abstractout.h:19
virtual void link(Item *_item)
Definition abstractout.h:24
Item (virtual channel) system of LightHub.