DTCs now hav severity and improved DTCMaintenance

This commit is contained in:
Marcel Peterkau 2022-08-22 14:13:55 +02:00
parent 808709f5c2
commit bd4c1d9d53
14 changed files with 109 additions and 29 deletions

View File

@ -75,13 +75,25 @@
<table class="table">
<tbody>
<tr>
<th class="col-md-4" scope="col">Timestamp</th>
<th class="col-md-4" scope="col">DTC</th>
<th class="col-md-4" scope="col">active</th>
<th class="col-md-3" scope="col">Zeitstempel</th>
<th class="col-md-3" scope="col">Fehlercode</th>
<th class="col-md-3" scope="col">Schwere</th>
<th class="col-md-3" scope="col">Aktiv</th>
</tr>
%DTC_TABLE%
</tbody>
</table>
<p>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseDTCDescription"
aria-expanded="false" aria-controls="collapseDTCDescription">
DTC Beschreibung
</button>
</p>
<div class="collapse" id="collapseDTCDescription">
<div class="card card-body">
<embed type="text/html" src="static/dtc.txt" width="100&#37;">
</div>
</div>
</div>
</p>
</div>

View File

@ -0,0 +1,12 @@
1 - TANK_EMPTY
2 - DTC_TANK_LOW
3 - DTC_NO_EEPROM_FOUND
4 - DTC_EEPROM_CFG_BAD
5 - DTC_EEPROM_PDS_BAD
6 - DTC_EEPROM_PDSADRESS_BAD
7 - DTC_EEPROM_VERSION_BAD
8 - DTC_FLASHFS_ERROR
9 - DTC_FLASHFS_VERSION_ERROR
10 - DTC_NO_GPS_SERIAL
11 - DTC_CAN_TRANSCEIVER_FAILED
12 - DTC_NO_CAN_SIGNAL

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -7,7 +7,7 @@ void Init_CAN()
{
if (CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_16MHZ) != CAN_OK)
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, true);
MaintainDTC(DTC_CAN_TRANSCEIVER_FAILED, DTC_CRITICAL, true);
CAN0.init_Mask(0, 0, 0x07FF0000); // Init first mask...
CAN0.init_Mask(1, 0, 0x07FF0000); // Init second mask...
@ -39,7 +39,7 @@ uint32_t Process_CAN_WheelSpeed()
return milimeters_to_add;
}
MaintainDTC(DTC_NO_CAN_SIGNAL, (millis() > lastRecTimestamp + 10000 ? true : false));
MaintainDTC(DTC_NO_CAN_SIGNAL, DTC_CRITICAL, (millis() > lastRecTimestamp + 10000 ? true : false));
return 0;
}

View File

@ -84,8 +84,7 @@ void GetConfig_EEPROM()
if (Checksum_EEPROM((uint8_t *)&LubeConfig, sizeof(LubeConfig)) != checksum)
{
MaintainDTC(DTC_EEPROM_CFG_BAD, true);
FormatConfig_EEPROM();
MaintainDTC(DTC_EEPROM_CFG_BAD, DTC_CRITICAL, true);
}
LubeConfig.checksum = checksum;
}
@ -118,7 +117,7 @@ void GetPersistence_EEPROM()
{
MovePersistencePage_EEPROM(true);
FormatPersistence_EEPROM();
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, true);
MaintainDTC(DTC_EEPROM_PDSADRESS_BAD, DTC_CRITICAL, true);
}
else
{
@ -129,7 +128,7 @@ void GetPersistence_EEPROM()
if (Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData)) != checksum)
{
MaintainDTC(DTC_EEPROM_PDS_BAD, true);
MaintainDTC(DTC_EEPROM_PDS_BAD, DTC_CRITICAL, true);
}
PersistenceData.checksum = checksum;
}
@ -224,10 +223,10 @@ boolean checkEEPROMavailable()
{
if (!ee.isConnected())
{
MaintainDTC(DTC_NO_EEPROM_FOUND, true);
MaintainDTC(DTC_NO_EEPROM_FOUND, DTC_CRITICAL, true);
globals.systemStatus = sysStat_Error;
return false;
}
MaintainDTC(DTC_NO_EEPROM_FOUND, false);
MaintainDTC(DTC_NO_EEPROM_FOUND, DTC_CRITICAL, false);
return true;
}

View File

@ -2,7 +2,7 @@
DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
void MaintainDTC(DTCNums_t DTC_no, boolean active)
void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active)
{
for (int i = 0; i < MAX_DTC_STORAGE; i++)
{
@ -13,6 +13,7 @@ void MaintainDTC(DTCNums_t DTC_no, boolean active)
Serial.printf("DTC gone active: %d\n", DTC_no);
DTCStorage[i].timestamp = millis();
DTCStorage[i].active = DTC_ACTIVE;
DTCStorage[i].severity = DTC_severity;
}
if (!active && DTCStorage[i].active == DTC_ACTIVE)
{
@ -81,5 +82,25 @@ DTCNums_t getlastDTC(boolean only_active)
}
}
return pointer >= 0 ? DTCStorage[pointer].Number : DTC_LAST_DTC;
}
DTCNums_t getlastDTC_Severity(boolean only_active, DTCSeverity_t severity)
{
int8_t pointer = -1;
uint32_t lasttimestamp = 0;
for (int i = 0; i < MAX_DTC_STORAGE; i++)
{
if (DTCStorage[i].Number > 0 && DTCStorage[i].timestamp > lasttimestamp)
{
if ((only_active == false || DTCStorage[i].active == DTC_ACTIVE) && DTCStorage[i].severity == severity)
{
pointer = i;
lasttimestamp = DTCStorage[i].timestamp;
}
}
}
return pointer >= 0 ? DTCStorage[pointer].Number : DTC_LAST_DTC;
}

View File

@ -8,6 +8,7 @@
typedef enum DTCNums_e
{
DTC_TANK_EMPTY = 1,
DTC_TANK_LOW,
DTC_NO_EEPROM_FOUND,
DTC_EEPROM_CFG_BAD,
DTC_EEPROM_PDS_BAD,
@ -31,17 +32,26 @@ typedef enum DTCActive_e
DTC_PREVIOUS
} DTCActive_t;
typedef enum DTCSeverity_e
{
DTC_INFO,
DTC_WARN,
DTC_CRITICAL
} DTCSeverity_t;
typedef struct DTCEntry_s
{
DTCNums_t Number;
uint32_t timestamp;
DTCActive_t active;
DTCSeverity_t severity;
} DTCEntry_t;
void MaintainDTC(DTCNums_t DTC_no, boolean active);
void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active);
void ClearDTC(DTCNums_t DTC_no);
void ClearAllDTC();
DTCNums_t getlastDTC(boolean only_active);
DTCNums_t getlastDTC_Severity(boolean only_active, DTCSeverity_t severity);
extern DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
#endif

View File

@ -33,6 +33,8 @@ typedef struct Globals_s
char DeviceName[33];
uint32_t FlashVersion;
uint16_t eePersistanceAdress;
uint8_t TankPercentage;
bool hasDTC;
} Globals_t;
extern Globals_t globals;

View File

@ -51,7 +51,7 @@ uint32_t Process_GPS_WheelSpeed()
}
}
MaintainDTC(DTC_NO_GPS_SERIAL, (millis() > lastRecTimestamp + 10000));
MaintainDTC(DTC_NO_GPS_SERIAL,DTC_CRITICAL, (millis() > lastRecTimestamp + 10000));
return 0;
}

View File

@ -5,23 +5,35 @@ uint32_t lubePulseTimestamp = 0;
void RunLubeApp(uint32_t add_milimeters)
{
MaintainDTC(DTC_TANK_EMPTY, (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl));
globals.TankPercentage = PersistenceData.tankRemain_µl / (LubeConfig.tankCapacity_ml * 1000);
MaintainDTC(DTC_TANK_EMPTY, DTC_CRITICAL, (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl));
MaintainDTC(DTC_TANK_LOW, DTC_WARN, (globals.TankPercentage < LubeConfig.TankRemindAtPercentage));
static tSystem_Status preserverSysStatusError;
if (globals.systemStatus != sysStat_Error)
preserverSysStatusError = globals.systemStatus;
if (getlastDTC(true) < DTC_LAST_DTC)
if (getlastDTC(false) < DTC_LAST_DTC)
{
globals.systemStatus = sysStat_Error;
globals.hasDTC = true;
if (getlastDTC_Severity(true, DTC_CRITICAL) < DTC_LAST_DTC)
{
if (globals.systemStatus != sysStat_Error)
{
preserverSysStatusError = globals.systemStatus;
}
globals.systemStatus = sysStat_Error;
}
else
{
if (globals.systemStatus == sysStat_Error)
{
globals.systemStatus = preserverSysStatusError;
}
}
}
else
{
if (globals.systemStatus == sysStat_Error)
{
globals.systemStatus = preserverSysStatusError;
}
globals.hasDTC = false;
}
// Add traveled Distance in mm

View File

@ -506,14 +506,12 @@ void LED_Process(uint8_t override, CRGB SetColor)
oldSysStatus = globals.systemStatus;
}
uint32_t percentage = PersistenceData.tankRemain_µl / (LubeConfig.tankCapacity_ml * 1000);
switch (LED_Status)
{
case LED_Startup:
FastLED.setBrightness(255);
if (percentage < LubeConfig.TankRemindAtPercentage)
if (globals.TankPercentage < LubeConfig.TankRemindAtPercentage)
leds[0] = CRGB::OrangeRed;
else
leds[0] = CRGB::White;

View File

@ -16,7 +16,7 @@ void initWebUI()
if (!LittleFS.begin())
{
Serial.println("An Error has occurred while mounting LittleFS");
MaintainDTC(DTC_FLASHFS_ERROR, true);
MaintainDTC(DTC_FLASHFS_ERROR, DTC_CRITICAL, true);
return;
}
@ -117,7 +117,7 @@ String processor(const String &var)
return "hidden";
#endif
if (var == "SHOW_DTC_TABLE")
return globals.systemStatus == sysStat_Error ? "" : "hidden";
return globals.hasDTC ? "" : "hidden";
if (var == "DTC_TABLE")
{
@ -137,6 +137,20 @@ String processor(const String &var)
temp = temp + "<tr><td>" + String(buff_timestamp);
temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>";
temp = temp + "<img src=static/img/";
switch (DTCStorage[i].severity)
{
case DTC_CRITICAL:
temp = temp + "critical";
break;
case DTC_WARN:
temp = temp + "warn";
break;
case DTC_INFO:
temp = temp + "info";
break;
}
temp = temp + "_black.png></td><td>";
if (DTCStorage[i].active == DTC_ACTIVE)
temp = temp + "active";