Added DTC-Table in WebUI and improved DTC-System
This commit is contained in:
parent
6e0b7581eb
commit
dab826b862
@ -70,6 +70,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<h4>aktueller Modus</h4>
|
<h4>aktueller Modus</h4>
|
||||||
<input class="form-control" type="text" placeholder="%SYSTEM_STATUS%" readonly>
|
<input class="form-control" type="text" placeholder="%SYSTEM_STATUS%" readonly>
|
||||||
|
<div %SHOW_DTC_TABLE%>
|
||||||
|
<h4>Fehlercodes</h4>
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th class="col-md-4" scope="col">Timestamp</td>
|
||||||
|
<th class="col-md-4" scope="col">DTC</td>
|
||||||
|
<th class="col-md-4" scope="col">active</td>
|
||||||
|
</tr>
|
||||||
|
%DTC_TABLE%
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<!-- Div Tab Home-->
|
<!-- Div Tab Home-->
|
||||||
|
@ -22,7 +22,7 @@ uint32_t Process_CAN_WheelSpeed()
|
|||||||
#define FACTOR_RWP_KMH_890ADV 18 // Divider to convert Raw Data to km/h
|
#define FACTOR_RWP_KMH_890ADV 18 // Divider to convert Raw Data to km/h
|
||||||
|
|
||||||
can_frame canMsg;
|
can_frame canMsg;
|
||||||
static uint32_t lastRecTimestamp;
|
static uint32_t lastRecTimestamp = 0;
|
||||||
uint16_t RearWheelSpeed_raw;
|
uint16_t RearWheelSpeed_raw;
|
||||||
|
|
||||||
if (CAN0.readMsgBuf(&canMsg.can_id, &canMsg.can_dlc, canMsg.data) == CAN_OK)
|
if (CAN0.readMsgBuf(&canMsg.can_id, &canMsg.can_dlc, canMsg.data) == CAN_OK)
|
||||||
@ -40,18 +40,7 @@ uint32_t Process_CAN_WheelSpeed()
|
|||||||
return milimeters_to_add;
|
return milimeters_to_add;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (millis() > lastRecTimestamp + 10000)
|
MaintainDTC(DTC_NO_CAN_SIGNAL, (millis() > lastRecTimestamp + 10000));
|
||||||
{
|
|
||||||
if (globals.systemStatus != sysStat_Shutdown)
|
|
||||||
globals.systemStatus = sysStat_Error;
|
|
||||||
MaintainDTC(DTC_NO_CAN_SIGNAL, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (globals.systemStatus != sysStat_Shutdown)
|
|
||||||
globals.systemStatus = globals.resumeStatus;
|
|
||||||
MaintainDTC(DTC_NO_CAN_SIGNAL, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,24 @@
|
|||||||
|
|
||||||
DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
|
DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
|
||||||
|
|
||||||
void MaintainDTC(uint32_t DTC_no, boolean active)
|
void MaintainDTC(DTCNums_t DTC_no, boolean active)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
{
|
{
|
||||||
if (DTCStorage[i].Number == DTC_no)
|
if (DTCStorage[i].Number == DTC_no)
|
||||||
{
|
{
|
||||||
if (active == true)
|
if (active && DTCStorage[i].active != DTC_ACTIVE)
|
||||||
{
|
{
|
||||||
|
Serial.printf("DTC gone active: %d", DTC_no);
|
||||||
DTCStorage[i].timestamp = millis();
|
DTCStorage[i].timestamp = millis();
|
||||||
DTCStorage[i].active = DTC_ACTIVE;
|
DTCStorage[i].active = DTC_ACTIVE;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else
|
if (!active && DTCStorage[i].active == DTC_ACTIVE)
|
||||||
{
|
{
|
||||||
DTCStorage[i].active = DTCStorage[i].active == DTC_ACTIVE ? DTC_PREVIOUS : DTC_NONE;
|
Serial.printf("DTC gone previous: %d", DTC_no);
|
||||||
return;
|
DTCStorage[i].active = DTC_PREVIOUS;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +29,10 @@ void MaintainDTC(uint32_t DTC_no, boolean active)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
{
|
{
|
||||||
if (DTCStorage[i].Number == 0)
|
if (DTCStorage[i].Number == DTC_LAST_DTC)
|
||||||
{
|
{
|
||||||
|
Serial.printf("new DTC registered: %d", DTC_no);
|
||||||
|
DTCStorage[i].Number = DTC_no;
|
||||||
DTCStorage[i].timestamp = millis();
|
DTCStorage[i].timestamp = millis();
|
||||||
DTCStorage[i].active = DTC_ACTIVE;
|
DTCStorage[i].active = DTC_ACTIVE;
|
||||||
return;
|
return;
|
||||||
@ -38,13 +41,15 @@ void MaintainDTC(uint32_t DTC_no, boolean active)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearDTC(uint32_t DTC_no)
|
void ClearDTC(DTCNums_t DTC_no)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
{
|
{
|
||||||
if (DTCStorage[i].Number == DTC_no)
|
if (DTCStorage[i].Number == DTC_no)
|
||||||
{
|
{
|
||||||
DTCStorage[i].Number = 0;
|
DTCStorage[i].Number = DTC_LAST_DTC;
|
||||||
|
DTCStorage[i].active = DTC_NONE;
|
||||||
|
DTCStorage[i].timestamp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,12 +57,16 @@ void ClearDTC(uint32_t DTC_no)
|
|||||||
void ClearAllDTC()
|
void ClearAllDTC()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
DTCStorage[i].Number = 0;
|
{
|
||||||
|
DTCStorage[i].Number = DTC_LAST_DTC;
|
||||||
|
DTCStorage[i].active = DTC_NONE;
|
||||||
|
DTCStorage[i].timestamp = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getlastDTC(boolean only_active)
|
DTCNums_t getlastDTC(boolean only_active)
|
||||||
{
|
{
|
||||||
uint8_t pointer = 0;
|
int8_t pointer = -1;
|
||||||
uint32_t lasttimestamp = 0;
|
uint32_t lasttimestamp = 0;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
for (int i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
@ -72,5 +81,5 @@ uint32_t getlastDTC(boolean only_active)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pointer > 0 ? DTCStorage[pointer].Number : 0;
|
return pointer >= 0 ? DTCStorage[pointer].Number : DTC_LAST_DTC;
|
||||||
}
|
}
|
@ -3,29 +3,34 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define MAX_DTC_STORAGE 16
|
#define MAX_DTC_STORAGE 3
|
||||||
|
|
||||||
#define DTC_NO_GPS_SERIAL 100
|
typedef enum DTCNums_e
|
||||||
#define DTC_NO_CAN_SIGNAL 101
|
{
|
||||||
#define DTC_TANK_EMPTY 102
|
DTC_NO_GPS_SERIAL,
|
||||||
|
DTC_NO_CAN_SIGNAL,
|
||||||
|
DTC_TANK_EMPTY,
|
||||||
|
DTC_LAST_DTC
|
||||||
|
} DTCNums_t;
|
||||||
|
|
||||||
typedef enum DTCActive_e
|
typedef enum DTCActive_e
|
||||||
{
|
{
|
||||||
DTC_ACTIVE,
|
DTC_ACTIVE,
|
||||||
DTC_PREVIOUS,
|
DTC_PREVIOUS,
|
||||||
DTC_NONE
|
DTC_NONE
|
||||||
} DTCActive_s;
|
} DTCActive_t;
|
||||||
|
|
||||||
typedef struct DTCEntry_s
|
typedef struct DTCEntry_s
|
||||||
{
|
{
|
||||||
uint32_t Number;
|
DTCNums_t Number;
|
||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
DTCActive_s active;
|
DTCActive_t active;
|
||||||
} DTCEntry_t;
|
} DTCEntry_t;
|
||||||
|
|
||||||
void MaintainDTC(uint32_t DTC_no, boolean active);
|
void MaintainDTC(DTCNums_t DTC_no, boolean active);
|
||||||
void ClearDTC(uint32_t DTC_no);
|
void ClearDTC(DTCNums_t DTC_no);
|
||||||
void ClearAllDTC();
|
void ClearAllDTC();
|
||||||
uint32_t getlastDTC(boolean only_active);
|
DTCNums_t getlastDTC(boolean only_active);
|
||||||
|
|
||||||
|
extern DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
|
||||||
#endif
|
#endif
|
@ -50,18 +50,7 @@ uint32_t Process_GPS_WheelSpeed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (millis() > lastRecTimestamp + 10000)
|
MaintainDTC(DTC_NO_GPS_SERIAL, (millis() > lastRecTimestamp + 10000));
|
||||||
{
|
|
||||||
if (globals.systemStatus != sysStat_Shutdown)
|
|
||||||
globals.systemStatus = sysStat_Error;
|
|
||||||
MaintainDTC(DTC_NO_GPS_SERIAL, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (globals.systemStatus != sysStat_Shutdown)
|
|
||||||
globals.systemStatus = globals.resumeStatus;
|
|
||||||
MaintainDTC(DTC_NO_GPS_SERIAL, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,11 @@ uint32_t lubePulseTimestamp = 0;
|
|||||||
|
|
||||||
void RunLubeApp(uint32_t add_milimeters)
|
void RunLubeApp(uint32_t add_milimeters)
|
||||||
{
|
{
|
||||||
if (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl)
|
|
||||||
{
|
MaintainDTC(DTC_TANK_EMPTY, (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl));
|
||||||
MaintainDTC(DTC_TANK_EMPTY, true);
|
|
||||||
}
|
if (getlastDTC(true) < DTC_LAST_DTC)
|
||||||
else
|
globals.systemStatus = sysStat_Error;
|
||||||
{
|
|
||||||
if (globals.systemStatus != sysStat_Shutdown)
|
|
||||||
globals.systemStatus = globals.resumeStatus;
|
|
||||||
MaintainDTC(DTC_TANK_EMPTY, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add traveled Distance in mm
|
// Add traveled Distance in mm
|
||||||
PersistenceData.TravelDistance_highRes += add_milimeters;
|
PersistenceData.TravelDistance_highRes += add_milimeters;
|
||||||
|
@ -81,6 +81,8 @@ void setup()
|
|||||||
snprintf(DeviceName, 32, HOST_NAME, ESP.getChipId());
|
snprintf(DeviceName, 32, HOST_NAME, ESP.getChipId());
|
||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
|
|
||||||
|
ClearAllDTC(); // Init DTC-Storage
|
||||||
|
|
||||||
#ifdef WIFI_CLIENT
|
#ifdef WIFI_CLIENT
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.setHostname(DeviceName);
|
WiFi.setHostname(DeviceName);
|
||||||
|
@ -17,7 +17,7 @@ void initWebUI()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
webServer.serveStatic("/static/", LittleFS, "/static/").setCacheControl("max-age=360000");;
|
webServer.serveStatic("/static/", LittleFS, "/static/").setCacheControl("max-age=360000");
|
||||||
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||||
{ request->redirect("/index.htm"); });
|
{ request->redirect("/index.htm"); });
|
||||||
webServer.onNotFound(WebserverNotFound_Callback);
|
webServer.onNotFound(WebserverNotFound_Callback);
|
||||||
@ -85,6 +85,40 @@ String processor(const String &var)
|
|||||||
return LubeConfig.SpeedSource == SOURCE_CAN ? "" : "hidden";
|
return LubeConfig.SpeedSource == SOURCE_CAN ? "" : "hidden";
|
||||||
if (var == "SHOW_GPS_SETTINGS")
|
if (var == "SHOW_GPS_SETTINGS")
|
||||||
return LubeConfig.SpeedSource == SOURCE_GPS ? "" : "hidden";
|
return LubeConfig.SpeedSource == SOURCE_GPS ? "" : "hidden";
|
||||||
|
if (var == "SHOW_DTC_TABLE")
|
||||||
|
return globals.systemStatus == sysStat_Error ? "" : "hidden";
|
||||||
|
|
||||||
|
if (var == "DTC_TABLE")
|
||||||
|
{
|
||||||
|
String temp;
|
||||||
|
char buff_timestamp[16]; // Format: DD-hh:mm:ss:xxx
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
|
||||||
|
{
|
||||||
|
if (DTCStorage[i].Number > 0)
|
||||||
|
{
|
||||||
|
sprintf(buff_timestamp, "%02d-%02d:%02d:%02d:%03d",
|
||||||
|
DTCStorage[i].timestamp / 86400000, // Days
|
||||||
|
DTCStorage[i].timestamp / 360000 % 24, // Hours
|
||||||
|
DTCStorage[i].timestamp / 60000 % 60, // Minutes
|
||||||
|
DTCStorage[i].timestamp / 1000 % 60, // Seconds
|
||||||
|
DTCStorage[i].timestamp % 1000); // milliseconds
|
||||||
|
|
||||||
|
temp = "<tr><td>" + String(buff_timestamp);
|
||||||
|
temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>";
|
||||||
|
|
||||||
|
if (DTCStorage[i].active == DTC_ACTIVE)
|
||||||
|
temp = temp + "active";
|
||||||
|
else if (DTCStorage[i].active == DTC_PREVIOUS)
|
||||||
|
temp = temp + "previous";
|
||||||
|
else
|
||||||
|
temp = temp + "none";
|
||||||
|
|
||||||
|
temp = temp + "</td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
if (var == "SOURCE_SELECT_OPTIONS")
|
if (var == "SOURCE_SELECT_OPTIONS")
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "dtc.h"
|
||||||
|
|
||||||
void initWebUI();
|
void initWebUI();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user