#pragma once /** * @file EqpmRecord.h * @brief eqpm 累计数据的shm数据结构 * @author your name (you@domain.com) * @version 0.1 * @date 2023-12-22 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #include namespace EqpmShm { 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 = "EqpmRecord"; ///<映射文件名 const double data_size = 500; ///< 数据大小 MB const static int MinTime = 1672502400; ///< 2023-01-01 00:00:00 const static int Days = 3650; ///<最多保持10年内的数据 const static int Defalt_Days = 30; ///<默认计算从一个月前开始 const static int MaxYear = 50; ///<最多 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)); /** * @brief 每日的长度、重量 */ struct EqpmRecord { double weight; double length; }; /** * @brief 记录的开始时间,结束时间,默认日重量,日长度 */ struct TimeRecord { int stime; int etime; double per_weight; ///<千克 double per_length; ///<米 }; /*单例 map 记录每天的重量 长度*/ const static bipc::offset_ptr> EqpmRecordPtr = 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 EqpmShm