eis/TestProject/ProxyTest/shm/item_data.h

43 lines
1.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
/**
* @file item_data.h
* @brief 查询ihd在一段时间的数据最多1024个tag点
* @author your name (you@domain.com)
* @version 0.1
* @date 2024-01-11
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include <mix_cc/shm.h>
namespace ItemShm {
namespace SHM = mix_cc::shm;
namespace bipc = mix_cc::shm::bip;
const static std::string dir_path = "/users/dsc/shm";
const static std::string shm_file = "ItemData"; ///<映射文件名
const double data_size = 1024; ///< 数据大小 MB
const int max_item_num = 1024; ///<最大数据个数
static bipc::managed_mapped_file obj_mapped_file(
bipc::open_or_create, (dir_path + "/" + shm_file + "_boost.mmap").c_str(),
mix_cc::data_size::MB(data_size));
typedef double ItemData[max_item_num]; ///<一个时间点上所有item的数据值
struct IhdTimeRecord {
int stime; ///<查询的开始时间
int etime; ///<查询的结束时间
int data_size; ///<查询的数据长度
};
/*单例 vector item的数据每个原始位一个时间戳的所有数据最长1024个tag点*/
const static bipc::offset_ptr<SHM::Vector<ItemData>> ItemDataPtr =
SHM::VectorBuilder<ItemData>::find_or_construct(&obj_mapped_file, shm_file);
/*单例 TimeRecord 保持 记录的起止时间*/
const static bipc::offset_ptr<IhdTimeRecord> IhdTimeRecordPtr =
obj_mapped_file.find_or_construct<IhdTimeRecord>("IhdTimeRecord")();
} // namespace ItemShm