aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/app.cpp41
-rw-r--r--src/app.hpp8
-rw-r--r--src/low_can_client.cpp23
-rw-r--r--src/low_can_client.hpp15
-rw-r--r--src/main.cpp11
-rw-r--r--src/policy_manager/policy_manager.cpp13
-rw-r--r--src/policy_manager/zipc/dummy_stm.c68
-rw-r--r--src/policy_manager/zipc/dummy_stm.h33
8 files changed, 168 insertions, 44 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 7191727..1d6b504 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -382,11 +382,15 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
// Update state and emit event
if ("parking_brake_off" == parking_brake_state) {
this->crr_car_info_.parking_brake_stt = false;
+#if 0 // FOR ALS: using lightstatus brake, so do not emit parking brake event
this->emitParkingBrakeOff();
+#endif
}
else if ("parking_brake_on" == parking_brake_state) {
this->crr_car_info_.parking_brake_stt = true;
+#if 0 // FOR ALS: using lightstatus brake, so do not emit parking brake event
this->emitParkingBrakeOn();
+#endif
}
else {
reply("Unknown parking brake state");
@@ -419,6 +423,33 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
}
}
+ // Check lightstatus brake state
+ json_object* json_lightstatus_brake;
+ if (!json_object_object_get_ex(json_out, "lightstatus_brake", &json_lightstatus_brake)) {
+ reply("Not found key \"lightstatus_brake\"");
+ return;
+ }
+
+ is_changed = jh::getBoolFromJson(json_lightstatus_brake, "is_changed");
+ if (is_changed) {
+ std::string lightstatus_brake_state = jh::getStringFromJson(json_lightstatus_brake, "state");
+ HMI_DEBUG("wm", "lightstatus_brake_state: %s", lightstatus_brake_state.c_str());
+
+ // Update state and emit event
+ if ("lightstatus_brake_off" == lightstatus_brake_state) {
+ this->crr_car_info_.lightstatus_brake_stt = false;
+ this->emitLightstatusBrakeOff();
+ }
+ else if ("lightstatus_brake_on" == lightstatus_brake_state) {
+ this->crr_car_info_.lightstatus_brake_stt = true;
+ this->emitLightstatusBrakeOn();
+ }
+ else {
+ reply("Unknown lightstatus brake state");
+ return;
+ }
+ }
+
// Check car state
json_object* json_car;
if (!json_object_object_get_ex(json_out, "car", &json_car)) {
@@ -666,6 +697,16 @@ void App::emitParkingBrakeOn() {
this->send_event(kListEventName[Event_ParkingBrakeOn]);
}
+void App::emitLightstatusBrakeOff() {
+ // Send LightstatusBrakeOff event for all application
+ this->send_event(kListEventName[Event_LightstatusBrakeOff]);
+}
+
+void App::emitLightstatusBrakeOn() {
+ // Send LightstatusBrakeOn event for all application
+ this->send_event(kListEventName[Event_LightstatusBrakeOn]);
+}
+
void App::emitCarStop() {
// Send CarStop event for all application
this->send_event(kListEventName[Event_CarStop]);
diff --git a/src/app.hpp b/src/app.hpp
index 2e6ad69..590b23a 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -134,6 +134,7 @@ typedef struct CarInfo {
double accel_pedal_pos;
const char *car_stt;
bool headlamp_stt;
+ bool lightstatus_brake_stt;
} CarInfo;
struct App {
@@ -159,6 +160,9 @@ struct App {
Event_ParkingBrakeOff,
Event_ParkingBrakeOn,
+ Event_LightstatusBrakeOff,
+ Event_LightstatusBrakeOn,
+
Event_CarStop,
Event_CarRun,
@@ -176,6 +180,8 @@ struct App {
"headlamp_on",
"parking_brake_off",
"parking_brake_on",
+ "lightstatus_brake_off",
+ "lightstatus_brake_on",
"car_stop",
"car_run",
};
@@ -287,6 +293,8 @@ private:
void emitHeadlampOn();
void emitParkingBrakeOff();
void emitParkingBrakeOn();
+ void emitLightstatusBrakeOff();
+ void emitLightstatusBrakeOn();
void emitCarStop();
void emitCarRun();
diff --git a/src/low_can_client.cpp b/src/low_can_client.cpp
index 192e124..c02a71c 100644
--- a/src/low_can_client.cpp
+++ b/src/low_can_client.cpp
@@ -33,6 +33,7 @@ LowCanClient::LowCanClient() :
parking_brake_status_(TRUE),
accel_pedal_pos_(0),
accel_pedal_stt_(FALSE),
+ lightstatus_brake_status_(TRUE),
is_changed_accel_pedal_stt_(false)
{
HMI_DEBUG("wm:lcc", "Call");
@@ -56,6 +57,7 @@ void LowCanClient::initialize() {
// low-can subscribe { "event": "headlamp_status" }
// low-can subscribe { "event": "parking_brake_status" }
// low-can subscribe { "event": "accelerator.pedal.position" }
+ // low-can subscribe { "event": "lightstatus.brake" }
for (int i=SignalNoMin; i<=SignalNoMax; i++) {
// Set Event
json_object *json_obj = json_object_new_object();
@@ -87,27 +89,27 @@ const char* LowCanClient::analyzeCanSignal(struct json_object *object) {
const char* name = jh::getStringFromJson(object, "name");
HMI_DEBUG("wm:lcc", "CAN signal name:%s", name);
- if (strstr(name, this->kSignalName_[0])) {
+ if (strstr(name, this->kSignalName_[SignalNoVehicliSpeed])) {
// Update vehicle speed
this->vehicle_speed_ = jh::getIntFromJson(object, "value");
HMI_DEBUG("wm:lcc", "Update vehicle speed:%d", this->vehicle_speed_);
}
- else if (strstr(name, this->kSignalName_[1])) {
+ else if (strstr(name, this->kSignalName_[SignalNoTransGearPos])) {
// Update transmission gear position
this->trans_gear_pos_ = jh::getIntFromJson(object, "value");
HMI_DEBUG("wm:lcc", "Update transmission gear position:%d", this->trans_gear_pos_);
}
- else if (strstr(name, this->kSignalName_[2])) {
+ else if (strstr(name, this->kSignalName_[SignalNoHeadlame])) {
// Update headlamp status
this->headlamp_status_ = jh::getBoolFromJson(object, "value");
HMI_DEBUG("wm:lcc", "Update headlamp status:%d", this->headlamp_status_);
}
- else if (strstr(name, this->kSignalName_[3])) {
+ else if (strstr(name, this->kSignalName_[SignalNoParkingBrake])) {
// Update parking gear status
this->parking_brake_status_ = jh::getBoolFromJson(object, "value");
HMI_DEBUG("wm:lcc", "Update parking brake status:%d", this->parking_brake_status_);
}
- else if (strstr(name, this->kSignalName_[4])) {
+ else if (strstr(name, this->kSignalName_[SignalNoAccelPedalPos])) {
// Clear flag for whether accel pedal state is changed
this->is_changed_accel_pedal_stt_ = false;
@@ -128,6 +130,11 @@ const char* LowCanClient::analyzeCanSignal(struct json_object *object) {
this->accel_pedal_stt_ = accel_pedal_stt;
}
}
+ else if (strstr(name, this->kSignalName_[SignalNoLightstatusBrake])) {
+ // Update lightstatus brake status
+ this->lightstatus_brake_status_ = jh::getBoolFromJson(object, "value");
+ HMI_DEBUG("wm:lcc", "Update lightstatus brake status:%d", this->lightstatus_brake_status_);
+ }
return name;
}
@@ -168,5 +175,11 @@ bool LowCanClient::getCurrentAccelPedalState() {
return this->accel_pedal_stt_;
}
+bool LowCanClient::getCurrentLightstatusBrakeState() {
+ HMI_DEBUG("wm:lcc", "Call");
+
+ return (bool)this->lightstatus_brake_status_;
+}
+
} // namespace wm
diff --git a/src/low_can_client.hpp b/src/low_can_client.hpp
index 4bc3747..390d752 100644
--- a/src/low_can_client.hpp
+++ b/src/low_can_client.hpp
@@ -37,6 +37,7 @@ public:
SignalNoHeadlame,
SignalNoParkingBrake,
SignalNoAccelPedalPos,
+ SignalNoLightstatusBrake,
SignalNum,
@@ -50,6 +51,7 @@ public:
"headlamp_status",
"parking_brake_status",
"accelerator.pedal.position",
+ "lightstatus.brake",
};
void initialize();
@@ -60,6 +62,7 @@ public:
bool getCurrentParkingBrakeState();
double getCurrentAccelPedalPosition();
bool getCurrentAccelPedalState();
+ bool getCurrentLightstatusBrakeState();
bool isChangedAccelPedalState();
@@ -84,11 +87,12 @@ private:
};
const std::vector<const char*> kFilterValue_{
- "",
- "",
- "",
- "",
- "", //"{ \"min\": 0, \"max\": 10}",
+ "", // vehicle.speed
+ "", // transmission_gear_position
+ "", // headlamp_status
+ "", // parking_brake_status
+ "", // accelerator.pedal.position
+ "", // lightstatus.brake
};
int vehicle_speed_;
@@ -97,6 +101,7 @@ private:
json_bool parking_brake_status_;
double accel_pedal_pos_;
bool accel_pedal_stt_;
+ json_bool lightstatus_brake_status_;
bool is_changed_accel_pedal_stt_;
};
diff --git a/src/main.cpp b/src/main.cpp
index 99ad323..07baf2a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -745,6 +745,17 @@ void on_event(const char *event, struct json_object *object){
can_event = "headlamp_off";
}
}
+ else if (strstr(signal_name, lcc->kSignalName_[lcc->SignalNoLightstatusBrake])) {
+ HMI_DEBUG("wm", "Lightstatus Brake state is changed");
+
+ // Set event
+ if (lcc->getCurrentLightstatusBrakeState()) {
+ can_event = "lightstatus_brake_on";
+ }
+ else {
+ can_event = "lightstatus_brake_off";
+ }
+ }
// Allocate window resource
if (nullptr != can_event) {
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index b790794..648c681 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -158,6 +158,19 @@ int PolicyManager::checkPolicy(json_object* json_in, json_object** json_out) {
stm::gStmAccelPedalStateNo2Name[crr_state.accel_pedal.state],
json_out);
+ // "lightstatus_brake": {
+ // "is_changed": <bool>,
+ // "state": <const char*>
+ // },
+ HMI_DEBUG("wm", "lightstatus brake state (is_changed:%d state:%d:%s)",
+ crr_state.lightstatus_brake.is_changed,
+ crr_state.lightstatus_brake.state,
+ stm::gStmLightstatusBrakeStateNo2Name[crr_state.lightstatus_brake.state]);
+ this->addStateToJson("lightstatus_brake",
+ crr_state.lightstatus_brake.is_changed,
+ stm::gStmLightstatusBrakeStateNo2Name[crr_state.lightstatus_brake.state],
+ json_out);
+
// "car": {
// "is_changed": <bool>,
// "state": <const char*>
diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c
index a7d7b67..fc92c3e 100644
--- a/src/policy_manager/zipc/dummy_stm.c
+++ b/src/policy_manager/zipc/dummy_stm.c
@@ -12,7 +12,9 @@ const char* gStmEventName[] = {
"accel_pedal_on",
"timer_expired",
"lamp_off",
- "lamp_on"
+ "lamp_on",
+ "lightstatus_brake_off",
+ "lightstatus_brake_on",
};
const int gStmEventNo[] = {
@@ -26,7 +28,9 @@ const int gStmEventNo[] = {
STM_EVT_NO_ACCEL_PEDAL_ON,
STM_EVT_NO_TIMER_EXPIRED,
STM_EVT_NO_LAMP_OFF,
- STM_EVT_NO_LAMP_ON
+ STM_EVT_NO_LAMP_ON,
+ STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF,
+ STM_EVT_NO_LIGHTSTATUS_BRAKE_ON,
};
const char* gStmCategoryName[] = {
@@ -97,6 +101,11 @@ const char* gStmLampStateNo2Name[] = {
"lamp_on"
};
+const char* gStmLightstatusBrakeStateNo2Name[] = {
+ "lightstatus_brake_off",
+ "lightstatus_brake_on"
+};
+
const char* gStmLayoutNo2Name[] = {
"none",
"pu",
@@ -126,11 +135,12 @@ 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;
- g_prv_state.lamp.state = gStmLampStateNoOff;
+ g_prv_state.trans_gear.state = gStmTransGearStateNoN;
+ g_prv_state.lightstatus_brake.state = gStmLightstatusBrakeStateNoOn;
+ g_prv_state.accel_pedal.state = gStmAccelPedalStateNoOff;
+ g_prv_state.car.state = gStmCarStateNoStop;
+ g_prv_state.lamp.state = gStmLampStateNoOff;
+ g_prv_state.parking_brake.state = gStmParkingBrakeStateNoOn;
// Initialize current state
g_crr_state = g_prv_state;
@@ -139,7 +149,7 @@ void stmInitialize() {
int stmTransitionState(int event, stm_state_t* state) {
int event_no, category_no, area_no;
int restriction_state, apps_state;
- int trans_gear_state, parking_brake_state, accel_pedal_state, car_state, lamp_state;
+ int trans_gear_state, parking_brake_state, lightstatus_brake_state, accel_pedal_state, car_state, lamp_state;
event_no = event & STM_MSK_EVT_NO;
category_no = event & STM_MSK_CTG_NO;
@@ -151,22 +161,24 @@ 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;
- 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;
+ 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;
+ lightstatus_brake_state = g_prv_state.lightstatus_brake.state;
// Clear flags
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.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.trans_gear.is_changed = STM_FALSE;
+ g_crr_state.parking_brake.is_changed = STM_FALSE;
+ g_crr_state.lightstatus_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;
// Set car state
@@ -219,15 +231,27 @@ int stmTransitionState(int event, stm_state_t* state) {
g_crr_state.lamp.is_changed = STM_TRUE;
}
break;
+ case STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF:
+ if (gStmLightstatusBrakeStateNoOff != lightstatus_brake_state) {
+ g_crr_state.lightstatus_brake.state = gStmLightstatusBrakeStateNoOff;
+ g_crr_state.lightstatus_brake.is_changed = STM_TRUE;
+ }
+ break;
+ case STM_EVT_NO_LIGHTSTATUS_BRAKE_ON:
+ if (gStmLightstatusBrakeStateNoOn != lightstatus_brake_state) {
+ g_crr_state.lightstatus_brake.state = gStmLightstatusBrakeStateNoOn;
+ g_crr_state.lightstatus_brake.is_changed = STM_TRUE;
+ }
+ break;
default:
// nop
break;
}
#if 1 // FOR ALS
- if (g_crr_state.parking_brake.is_changed
+ if (g_crr_state.lightstatus_brake.is_changed
|| g_crr_state.accel_pedal.is_changed) {
- if ((gStmParkingBrakeStateNoOff == g_crr_state.parking_brake.state)
+ if ((gStmLightstatusBrakeStateNoOff == g_crr_state.lightstatus_brake.state)
&& (gStmAccelPedalStateNoOn == g_crr_state.accel_pedal.state)){
#else
if (g_crr_state.parking_brake.is_changed
@@ -431,7 +455,7 @@ int stmTransitionState(int event, stm_state_t* state) {
// Set restriction layer
if (STM_CTG_NO_RESTRICTION == category_no) {
if (STM_EVT_NO_ACTIVATE == event_no) {
- if (gStmParkingBrakeStateNoOff == g_crr_state.parking_brake.state) {
+ if (gStmLightstatusBrakeStateNoOff == g_crr_state.lightstatus_brake.state) {
switch (area_no) {
case STM_ARA_NO_RESTRICTION_NORMAL:
switch (restriction_state) {
@@ -487,7 +511,7 @@ int stmTransitionState(int event, stm_state_t* state) {
}
}
else if (g_crr_state.layer.apps.is_changed) {
- if (gStmParkingBrakeStateNoOff == g_crr_state.parking_brake.state) {
+ if (gStmLightstatusBrakeStateNoOff == g_crr_state.lightstatus_brake.state) {
if (gStmLayoutNoM2 == g_crr_state.layer.apps.state) {
g_crr_state.layer.restriction.state = gStmLayoutNoRestrictionSplitSub;
g_crr_state.layer.restriction.is_changed = STM_TRUE;
diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h
index bb99af7..987bd00 100644
--- a/src/policy_manager/zipc/dummy_stm.h
+++ b/src/policy_manager/zipc/dummy_stm.h
@@ -24,17 +24,19 @@
#define STM_FALSE 0
// Event number
-#define STM_EVT_NO_ACTIVATE 0x01
-#define STM_EVT_NO_DEACTIVATE 0x02
-#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
+#define STM_EVT_NO_ACTIVATE 0x01
+#define STM_EVT_NO_DEACTIVATE 0x02
+#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
+#define STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF 0x0C
+#define STM_EVT_NO_LIGHTSTATUS_BRAKE_ON 0x0D
// Category number
#define STM_CTG_NO_HOMESCREEN 0x0100
@@ -61,7 +63,7 @@
#define STM_MSK_ARA_NO 0xFF0000
// Number of events, categories and areas
-#define STM_NUM_EVT 11
+#define STM_NUM_EVT 13
#define STM_NUM_CTG 7
#define STM_NUM_ARA 8
@@ -91,6 +93,11 @@ enum stm_lamp_state_ {
gStmLampStateNoOn
};
+enum stm_lightstatus_brake_state_ {
+ gStmLightstatusBrakeStateNoOff = 0,
+ gStmLightstatusBrakeStateNoOn
+};
+
enum stm_layout_ {
gStmLayoutNoNone = 0,
gStmLayoutNoPu,
@@ -121,6 +128,7 @@ extern const char* gStmAccelPedalStateNo2Name[];
extern const char* gStmCarStateNo2Name[];
extern const char* gStmLampStateNo2Name[];
extern const char* gStmLayoutNo2Name[];
+extern const char* gStmLightstatusBrakeStateNo2Name[];
// Struct for state
typedef struct stm_base_state_ {
@@ -141,6 +149,7 @@ typedef struct {
stm_base_state accel_pedal;
stm_base_state car;
stm_base_state lamp;
+ stm_base_state lightstatus_brake;
stm_layer_state layer;
} stm_state_t;