bool JSONParser::isValid(std::string& error) { VALIDATE_STATE(); error = mState->mError; return mState->mValid; }
/** * Called once validation is done and a may change the wakeup at a very * late stage. * * For example if a wakeup event have been verified (=ECUM_WKACT_RUN) but here * a switch or something indicating immediate shutdown the reaction * can be changed here from ECUM_WKACT_RUN to ECUM_WKACT_SHUTDOWN. * This makes would make EcuM to go to * ECUM_STATE_PREP_SHUTDOWN(ECUM_STATE_WAKEUP_WAKESLEEP) instead of * ECUM_STATE_WAKEUP_TWO * * @param wact * @return */ EcuM_WakeupReactionType EcuM_OnWakeupReaction( EcuM_WakeupReactionType wact ) { VALIDATE_STATE( ECUM_STATE_WAKEUP_REACTION ); /* ADD CODE BELOW */ return wact; }
/** * Check RAM hash. * We are still in ECUM_STATE_SLEEP here. * * @return */ uint8 EcuM_CheckRamHash( void ) { VALIDATE_STATE( ECUM_STATE_SLEEP ); /* ADD CODE BELOW */ return 0; }
/** * * @param wakeupSource */ void EcuM_CheckValidation(EcuM_WakeupSourceType wakeupSource) { VALIDATE_STATE( ECUM_STATE_WAKEUP_VALIDATION); /* ADD CODE BELOW */ (void) wakeupSource; }
bool JSONGenerator::openMap() { VALIDATE_STATE(); if (yajl_gen_map_open(mState->mGen) != yajl_gen_status_ok) { return false; } return true; }
void Session::updateState(Session::State state, const list<string> &permissions, SessionError *error) { CCASSERT(VALIDATE_STATE(state), "Invalid state"); FB_LOG("Session::updateState - state = %s", __stateString[state]); FB_LOG("Session::updateState - permissions = (%s)", utils::StringUtils::join(permissions, ",").c_str()); _state = state; _permissions = permissions; if (_callback) _callback(this, error); }
bool JSONGenerator::addPair(const std::string& key, const std::string& value) { VALIDATE_STATE(); if (yajl_gen_string(mState->mGen, (const unsigned char *)key.c_str(), key.length()) != yajl_gen_status_ok) { return false; } else if (yajl_gen_string(mState->mGen, (const unsigned char *)value.c_str(), value.length()) != yajl_gen_status_ok) { return false; } return true; }
bool JSONGenerator::getJSON(std::string& key) { VALIDATE_STATE(); const unsigned char* buf = NULL; size_t len = 0; if (yajl_gen_get_buf(mState->mGen, &buf, &len) != yajl_gen_status_ok) { return false; } key = (const char*)buf; return true; }
bool JSONGenerator::addPair(const std::string& key, const int value) { VALIDATE_STATE(); std::stringstream stream; stream << value; std::string str = stream.str(); if (yajl_gen_string(mState->mGen, (const unsigned char *)key.c_str(), key.length()) != yajl_gen_status_ok) { return false; } else if (yajl_gen_number(mState->mGen, str.c_str(), str.length()) != yajl_gen_status_ok) { return false; } return true; }
bool JSONParser::find(const std::string& key, std::string& value) { VALIDATE_STATE(); bool result = false; if (mState->mTree) { const char* path[2] = { key.c_str(), NULL }; yajl_val str = yajl_tree_get(mState->mTree, path, yajl_t_string); if (str) { result = true; value = YAJL_GET_STRING(str); } } return result; }
bool JSONParser::find(const std::string& key, int& value) { VALIDATE_STATE(); bool result = false; if (mState->mTree) { const char* path[2] = { key.c_str(), NULL }; yajl_val num = yajl_tree_get(mState->mTree, path, yajl_t_number); if (YAJL_IS_INTEGER(num)) { result = true; value = (int)YAJL_GET_INTEGER(num); } } return result; }
/** * Generate RAM hash. * We are in ECUM_STATE_SLEEP here. * */ void EcuM_GenerateRamHash(void) { /* De-init drivers. * There is really no suiteable place to do this but here */ VALIDATE_STATE( ECUM_STATE_SLEEP ); #if defined(USE_GPT) && (GPT_DEINIT_API == STD_ON) Gpt_DeInit(); #endif #if defined(USE_ADC) && (ADC_DEINIT_API == STD_ON) Adc_DeInit(); #endif #if defined(USE_PWM) && (PWM_DE_INIT_API == STD_ON) Pwm_DeInit(); #endif #if defined(USE_SPI) Spi_DeInit(); #endif }
/** * Restart drivers. Have no restart list, instead the * drivers restarted are drivers that have had it's hardware * registers reset. If memory is also lost (=all memory is not * powered during sleep), this strategy does not work. * * This calls: * - EcuM_AL_DriverInitOne() * - EcuM_AL_DriverInitTwo() * */ void EcuM_AL_DriverRestart(const struct EcuM_ConfigS* ConfigPtr) { EcuM_ConfigType* config; VALIDATE_STATE( ECUM_STATE_WAKEUP_ONE); config = EcuM_DeterminePbConfiguration(); /* Start all drivers for now */ EcuM_AL_DriverInitOne(config); /* Setup the systick interrupt */ #if defined(USE_MCU) { uint32_t sys_freq = McuE_GetSystemClock(); Os_SysTickInit(); Os_SysTickStart(sys_freq / OsTickFreq); } #endif EcuM_AL_DriverInitTwo(config); }
/** * Restart drivers. Have no restart list, instead the * drivers restarted are drivers that have had it's hardware * registers reset. If memory is also lost (=all memory is not * powered during sleep), this strategy does not work. * * This calls: * - EcuM_AL_DriverInitOne() * - EcuM_AL_DriverInitTwo() * */ void EcuM_AL_DriverRestart(const struct EcuM_ConfigS* ConfigPtr) { EcuM_ConfigType* config; VALIDATE_STATE( ECUM_STATE_WAKEUP_ONE); config = EcuM_DeterminePbConfiguration(); /* Start all drivers for now */ EcuM_AL_DriverInitOne(config); /* Setup the systick interrupt */ #if defined(USE_MCU) { #if defined(CFG_OS_SYSTICK2) Os_SysTickStart2(OsTickFreq); #else Os_SysTickStart(Mcu_Arc_GetSystemClock() / OsTickFreq); #endif } #endif EcuM_AL_DriverInitTwo(config); }
/** * Stop not validated events * * @param wakeupSource */ void EcuM_StopWakeupSources(EcuM_WakeupSourceType wakeupSource) { printf("EcuM_StopWakeupSources\r\n"); VALIDATE_STATE( ECUM_STATE_WAKEUP_VALIDATION); (void)wakeupSource; }
void Session::initActiveSession(State state, const string &appid, const list<string> &permissions) { CCASSERT(VALIDATE_STATE(state), "Invalid state"); CCASSERT(!_activeSession, "It must be null"); _activeSession = new Session(); _activeSession->init(state, appid, permissions); }
/** * Stop not validated events * * @param wakeupSource */ void EcuM_StopWakeupSources(EcuM_WakeupSourceType wakeupSource) { VALIDATE_STATE( ECUM_STATE_WAKEUP_VALIDATION); (void)wakeupSource; }
void EcuM_StartWakeupSources(EcuM_WakeupSourceType wakeupSource) { VALIDATE_STATE( ECUM_STATE_WAKEUP_VALIDATION ); /* ADD CODE BELOW */ }