[修改]修改了错误的exporter名称
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
add_library(
|
||||
step
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
target_sources(
|
||||
step
|
||||
INTERFACE
|
||||
step.cpp
|
||||
step.h
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
step
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
step
|
||||
INTERFACE
|
||||
nlohmann_json::nlohmann_json
|
||||
)
|
||||
44
opcua-exporter/fault-simulation-algorithm/step/main.cpp
Normal file
44
opcua-exporter/fault-simulation-algorithm/step/main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Created by baiguwen on 2022/4/20.
|
||||
//
|
||||
#include <iostream>
|
||||
#include "step.h"
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
step algorithm;
|
||||
|
||||
algorithm.set_config(
|
||||
{
|
||||
{"STEP_AMPLITUDE_BASE", 10}
|
||||
}
|
||||
);
|
||||
std::vector <std::vector<double>> user_arr;
|
||||
std::ifstream fp("C:/data/user_data.csv");
|
||||
std::string line;
|
||||
getline(fp,line);
|
||||
while (getline(fp,line)){
|
||||
std::vector <double> data_line;
|
||||
std::string number;
|
||||
std::istringstream readstr(line);
|
||||
for(int j = 0;j < 2814;j++){
|
||||
getline(readstr,number,',');
|
||||
data_line.push_back(atof(number.c_str()));
|
||||
}
|
||||
user_arr.push_back(data_line);
|
||||
}
|
||||
std::ofstream outfile;
|
||||
outfile.open("C:/data/user_data6.csv", std::ios::out);
|
||||
outfile<<"origin"<<','<<"step"<<std::endl;
|
||||
for (int i = 0; i <2814; ++i) {
|
||||
user_arr[i][1]=algorithm.eval(user_arr[i][0]);
|
||||
std::cout << i << "\t" << user_arr[i][1] << std::endl;
|
||||
outfile<<user_arr[i][0]<<','<<user_arr[i][1]<<std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
opcua-exporter/fault-simulation-algorithm/step/step.cpp
Normal file
23
opcua-exporter/fault-simulation-algorithm/step/step.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by baiguwen on 2022/4/20.
|
||||
//
|
||||
#include "step.h"
|
||||
#include <iostream>
|
||||
|
||||
void step::set_config(const nlohmann::json &config) {
|
||||
try {
|
||||
amplitude_base_ = jsonValue(config, "STEP_AMPLITUDE_BASE");
|
||||
config_ = config;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
nlohmann::json step::config() {
|
||||
return config_;
|
||||
}
|
||||
|
||||
|
||||
double step::eval(double value) {
|
||||
return value + amplitude_base_;
|
||||
}
|
||||
21
opcua-exporter/fault-simulation-algorithm/step/step.h
Normal file
21
opcua-exporter/fault-simulation-algorithm/step/step.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by baiguwen on 2022/4/20.
|
||||
//
|
||||
|
||||
#ifndef FAULT_SIMULATION_ALGORITHM_MAIN_STEP_H
|
||||
#define FAULT_SIMULATION_ALGORITHM_MAIN_STEP_H
|
||||
#include <algorithm.hpp>
|
||||
|
||||
class step : public algorithm {
|
||||
public:
|
||||
void set_config(const nlohmann::json &config) override;
|
||||
|
||||
nlohmann::json config() override;
|
||||
|
||||
double eval(double value) override;
|
||||
|
||||
protected:
|
||||
nlohmann::json config_{};
|
||||
double amplitude_base_{0};
|
||||
};
|
||||
#endif //FAULT_SIMULATION_ALGORITHM_MAIN_STEP_H
|
||||
Reference in New Issue
Block a user