Browse Source

Merge branch 'master' into try_support_dt100n

try_support_dt100n
zhaohe 4 weeks ago
parent
commit
5848d4caaf
  1. 35
      appdep/iflytop/core/components/timeutils.hpp
  2. 2
      appsrc/appconfig/basic/zappversion.hpp
  3. 2
      appsrc/service/h2o2_sensor_mgr.cpp
  4. 16
      appsrc/service/os_mgr_service.cpp

35
appdep/iflytop/core/components/timeutils.hpp

@ -22,19 +22,19 @@ using namespace chrono;
template <class T>
class T_TimeUtils {
public:
time_point<T> zero() { return time_point<T>(nanoseconds(0)); }
time_point<T> now() { return move(T::now()); }
int64_t getus() { return duration_cast<microseconds>(T::now().time_since_epoch()).count(); }
int64_t gets() { return duration_cast<seconds>(T::now().time_since_epoch()).count(); }
int64_t getms() { return duration_cast<milliseconds>(T::now().time_since_epoch()).count(); }
int64_t geth() { return duration_cast<hours>(T::now().time_since_epoch()).count(); }
static int64_t tpToMs(time_point<T> t) { return duration_cast<milliseconds>(t.time_since_epoch()).count(); }
static int64_t tpToUs(time_point<T> t) { return duration_cast<microseconds>(t.time_since_epoch()).count(); }
static int64_t tpToS(time_point<T> t) { return duration_cast<seconds>(t.time_since_epoch()).count(); }
static int64_t dToMs(nanoseconds ns) { return duration_cast<milliseconds>(ns).count(); }
static int64_t dToUs(nanoseconds ns) { return duration_cast<microseconds>(ns).count(); }
static int64_t dToS(nanoseconds ns) { return duration_cast<seconds>(ns).count(); }
static int64_t dToNs(nanoseconds ns) { return ns.count(); }
time_point<T> zero() { return time_point<T>(nanoseconds(0)); }
time_point<T> now() { return move(T::now()); }
int64_t getus() { return duration_cast<microseconds>(T::now().time_since_epoch()).count(); }
int64_t gets() { return duration_cast<seconds>(T::now().time_since_epoch()).count(); }
int64_t getms() { return duration_cast<milliseconds>(T::now().time_since_epoch()).count(); }
int64_t geth() { return duration_cast<hours>(T::now().time_since_epoch()).count(); }
static int64_t tpToMs(time_point<T> t) { return duration_cast<milliseconds>(t.time_since_epoch()).count(); }
static int64_t tpToUs(time_point<T> t) { return duration_cast<microseconds>(t.time_since_epoch()).count(); }
static int64_t tpToS(time_point<T> t) { return duration_cast<seconds>(t.time_since_epoch()).count(); }
static int64_t dToMs(nanoseconds ns) { return duration_cast<milliseconds>(ns).count(); }
static int64_t dToUs(nanoseconds ns) { return duration_cast<microseconds>(ns).count(); }
static int64_t dToS(nanoseconds ns) { return duration_cast<seconds>(ns).count(); }
static int64_t dToNs(nanoseconds ns) { return ns.count(); }
static inline time_point<T> msToTp(int64_t ms) {
time_point<T> tp = time_point<T>(milliseconds(ms));
@ -96,6 +96,15 @@ typedef time_point<system_clock> zsystem_tp;
typedef time_point<steady_clock> zsteady_tp;
static inline int64_t zsys_get_ticket() { return zsystem_clock().getms(); }
// static inline int64_t zsys_get_local_clock() {
// struct timeval tv;
// gettimeofday(&tv, NULL);
// // 计算毫秒级 Unix 时间戳
// // TODO: 修改成时区来自系统
// long long timestamp_ms = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
// timestamp_ms += 8 * 3600 * 1000; // 转换为北京时间(UTC+8)
// return timestamp_ms;
// }
static inline int64_t zsys_haspassedms(int64_t old) { return zsystem_clock().elapsedTimeMs(old); }
}; // namespace core

2
appsrc/appconfig/basic/zappversion.hpp

@ -1,3 +1,3 @@
#pragma once
#define VERSION "3.0.7"
#define VERSION "3.0.8"
#define PROJECT_NAME "TRANSMIT_DM"

2
appsrc/service/h2o2_sensor_mgr.cpp

@ -74,7 +74,7 @@ void H2O2SensorMgr::stateUpdateThreadFunc() {
sensorData["rh"] = data.rh;
sensorData["temp"] = data.temp;
sensorData["rs"] = data.rs;
sensorData["timestamp"] = zsys_get_ticket(); // Use current timestamp for reporting
sensorData["timestamp"] = data.timestamp;
}
report.push_back(sensorData);

16
appsrc/service/os_mgr_service.cpp

@ -36,14 +36,14 @@ void OsMgrService::updateTime(shared_ptr<MsgProcessContext> cxt, int hour, int m
}
void OsMgrService::getTime(shared_ptr<MsgProcessContext> cxt) {
// cxt->rely["time"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
cxt->rely["time"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
struct timeval tv;
gettimeofday(&tv, NULL);
// struct timeval tv;
// gettimeofday(&tv, NULL);
// 计算毫秒级 Unix 时间戳
// TODO: 修改成时区来自系统
long long timestamp_ms = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
timestamp_ms += 8 * 3600 * 1000; // 转换为北京时间(UTC+8)
cxt->rely["time"] = timestamp_ms;
// // 计算毫秒级 Unix 时间戳
// // TODO: 修改成时区来自系统
// long long timestamp_ms = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
// timestamp_ms += 8 * 3600 * 1000; // 转换为北京时间(UTC+8)
// cxt->rely["time"] = timestamp_ms;
}
Loading…
Cancel
Save