aboutsummaryrefslogtreecommitdiffstats
path: root/src/low_can_client.cpp
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-05-09 13:34:19 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-09 13:34:19 +0900
commita660fd2bc4e232dd8bb61febd1eae1e26d674804 (patch)
tree36362f2462d4eb37d3b5eacf300896e4d3c1c5e1 /src/low_can_client.cpp
parenta98320a337645609da7060b20478969196cc2f4e (diff)
Add parking brake ON/OFF event
Change-Id: I3b9face35972a275918ac4f95f4a97df035ee924 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/low_can_client.cpp')
-rw-r--r--src/low_can_client.cpp47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/low_can_client.cpp b/src/low_can_client.cpp
index 23a39e2..2db565c 100644
--- a/src/low_can_client.cpp
+++ b/src/low_can_client.cpp
@@ -29,7 +29,7 @@ namespace wm {
LowCanClient::LowCanClient() :
vehicle_speed_(0),
trans_gear_pos_(0),
- park_brake_status_(TRUE),
+ parking_brake_status_(TRUE),
headlamp_status_(FALSE),
prv_car_state_("car_stop"),
crr_car_state_("car_stop"),
@@ -102,10 +102,10 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) {
else if (strstr(name, "parking_brake_status")) {
HMI_DEBUG("wm:lcc", "Receive parking brake status");
// Update parking gear status
- json_bool park_brake = jh::getBoolFromJson(object, "value");
- if (this->park_brake_status_ != park_brake) {
- this->park_brake_status_ = park_brake;
- HMI_DEBUG("wm:lcc", "Update parking brake status:%d", this->park_brake_status_);
+ json_bool parking_brake = jh::getBoolFromJson(object, "value");
+ if (this->parking_brake_status_ != parking_brake) {
+ this->parking_brake_status_ = parking_brake;
+ HMI_DEBUG("wm:lcc", "Update parking brake status:%d", this->parking_brake_status_);
}
}
else if (strstr(name, "headlamp_status")) {
@@ -118,8 +118,17 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) {
}
}
+ // Update parking brake state
+ if (this->parking_brake_status_) {
+ this->crr_parking_brake_state_ = "parking_brake_on";
+ }
+ else {
+ this->crr_parking_brake_state_ = "parking_brake_off";
+ }
+ HMI_DEBUG("wm:lcc", "Current parking brake state:%s", this->crr_parking_brake_state_.c_str());
+
// Update car state
- if ((0 == this->vehicle_speed_) || (true == this->park_brake_status_)) {
+ if ((0 == this->vehicle_speed_) || (true == this->parking_brake_status_)) {
this->crr_car_state_ = "car_stop";
}
else {
@@ -136,6 +145,15 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) {
}
HMI_DEBUG("wm:lcc", "Current lamp state:%s", this->crr_lamp_state_.c_str());
+ // If parking brake state is changed,
+ // backup current state for previous state and set flag
+ if (this->prv_parking_brake_state_ != this->crr_parking_brake_state_) {
+ HMI_DEBUG("wm:lcc", "Parking Brake state is changed: %s -> %s",
+ this->prv_parking_brake_state_.c_str(), this->crr_parking_brake_state_.c_str());
+ this->prv_parking_brake_state_ = this->crr_parking_brake_state_;
+ this->is_changed_parking_brake_state_ = true;
+ }
+
// If car state is changed,
// backup current state for previous state and set flag
if (this->prv_car_state_ != this->crr_car_state_) {
@@ -155,6 +173,13 @@ void LowCanClient::analyzeCanSignal(struct json_object *object) {
}
}
+bool LowCanClient::isChangedParkingBrakeState() {
+ HMI_DEBUG("wm:lcc", "Call");
+
+ // Return changed flag
+ return this->is_changed_parking_brake_state_;
+}
+
bool LowCanClient::isChangedCarState() {
HMI_DEBUG("wm:lcc", "Call");
@@ -169,6 +194,16 @@ bool LowCanClient::isChangedLampState() {
return this->is_changed_lamp_state_;
}
+const char* LowCanClient::getCurrentParkingBrakeState() {
+ HMI_DEBUG("wm:lcc", "Call");
+
+ // Clear changed flag
+ this->is_changed_parking_brake_state_ = false;
+
+ // Return current parking brake state
+ return this->crr_parking_brake_state_.c_str();
+}
+
const char* LowCanClient::getCurrentCarState() {
HMI_DEBUG("wm:lcc", "Call");