NSUKit 1.4.0
板卡级统一交互接口
载入中...
搜索中...
未找到
config.h
浏览该文件的文档.
1//
2// Created by 56585 on 2023/8/14.
3//
4
5#ifndef NSUKIT_CONFIG_H
6#define NSUKIT_CONFIG_H
7
8#include <iostream>
9#include <string>
10#include <any>
11#include <map>
12#include <vector>
13
14#include <cmath>
15#include <cstring>
16
17#include <thread>
18#include <mutex>
19#include <chrono>
20
21#include <cstdarg>
22#include <cstdint>
23#include <chrono>
24#include <iomanip>
25#include <ctime>
26
27#include "type.h"
28#include "version.h"
29
30
31namespace nsukit {
32
33#ifdef NSUKIT_DEBUG_EN
34 #define DEBUG_ENABLED true
35#else
36#define DEBUG_ENABLED true
37#endif
38
39#define NSU_REG_BWIDTH 4
40
41#define DEBUG_PRINT(message) debugPrint("func", __func__, message)
42#define DEBUG_PRINT_CLASS(message) debugPrint(typeid(*this).name(), __func__, message)
43
48 uint32_t packHead = 0;
49 uint32_t packId = 0;
50 uint32_t packNum = 0;
51 uint32_t packLength = 0;
52 uint32_t execSucceed = 0;
53 };
54
55 std::string NSU_DLLEXPORT api_info();
56
58
59}
60
61
62inline void debugPrint(const std::string &className, const std::string &functionName, const std::string &message) {
63#if DEBUG_ENABLED
64 // 获取当前时间
65 auto now = std::chrono::system_clock::now();
66
67 // 转换时间为秒和毫秒
68 auto time_since_epoch = now.time_since_epoch();
69 auto seconds = std::chrono::duration_cast<std::chrono::seconds>(time_since_epoch);
70 auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(time_since_epoch - seconds);
71
72 // 获取本地时间
73 std::time_t time_now = std::chrono::system_clock::to_time_t(now);
74 std::tm* local_time = localtime(&time_now);
75
76 // 打印时间、调用函数信息和消息
77 std::cout << "[" << std::put_time(local_time, "%F %T") << "." << std::setw(3) << std::setfill('0')
78 << milliseconds.count() << "] ";
79 std::cout << "DEBUG (" << className << "::" << functionName << "): " << message << std::endl;
80#endif
81}
82
83#endif //NSUKIT_CONFIG_H
void debugPrint(const std::string &className, const std::string &functionName, const std::string &message)
Definition: config.h:62
std::string NSU_DLLEXPORT status2_string(nsukitStatus_t status)
Definition: config.cpp:15
std::string NSU_DLLEXPORT api_info()
Definition: config.cpp:8
nsukitStatus_t
Definition: type.h:53
#define NSU_DLLEXPORT
Definition: type.h:18