From edea8081f2c434df036cc7493d2eb0d8eac7dc48 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Wed, 20 Mar 2024 10:47:40 +0800 Subject: [PATCH] =?utf8?q?=E6=BC=8F=E5=85=89=E5=92=8C=E7=81=B0=E5=8D=A1?= =?utf8?q?=E6=B5=8B=E8=AF=95=E4=BA=A7=E6=B5=8Bui?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 3 +- .../producttest/include/testPresenter.h | 2 + .../nativeui/producttest/include/testView.h | 6 +- .../producttest/include/testhrsenson.h | 95 +++++++ .../producttest/src/testPresenter.cpp | 15 +- .../nativeui/producttest/src/testView.cpp | 18 ++ .../nativeui/producttest/src/testcat1.cpp | 4 +- .../nativeui/producttest/src/testhrsenson.cpp | 257 ++++++++++++++++++ .../msg_center/src/msg_center_customer.cpp | 40 +++ 9 files changed, 433 insertions(+), 7 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/producttest/include/testhrsenson.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index ce419c505..3123c0abb 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -468,7 +468,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testmotor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testbutton.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testmakephone.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testcat1.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testcat1.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testhrsenson.cpp ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) set(SOURCES diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h index 994e54606..e11ce9a4f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h @@ -13,6 +13,7 @@ #include "producttest/include/testbutton.h" #include "producttest/include/testmakephone.h" #include "producttest/include/testcat1.h" +#include "producttest/include/testhrsenson.h" #include "common/key_code.h" namespace OHOS { @@ -30,6 +31,7 @@ namespace OHOS CAT1, BUTTON, MAKEPHONE, + HRSENSON, TEST_1, MAX_TESTVIEWID, diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h index 78242fe8c..164ce47ae 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h @@ -22,7 +22,7 @@ #include "producttest/include/testmagnetic.h" #include "producttest/include/testmakephone.h" #include "producttest/include/testcat1.h" - +#include "producttest/include/testhrsenson.h" namespace OHOS { @@ -77,8 +77,9 @@ namespace OHOS bool ChangKEYTESTView(int16_t thisView); bool ChangeMGTESTView(int16_t thisView); bool ChangeMPTESTView(int16_t thisView); + bool ChangeHRTESTView(int16_t thisView); + bool ChangeCAT1TESTView(int16_t thisView); - bool ChangeCAT1TESTView(int16_t thisView); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); UIScrollView *GetSystemScrollView(int ViewId); @@ -110,6 +111,7 @@ namespace OHOS testcat1View *test_cat1_view{nullptr}; testbuttonView *test_KEY_view{nullptr}; testMagicView *test_MG_view{nullptr}; + testhrsenson1View *test_hr_view{nullptr}; testmakephoneView *test_MP_view{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testhrsenson.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testhrsenson.h new file mode 100644 index 000000000..0e7cb670f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testhrsenson.h @@ -0,0 +1,95 @@ +#ifndef TEST_HRSENSON_VIEW_H +#define TEST_HRSENSON_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" + +//#include "cmsis_os.h" +#include +namespace OHOS +{ + + class testhrsenson1View + { + + public: + struct ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + const char *ImageSrc; + + //label + int label_x; + int label_y; + uint8_t ALIGN; + int Fontsize; + + }; + + + + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + + + struct cat1_msg + { + char * imei; + int sim; + char * oper; + uint8_t signal; + }; + + struct cat1_Ver + { + char * modem_version; + char * cat1appver; + }; + + + + + testhrsenson1View(); + virtual ~testhrsenson1View(); + static testhrsenson1View *GetInstance(void); + void gray_test(bool); + void leeklight_test(bool); + UIScrollView *testhrsensonInitIView(void); + void ClearAll(void); + void setgrayvalue(int,int,int); + void setlightvalue(int g,int r,int ir); + private: + UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener); + UILabel *InitLabel(LabelConfig &labelConfig); + bool tesScat1ScrollViewcrollViewinit(void); + UIScrollView *testhrsensonScrollView{nullptr}; + UILabel *label_1_cat1msg_1=NULL; + // UILabel *label_1_cat1msg_oper{nullptr}; + // UILabel *label_1_cat1msg_sim{nullptr}; + // UILabel *label_1_cat1msg_signal{nullptr}; + UILabelButtonExt* button_1{NULL}; + UILabelButtonExt* button_2{NULL}; + UILabel *label_hrsenson_value_vison{nullptr}; + bool initViewStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp index b69ead38c..c98ba2c93 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp @@ -46,7 +46,7 @@ namespace OHOS {CAT1,"cat1button",true}, {BUTTON,"buttonbutton",true}, {MAKEPHONE,"makephonebutton",true}, - + {HRSENSON,"hrsensonbutton",true}, }; // {FACTORYRESETVIEW,"FactoryResetButton",true}, // {SYSTEMLUPGRADE,"systemupgread",true}, @@ -201,9 +201,20 @@ namespace OHOS if(strcmp(view.GetViewId(),"dial_112") == 0) { testcat1View::GetInstance()->dial_112(true); + } + + if(strcmp(view.GetViewId(),"gray_card") == 0) + { + + testhrsenson1View::GetInstance()->gray_test(true); } - + + if(strcmp(view.GetViewId(),"leeklight") == 0) + { + + testhrsenson1View::GetInstance()->leeklight_test(true); + } return false; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp index adcd71960..996d90720 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp @@ -30,6 +30,7 @@ namespace OHOS {CAT1,"cat1button","CAT1", &testView::ChangeCAT1TESTView}, {BUTTON,"buttonbutton","button" ,&testView::ChangKEYTESTView}, {MAKEPHONE,"makephonebutton","makephone" ,&testView::ChangeMPTESTView}, + {HRSENSON,"hrsensonbutton","hrsenson" ,&testView::ChangeHRTESTView}, // {FACTORYRESETVIEW,"FactoryResetButton","恢复出厂", &testView::ChangeSystemAboutView}, // {SYSTEMLUPGRADE,"systemupgread","系统升级",&testView::ChangeSystemAboutView}, // {TEST,"testButton","测试模式", &testView::ChangeSystemAboutView}, @@ -415,6 +416,23 @@ namespace OHOS return true; } + bool testView::ChangeHRTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); + test_hr_view = new testhrsenson1View(); + if (test_hr_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_hr_view->testhrsensonInitIView(); + RootView::GetInstance()->Add(SystemScrollView[thisView]); + } + return true; + } + UIScrollView *testView::GetSystemScrollView(int ViewId) { if (SystemScrollView[ViewId] == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp index b333afdfb..cf0253a92 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp @@ -99,12 +99,12 @@ namespace OHOS static UILabelButtonExt* button{NULL}; - + char *phone="112"; void testcat1View::dial_112(bool falg) { if(button!=NULL) { - calldial_event_sendmsg_toUI("112"); + calldial_event_sendmsg_toUI(phone); RootView::GetInstance()->Invalidate(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp new file mode 100644 index 000000000..ddd63663f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp @@ -0,0 +1,257 @@ +#include "wearable_log.h" +#include "custom_utils.h" +#include "producttest/include/testPresenter.h" +#include "producttest/include/testhrsenson.h" +#include "AlarmClockModel.h" +#include "cmsis_os2.h" +#include "cat1_server.h" +#include "cat1_ctl.h" +#include "cat1_server_hal.h" +#include "ppg_service.h" +namespace OHOS +{ + + static testhrsenson1View *g_pSystemAboutTheWatchView{nullptr}; + + testhrsenson1View::testhrsenson1View() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + g_pSystemAboutTheWatchView = this; + } + + testhrsenson1View::~testhrsenson1View() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::~SystemAboutTheWatchView"); + ClearAll(); + g_pSystemAboutTheWatchView = nullptr; + } + + testhrsenson1View *testhrsenson1View::GetInstance() + { + + return g_pSystemAboutTheWatchView; + } + + void testhrsenson1View::ClearAll() + { + if (initViewStatus == true) + { + } + } + static bool button_falg=true; + void testhrsenson1View:: setgrayvalue(int g,int r,int ir) + { + + if(label_hrsenson_value_vison!=NULL) + { + + char buf[124]={0}; + sprintf(buf,"gray:\n green:%d\nred:%d\nir:%d",g,r,ir); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); + label_hrsenson_value_vison->SetText(buf); + RootView::GetInstance()->Invalidate(); + int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; + send_ppg_cmd_msg(md); + button_falg=true; + } + + } + void testhrsenson1View:: setlightvalue(int g,int r,int ir) + { + + if(label_hrsenson_value_vison!=nullptr) + { + char buf[124]={0}; + sprintf(buf,"leaklight:\ngreen:%d\nred:%d\nir:%d",g,r,ir); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); + label_hrsenson_value_vison->SetText(buf); + RootView::GetInstance()->Invalidate(); + int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; + send_ppg_cmd_msg(md); + button_falg=true; + } + + } + + UILabelButtonExt *testhrsenson1View::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig) + { + UILabelButtonExt *button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); + return nullptr; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + //button->SetStyle(STYLE_BORDER_RADIUS,0); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED); + //button->SetStyleForState(STYLE_BORDER_RADIUS,0, UIButton::PRESSED); + button->SetTouchable(true); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); + UIView:: OnClickListener *touchListener = static_cast(testPresenter::GetInstance()); + button->SetOnClickListener(touchListener); + + // UIView::OnDragListener *drgListener = static_cast(testPresenter::GetInstance()); + // button->SetOnDragListener(drgListener); + + // button->SetDraggable(false); + return button; + } + static bool speakfalg=false; + + + + void testhrsenson1View::gray_test(bool falg) + { + if(button_1!=NULL) + { + int8_t md = PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST; + send_ppg_cmd_msg(md); + button_falg=false; + } + } + + void testhrsenson1View::leeklight_test(bool falg) + { + if(button_2!=NULL) + { + int8_t md = PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST; + send_ppg_cmd_msg(md); + button_falg=false; + } + } + + UILabel *testhrsenson1View::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + label->SetAlign(TEXT_ALIGNMENT_LEFT); + return label; + } + + + + + + bool testhrsenson1View::tesScat1ScrollViewcrollViewinit(void) + { + + testhrsensonScrollView = new UIScrollView(); + if (testhrsensonScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testhrsensonScrollView new fail!"); + return false; + } + testhrsensonScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + testhrsensonScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + testhrsensonScrollView->SetStyle(STYLE_BORDER_RADIUS, 0); + testhrsensonScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + testhrsensonScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue); + + LabelConfig Config = { + .left = 50, + .top = 70, + .width = 60, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "green:\nred:\nir:", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + label_hrsenson_value_vison= InitLabel(Config); + if (label_hrsenson_value_vison == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + return false; + } + testhrsensonScrollView->Add(label_hrsenson_value_vison); + + + + + // uapi_cat1_power_on(1); + // uapi_cat1_reset(0); + + // cat1_getsignal(); + // cat1_getver(); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 100; + buttonconfig.y = 300; + buttonconfig.w = 180; + buttonconfig.h = 116; + buttonconfig.label_x=40; + buttonconfig.label_y=0; + buttonconfig.Fontsize=30; + buttonconfig.ViewId="gray_card"; + buttonconfig.str="gray_card"; + buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + button_1=SetTheButton_ext(buttonconfig); + testhrsensonScrollView->Add(button_1); + + + + buttonconfig.x = 300; + buttonconfig.ViewId="leeklight"; + buttonconfig.str="light"; + button_2=SetTheButton_ext(buttonconfig); + testhrsensonScrollView->Add(button_2); + + // buttonconfig.x = 100; + // buttonconfig.y = 300; + // buttonconfig.w = 200; + // buttonconfig.h = 116; + // buttonconfig.label_x=40; + // buttonconfig.label_y=0; + // buttonconfig.Fontsize=30; + // buttonconfig.ViewId="DOWN_KEY"; + // buttonconfig.str="DOWN_KEY"; + // buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + // button[1]=SetTheButton_ext(buttonconfig); + // testhrsensonScrollView->Add(button[1]); + + // UIView::OnDragListener *draglistener = static_cast(testPresenter::GetInstance()); + // if (draglistener == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + // return false; + // } + // testhrsensonScrollView->SetOnDragListener(draglistener); + + + + + + testhrsensonScrollView->SetTouchable(true); + testhrsensonScrollView->SetDraggable(false); + + int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; + send_ppg_cmd_msg(md); + + return true; + } + + UIScrollView *testhrsenson1View::testhrsensonInitIView() + { + if (!tesScat1ScrollViewcrollViewinit()) + { + return nullptr; + } + return testhrsensonScrollView; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index ba3153549..642c0a77c 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -35,6 +35,7 @@ #include "cat1_server.h" #include "testchanging.h" #include "testcat1.h" +#include "testhrsenson.h" namespace OHOS { #ifdef __cplusplus @@ -246,12 +247,51 @@ void MsgCenterNotifyCardhProc(const Topic topic, Request* req) { unused(topic); unused(req); + //req->data; + //green,red,ir + int green,red,ir; + char* str= (char *)req->data; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",str); + char *tokbuf=NULL; + tokbuf=strtok(str,","); + green=atoi(tokbuf); + tokbuf=strtok(NULL,","); + red=atoi(tokbuf); + tokbuf=strtok(NULL,"\0"); + ir=atoi(tokbuf); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d,%d,%d",green,red,ir); + + testhrsenson1View * t= testhrsenson1View::GetInstance(); + if(t!=NULL) + { + t->setgrayvalue(green,red,ir); + } + } void MsgCenterNotifyleaklighthProc(const Topic topic, Request* req) { unused(topic); unused(req); + //req->data; + //green,red,ir + int green,red,ir; + char* str= (char *)req->data; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",str); + char *tokbuf=NULL; + tokbuf=strtok(str,","); + green=atoi(tokbuf); + tokbuf=strtok(NULL,","); + red=atoi(tokbuf); + tokbuf=strtok(NULL,"\0"); + ir=atoi(tokbuf); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d,%d,%d",green,red,ir); + + testhrsenson1View * t= testhrsenson1View::GetInstance(); + if(t!=NULL) + { + t->setlightvalue(green,red,ir); + } } //穿戴状态 -- 2.17.1