mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Add separate web datalayer
This commit is contained in:
parent
742f51c658
commit
d096caf9bb
6 changed files with 74 additions and 20 deletions
|
@ -18,7 +18,7 @@
|
|||
//#define KIA_E_GMP_BATTERY
|
||||
//#define KIA_HYUNDAI_HYBRID_BATTERY
|
||||
//#define MG_5_BATTERY
|
||||
#define NISSAN_LEAF_BATTERY
|
||||
//#define NISSAN_LEAF_BATTERY
|
||||
//#define PYLON_BATTERY
|
||||
//#define RJXZS_BMS
|
||||
//#define RENAULT_KANGOO_BATTERY
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "../include.h"
|
||||
#ifdef TESLA_BATTERY
|
||||
#include "../datalayer/datalayer.h"
|
||||
#include "../datalayer/datalayer_web.h" //For Advanced Battery Insights webpage
|
||||
#include "../devboard/utils/events.h"
|
||||
#include "TESLA-BATTERY.h"
|
||||
|
||||
|
@ -341,6 +342,15 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
}
|
||||
#endif // TESLA_MODEL_3Y_BATTERY
|
||||
|
||||
// Update webserver datalayer
|
||||
datalayer_web.tesla.status_contactor = battery_contactor;
|
||||
datalayer_web.tesla.hvil_status = battery_hvil_status;
|
||||
datalayer_web.tesla.packContNegativeState = battery_packContNegativeState;
|
||||
datalayer_web.tesla.packContPositiveState = battery_packContPositiveState;
|
||||
datalayer_web.tesla.packContactorSetState = battery_packContactorSetState;
|
||||
datalayer_web.tesla.packCtrsClosingAllowed = battery_packCtrsClosingAllowed;
|
||||
datalayer_web.tesla.pyroTestInProgress = battery_pyroTestInProgress;
|
||||
|
||||
#ifdef DEBUG_VIA_USB
|
||||
|
||||
printFaultCodesIfActive();
|
||||
|
|
4
Software/src/datalayer/datalayer_web.cpp
Normal file
4
Software/src/datalayer/datalayer_web.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "datalayer_web.h"
|
||||
#include "../include.h"
|
||||
|
||||
DataLayerWeb datalayer_web;
|
38
Software/src/datalayer/datalayer_web.h
Normal file
38
Software/src/datalayer/datalayer_web.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef _DATALAYER_WEB_H_
|
||||
#define _DATALAYER_WEB_H_
|
||||
|
||||
#include "../include.h"
|
||||
|
||||
typedef struct {
|
||||
/** uint8_t */
|
||||
/** Contactor status */
|
||||
uint8_t status_contactor = 0;
|
||||
/** uint8_t */
|
||||
/** Contactor status */
|
||||
uint8_t hvil_status = 0;
|
||||
/** uint8_t */
|
||||
/** Negative contactor state */
|
||||
uint8_t packContNegativeState = 0;
|
||||
/** uint8_t */
|
||||
/** Positive contactor state */
|
||||
uint8_t packContPositiveState = 0;
|
||||
/** uint8_t */
|
||||
/** Set state of contactors */
|
||||
uint8_t packContactorSetState = 0;
|
||||
/** uint8_t */
|
||||
/** Battery pack allows closing of contacors */
|
||||
uint8_t packCtrsClosingAllowed = 0;
|
||||
/** uint8_t */
|
||||
/** Pyro test in progress */
|
||||
uint8_t pyroTestInProgress = 0;
|
||||
|
||||
} DATALAYER_INFO_TESLA;
|
||||
|
||||
class DataLayerWeb {
|
||||
public:
|
||||
DATALAYER_INFO_TESLA tesla;
|
||||
};
|
||||
|
||||
extern DataLayerWeb datalayer_web;
|
||||
|
||||
#endif
|
|
@ -1,6 +1,7 @@
|
|||
#include "advanced_battery_html.h"
|
||||
#include <Arduino.h>
|
||||
#include "../../datalayer/datalayer.h"
|
||||
#include "../../datalayer/datalayer_web.h"
|
||||
|
||||
String advanced_battery_processor(const String& var) {
|
||||
if (var == "X") {
|
||||
|
@ -15,7 +16,19 @@ String advanced_battery_processor(const String& var) {
|
|||
// Start a new block with a specific background color
|
||||
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";
|
||||
|
||||
#ifdef TESLA_BATTERY
|
||||
content += "<h4>Contactor Status: " + String(datalayer_web.tesla.status_contactor) + "</h4>";
|
||||
content += "<h4>HVIL: " + String(datalayer_web.tesla.hvil_status) + "</h4>";
|
||||
content += "<h4>Negative contactor: " + String(datalayer_web.tesla.packContNegativeState) + "</h4>";
|
||||
content += "<h4>Positive contactor: " + String(datalayer_web.tesla.packContPositiveState) + "</h4>";
|
||||
content += "<h4>Contactor set state: " + String(datalayer_web.tesla.packContactorSetState) + "</h4>";
|
||||
content += "<h4>Closing allowed?: " + String(datalayer_web.tesla.packCtrsClosingAllowed) + "</h4>";
|
||||
content += "<h4>Pyrotest: " + String(datalayer_web.tesla.pyroTestInProgress) + "</h4>";
|
||||
#endif
|
||||
|
||||
#ifndef TESLA_BATTERY //Only the listed types have extra info
|
||||
content += "No extra information available for this battery type";
|
||||
#endif
|
||||
|
||||
content += "</div>";
|
||||
|
||||
|
|
|
@ -432,14 +432,6 @@ String processor(const String& var) {
|
|||
content += "body { background-color: black; color: white; }";
|
||||
content += "</style>";
|
||||
|
||||
// Draw buttons
|
||||
content += "<button onclick='OTA()'>Perform OTA update</button> ";
|
||||
content += "<button onclick='Settings()'>Change Settings</button> ";
|
||||
content += "<button onclick='Advanced()'>Advanced Battery Insights</button> ";
|
||||
content += "<button onclick='Cellmon()'>Cellmonitor</button> ";
|
||||
content += "<button onclick='Events()'>Events</button> ";
|
||||
content += "<button onclick='askReboot()'>Reboot Emulator</button>";
|
||||
|
||||
// Start a new block with a specific background color
|
||||
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px;border-radius: 50px'>";
|
||||
|
||||
|
@ -879,21 +871,18 @@ String processor(const String& var) {
|
|||
#endif // defined CHEVYVOLT_CHARGER || defined NISSANLEAF_CHARGER
|
||||
|
||||
if (emulator_pause_request_ON)
|
||||
content += "<button onclick='PauseBattery(false)'>Resume charge/discharge</button>";
|
||||
content += "<button onclick='PauseBattery(false)'>Resume charge/discharge</button> ";
|
||||
else
|
||||
content +=
|
||||
"<button onclick=\"if(confirm('Are you sure you want to pause charging and discharging? This will set the "
|
||||
"maximum charge and discharge values to zero, preventing any further power flow.')) { PauseBattery(true); "
|
||||
"}\">Pause charge/discharge</button>";
|
||||
content += " ";
|
||||
content += "<button onclick='OTA()'>Perform OTA update</button>";
|
||||
content += " ";
|
||||
content += "<button onclick='Settings()'>Change Settings</button>";
|
||||
content += " ";
|
||||
content += "<button onclick='Cellmon()'>Cellmonitor</button>";
|
||||
content += " ";
|
||||
content += "<button onclick='Events()'>Events</button>";
|
||||
content += " ";
|
||||
"}\">Pause charge/discharge</button> ";
|
||||
|
||||
content += "<button onclick='OTA()'>Perform OTA update</button> ";
|
||||
content += "<button onclick='Settings()'>Change Settings</button> ";
|
||||
content += "<button onclick='Advanced()'>Advanced Battery Insights</button> ";
|
||||
content += "<button onclick='Cellmon()'>Cellmonitor</button> ";
|
||||
content += "<button onclick='Events()'>Events</button> ";
|
||||
content += "<button onclick='askReboot()'>Reboot Emulator</button>";
|
||||
if (WEBSERVER_AUTH_REQUIRED)
|
||||
content += "<button onclick='logout()'>Logout</button>";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue