Skip to content

Commit 1feb4f4

Browse files
committed
Fixes for the divertt mode simulator
1 parent e7fd6aa commit 1feb4f4

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

divert_sim/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CPP := g++
2-
CPPFLAGS := -I FakeDuino -I ../src -ggdb -DRAPI_PORT=Console
2+
3+
BASE_ENV = openevse_huzzah32_idf
4+
5+
CPPFLAGS := -I. -I FakeDuino -I ../src -I../.pio/libdeps/$(BASE_ENV)/ArduinoJson/src -I../.pio/libdeps/$(BASE_ENV)/OpenEVSE/src -ggdb -DDIVERT_SIM -DRAPI_PORT=Console
36
#-DENABLE_DEBUG -DDEBUG_PORT=Console
47
LDFLAGS := -pthread
58

divert_sim/divert_sim.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "RapiSender.h"
1212
#include "openevse.h"
1313
#include "divert.h"
14+
#include "emonesp.h"
15+
#include "event.h"
1416

1517
#include "parser.hpp"
1618
#include "cxxopts.hpp"
@@ -34,8 +36,10 @@ time_t simulated_time = 0;
3436
bool kw = false;
3537

3638
extern double smoothed_available_current;
37-
extern double divert_attack_smoothing_factor;
38-
extern double divert_decay_smoothing_factor;
39+
double divert_attack_smoothing_factor = 0.4;
40+
double divert_decay_smoothing_factor = 0.05;
41+
uint32_t divert_min_charge_time = (10 * 60);
42+
double voltage = DEFAULT_VOLTAGE; // Voltage from OpenEVSE or MQTT
3943

4044
time_t parse_date(const char *dateStr)
4145
{
@@ -89,7 +93,7 @@ int get_watt(const char *val)
8993
time_t divertmode_get_time()
9094
{
9195
return simulated_time;
92-
}
96+
}
9397

9498
int main(int argc, char** argv)
9599
{
@@ -142,12 +146,12 @@ int main(int argc, char** argv)
142146
CsvParser parser(std::cin);
143147
parser.delimiter(sep.c_str()[0]);
144148
int row_number = 0;
145-
149+
146150
std::cout << "Date,Solar,Grid IE,Pilot,Charge Power,Min Charge Power,State,Smoothed Available" << std::endl;
147151
for (auto& row : parser)
148152
{
149153
try
150-
{
154+
{
151155
int col = 0;
152156
std::string val;
153157

@@ -192,3 +196,7 @@ int main(int argc, char** argv)
192196
void event_send(String event)
193197
{
194198
}
199+
200+
void event_send(JsonDocument &event)
201+
{
202+
}

0 commit comments

Comments
 (0)