diff --git a/appdep/iflytop/core/components/timeutils.hpp b/appdep/iflytop/core/components/timeutils.hpp index 20bd21f..fb8f625 100644 --- a/appdep/iflytop/core/components/timeutils.hpp +++ b/appdep/iflytop/core/components/timeutils.hpp @@ -22,19 +22,19 @@ using namespace chrono; template class T_TimeUtils { public: - time_point zero() { return time_point(nanoseconds(0)); } - time_point now() { return move(T::now()); } - int64_t getus() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t gets() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t getms() { return duration_cast(T::now().time_since_epoch()).count(); } - int64_t geth() { return duration_cast(T::now().time_since_epoch()).count(); } - static int64_t tpToMs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } - static int64_t tpToUs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } - static int64_t tpToS(time_point t) { return duration_cast(t.time_since_epoch()).count(); } - static int64_t dToMs(nanoseconds ns) { return duration_cast(ns).count(); } - static int64_t dToUs(nanoseconds ns) { return duration_cast(ns).count(); } - static int64_t dToS(nanoseconds ns) { return duration_cast(ns).count(); } - static int64_t dToNs(nanoseconds ns) { return ns.count(); } + time_point zero() { return time_point(nanoseconds(0)); } + time_point now() { return move(T::now()); } + int64_t getus() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t gets() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t getms() { return duration_cast(T::now().time_since_epoch()).count(); } + int64_t geth() { return duration_cast(T::now().time_since_epoch()).count(); } + static int64_t tpToMs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } + static int64_t tpToUs(time_point t) { return duration_cast(t.time_since_epoch()).count(); } + static int64_t tpToS(time_point t) { return duration_cast(t.time_since_epoch()).count(); } + static int64_t dToMs(nanoseconds ns) { return duration_cast(ns).count(); } + static int64_t dToUs(nanoseconds ns) { return duration_cast(ns).count(); } + static int64_t dToS(nanoseconds ns) { return duration_cast(ns).count(); } + static int64_t dToNs(nanoseconds ns) { return ns.count(); } static inline time_point msToTp(int64_t ms) { time_point tp = time_point(milliseconds(ms)); @@ -96,6 +96,15 @@ typedef time_point zsystem_tp; typedef time_point 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 diff --git a/appsrc/appconfig/basic/zappversion.hpp b/appsrc/appconfig/basic/zappversion.hpp index c2093f3..0b746ae 100644 --- a/appsrc/appconfig/basic/zappversion.hpp +++ b/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" \ No newline at end of file diff --git a/appsrc/service/h2o2_sensor_mgr.cpp b/appsrc/service/h2o2_sensor_mgr.cpp index 825c9c3..e00d28d 100644 --- a/appsrc/service/h2o2_sensor_mgr.cpp +++ b/appsrc/service/h2o2_sensor_mgr.cpp @@ -73,7 +73,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); diff --git a/appsrc/service/os_mgr_service.cpp b/appsrc/service/os_mgr_service.cpp index bae535c..f7340ef 100644 --- a/appsrc/service/os_mgr_service.cpp +++ b/appsrc/service/os_mgr_service.cpp @@ -35,14 +35,14 @@ void OsMgrService::updateTime(shared_ptr cxt, int hour, int m } void OsMgrService::getTime(shared_ptr cxt) { - // cxt->rely["time"] = duration_cast(system_clock::now().time_since_epoch()).count(); + cxt->rely["time"] = duration_cast(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; }