- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright Pionix GmbH and Contributors to EVerest
|
|
#ifndef SESSION_LOG_HPP
|
|
#define SESSION_LOG_HPP
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <nlohmann/json_fwd.hpp>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace module {
|
|
/*
|
|
Simple session logger that outputs to one file per session and EVLOG
|
|
*/
|
|
|
|
class SessionLog {
|
|
public:
|
|
using mqtt_publish_ftor = std::function<void(nlohmann::json const&)>;
|
|
SessionLog();
|
|
~SessionLog();
|
|
|
|
void setPath(const std::string& path);
|
|
void setMqtt(mqtt_publish_ftor const& mqtt_provider);
|
|
void enable();
|
|
std::optional<std::filesystem::path> startSession(const std::string& suffix_string);
|
|
void stopSession();
|
|
|
|
void car(bool iso15118, const std::string& msg);
|
|
void car(bool iso15118, const std::string& msg, const std::string& xml, const std::string& xml_hex,
|
|
const std::string& xml_base64, const std::string& json_str);
|
|
|
|
void evse(bool iso15118, const std::string& msg);
|
|
void evse(bool iso15118, const std::string& msg, const std::string& xml, const std::string& xml_hex,
|
|
const std::string& xml_base64, const std::string& json_str);
|
|
|
|
void xmlOutput(bool e);
|
|
|
|
void sys(const std::string& msg);
|
|
|
|
private:
|
|
void output(unsigned int evse, bool iso15118, const std::string& msg, const std::string& xml,
|
|
const std::string& xml_hex, const std::string& xml_base64, const std::string& json_str);
|
|
std::string html_encode(const std::string& msg);
|
|
bool xmloutput;
|
|
bool session_active;
|
|
bool enabled;
|
|
std::filesystem::path logpath_root;
|
|
std::filesystem::path logpath;
|
|
std::filesystem::path fn, fnhtml, fn_complete, fnhtml_complete;
|
|
|
|
std::ofstream logfile_csv;
|
|
std::ofstream logfile_html;
|
|
mqtt_publish_ftor mqtt;
|
|
};
|
|
|
|
extern SessionLog session_log;
|
|
|
|
} // namespace module
|
|
|
|
#endif // SESSION_LOG_HPP
|