eis/eqpalg/.do_not_use/data_handler/rs_tools.h

103 lines
2.6 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.

/**
* @file eqpalg/data_handler/rs_tools.h
* @brief 数据工具
* @author Cat (null.null.null@qq.com)
* @version 0.1
* @date 2021-09-17
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#pragma once
#include <memory>
#include <string>
#include <filesystem>
#include <fstream>
#include <functional>
#include <optional>
#include <dlib/statistics.h>
#include "mix_cc/json.h"
namespace data_handler {
using mix_cc::json;
/**
* @brief 得到对应ruleId的running state存放的文件夹
* @param ruleId My Param doc
* @param dim My Param doc
* @return std::string
*/
std::string get_data_path(std::string ruleId, int dim);
/**
* @brief 得到总的rs的位置目录函数
* @param ruleId My Param doc
* @param dim My Param doc
* @return std::string
*/
std::string get_total_rs_path(std::string ruleId, int dim);
/**
* @brief 得到本周的rs的位置目录函数
* @param ruleId My Param doc
* @param dim My Param doc
* @return std::string
*/
std::string get_this_rs_path(std::string ruleId, int dim);
/**
* @brief 得到上周的rs的位置目录函数
* @param ruleId My Param doc
* @param dim My Param doc
* @return std::string
*/
std::string get_prev_rs_path(std::string ruleId, int dim);
/**
* @brief 得到rs的数量正常有两个一旦发生周更替有三个
* @param ruleId My Param doc
* @param dim My Param doc
* @return size_t
*/
size_t get_rs_count(std::string ruleId, int dim);
/**
* @brief 移除上周的rs
* @param ruleId My Param doc
* @param dim My Param doc
* @return true
* @return false
*/
bool remove_old_rs(std::string ruleId, int dim);
/**
* @brief 把本周的rs移动到上周
* @param ruleId My Param doc
* @param dim My Param doc
* @return true
* @return false
*/
bool move_this_rs_to_old(std::string ruleId, int dim);
/**
* @brief 得到running state对象
* @param ruleId 规则id
* @param dim 维度
* @param path_func 目录函数,使用上面的任意函数皆可
* @return std::optional<dlib::running_stats<double>>
*/
std::optional<dlib::running_stats<double>> get_rs(
std::string ruleId, int dim,
std::function<std::string(std::string, int)> path_func);
json get_running_stats_format(dlib::running_stats<double> rs);
/**
* @brief 确保 "/users/dsc/stat_data"一定存在,没有就创建
* @return true
* @return false
*/
bool make_sure_stat_data_exist();
} // namespace data_handler