eis/shm/TaskData.h

53 lines
1.8 KiB
C++
Raw 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 TaskData.h
* @brief task进程缓存数据
* @author your name (you@domain.com)
* @version 0.1
* @date 2024-02-27
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include <mix_cc/shm.h>
namespace TaskShm {
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 = "TaskData"; ///<映射文件名
const double data_size = 500*10; ///< 数据大小 MB
const size_t MAX_LEN_DAYS = 30; ///<最多可放30天的数据
const size_t DATA_COL_FRE = 50; ///<每秒采集数据点数
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));
struct DataRecord {
float data_record[MAX_LEN_DAYS * 24 * 60 * 60 * DATA_COL_FRE];
};
/**
* @brief 记录的开始时间,结束时间,数据长度
*/
struct TimeRecord {
int stime;
int etime;
size_t data_size; ///<数据长度
};
/*单例 map 记录task数据项*/
const static bipc::offset_ptr<SHM::Map<int, DataRecord>> TaskRecordPtr =
SHM::MapBuilder<int, DataRecord>::find_or_construct(&obj_mapped_file,
shm_file);
/*单例 TimeRecord 保持 记录的起止时间*/
// const static bipc::offset_ptr<SHM::Map<int, TimeRecord>> TimeRecordPtr =
// SHM::MapBuilder<int, TimeRecord>::find_or_construct(&obj_mapped_file,
// shm_file);
/*单例 TimeRecord 保持 记录的起止时间*/
// const static bipc::offset_ptr<TimeRecord> TimeRecordPtr =
// obj_mapped_file.find_or_construct<TimeRecord>("TimeRecord")();
} // namespace TaskShm