add rtdata idx
This commit is contained in:
@@ -235,7 +235,8 @@ public:
|
||||
std::string dev_series;
|
||||
std::string addr_str; //装置ip
|
||||
std::string port; //装置端口
|
||||
std::string timestamp;
|
||||
std::string timestamp; //更新时间
|
||||
std::string Righttime; //对时
|
||||
std::string processNo;
|
||||
std::string maxProcessNum;
|
||||
|
||||
@@ -710,6 +711,25 @@ inline std::string now_yyyy_mm_dd_hh_mm_ss() {
|
||||
oss << std::put_time(&tmv, "%Y-%m-%d %H:%M:%S");
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////实时数据用
|
||||
// === 专用锁 + 数据表(仅管实时 idx 映射) ===
|
||||
extern std::mutex devidx_lock; // 新锁(不要用 ledgermtx)
|
||||
extern std::unordered_map<std::string,int> devIdxMap; // id -> idx,一对一
|
||||
|
||||
// === 常用操作:全部用这把锁保护 ===
|
||||
inline void devidx_set(const std::string& id, int idx) {
|
||||
std::lock_guard<std::mutex> lk(devidx_lock);
|
||||
devIdxMap[id] = idx; // 覆盖更新
|
||||
}
|
||||
|
||||
inline bool devidx_get(const std::string& id, int& out_idx) {
|
||||
std::lock_guard<std::mutex> lk(devidx_lock);
|
||||
auto it = devIdxMap.find(id);
|
||||
if (it == devIdxMap.end()) return false;
|
||||
out_idx = it->second;
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
extern int g_front_seg_index;
|
||||
extern std::string FRONT_INST;
|
||||
|
||||
Reference in New Issue
Block a user