Merge #1615 into sdk602patch1126 from refs/changes/1615/head
author胡传军 <1224667075@qq.com>
Thu, 9 Jan 2025 13:37:00 +0000 (13:37 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Thu, 9 Jan 2025 13:37:00 +0000 (13:37 +0000)
增加压力计测试项(未实现)

* refs/changes/1615/head: (3 commits squashed)

  - 增加压力计测试项(未实现)

  - 增加压力计测试项(未实现 )

  - 增加压力计测试项(未实现 )

Signed-off-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1615
code/sdk/zhihui/UI/producttest/CMakeLists.txt
code/sdk/zhihui/UI/producttest/include/testPresenter.h
code/sdk/zhihui/UI/producttest/include/testView.h
code/sdk/zhihui/UI/producttest/include/testpressure.h [new file with mode: 0644]
code/sdk/zhihui/UI/producttest/src/testGPS.cpp
code/sdk/zhihui/UI/producttest/src/testView.cpp
code/sdk/zhihui/UI/producttest/src/testpressure.cpp [new file with mode: 0644]

index 6d6e502..e3e73c1 100644 (file)
@@ -26,6 +26,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/testModel.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/testPing.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/testGPS.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/testpressure.cpp
+    
 )
 
 set(PUBLIC_HEADER
index f651e28..e1aedea 100644 (file)
@@ -49,6 +49,8 @@ namespace OHOS
         PingTest,\r
 \r
         GPSTEST,\r
+        // pressuretest,\r
+        PRESSURETEST,\r
         OLDTEST,\r
         DEEPSLEEP,\r
         \r
index a24c08b..9c0d29c 100644 (file)
@@ -30,6 +30,7 @@
 #include "producttest/include/testSEChipTest.h"\r
 #include "producttest/include/testPing.h"\r
 #include "producttest/include/testGPS.h"\r
+#include "producttest/include/testpressure.h"\r
 \r
 #ifdef SUPPORT_A5133_SERVICE\r
 #include "producttest/include/testA5133.h"\r
@@ -99,6 +100,7 @@ namespace OHOS
         bool ChangeSEChipTESTView(int16_t thisView);\r
         bool ChangePingTESTView(int16_t thisView);\r
         bool ChangeGPSTESTView(int16_t thisView);\r
+        bool ChangepressureTestTESTView(int16_t thisView);\r
     #ifdef SUPPORT_A5133_SERVICE\r
         bool ChangeA5133TESTView(int16_t thisView);\r
     #endif\r
@@ -141,6 +143,7 @@ namespace OHOS
         testSEChipView *test_SEChip_view{nullptr};\r
         testPingView *test_Ping_view{nullptr};\r
         testGPSView *test_GPS_view{nullptr};\r
+        testpressureView * test_pressure_view{nullptr};\r
         \r
     #ifdef SUPPORT_A5133_SERVICE\r
         testA5133View  *test_A5133_view{nullptr};\r
diff --git a/code/sdk/zhihui/UI/producttest/include/testpressure.h b/code/sdk/zhihui/UI/producttest/include/testpressure.h
new file mode 100644 (file)
index 0000000..a864079
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef TEST_PRESSURE_VIEW_H
+#define TEST_PRESSURE_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button_ext.h"
+
+//#include "cmsis_os.h"
+#include <iostream>
+namespace OHOS
+{
+
+    class testpressureView
+    {
+
+    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; // 断行模式。
+        };
+
+
+       
+        
+        testpressureView();
+        virtual ~testpressureView();
+        static testpressureView *GetInstance(void);
+   
+        UIScrollView *testpressureInitIView(uint8_t);
+        void  pressuredataTimerCallBack(void);
+
+        void ClearAll(void);
+    private:
+        UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
+        UILabel *InitLabel(LabelConfig &labelConfig);
+        bool testpressureScrollViewcrollViewinit(uint8_t);
+        UIScrollView *testpressureScrollView{nullptr};
+        UILabel *label_1_MSG=NULL;
+        UILabel *label_2_MSG{nullptr};
+        UILabelButtonExt*  GPSbutton[2]{nullptr};
+
+        UILabelButtonExt* labelButton_next = nullptr;
+        bool initViewStatus{false};
+        UILabel *Title{nullptr};           // 标题
+
+    };
+}
+#endif
\ No newline at end of file
index bdba8a2..4341286 100644 (file)
@@ -79,7 +79,7 @@ namespace OHOS
                 GPSbutton[0]=nullptr;
             }
 
-            if(GPSbutton[0])
+            if(GPSbutton[1])
             {
                 delete GPSbutton[1];
                 GPSbutton[1]=nullptr;
index 346c9c2..bbb64bd 100644 (file)
@@ -47,6 +47,7 @@ namespace OHOS
 #if defined(SUPPORT_GNSS)\r
         {GPSTEST,"GPSTestbutton","GPSTest","GPSTestbutton_next" ,&testView::ChangeGPSTESTView,true},\r
 #endif\r
+        {PRESSURETEST,"pressureTestbutton","pressureTest","pressureTestbutton_next" ,&testView::ChangepressureTestTESTView,true},\r
     #ifdef AGINGTEST\r
         {OLDTEST,"oldtestbutton","aging" ,"oldtestexit",&testView::ChangeoldTESTView,true},\r
     #endif\r
@@ -647,6 +648,26 @@ SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0);
         return true;\r
     }\r
 \r
+     bool testView::ChangepressureTestTESTView(int16_t thisView)\r
+    {\r
+\r
+        if (SystemScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView");\r
+            test_pressure_view = new testpressureView();\r
+            if (test_pressure_view == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            SystemScrollView[thisView] = test_pressure_view->testpressureInitIView((uint8_t)thisView);\r
+            RootView::GetInstance()->Add(SystemScrollView[thisView]);\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+\r
 \r
 #ifdef SUPPORT_A5133_SERVICE\r
     bool testView::ChangeA5133TESTView(int16_t thisView)\r
@@ -835,6 +856,13 @@ SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0);
                 SystemScrollView[hideView]=nullptr;\r
                 break;\r
 #endif\r
+             case PRESSURETEST:\r
+                RootView::GetInstance()->Remove(SystemScrollView[hideView]);\r
+                delete test_pressure_view;  \r
+                test_pressure_view = nullptr;\r
+                SystemScrollView[hideView]=nullptr;\r
+                break;\r
+\r
            default:\r
             break;\r
            }\r
diff --git a/code/sdk/zhihui/UI/producttest/src/testpressure.cpp b/code/sdk/zhihui/UI/producttest/src/testpressure.cpp
new file mode 100644 (file)
index 0000000..950a5e1
--- /dev/null
@@ -0,0 +1,226 @@
+#include "wearable_log.h"
+#include "custom_utils.h"
+#include "producttest/include/testPresenter.h"
+
+#include "cmsis_os2.h"
+#include "producttest/include/testView.h"
+#include "producttest/include/testpressure.h"
+// #include "gnss_sample.h"
+#include "graphic_service.h"
+
+namespace OHOS
+{
+
+    static testpressureView *g_pSystemAboutTheWatchView{nullptr};
+
+    testpressureView::testpressureView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView");
+        g_pSystemAboutTheWatchView = this;
+    }
+
+    testpressureView::~testpressureView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testpressureView::~testpressureView");
+        ClearAll();
+        //g_pSystemAboutTheWatchView = nullptr;
+    }
+
+    testpressureView *testpressureView::GetInstance()
+    {
+
+        return g_pSystemAboutTheWatchView;
+    }
+    static osTimerId_t  P_TEST_timer=NULL;
+
+    void testpressureView::ClearAll()
+    {
+        if(testpressureScrollView)
+        {
+            testpressureScrollView->RemoveAll();
+
+            if (P_TEST_timer != NULL) {
+                osTimerStop(P_TEST_timer);
+                osTimerDelete(P_TEST_timer);
+                P_TEST_timer = NULL;
+            }
+            if(labelButton_next)
+            {
+                delete labelButton_next;
+                labelButton_next=nullptr;
+            }
+            if(label_1_MSG)
+            {
+                delete label_1_MSG;
+                label_1_MSG=nullptr;
+            }
+
+            if(label_2_MSG)
+            {
+                delete label_2_MSG;
+                label_2_MSG=nullptr;
+            }
+
+            if(Title)
+            {
+                delete Title;
+                Title=nullptr;
+            }
+        
+            delete testpressureScrollView;
+            testpressureScrollView=nullptr;
+       }
+    }
+   
+    UILabelButtonExt *testpressureView::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->SetStyle(STYLE_BACKGROUND_OPA, 0x80);
+        button->SetText(buttonconfig.str);
+        button->SetAlign(TEXT_ALIGNMENT_LEFT);
+        button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );
+        button->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, buttonconfig.Fontsize);
+        UIView:: OnClickListener *touchListener = static_cast<UIView::OnClickListener *>(testPresenter::GetInstance());
+        button->SetOnClickListener(touchListener);
+
+        return button;
+    }
+   
+     UILabel *testpressureView::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_EN, labelConfig.fontSize);
+        label->SetAlign(TEXT_ALIGNMENT_LEFT);
+        return label;
+    }
+    
+
+    void testpressureView:: pressuredataTimerCallBack(void)
+    {
+        //此处实现数据刷新
+    }
+
+    void pressuredataTimerCallBackproc()
+    {
+         GraphicService::GetInstance()->PostGraphicEvent(std::bind(&testpressureView::pressuredataTimerCallBack,testpressureView::GetInstance()));
+    }
+
+    
+    bool testpressureView::testpressureScrollViewcrollViewinit(uint8_t id)
+    {
+
+        testpressureScrollView = new UIScrollView();
+        if (testpressureScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testpressureScrollView new fail!");
+            return false;
+        }
+        testpressureScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        testpressureScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        testpressureScrollView->SetStyle(STYLE_BORDER_RADIUS, 0);
+        testpressureScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        testpressureScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue);
+
+
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!");
+            return false;
+        }
+       testpressureScrollView->SetOnDragListener(draglistener);
+
+        LabelConfig Config = {
+            .left = 50,
+            .top = 85,
+            .width = Screen::GetInstance().GetWidth()-80,
+            .height = 35,
+            .fontSize = 20,
+            .lineHeigh = 25,
+            .text = "",
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+        };
+        label_1_MSG= InitLabel(Config);
+        if (label_1_MSG == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testpressureScrollView->Add(label_1_MSG);
+
+        Config = {
+            .left = 50,
+            .top = 50,
+            .width = 350,
+            .height = 30,
+            .fontSize = 25,
+            .lineHeigh = 35,
+            .text = "",
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+        };
+        label_2_MSG= InitLabel(Config);
+        if (label_2_MSG == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testpressureScrollView->Add(label_2_MSG);
+
+
+
+        labelButton_next= testAboutView::GetInstance()->init_button_next(267,320,Test_ViewMapper_t[id].viewid_str_next);
+        testpressureScrollView->Add(labelButton_next);
+        
+        Title= testAboutView::GetInstance()->init_title(165,45,"PRESSURE_TEST");
+        testpressureScrollView->Add(Title);
+
+
+        testpressureScrollView->SetTouchable(true);
+        testpressureScrollView->SetDraggable(true);
+        uint32_t tick;
+        osStatus_t retTimer;
+        P_TEST_timer = osTimerNew((osTimerFunc_t)pressuredataTimerCallBackproc, osTimerPeriodic, NULL, NULL);
+        tick =2000;// osMs2Tick(1000);
+        retTimer = osTimerStart(P_TEST_timer, tick);
+        if (retTimer != osOK && P_TEST_timer != NULL) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+            osTimerDelete(P_TEST_timer);
+            P_TEST_timer = NULL;
+            return false;
+        }
+        return true;
+    }
+
+    UIScrollView *testpressureView::testpressureInitIView(uint8_t id)
+    {
+        if (!testpressureScrollViewcrollViewinit(id))
+        {
+            return nullptr;
+        }
+        return testpressureScrollView;
+    }
+}
+
+// #endif