#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 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> TaskRecordPtr = SHM::MapBuilder::find_or_construct(&obj_mapped_file, shm_file); /*单例 TimeRecord 保持 记录的起止时间*/ // const static bipc::offset_ptr> TimeRecordPtr = // SHM::MapBuilder::find_or_construct(&obj_mapped_file, // shm_file); /*单例 TimeRecord 保持 记录的起止时间*/ // const static bipc::offset_ptr TimeRecordPtr = // obj_mapped_file.find_or_construct("TimeRecord")(); } // namespace TaskShm