diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-14 18:39:23 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-14 18:39:23 +0900 |
commit | a21dd2b748731f1bbe956da6d22a87cc1412de30 (patch) | |
tree | d5b1fd447ded544b3a20385d1e48362b10f58c6f /src | |
parent | bfadb522b21256fde7283746b90116c237e57a5b (diff) |
Add transmission gear position event in PolicyManager
Change-Id: Ibf528b5ab3877d2cf094920fd0723873fb12647c
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r-- | src/layout_manager/layout.cpp | 2 | ||||
-rw-r--r-- | src/low_can_client.cpp | 35 | ||||
-rw-r--r-- | src/low_can_client.hpp | 18 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.c | 55 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.h | 24 |
5 files changed, 113 insertions, 21 deletions
diff --git a/src/layout_manager/layout.cpp b/src/layout_manager/layout.cpp index 6bec42d..27ef010 100644 --- a/src/layout_manager/layout.cpp +++ b/src/layout_manager/layout.cpp @@ -170,7 +170,7 @@ bool LayoutManager::updateLayout(json_object* obj, if (is_car_state_changed) { // Updating role is not necessary // because new_role is not specified - // when car or accel pedal state is changed + // when car state is changed } else { // Get new_area for new role diff --git a/src/low_can_client.cpp b/src/low_can_client.cpp index 025418a..e3e472f 100644 --- a/src/low_can_client.cpp +++ b/src/low_can_client.cpp @@ -140,6 +140,15 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) { } } + // Update transmission gear position state + if (TransGearPosValN == this->trans_gear_pos_) { + this->crr_accel_pedal_state_ = "trans_gear_neutral"; + } + else { + this->crr_accel_pedal_state_ = "trans_gear_not_neutral"; + } + HMI_DEBUG("wm:lcc", "Current transmission gear state:%s", this->crr_trans_gear_state_.c_str()); + // Update lamp state if (true == this->headlamp_status_) { this->crr_lamp_state_ = "lamp_on"; @@ -167,6 +176,15 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) { } HMI_DEBUG("wm:lcc", "Current accelerator pedal state:%s", this->crr_accel_pedal_state_.c_str()); + // If transmission gear state is changed, + // backup current state for previous state and set flag + if (this->prv_trans_gear_state_ != this->crr_trans_gear_state_) { + HMI_DEBUG("wm:lcc", "Transmission Gear is changed: %s -> %s", + this->prv_trans_gear_state_.c_str(), this->crr_trans_gear_state_.c_str()); + this->prv_trans_gear_state_ = this->crr_trans_gear_state_; + this->is_changed_trans_gear_state_ = true; + } + // If lamp state is changed, // backup current state for previous state and set flag if (this->prv_lamp_state_ != this->crr_lamp_state_) { @@ -195,6 +213,13 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) { } } +bool LowCanClient::isChangedTransGearState() { + HMI_DEBUG("wm:lcc", "Call"); + + // Return changed flag + return this->is_changed_trans_gear_state_; +} + bool LowCanClient::isChangedLampState() { HMI_DEBUG("wm:lcc", "Call"); @@ -216,6 +241,16 @@ bool LowCanClient::isChangedAccelPedalState() { return this->is_changed_accel_pedal_state_; } +const char* LowCanClient::getCurrentTransGearState() { + HMI_DEBUG("wm:lcc", "Call"); + + // Clear changed flag + this->is_changed_trans_gear_state_ = false; + + // Return current transmission gear state + return this->crr_trans_gear_state_.c_str(); +} + const char* LowCanClient::getCurrentLampState() { HMI_DEBUG("wm:lcc", "Call"); diff --git a/src/low_can_client.hpp b/src/low_can_client.hpp index 58d0d8f..9cd10e2 100644 --- a/src/low_can_client.hpp +++ b/src/low_can_client.hpp @@ -33,9 +33,11 @@ public: void initialize(); void analyzeCanSignal(struct json_object *object); + bool isChangedTransGearState(); bool isChangedLampState(); bool isChangedParkingBrakeState(); bool isChangedAccelPedalState(); + const char* getCurrentTransGearState(); const char* getCurrentLampState(); const char* getCurrentParkingBrakeState(); const char* getCurrentAccelPedalState(); @@ -47,6 +49,19 @@ private: LowCanClient(LowCanClient &&) = delete; LowCanClient &operator=(LowCanClient &&) = delete; + enum TransGearPosVal { + TransGearPosValD1 = 1, + TransGearPosValD2, + TransGearPosValD3, + TransGearPosValD4, + TransGearPosValD5, + TransGearPosValD6, + TransGearPosValD7, + TransGearPosValD8, + TransGearPosValR, + TransGearPosValN, + }; + enum SignalNo { SignalNoVehicliSpeed = 0, SignalNoTransGearPos, @@ -82,6 +97,8 @@ private: json_bool parking_brake_status_; double accel_pedal_pos_; + std::string prv_trans_gear_state_; + std::string crr_trans_gear_state_; std::string prv_lamp_state_; std::string crr_lamp_state_; std::string prv_parking_brake_state_; @@ -89,6 +106,7 @@ private: std::string prv_accel_pedal_state_; std::string crr_accel_pedal_state_; + bool is_changed_trans_gear_state_; bool is_changed_lamp_state_; bool is_changed_parking_brake_state_; bool is_changed_accel_pedal_state_; diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c index 968b086..095e5b0 100644 --- a/src/policy_manager/zipc/dummy_stm.c +++ b/src/policy_manager/zipc/dummy_stm.c @@ -4,6 +4,8 @@ const char* gStmEventName[] = { "activate", "deactivate", + "trans_gear_neutral", + "trans_gear_not_neutral", "parking_brake_off", "parking_brake_on", "accel_pedal_off", @@ -16,6 +18,8 @@ const char* gStmEventName[] = { const int gStmEventNo[] = { STM_EVT_NO_ACTIVATE, STM_EVT_NO_DEACTIVATE, + STM_EVT_NO_TRANS_GEAR_N, + STM_EVT_NO_TRANS_GEAR_NOT_N, STM_EVT_NO_PARKING_BRAKE_OFF, STM_EVT_NO_PARKING_BRAKE_ON, STM_EVT_NO_ACCEL_PEDAL_OFF, @@ -68,6 +72,11 @@ const int gStmAreaNo[] = { }; // String for state +const char* gStmTransGearStateNo2Name[] = { + "trans_gear_neutral", + "trans_gear_not_neutral" +}; + const char* gStmParkingBrakeStateNo2Name[] = { "parking_brake_off", "parking_brake_on" @@ -117,6 +126,7 @@ void stmInitialize() { g_prv_state.layer.restriction.state = gStmLayoutNoNone; g_prv_state.layer.apps.state = gStmLayoutNoNone; g_prv_state.layer.homescreen.state = gStmLayoutNoNone; + g_prv_state.trans_gear.state = gStmTransGearStateNoN; g_prv_state.parking_brake.state = gStmParkingBrakeStateNoOn; g_prv_state.accel_pedal.state = gStmAccelPedalStateNoOff; g_prv_state.car.state = gStmCarStateNoStop; @@ -129,7 +139,7 @@ void stmInitialize() { int stmTransitionState(int event, stm_state_t* state) { int event_no, category_no, area_no; int restriction_state, apps_state; - int parking_brake_state, accel_pedal_state, car_state, lamp_state; + int trans_gear_state, parking_brake_state, accel_pedal_state, car_state, lamp_state; event_no = event & STM_MSK_EVT_NO; category_no = event & STM_MSK_CTG_NO; @@ -140,21 +150,23 @@ int stmTransitionState(int event, stm_state_t* state) { // Get previous state restriction_state = g_prv_state.layer.restriction.state; - apps_state = g_prv_state.layer.apps.state; - parking_brake_state = g_prv_state.parking_brake.state; - accel_pedal_state = g_prv_state.accel_pedal.state; - car_state = g_prv_state.car.state; - lamp_state = g_prv_state.lamp.state; + apps_state = g_prv_state.layer.apps.state; + trans_gear_state = g_prv_state.trans_gear.state; + parking_brake_state = g_prv_state.parking_brake.state; + accel_pedal_state = g_prv_state.accel_pedal.state; + car_state = g_prv_state.car.state; + lamp_state = g_prv_state.lamp.state; // Clear flags - g_crr_state.layer.on_screen.is_changed = STM_FALSE; + g_crr_state.layer.on_screen.is_changed = STM_FALSE; g_crr_state.layer.restriction.is_changed = STM_FALSE; - g_crr_state.layer.apps.is_changed = STM_FALSE; - g_crr_state.layer.homescreen.is_changed = STM_FALSE; + g_crr_state.layer.apps.is_changed = STM_FALSE; + g_crr_state.layer.homescreen.is_changed = STM_FALSE; + g_crr_state.trans_gear.is_changed = STM_FALSE; g_crr_state.parking_brake.is_changed = STM_FALSE; - g_crr_state.accel_pedal.is_changed = STM_FALSE; - g_crr_state.car.is_changed = STM_FALSE; - g_crr_state.lamp.is_changed = STM_FALSE; + g_crr_state.accel_pedal.is_changed = STM_FALSE; + g_crr_state.car.is_changed = STM_FALSE; + g_crr_state.lamp.is_changed = STM_FALSE; switch (event_no) { case STM_EVT_NO_ACTIVATE: @@ -362,6 +374,18 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; + case STM_EVT_NO_TRANS_GEAR_N: + if (gStmTransGearStateNoN != trans_gear_state) { + g_crr_state.trans_gear.state = gStmTransGearStateNoN; + g_crr_state.trans_gear.is_changed = STM_TRUE; + } + break; + case STM_EVT_NO_TRANS_GEAR_NOT_N: + if (gStmTransGearStateNoNotN != trans_gear_state) { + g_crr_state.trans_gear.state = gStmTransGearStateNoNotN; + g_crr_state.trans_gear.is_changed = STM_TRUE; + } + break; case STM_EVT_NO_PARKING_BRAKE_OFF: if (gStmParkingBrakeStateNoOff != parking_brake_state) { g_crr_state.parking_brake.state = gStmParkingBrakeStateNoOff; @@ -404,10 +428,17 @@ int stmTransitionState(int event, stm_state_t* state) { } // Set car state +#if 1 // FOR ALS if (g_crr_state.parking_brake.is_changed || g_crr_state.accel_pedal.is_changed) { if ((gStmParkingBrakeStateNoOff == g_crr_state.parking_brake.state) && (gStmAccelPedalStateNoOn == g_crr_state.accel_pedal.state)){ +#else + if (g_crr_state.parking_brake.is_changed + || g_crr_state.trans_gear.is_changed) { + if ((gStmParkingBrakeStateNoOff == g_crr_state.parking_brake.state) + && (gStmTransGearStateNoNotN == g_crr_state.trans_gear.state)){ +#endif if (gStmCarStateNoRun != car_state) { // Car state is changed stop -> run g_crr_state.car.state = gStmCarStateNoRun; diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h index 42c5148..bb99af7 100644 --- a/src/policy_manager/zipc/dummy_stm.h +++ b/src/policy_manager/zipc/dummy_stm.h @@ -26,13 +26,15 @@ // Event number #define STM_EVT_NO_ACTIVATE 0x01 #define STM_EVT_NO_DEACTIVATE 0x02 -#define STM_EVT_NO_PARKING_BRAKE_OFF 0x03 -#define STM_EVT_NO_PARKING_BRAKE_ON 0x04 -#define STM_EVT_NO_ACCEL_PEDAL_OFF 0x05 -#define STM_EVT_NO_ACCEL_PEDAL_ON 0x06 -#define STM_EVT_NO_TIMER_EXPIRED 0x07 -#define STM_EVT_NO_LAMP_OFF 0x08 -#define STM_EVT_NO_LAMP_ON 0x09 +#define STM_EVT_NO_TRANS_GEAR_N 0x03 +#define STM_EVT_NO_TRANS_GEAR_NOT_N 0x04 +#define STM_EVT_NO_PARKING_BRAKE_OFF 0x05 +#define STM_EVT_NO_PARKING_BRAKE_ON 0x06 +#define STM_EVT_NO_ACCEL_PEDAL_OFF 0x07 +#define STM_EVT_NO_ACCEL_PEDAL_ON 0x08 +#define STM_EVT_NO_TIMER_EXPIRED 0x09 +#define STM_EVT_NO_LAMP_OFF 0x0A +#define STM_EVT_NO_LAMP_ON 0x0B // Category number #define STM_CTG_NO_HOMESCREEN 0x0100 @@ -59,11 +61,16 @@ #define STM_MSK_ARA_NO 0xFF0000 // Number of events, categories and areas -#define STM_NUM_EVT 9 +#define STM_NUM_EVT 11 #define STM_NUM_CTG 7 #define STM_NUM_ARA 8 // Enum for state +enum stm_trans_gear_state_ { + gStmTransGearStateNoN = 0, + gStmTransGearStateNoNotN +}; + enum stm_parking_brake_state_ { gStmParkingBrakeStateNoOff = 0, gStmParkingBrakeStateNoOn @@ -129,6 +136,7 @@ typedef struct stm_layer_state_ { } stm_layer_state; typedef struct { + stm_base_state trans_gear; stm_base_state parking_brake; stm_base_state accel_pedal; stm_base_state car; |