Skip to content

Commit

Permalink
Fixes for the divertt mode simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremypoulter committed Jul 9, 2020
1 parent e7fd6aa commit 1feb4f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion divert_sim/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CPP := g++
CPPFLAGS := -I FakeDuino -I ../src -ggdb -DRAPI_PORT=Console

BASE_ENV = openevse_huzzah32_idf

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
#-DENABLE_DEBUG -DDEBUG_PORT=Console
LDFLAGS := -pthread

Expand Down
18 changes: 13 additions & 5 deletions divert_sim/divert_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "RapiSender.h"
#include "openevse.h"
#include "divert.h"
#include "emonesp.h"
#include "event.h"

#include "parser.hpp"
#include "cxxopts.hpp"
Expand All @@ -34,8 +36,10 @@ time_t simulated_time = 0;
bool kw = false;

extern double smoothed_available_current;
extern double divert_attack_smoothing_factor;
extern double divert_decay_smoothing_factor;
double divert_attack_smoothing_factor = 0.4;
double divert_decay_smoothing_factor = 0.05;
uint32_t divert_min_charge_time = (10 * 60);
double voltage = DEFAULT_VOLTAGE; // Voltage from OpenEVSE or MQTT

time_t parse_date(const char *dateStr)
{
Expand Down Expand Up @@ -89,7 +93,7 @@ int get_watt(const char *val)
time_t divertmode_get_time()
{
return simulated_time;
}
}

int main(int argc, char** argv)
{
Expand Down Expand Up @@ -142,12 +146,12 @@ int main(int argc, char** argv)
CsvParser parser(std::cin);
parser.delimiter(sep.c_str()[0]);
int row_number = 0;

std::cout << "Date,Solar,Grid IE,Pilot,Charge Power,Min Charge Power,State,Smoothed Available" << std::endl;
for (auto& row : parser)
{
try
{
{
int col = 0;
std::string val;

Expand Down Expand Up @@ -192,3 +196,7 @@ int main(int argc, char** argv)
void event_send(String event)
{
}

void event_send(JsonDocument &event)
{
}

0 comments on commit 1feb4f4

Please sign in to comment.