Compare commits

...

2 Commits

11 changed files with 104 additions and 82 deletions

View File

@ -46,15 +46,23 @@ typedef enum {
INICHK_START = 0, INICHK_START = 0,
INICHK_WD_CHECK = 1, INICHK_WD_CHECK = 1,
INICHK_WD_OK = 2, INICHK_WD_OK = 2,
INICHK_ASB_CHECK_1 = 3, INICHK_POS_CHK_1 = 3,
INICHK_ASB_CHECK_2 = 4, INICHK_ASB_CHECK_A_1 = 4,
INICHK_WAIT_TS = 5, INICHK_ASB_CHECK_A_2 = 5,
INICHK_EBS_CHECK_A = 6, INICHK_SWITCH_B = 6,
INICHK_EBS_CHECK_B = 7, INICHK_ASB_CHECK_B_1 = 7,
INICHK_DONE = 8, INICHK_ASB_CHECK_B_2 = 8,
INICHK_ERROR = 9 INICHK_SWITCH_A = 9,
INICHK_ASB_CHECK_AB_1 = 10,
INICHK_ASB_CHECK_AB_2 = 11,
INICHK_POS_CHK_2 = 12,
INICHK_WAIT_TS = 13,
INICHK_DONE = 14,
INICHK_ERROR = 15
} IniChkState; } IniChkState;
const char *inichkstate_str(IniChkState state);
typedef enum { typedef enum {
AMS_ERROR_NONE = 0x00, AMS_ERROR_NONE = 0x00,
AMS_ERROR_SLAVE_TIMEOUT = 0x01, AMS_ERROR_SLAVE_TIMEOUT = 0x01,

View File

@ -1,3 +1,41 @@
#include "vehicle_state.h" #include "vehicle_state.h"
VehicleState vehicle_state = {0}; VehicleState vehicle_state = {0};
const char *inichkstate_str(IniChkState state) {
switch (vehicle_state.ini_chk_state) {
case INICHK_START:
return "START";
case INICHK_WD_CHECK:
return "WD CHK";
case INICHK_WD_OK:
return "WD OK";
case INICHK_POS_CHK_1:
return "POS CHK 1";
case INICHK_ASB_CHECK_A_1:
return "ASB CHK A1";
case INICHK_ASB_CHECK_A_2:
return "ASB CHK A2";
case INICHK_SWITCH_B:
return "SWITCH B";
case INICHK_ASB_CHECK_B_1:
return "ASB CHK B1";
case INICHK_ASB_CHECK_B_2:
return "ASB CHK B2";
case INICHK_SWITCH_A:
return "SWITCH A";
case INICHK_ASB_CHECK_AB_1:
return "ASB CHK AB1";
case INICHK_ASB_CHECK_AB_2:
return "ASB CHK AB2";
case INICHK_POS_CHK_2:
return "POS CHK 2";
case INICHK_WAIT_TS:
return "WAIT TS";
case INICHK_DONE:
return "DONE";
case INICHK_ERROR:
return "ERROR";
}
return "UNKNOWN";
}

View File

@ -28,6 +28,7 @@ public:
virtual ~AMIPresenter(){}; virtual ~AMIPresenter(){};
void vehicleStateUpdated() override; void vehicleStateUpdated() override;
void nextScreen() override;
private: private:
AMIPresenter(); AMIPresenter();

View File

@ -17,7 +17,11 @@ public:
model.tick(); model.tick();
} }
void setBackToMissionSelect(bool backToMissionSelect);
bool getBackToMissionSelect() const;
private: private:
bool backToMissionSelect;
}; };
#endif // FRONTENDAPPLICATION_HPP #endif // FRONTENDAPPLICATION_HPP

View File

@ -1,6 +1,7 @@
#ifndef MISSIONSELECTPRESENTER_HPP #ifndef MISSIONSELECTPRESENTER_HPP
#define MISSIONSELECTPRESENTER_HPP #define MISSIONSELECTPRESENTER_HPP
#include "stw_defines.h"
#include <gui/model/ModelListener.hpp> #include <gui/model/ModelListener.hpp>
#include <mvp/Presenter.hpp> #include <mvp/Presenter.hpp>
@ -30,10 +31,14 @@ public:
void vehicleStateUpdated() override; void vehicleStateUpdated() override;
void nextScreen() override;
private: private:
MissionSelectPresenter(); MissionSelectPresenter();
MissionSelectView &view; MissionSelectView &view;
Mission initialMission;
}; };
#endif // MISSIONSELECTPRESENTER_HPP #endif // MISSIONSELECTPRESENTER_HPP

View File

@ -33,3 +33,9 @@ void AMIPresenter::vehicleStateUpdated() {
} }
view.setConePositions(vehicle_state.cone_pos, cone_count); view.setConePositions(vehicle_state.cone_pos, cone_count);
} }
void AMIPresenter::nextScreen() {
FrontendApplication *app =
static_cast<FrontendApplication *>(FrontendApplication::getInstance());
app->gotoDebugViewScreenNoTransition();
}

View File

@ -80,47 +80,16 @@ void AMIView::setIniChkState(IniChkState state) {
} else { } else {
if (state == INICHK_WAIT_TS) { if (state == INICHK_WAIT_TS) {
progressBar.setColor(DriverViewStatusItem::COLOR_TS); progressBar.setColor(DriverViewStatusItem::COLOR_TS);
progressBar.setValue(100);
} else { } else {
progressBar.setColor(DriverViewStatusItem::COLOR_OK); progressBar.setColor(DriverViewStatusItem::COLOR_OK);
}
float prog = ((float)vehicle_state.ini_chk_state) / INICHK_DONE; float prog = ((float)vehicle_state.ini_chk_state) / INICHK_DONE;
progressBar.setValue(prog * 100); progressBar.setValue(prog * 100);
} }
}
progressBar.invalidate(); progressBar.invalidate();
const char *label = "UNKNOWN"; const char *label = inichkstate_str(state);
switch (vehicle_state.ini_chk_state) {
case INICHK_START:
label = "START";
break;
case INICHK_WD_CHECK:
label = "WD CHK";
break;
case INICHK_WD_OK:
label = "WD OK";
break;
case INICHK_ASB_CHECK_1:
label = "ASB CHK 1";
break;
case INICHK_ASB_CHECK_2:
label = "ASB CHK 2";
break;
case INICHK_WAIT_TS:
label = "WAIT TS";
break;
case INICHK_EBS_CHECK_A:
label = "EBS CHK A";
break;
case INICHK_EBS_CHECK_B:
label = "EBS CHK B";
break;
case INICHK_DONE:
label = "DONE";
break;
case INICHK_ERROR:
label = "ERROR";
break;
}
touchgfx::Unicode::strncpy(progressBuffer, label, touchgfx::Unicode::strncpy(progressBuffer, label,
sizeof(progressBuffer) / sizeof(*progressBuffer)); sizeof(progressBuffer) / sizeof(*progressBuffer));
progressLabel.setWildcard(progressBuffer); progressLabel.setWildcard(progressBuffer);

View File

@ -3,6 +3,14 @@
#include "gui/common/NamedField.hpp" #include "gui/common/NamedField.hpp"
FrontendApplication::FrontendApplication(Model &m, FrontendHeap &heap) FrontendApplication::FrontendApplication(Model &m, FrontendHeap &heap)
: FrontendApplicationBase(m, heap) { : FrontendApplicationBase(m, heap), backToMissionSelect(false) {
namedFieldSort(); namedFieldSort();
} }
void FrontendApplication::setBackToMissionSelect(bool backToMissionSelect) {
this->backToMissionSelect = backToMissionSelect;
}
bool FrontendApplication::getBackToMissionSelect() const {
return backToMissionSelect;
}

View File

@ -144,42 +144,7 @@ void *get_r2dprog_text() {
} }
void *get_inichk_text() { void *get_inichk_text() {
const char *text; return (void *)inichkstate_str(vehicle_state.ini_chk_state);
switch (vehicle_state.ini_chk_state) {
case INICHK_START:
text = "START";
break;
case INICHK_WD_CHECK:
text = "WD CHK";
break;
case INICHK_WD_OK:
text = "WD OK";
break;
case INICHK_ASB_CHECK_1:
text = "ASB CHK1";
break;
case INICHK_ASB_CHECK_2:
text = "ASB CHK2";
break;
case INICHK_WAIT_TS:
text = "WAIT TS";
break;
case INICHK_EBS_CHECK_A:
text = "EBS CHKA";
break;
case INICHK_EBS_CHECK_B:
text = "EBS CHKB";
break;
case INICHK_DONE:
text = "DONE";
break;
case INICHK_ERROR:
text = "ERROR";
break;
default:
text = "UNKNOWN";
}
return (void *)text;
} }
void *get_sdc_text() { void *get_sdc_text() {

View File

@ -1,3 +1,4 @@
#include "gui/common/FrontendApplication.hpp"
#include <gui/debugview_screen/DebugViewPresenter.hpp> #include <gui/debugview_screen/DebugViewPresenter.hpp>
#include <gui/debugview_screen/DebugViewView.hpp> #include <gui/debugview_screen/DebugViewView.hpp>
@ -10,6 +11,8 @@ void DebugViewPresenter::deactivate() {}
void DebugViewPresenter::vehicleStateUpdated() { view.updateFieldValues(); } void DebugViewPresenter::vehicleStateUpdated() { view.updateFieldValues(); }
void DebugViewPresenter::nextScreen() { void DebugViewPresenter::nextScreen() {
static_cast<FrontendApplication *>(Application::getInstance()) FrontendApplication *app =
->gotoDriverViewScreenNoTransition(); static_cast<FrontendApplication *>(Application::getInstance());
app->setBackToMissionSelect(true);
app->gotoMissionSelectScreenNoTransition();
} }

View File

@ -9,13 +9,19 @@
MissionSelectPresenter::MissionSelectPresenter(MissionSelectView &v) MissionSelectPresenter::MissionSelectPresenter(MissionSelectView &v)
: view(v) {} : view(v) {}
void MissionSelectPresenter::activate() {} void MissionSelectPresenter::activate() {
initialMission = vehicle_state.active_mission;
}
void MissionSelectPresenter::deactivate() {} void MissionSelectPresenter::deactivate() {}
void MissionSelectPresenter::vehicleStateUpdated() { void MissionSelectPresenter::vehicleStateUpdated() {
FrontendApplication *app = FrontendApplication *app =
static_cast<FrontendApplication *>(FrontendApplication::getInstance()); static_cast<FrontendApplication *>(FrontendApplication::getInstance());
if (app->getBackToMissionSelect() &&
vehicle_state.active_mission == initialMission) {
return;
}
switch (vehicle_state.active_mission) { switch (vehicle_state.active_mission) {
case MISSION_NONE: case MISSION_NONE:
// Do nothing // Do nothing
@ -27,3 +33,12 @@ void MissionSelectPresenter::vehicleStateUpdated() {
app->gotoAMIScreenNoTransition(); app->gotoAMIScreenNoTransition();
} }
} }
void MissionSelectPresenter::nextScreen() {
FrontendApplication *app =
static_cast<FrontendApplication *>(FrontendApplication::getInstance());
if (app->getBackToMissionSelect()) {
app->gotoAMIScreenNoTransition();
return;
}
}