bool load_popup_windows_log(); // 加载popup_windows日志
const std::deque<popup_windows_log_data> &get_popup_windows_log() const; // 获取popup_windows日志记录(常量引用)
size_t get_popup_windows_log_size() const; // 获取日志大小
- void clear_popup_windows_log(); // 清空popup_windows日志记录
-
+ void clear_popup_windows_log(); // 清空popup_windows日志记录
+ /* ---------------------------------- 串口控制 ---------------------------------- */
+ void init_uart();
+ void set_uart_status(bool status);
+ bool get_uart_status();
private:
SystemLogModel() = default; // 私有构造函数
SystemLogModel &operator=(const SystemLogModel &) = delete;
std::deque<SystemLogData> logData; // 存储日志数据
- std::deque<nextday_log_data> nextday_log; // 存储nextday时间戳
- std::deque<popup_windows_log_data> popup_windows_log; // 存储popup_windows时间戳
+ std::deque<nextday_log_data> nextday_log; // 存储nextday时间戳
+ std::deque<popup_windows_log_data>
+ popup_windows_log; // 存储popup_windows时间戳
+
+ bool uart_status{false};
};
} // namespace OHOS
#include <sys/time.h>
#include <thread>
#include <vector>
+#include "ConfigModel.h"
#define SYSTEM_LOG_PATH "/user/system/"
#define SYSTEM_LOG_FILE_PATH "/user/system/system_log.txt"
{
OHOS::SystemLogModel::GetInstance()->save_popup_windows_log_type(type);
}
+//进行开机配置uart
+void system_init_uart(void)
+{
+ OHOS::SystemLogModel::GetInstance()->init_uart();
+}
}
namespace OHOS {
outFile << "";
outFile.close();
}
+/*串口控制*/
+void SystemLogModel::init_uart() {
+ //读取configmodle
+ uart_status = ConfigModel::GetInstance()->get_configData_bool(
+ ConfigModel::CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS);
+ uapi_custom_set_uart_rx_enable_flag(uart_status);
+}
+//设置串口状态
+void SystemLogModel::set_uart_status(bool status) {
+ uart_status = status;
+ uapi_custom_set_uart_rx_enable_flag(uart_status);
+ ConfigModel::GetInstance()->set_condigData_Bool(
+ ConfigModel::CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS,uart_status);
+}
+//获取串口状态
+bool SystemLogModel::get_uart_status() { return uart_status;}
} // namespace OHOS
#include "components/ui_label_button.h"
#include "components/ui_label_ext.h"
#include "components/ui_scroll_view.h"
+#include "components/ui_toggle_button.h"
#include "custom_runtime.h"
#include "custom_utils.h"
#include "graphic_service.h"
DebugOutputAdapter *debugOutputAdapter{nullptr};
UILabel *debugOutputLabel{nullptr};
UILabelButton *debugOutputLabelButton{nullptr};
+ UIToggleButton* toggleButton = nullptr;
UILabelButton *debugOutputbleServiceLabelButton{nullptr};
static constexpr const char *DEBUGOUTPUTLABELBUTTON = "debugOutputLabelButton";
static constexpr const char *DEBUGOUTPUTBLESERVICELABELBUTTON = "debugOutputbleServiceLabelButton";
debugOutputItemInfo[index++] = {index, "popup_windows_log"};
//当前系统亮屏时长
debugOutputItemInfo[index++] = {index, "current_screen_time"};
+ //串口状态服务
+ debugOutputItemInfo[index++] = {index, "uart_service_status"};
usedLen = index;
/* -------------------------------- Add data -------------------------------- */
for (uint8_t i = 0; i < usedLen; i++)
str<<"["<<std::to_string(uapi_dev_runtime_get_screen_always_on_status())<<"]\n";
return str.str();
}
+ //增加串口日志服务
+ std::string DebugOutputViewEventListener::get_uart_at_status() {
+ // 获取系统日志实例
+ auto logModel = SystemLogModel::GetInstance();
+ bool status = logModel->get_uart_status();
+ return std::string("uart_at_status:") + std::to_string(status);
+ }
bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
std::string viewId = view.GetViewId();
{
viewIndex = GetCurViewIndex();
}
+ //点击开启按键
+ else if (viewId == "uart_at_set") {
+ if (toggleButton) {
+ if (toggleButton->GetState() == false) {
+ // toggleButton->SetState(false);
+ SystemLogModel::GetInstance()->set_uart_status(false);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uart_at_set false");
+ }
+ else {
+ // toggleButton->SetState(true);
+ SystemLogModel::GetInstance()->set_uart_status(true);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uart_at_set true");
+ }
+ } else {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"组件不存在");
+ }
+ // viewIndex = GetCurViewIndex();
+ return true; //进行UI刷新
+ }
else // 如果点击的是列表中的itemview
{
DebugOutputItemView *debugOutputItemView = static_cast<DebugOutputItemView *>(&view);
case 11:
str = get_popup_windows_log();
break;
- case 12:
+ case 12:
str = get_system_screen_time();
break;
+ case 13:
+ str = get_uart_at_status();
+ if (toggleButton) {
+ if (toggleButton->IsVisible() == false) {
+ toggleButton->SetVisible(true);
+ }
+ }
+ break;
default:
str = "--";
break;
}
debugOutputLabelButton->SetOnClickListener(clickListener);
DebugScrollView[1]->Add(debugOutputLabelButton);
+ /* -------------------------------------------------------------------------- */
+ if (toggleButton == nullptr) {
+ toggleButton = new UIToggleButton();
+ }
+ toggleButton->SetPosition(147, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20+120); // widget's left position and top position
+ toggleButton->Resize(171, 121); // widget's width and height
+ toggleButton->SetViewId("uart_at_set");// Set style
+ toggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ //获取状态
+ auto logModel = SystemLogModel::GetInstance();
+ bool status = logModel->get_uart_status();
+ toggleButton->SetState(status);
+ toggleButton->SetVisible(false); //设置不可见
+ UIView::OnClickListener *clickListener_ = static_cast<UIView::OnClickListener *>(&DebugOutputViewEventListener::GetInstance());
+ if (clickListener_ == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!");
+ return nullptr;
+ }
+ toggleButton->SetOnClickListener(clickListener_);
+ DebugScrollView[1]->Add(toggleButton);
return DebugScrollView[1];
}
CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES_TIME, //运动目标站立次数
CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION_TIME, //运动燃脂达成时间
CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE_TIME, //运动目标距离
+
+ CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS,//串口控制状态
CONFIGMODEL_ITEM_MAX,
{ConfigDataType::DATATYPE_INT, "goal_standup_times_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES, //运动目标站立次数 10
{ConfigDataType::DATATYPE_INT, "goal_duration_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION, //运动目标时长 30(分钟)
{ConfigDataType::DATATYPE_INT, "goal_distance_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km)
+ {ConfigDataType::DATATYPE_INT, "urat_at_status", "false" },//CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS // 串口AT 默认 关闭
};
ConfigModel(); // 私有构造函数,确保无法在外部实例化