Skip to content

Commit

Permalink
Default event hours per PG&E EV-A schedule. First 2 for weekdays off …
Browse files Browse the repository at this point in the history
…peak (go/stop),

3rd for weekend (go) and peak any day (stop). So on weedays, if manually unpaused during partial peak,
will pause again on full peak start.
  • Loading branch information
dlyubimov committed Jul 1, 2017
1 parent f6d25f2 commit 9d54c85
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
12 changes: 11 additions & 1 deletion Hydra_EVSE/Hydra_EVSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define SW_VERSION "2.4.1-dev"

// Define this for the basic unit tests run in a generica arduino uno board with a display shield.
//#define UNIT_TESTS
#define UNIT_TESTS

#define UINT_BITS (sizeof(unsigned int) << 3)
#define ULONG_BITS (sizeof(unsigned long) << 3)
Expand Down Expand Up @@ -476,6 +476,16 @@ extern persisted_struct persisted;
extern void Delay(unsigned int);
extern void displayStatus(unsigned int status);
extern char errLetter(unsigned int status);
extern boolean &enable_dst;
extern Timezone dst;


///////////////////////////////////////////////////////////
// Inline declarations
static inline time_t localTime()
{
return enable_dst ? dst.toLocal(now()) : now();
}


#endif // ___HYDRA_EVSE_H___
24 changes: 18 additions & 6 deletions Hydra_EVSE/Hydra_EVSE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,26 @@ void persisted_struct::reset()
signature = PERSIST_SIG;
operatingMode = MODE_SHARED;
max_amps = currentMenuChoices[0];
enable_dst = false;

// By default, use the time zone for schedule.
enable_dst = true;
rtc_cal = 0;
for (int i = 0; i < EVENT_COUNT; i++) events[i].reset();

// Set up events hours according to PGE EV-A TOU schedule:
// Weekends off peak 7pm to 3 pm; no partial peak.
// The idea is to pause for peak on any day and for partial and full peak on weekdays
// (so on weekdays, if unpaused manually for partial peak, will pause again for full peak).
unsigned char weekdays = -1u >> (sizeof(int) << 3) - 5 << 1;

// Pause any day at 7am and resume at 11pm on weekdays.
events[0].dow_mask = events[1].dow_mask = weekdays;
events[0].hour = 23; events[1].hour = 7;

// Weekends: start at 7pm and pause (any day) on 3pm
events[2].dow_mask = ~weekdays; events[2].hour = 19;
events[3].dow_mask = -1u; events[3].hour = 15;

calib.reset();
}

Expand Down Expand Up @@ -1109,11 +1126,6 @@ static void gfiSelfTest()
gfiTriggered = false;
}

static inline time_t localTime()
{
return enable_dst ? dst.toLocal(now()) : now();
}

void doClockMenu(boolean initialize)
{
unsigned int event = checkEvent();
Expand Down
31 changes: 16 additions & 15 deletions Hydra_EVSE/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ static void testEepromSetup() {
}


static void testDS(char* desc, unsigned int status) {
static void showDS(char* desc, unsigned int status) {
display.clear();
display.print (desc);
displayStatus(status);
Delay(3000);
Delay(1000);
}

void testDisplayStatus() {
testDS(P("A&B UNPL"), BOTH | STATUS_UNPLUGGED);
testDS(P("A&B off"), BOTH | STATUS_OFF);
testDS(P("B off tie"), CAR_B | STATUS_OFF | STATUS_TIEBREAK);
testDS(P("A off tie"), CAR_A | STATUS_OFF | STATUS_TIEBREAK);
testDS(P("A&B on"), BOTH | STATUS_ON);
testDS(P("A&B done"), BOTH | STATUS_DONE);
testDS(P("A&B wait"), BOTH | STATUS_WAIT);
showDS(P("A&B UNPL"), BOTH | STATUS_UNPLUGGED);
showDS(P("A&B off"), BOTH | STATUS_OFF);
showDS(P("B off tie"), CAR_B | STATUS_OFF | STATUS_TIEBREAK);
showDS(P("A off tie"), CAR_A | STATUS_OFF | STATUS_TIEBREAK);
showDS(P("A&B on"), BOTH | STATUS_ON);
showDS(P("A&B done"), BOTH | STATUS_DONE);
showDS(P("A&B wait"), BOTH | STATUS_WAIT);

char* msg = P("incorrect letter %c UNIT FAIL");
if ( 'F' != errLetter(BOTH | STATUS_ERR | STATUS_ERR_F) )
Expand All @@ -85,12 +85,12 @@ void testDisplayStatus() {
if ( 'E' != errLetter(BOTH | STATUS_ERR | STATUS_ERR_E) )
logInfo(msg, 'E');

testDS(P("A&B ERR G"), BOTH | STATUS_ERR | STATUS_ERR_G);
testDS(P("A&B ERR F"), BOTH | STATUS_ERR | STATUS_ERR_F);
testDS(P("A&B ERR T"), BOTH | STATUS_ERR | STATUS_ERR_T);
testDS(P("A&B ERR O"), BOTH | STATUS_ERR | STATUS_ERR_O);
testDS(P("A&B ERR E"), BOTH | STATUS_ERR | STATUS_ERR_E);
testDS(P("A&B ERR R"), BOTH | STATUS_ERR | STATUS_ERR_R);
showDS(P("A&B ERR G"), BOTH | STATUS_ERR | STATUS_ERR_G);
showDS(P("A&B ERR F"), BOTH | STATUS_ERR | STATUS_ERR_F);
showDS(P("A&B ERR T"), BOTH | STATUS_ERR | STATUS_ERR_T);
showDS(P("A&B ERR O"), BOTH | STATUS_ERR | STATUS_ERR_O);
showDS(P("A&B ERR E"), BOTH | STATUS_ERR | STATUS_ERR_E);
showDS(P("A&B ERR R"), BOTH | STATUS_ERR | STATUS_ERR_R);


}
Expand All @@ -103,6 +103,7 @@ static void testMenuSetup() {


int unitsSetup() {

testEepromSetup();
testDisplayStatus();
testMenuSetup();
Expand Down

0 comments on commit 9d54c85

Please sign in to comment.