55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
|
|
#pragma once
|
||
|
|
/**
|
||
|
|
* @file PolyfitStat.h
|
||
|
|
* @brief
|
||
|
|
* @author Cat (null.null.null@qq.com)
|
||
|
|
* @version 0.1
|
||
|
|
* @date 2021-04-07
|
||
|
|
*
|
||
|
|
* Company: Baosight Co. Ltd.
|
||
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
||
|
|
*
|
||
|
|
* @ChangeLog:
|
||
|
|
*/
|
||
|
|
#include <boost/optional.hpp>
|
||
|
|
#include <mix_cc/algorithm/polyfit.h>
|
||
|
|
#include <mix_cc/utility/db2/db_com.h>
|
||
|
|
#include <log4cplus/LOG.h>
|
||
|
|
|
||
|
|
class PolyfitStat {
|
||
|
|
private:
|
||
|
|
/* data */
|
||
|
|
mix_cc::DBCom db_com_;
|
||
|
|
int level_count_;
|
||
|
|
double data_full_level_;
|
||
|
|
long max_fit_count_;
|
||
|
|
|
||
|
|
std::string rule_id_;
|
||
|
|
|
||
|
|
std::vector<std::vector<double>> tmp_sampled_data_;
|
||
|
|
|
||
|
|
struct SampleDataPolyfit {
|
||
|
|
bool calculated_;
|
||
|
|
std::vector<double> coeff_;
|
||
|
|
std::vector<double> x_;
|
||
|
|
std::vector<double> y_;
|
||
|
|
};
|
||
|
|
|
||
|
|
std::vector<SampleDataPolyfit>
|
||
|
|
loaded_sample_data_; // index is level, data is sample data
|
||
|
|
|
||
|
|
public:
|
||
|
|
PolyfitStat(std::string ruleid, int max_fit_count);
|
||
|
|
~PolyfitStat();
|
||
|
|
|
||
|
|
int SetLevelInfo(int level_count, double data_full_level);
|
||
|
|
|
||
|
|
int SaveXY(double x, double y, double level_param);
|
||
|
|
|
||
|
|
int LoadXY();
|
||
|
|
|
||
|
|
int Fit();
|
||
|
|
|
||
|
|
boost::optional<double> GetY(double x, double level_param);
|
||
|
|
};
|