#ifndef TJD_UI_APP_PRODUCT_PRESENTER_H #define TJD_UI_APP_PRODUCT_PRESENTER_H #include "Presenter.h" #include "TjdUiTaskListener.h" #include "TjdUiScreenDrag.h" #include "cmsis_os2.h" #include "components/root_view.h" #include "components/ui_view.h" #include "service_pgnss.h" #include #include #include #define PRODUCT_NORMAL_BTN_VIEW_ID "normalBtn" #define PRODUCT_AGING_BTN_VIEW_ID "agingBtn" #define PRODUCT_TOUCH_BTN_VIEW_ID "touchBtn" #define PRODUCT_GPS_BTN_VIEW_ID "gpsBtn" #define PRODUCT_ONCE_BTN_VIEW_ID "onceBtn" #define PRODUCT_REPEAT_BTN_VIEW_ID "repeatBtn" #define PRODUCT_NEXT_BTN_VIEW_ID "nextBtn" #define PRODUCT_BACK_BTN_VIEW_ID "backBtn" namespace TJD { enum ProductViewIndex { PRODUCT_SELECT_LIST = 0, // 测试选择列表 PRODUCT_LCD_TEST, // LCD测试页面 PRODUCT_TP_CLICK_TEST, // TP点击测试页面 PRODUCT_TP_SLIDE_TEST, // TP滑动测试页面 PRODUCT_HEART_RATE_TEST, // 心率测试页面 PRODUCT_GSENSOR_TEST, // 重力传感器测试页面 PRODUCT_SPEAKER_TEST, // 扬声器测试页面 PRODUCT_MOTOR_TEST, // 马达测试页面 PRODUCT_MICROPHONE_TEST, // 麦克风测试页面 PRODUCT_BUTTON_TEST, // 按键测试页面 PRODUCT_AGING_CHOOSE_TEST, // 老化测试选择页面 PRODUCT_AGING_TEST, // 老化测试页面 PRODUCT_TP_REPORT_TEST, // TP报告测试页面 PRODUCT_GPS_REPORT_TEST, // GPS测试页面 PRODUCT_UNKNOWN }; struct AngingTestItem { bool lcdTest; bool heartRate; bool motor; bool speaker; }; struct AngingTestResult { uint32_t startTime_{0}; uint32_t endTime_{0}; uint8_t startPower_{0}; uint8_t endPower_{0}; AngingTestItem testItem_; }; class TjdUiAppProductView; class TjdUiAppProductPresenter : public OHOS::Presenter, public OHOS::UIView::OnClickListener, public TjdUiScreenDragListener, public OHOS::UIView::OnTouchListener, public OHOS::RootView::OnKeyActListener, public TjdUiTaskListener { public: TjdUiAppProductPresenter(); virtual ~TjdUiAppProductPresenter(); static TjdUiAppProductPresenter *GetInstance(void); void OnStart() override; void OnStop() override; void Notify(void) override; bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; bool OnDrag(OHOS::UIView &view, const OHOS::DragEvent &event) override; bool OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event) override; void ScreenDragEventCallback(OHOS::UIView &view, const OHOS::DragEvent &event) override { ViewExitEvent(true); } bool OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event) override; bool OnPress(OHOS::UIView &view, const OHOS::PressEvent &event) override; void StartJumpTimer(ProductViewIndex jumpView); void DeleteJumpTimer(void); void ShowViewEvent(ProductViewIndex showIndex); void PushGsvToMap(std::string starNum, int snr); void UpdataGsvData(void); std::unordered_map &GetGsvData(void) { return gsvData; } void GnssChangedEvent(bool open); void GnssSignalProcess(GnssQualityLevel &signal); private: bool ClickSelectList(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickAgingChooseTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickLcdTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickTpTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool SlideTpTest(void); bool ClickHeartRateTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickGsensorTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickSpeakerTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickMotorTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickMicrophoneTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickButtonTest(OHOS::UIView &view, const OHOS::ClickEvent &event); bool ClickGPSTest(OHOS::UIView &view, const OHOS::ClickEvent &event); void ShowLcdTestEvent(void); void ShowHeartRateEvent(void); void ShowSpeakerEvent(void); void ShowMotorEvent(void); void ShowMicrophoneEvent(void); void ShowAgintChooseTestEvent(void); void ShowAgintTestEvent(void); void ShowGpsEvent(void); void SetNotifyEnable(uint16_t timeMs, bool enable); void ResetTestView(void); void ViewExitEvent(bool isSwipe); void NormalTestEndEvent(void); void GPSEndEvent(void); void AgingEndEvent(void); void SaveAgingResultToFile(AngingTestResult &result); bool GetAgingResultToFile(AngingTestResult *result); osTimerId_t jumpTimerId_{nullptr}; uint8_t lcdColorIndex_{0}; uint8_t agingTestCount_{0}; AngingTestResult agingTestResult_; std::unordered_map gsvData; bool gpsNormal_{true}; bool notifyEnable_{false}; }; } // namespace TJD #endif