diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.cproject b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.cproject new file mode 100644 index 0000000..dd1ec4a --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.cproject @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.project b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.project new file mode 100644 index 0000000..a095984 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.project @@ -0,0 +1,32 @@ + + + 0 - Code + + + + + + org.eclipse.cdt.autotools.core.genmakebuilderV2 + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.cdt.autotools.core.autotoolsNatureV2 + + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.settings/language.settings.xml b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.settings/language.settings.xml new file mode 100644 index 0000000..6ab1745 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/.settings/language.settings.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/TeslaGunSafety.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/TeslaGunSafety.h index 86188a7..e114b2a 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/TeslaGunSafety.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/TeslaGunSafety.h @@ -85,7 +85,7 @@ extern void TeslaGunSafety_destruct(void); /** ---------------------------------------------------------------------------- - * TeslaGunSafety_unlock + * TeslaGunSafety_release * Opens the TeslaGunSafety * * @param self @@ -98,6 +98,18 @@ extern void TeslaGunSafety_destruct(void); extern ErrorStatus TeslaGunSafety_release(void); +/** ---------------------------------------------------------------------------- + * TeslaGunSafety_isRreleased + * Opens the TeslaGunSafety + * + * @return bool TRUE if released + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern bool TeslaGunSafety_release(void); + + /** ---------------------------------------------------------------------------- * TeslaGunSafety_block * Blocks the TeslaGunSafety diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/TeslaGunSafety.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/TeslaGunSafety.c index d674a1d..22c5e7f 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/TeslaGunSafety.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/TeslaGunSafety.c @@ -99,6 +99,16 @@ ErrorStatus TeslaGunSafety_release(void) } +bool TeslaGunSafety_isReleased(void) +{ + bool returnValue; + + GPIO_getValue(self.gpio, &returnValue); + + return returnValue; +} + + ErrorStatus TeslaGunSafety_block(void) { ErrorStatus returnValue = SUCCESS; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h index 503fd60..a394478 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h @@ -99,6 +99,7 @@ struct MenuPage struct MenuCore { + void* parent; struct MenuPage menuArray[RM_NUMBER_OF_MENUS]; struct Display* display; struct KeyboardDevice* keyboardDevice; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h index 7f9b2a2..725d15e 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h @@ -231,11 +231,12 @@ static const char MenuText_PAUSE[MENUTEXT_NUMBER_OF_LANGUAGES][5][MENUTEXT_POPUP } }; -static const char MenuText_FINISH[MENUTEXT_NUMBER_OF_LANGUAGES][2][MENUTEXT_POPUP_MESSAGE_LENGTH] = +static const char MenuText_FINISH[MENUTEXT_NUMBER_OF_LANGUAGES][3][MENUTEXT_POPUP_MESSAGE_LENGTH] = { // MAX 20 CHARACTERS { "REPAIR FINISHED", + "Error in row", "Hit ENT to continue", }, { diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h index 0ceebc3..7aa3810 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h @@ -42,6 +42,7 @@ // ----------------------------------------------------------------------------- #define REPAIR_PRESETS_NUMBER_OF_PRESETS (9) +#define REPAIR_PRESETS_DEFAULT_PRESET (1) // ----------------------------------------------------------------------------- // Type definitions. diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairMenu.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairMenu.h index 659204c..6158e85 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairMenu.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/repairMenu.h @@ -68,10 +68,12 @@ struct RepairMenu struct MemoryDevice* memoryDevice; struct CachedStorage presetStorage; SemaphoreHandle_t repairScreenUpdateSemaphore; - const struct RepairPreset* repairPreset; - struct RepairProcessParameters rpParameters; Observer observer; struct MenuCore* menuCore; + struct RepairProcess* repairProcess; + struct RepairProcessParameters rpParameters; + const struct RepairPreset* repairPreset; + bool processResult[REPAIRPROCESS_NUMBER_OF_ROWS]; }; // ----------------------------------------------------------------------------- diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hsb-mrts.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hsb-mrts.c index 5b65f5c..48237c7 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hsb-mrts.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hsb-mrts.c @@ -132,15 +132,7 @@ ErrorStatus hsb_enableSafetyWithError(void) // returnValue = ERROR; // } // } -// -// if (returnValue == SUCCESS) -// { -// // In case of a TESLA repair, release the teslaGunSafety -// if (PCBA_getInstance()->pcba == PCBA_Tesla) -// { -// TeslaGunSafety_release(); -// } -// } + if (returnValue == SUCCESS) { diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c index ebe0679..33cb85b 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c @@ -180,6 +180,7 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct MenuCore* menuC if (menuCore->initialized) { self->menuCore = menuCore; + self->menuCore->parent = self; } else { @@ -210,12 +211,12 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct MenuCore* menuC else if (PCBA_getInstance()->pcba == PCBA_Anode) { RepairPresets_loadPresets(REPAIR_PRESETS_ANODE); - self->repairPreset = RepairPresets_getPreset(1); + self->repairPreset = RepairPresets_getPreset(REPAIR_PRESETS_DEFAULT_PRESET); } else if (PCBA_getInstance()->pcba == PCBA_Tesla) { RepairPresets_loadPresets(REPAIR_PRESETS_TESLA); - self->repairPreset = RepairPresets_getPreset(1); + self->repairPreset = RepairPresets_getPreset(REPAIR_PRESETS_DEFAULT_PRESET); } MenuCore_changeState(self->menuCore, RM_MAINMENU); @@ -416,8 +417,30 @@ static void repairMenu_printPause(struct MenuCore* self) static void repairMenu_printFinish(struct MenuCore* self) { - Display_writeCentered(self->display, MenuText_FINISH[languageIndex][0], 2); - Display_writeCentered(self->display, MenuText_FINISH[languageIndex][1], 4); + char buffer[self->display->displayDevice->parameters.numberOfColumns]; + buffer[0] = '\0'; + int loopCounter; + bool printErrorMessage = false; + Display_writeCentered(self->display, MenuText_FINISH[languageIndex][0], 1); + + // Check if any error has appeared + for (loopCounter = ((PCBA_getInstance()->pcba == PCBA_Tesla) ? 1 : 0); loopCounter <= ((PCBA_getInstance()->pcba == PCBA_Tesla) ? 1 : 2); loopCounter++) + { + if (((struct RepairMenu*)self->parent)->processResult[loopCounter]) + { + printErrorMessage = true; + snprintf(buffer, sizeof(buffer), "%s %d ", buffer, loopCounter + 1); // +1 for human-readable row numbers + } + } + + // Error string only needs single printing + if (printErrorMessage) + { + Display_writeCentered(self->display, MenuText_FINISH[languageIndex][1], 2); + Display_writeCentered(self->display, buffer, 3); + } + + Display_writeCentered(self->display, MenuText_FINISH[languageIndex][2], 4); } @@ -1052,6 +1075,7 @@ static void repairMenu_teslagunBlock(struct MenuCore* self) static void repairMenu_startRepairProcess(struct MenuCore* self) { ErrorStatus returnValue = SUCCESS; + int loopCounter; struct RepairMenu* repairMenu = repairMenus_getMainRepairMenu(); @@ -1071,13 +1095,30 @@ static void repairMenu_startRepairProcess(struct MenuCore* self) // If all is OK, start the repair process if (returnValue == SUCCESS) { + // Check if a preset has been selected - otherwise go to default preset + if (repairMenu->repairPreset == NULL) + { + repairMenu->repairPreset = RepairPresets_getPreset(REPAIR_PRESETS_DEFAULT_PRESET); + } returnValue = repairProcesses_startMainRepairProcess(repairMenu->repairPreset, &repairMenu->rpParameters); + if (returnValue != SUCCESS) { Error_postError(REPAIR_FAIL); } } + if (returnValue == SUCCESS) + { + ((struct RepairMenu*)self->parent)->repairProcess = repairProcesses_getMainRepairProcess(); + + // Reset the test results (just in case) + for (loopCounter = ((PCBA_getInstance()->pcba == PCBA_Tesla) ? 1 : 0); loopCounter <= ((PCBA_getInstance()->pcba == PCBA_Tesla) ? 1 : 2); loopCounter++) + { + ((struct RepairMenu*)self->parent)->processResult[loopCounter] = false; + } + } + if (returnValue == SUCCESS) { returnValue = repairProcesses_mainRepairProcessAddObserver(repairMenu->observer); @@ -1136,6 +1177,7 @@ static void repairMenu_gotoLastState(struct MenuCore* self) void repairMenu_menuStateHandle(struct MenuCore* self) { + int loopCounter; // Stop the buzzer from recovered error or warning if (self->lastMenuState == RM_ERROR_STATE) @@ -1188,6 +1230,26 @@ void repairMenu_menuStateHandle(struct MenuCore* self) uint32_t remainingTime = repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess()); Led_on(LED_BICOLOR_GREEN); + + + // For the TESLA REPAIR, the tesla gun is only allowed to be released when the VOLTAGE HOLD state has been reached + // and the voltage is within the limits + if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + if (!TeslaGunSafety_isReleased()) + { + if (repairProcesses_getMainRepairProcess()->signalProfileGenerator.currentState == SPG_VOLTAGE_HOLD) + { + if (!repairProcesses_getMainRepairProcess()->row[1].errorData.rowHasError) + { + TeslaGunSafety_release(); + LOGGER_INFO(mainLog, "Tesla Gun is released"); + } + } + } + } + + if (remainingTime > (2 * REPAIRMENU_POPUPSCREEN_TIME_MS / 1000)) { self->popUpCounter = remainingTime - (2 * REPAIRMENU_POPUPSCREEN_TIME_MS / 1000); @@ -1222,6 +1284,14 @@ void repairMenu_menuStateHandle(struct MenuCore* self) } else if (self->menuState == RM_FINISH_CONTROL) { + LOGGER_DEBUG(mainLog, "Result %d %d %d", ((struct RepairMenu*)self->parent)->processResult[0], ((struct RepairMenu*)self->parent)->processResult[1], ((struct RepairMenu*)self->parent)->processResult[2]); + // Receive the final repair row status + for (loopCounter = ((PCBA_getInstance()->pcba == PCBA_Tesla) ? 1 : 0); loopCounter <= ((PCBA_getInstance()->pcba == PCBA_Tesla) ? 1 : 2); loopCounter++) + { + ((struct RepairMenu*)self->parent)->processResult[loopCounter] = ((struct RepairMenu*)self->parent)->repairProcess->row[loopCounter].errorData.rowHasError; + } + + repairMenu_stopRepairProcess(self); PowerLossDetector_clearBusyFlag(); MenuCore_changeState(self, RM_FINISH);