summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include/application_manager/request_controller.h
diff options
context:
space:
mode:
authorJustin Dickow <jjdickow@gmail.com>2015-02-20 09:11:18 -0500
committerJustin Dickow <jjdickow@gmail.com>2015-02-20 09:11:18 -0500
commita7c5d752cb75485baa0ded5226335d0f8eb10321 (patch)
treefbfd9251ada2cdcd5cf6a03a79887d08f6b496d7 /src/components/application_manager/include/application_manager/request_controller.h
parentb2b2233d866f102d3de339afa8ccaf37d3cf2570 (diff)
downloadsdl_core-a7c5d752cb75485baa0ded5226335d0f8eb10321.tar.gz
Bug Fixes and ImprovementsSynchronizationCommit
Fix Empty perform iteration request Fix type of name from string to enum SendLocation implemented on HTML5 HMI Fixed PI response on VR rejection due to high priority. Fix Apps not responsive/not able to start app/apps remain listed on SYNC even after USB disconnect Mobile API change and processing capabilities Change perform interaction request conditions. Fix SDL must always start 3sec timer before resuming the HMILevel of the app Remove redundant StartSavePersistentDataTimer() call. Change wrong predicate name to right. Added stream request handling feature Made streaming timeout in media manager configurable Put navi app in LIMITED in case of phone call Handling of audio state for applications Add stop streaming timeout into ini file Implement HMILevel resumption for job-1 Fix result code ABORTED when interrupts it by Voice recognition activation Fix incorrect value parameter unexpectedDisconnect in BCOnAppUnregistered Fix SDL send BC.OnAppUnregistered with "unexpectedDisconnect" set to "true" in case received from HMI OnExitAllApplications {"reason":"MASTER_RESET"} Fix Update ini file for iAP1 support Current working directory added to image path Fix helpers to make it workable with more then 2 parameters DCHECK() for ManageMobileCommand() replaced with log message because the latter returns false in some regular situations (e.g. TOO_MANY_PENDING_REQUESTS, see SDLAQ-CRS-10) Remove connection after closing. Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Diffstat (limited to 'src/components/application_manager/include/application_manager/request_controller.h')
-rw-r--r--src/components/application_manager/include/application_manager/request_controller.h112
1 files changed, 70 insertions, 42 deletions
diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller.h
index 2bc5f54666..8a307c7fc7 100644
--- a/src/components/application_manager/include/application_manager/request_controller.h
+++ b/src/components/application_manager/include/application_manager/request_controller.h
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (c) 2014, Ford Motor Company
* All rights reserved.
*
@@ -54,20 +54,16 @@ namespace application_manager {
namespace request_controller {
-using namespace threads;
-
/**
* @brief RequestController class is used to control currently active mobile
* requests.
*/
class RequestController {
public:
-
/**
* @brief Result code for addRequest
*/
- enum TResult
- {
+ enum TResult {
SUCCESS = 0,
TOO_MANY_REQUESTS,
TOO_MANY_PENDING_REQUESTS,
@@ -78,8 +74,7 @@ class RequestController {
/**
* @brief Thread pool state
*/
- enum TPoolState
- {
+ enum TPoolState {
UNDEFINED = 0,
STARTED,
STOPPED,
@@ -120,7 +115,7 @@ class RequestController {
* @return Result code
*
*/
- TResult addMobileRequest(const MobileRequestPtr& request,
+ TResult addMobileRequest(const RequestPtr request,
const mobile_apis::HMILevel::eType& hmi_level);
@@ -140,19 +135,31 @@ class RequestController {
*/
void addNotification(const RequestPtr ptr);
+
+ /**
+ * @brief Removes request from queue
+ *
+ * @param correlation_id Active request correlation ID,
+ * connection_key - Active request connection key (0 for HMI requersts)
+ *
+ */
+ void terminateRequest(const uint32_t& correlation_id,
+ const uint32_t& connection_key);
+
/**
* @brief Removes request from queue
*
- * @param mobile_corellation_id Active mobile request correlation ID
+ * @param mobile_correlation_id Active mobile request correlation ID
*
*/
- void terminateMobileRequest(const uint32_t& mobile_correlation_id);
+ void terminateMobileRequest(const uint32_t& mobile_correlation_id,
+ const uint32_t& connection_key);
/**
* @brief Removes request from queue
*
- * @param mobile_corellation_id Active mobile request correlation ID
+ * @param mobile_correlation_id Active mobile request correlation ID
*
*/
void terminateHMIRequest(const uint32_t& correlation_id);
@@ -177,6 +184,12 @@ class RequestController {
*/
void terminateAllHMIRequests();
+
+ /**
+ * @brief Terminates all requests from Mobile
+ */
+ void terminateAllMobileRequests();
+
/**
* @brief Updates request timeout
*
@@ -188,30 +201,23 @@ class RequestController {
const uint32_t& mobile_correlation_id,
const uint32_t& new_timeout);
- protected:
-
- /**
- * @brief Checs if this app as able to add new requests, or limits was exceeded
- * @param app_id - application id
- * @param app_time_scale - time scale (seconds)
- * @param max_request_per_time_scale - maximum count of request that should be allowed for app_time_scale secconds
+ /*
+ * @brief Function Should be called when Low Voltage is occured
*/
- bool checkTimeScaleMaxRequest(const uint32_t& app_id,
- const uint32_t& app_time_scale,
- const uint32_t& max_request_per_time_scale);
+ void OnLowVoltage();
- /**
- * @brief Checs if this app as able to add new requests in current hmi_level, or limits was exceeded
- * @param hmi_level - hmi level
- * @param app_id - application id
- * @param app_time_scale - time scale (seconds)
- * @param max_request_per_time_scale - maximum count of request that should be allowed for app_time_scale secconds
+ /*
+ * @brief Function Should be called when Low Voltage is occured
*/
- bool checkHMILevelTimeScaleMaxRequest(const mobile_apis::HMILevel::eType& hmi_level,
- const uint32_t& app_id,
- const uint32_t& app_time_scale,
- const uint32_t& max_request_per_time_scale);
+ void OnWakeUp();
+
+ bool IsLowVoltage();
+
+ protected:
+ /**
+ * @brief Timer Callback
+ */
void onTimer();
/**
@@ -220,16 +226,30 @@ class RequestController {
*/
void UpdateTimer();
- private:
+ void terminateWaitingForExecutionAppRequests(const uint32_t& app_id);
+ void terminateWaitingForResponseAppRequests(const uint32_t& app_id);
- // Data types
+ /**
+ * @brief Check Posibility to add new requests, or limits was exceeded
+ * @param request - request to check possipility to Add
+ * @return True if new request could be added, false otherwise
+ */
+ TResult CheckPosibilitytoAdd(const RequestPtr request);
+
+ /**
+ * @brief Check Posibility to add new requests, or limits was exceeded
+ * @param pending_requests_amount - maximum count of request that should be allowed for all applications
+ * @return True if new request could be added, false otherwise
+ */
+ bool CheckPendingRequestsAmount(const uint32_t& pending_requests_amount);
- class Worker : public ThreadDelegate {
+ private:
+ class Worker : public threads::ThreadDelegate {
public:
- Worker(RequestController* requestController);
+ explicit Worker(RequestController* requestController);
virtual ~Worker();
virtual void threadMain();
- virtual bool exitThreadMain();
+ virtual void exitThreadMain();
protected:
private:
RequestController* request_controller_;
@@ -237,25 +257,33 @@ class RequestController {
volatile bool stop_flag_;
};
- std::vector<Thread*> pool_;
+ std::vector<threads::Thread*> pool_;
volatile TPoolState pool_state_;
uint32_t pool_size_;
sync_primitives::ConditionalVariable cond_var_;
- std::list<MobileRequestPtr> mobile_request_list_;
+ std::list<RequestPtr> mobile_request_list_;
sync_primitives::Lock mobile_request_list_lock_;
- RequestInfoSet pending_request_set_;
- sync_primitives::Lock pending_request_set_lock_;
+ /*
+ * Requests, that are waiting for responses
+ * RequestInfoSet provides correct processing of requests with thre same
+ * app_id and corr_id
+ */
+ RequestInfoSet waiting_for_response_;
/**
* @brief Set of HMI notifications with timeout.
*/
std::list<RequestPtr> notification_list_;
- timer::TimerThread<RequestController> timer_;
+ /*
+ * timer for checking requests timeout
+ */
+ timer::TimerThread<RequestController> timer_;
static const uint32_t dafault_sleep_time_ = UINT_MAX;
+ bool is_low_voltage_;
DISALLOW_COPY_AND_ASSIGN(RequestController);
};