Fixed some minor issues/bugs git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@284 05563f52-14a8-4384-a975-3d1654cca0fa
187 lines
5.1 KiB
C
187 lines
5.1 KiB
C
// -----------------------------------------------------------------------------
|
|
/// @file repairMenus.c
|
|
/// @brief Description
|
|
// -----------------------------------------------------------------------------
|
|
// Micro-Key bv
|
|
// Industrieweg 28, 9804 TG Noordhorn
|
|
// Postbus 92, 9800 AB Zuidhorn
|
|
// The Netherlands
|
|
// Tel: +31 594 503020
|
|
// Fax: +31 594 505825
|
|
// Email: support@microkey.nl
|
|
// Web: www.microkey.nl
|
|
// -----------------------------------------------------------------------------
|
|
/// $Revision$
|
|
/// $Author$
|
|
/// $Date$
|
|
// (c) 2017 Micro-Key bv
|
|
// -----------------------------------------------------------------------------
|
|
|
|
/// @file repairMenus.c
|
|
/// @ingroup {group_name}
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Include files
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "hsb-mrts.h"
|
|
|
|
#include "Error.h"
|
|
#include "MenuCore.h"
|
|
#include "repairMenus.h"
|
|
#include "repairMenu.h"
|
|
#include "Warning.h"
|
|
|
|
#include "platform.h"
|
|
#include "Logger.h"
|
|
#include "Observable.h"
|
|
#include "rtc.h"
|
|
#include "storm700.h"
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Constant and macro definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Type definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static struct MenuCore _menuCore = {.initialized = false};
|
|
struct MenuCore* const menuCore = &_menuCore;
|
|
|
|
static struct RepairMenu _mainMenu = {.initialized = false};
|
|
struct RepairMenu* const mainMenu = &_mainMenu;
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// File-scope variables
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function declarations
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static ErrorStatus repairMenus_errorReceive(const void* const data);
|
|
static ErrorStatus repairMenus_warningReceive(const void* const data);
|
|
static ErrorStatus repairMenus_freeMainMenuRepairScreenUpdateSemaphore(const void* const data);
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
ErrorStatus repairMenus_construct(void)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
// Create the Menu core
|
|
returnValue = MenuCore_construct(menuCore, mainDisplay, &storm700->keyboardDevice, HSB_MAINMENU_TASK_PRIORITY, HSB_MAINMENU_TASK_STACKSIZE, repairMenu_createMenuEntries, repairMenu_menuStateHandle);
|
|
}
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
// Create first repair menu
|
|
returnValue = repairMenu_construct(mainMenu, menuCore,&iFlash->memoryDevice, repairMenus_freeMainMenuRepairScreenUpdateSemaphore);
|
|
}
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
returnValue = Observable_addObserver(Error_getObservable(), repairMenus_errorReceive);
|
|
}
|
|
|
|
if (returnValue == SUCCESS)
|
|
{
|
|
returnValue = Observable_addObserver(Warning_getObservable(), repairMenus_warningReceive);
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
void repairMenus_destruct(void)
|
|
{
|
|
Observable_deleteObserver(Error_getObservable(), repairMenus_errorReceive);
|
|
repairMenu_destruct(mainMenu);
|
|
}
|
|
|
|
|
|
struct RepairMenu* repairMenus_getMainRepairMenu(void)
|
|
{
|
|
return mainMenu;
|
|
}
|
|
|
|
|
|
static ErrorStatus repairMenus_errorReceive(const void* const data)
|
|
{
|
|
T_ErrorCode errorCode = (T_ErrorCode)data;
|
|
|
|
switch (errorCode)
|
|
{
|
|
case INTERLOCK_COMMON_FAIL:
|
|
{
|
|
repairMenu_interlockFailed(mainMenu, COMMON_INTERLOCK);
|
|
break;
|
|
}
|
|
case POWERENABLE_FAIL:
|
|
{
|
|
break;
|
|
}
|
|
case REPAIR_FAIL:
|
|
{
|
|
repairMenu_processFailed(mainMenu);
|
|
break;
|
|
}
|
|
case ERROR_CRC_PIN:
|
|
case ERROR_CRC_PARAMETERS:
|
|
case ERROR_CRC_PRESETS:
|
|
{
|
|
repairMenu_printCRCFailure(mainMenu, errorCode);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
|
|
}
|
|
}
|
|
return SUCCESS;
|
|
}
|
|
|
|
|
|
static ErrorStatus repairMenus_warningReceive(const void* const data)
|
|
{
|
|
T_WarningCode warningCode = (T_WarningCode)data;
|
|
|
|
switch (warningCode)
|
|
{
|
|
case WARNING_INTERLOCK_COMMON_FAIL:
|
|
{
|
|
repairMenu_interlockWarning(mainMenu, COMMON_INTERLOCK);
|
|
break;
|
|
}
|
|
|
|
default:
|
|
{
|
|
|
|
}
|
|
}
|
|
return SUCCESS;
|
|
}
|
|
|
|
|
|
static ErrorStatus repairMenus_freeMainMenuRepairScreenUpdateSemaphore(const void* const data)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (xSemaphoreGive(mainMenu->repairScreenUpdateSemaphore) != pdTRUE)
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|