← Documentation
ADS-IDAC Engine 5.0.0
DisplayParameterValueRate.cpp
Go to the documentation of this file.
1// DisplayParameterValueRate.cpp: implementation of the DisplayParameterValueRate class.
2//
4
6#include "../Global/TermConversions.h"
7#include <boost/serialization/export.hpp>
8#include <boost/archive/binary_oarchive.hpp>
9#include <boost/archive/binary_iarchive.hpp>
10BOOST_CLASS_EXPORT_IMPLEMENT(DisplayParameterValueRate)
11using namespace std;
12
14// Construction/Destruction
16
18{
20 rate_of_change = 0.0;
22}
23
25{
26
27}
30}
33}
35 deque<double>::iterator par_history_itr;
36 deque<double>::iterator time_itr;
37 for(par_history_itr = dpv.par_history.begin(); par_history_itr != dpv.par_history.end(); par_history_itr++){
38 this->par_history.push_back(*par_history_itr);
39 }
40 for(time_itr = dpv.time.begin(); time_itr != dpv.time.end(); time_itr++){
41 this->time.push_back(*time_itr);
42 }
46}
47//slope m = (n *Sum(XY) - Sum(X)Sum(Y))/{nSum(x^2) - (Sum(X))^2}
49 double x1, x2, x21, x22, x3, x4;
50 x1 = 0.0;
51 x21 = 0.0;
52 x22 = 0.0;
53 x3 = 0.0;
54 x4 = 0.0;
55 deque<double>::iterator par_history_itr;
56 deque<double>::iterator time_itr;
58 time_itr = time.begin();
59 for(par_history_itr = par_history.begin(); par_history_itr != par_history.end(); par_history_itr++){
60 x1 += (*par_history_itr) * (*time_itr);
61 x21 += (*par_history_itr);
62 x22 += (*time_itr);
63 x3 += (*time_itr) * (*time_itr);
64 time_itr++;
65 }
66 x1 *= (double) par_history.size();
67 x2 = x21 * x22;
68 x3 *= (double) par_history.size();
69 x4 = x22 * x22;
70 if (x3 != x4){
71 rate_of_change = (x1 - x2)/(x3 - x4) * 60.0;//per minute
72 }
73 else{
74 rate_of_change = 0.0;
75 }
76 }
77 else{
78 rate_of_change = 0.0;
79 }
81};
87 double displayed_parameter_value, time_x;
88 int i, num;
91 }
92 else{
94 }
95 if(par_history.size() != 0){
96 par_history.push_back(displayed_parameter_value);
97 time.push_back(r5pars_.timesno);
98 }
99 else{
100 for(i = 0; i < num_of_item_for_cal_rate; i++){
102 time_x = r5pars_.timesno - num_of_item_for_cal_rate + i + 1.0;
103 time.push_back(time_x);
104 }
105
106 }
107 num = (int) par_history.size();
108 if(num > num_of_item_for_cal_rate){
109 do{
110 par_history.pop_front();
111 time.pop_front();
113 }while(num > num_of_item_for_cal_rate);
114 }
115}
117 par_history.clear();
118 time.clear();
119}
121 int i;
122 double rtemp;
124 rtemp = rate_of_change;
125 if (rtemp > -1e-30 && rtemp < 1e-30) {
126 rtemp = 0.0;
127 }
128 fout << rtemp << ' ' << num_of_item_for_cal_rate << '\n';
129 fout << par_history.size() << '\n';
130 for (i = 0; i < par_history.size(); i++){
131 rtemp = par_history.at(i);
132 if (rtemp > -1e-30 && rtemp < 1e-30) {
133 rtemp = 0.0;
134 }
135 fout << rtemp << ' ';
136 }
137 fout << '\n';
138 fout << time.size() << '\n';
139 for (i = 0; i < time.size(); i++){
140 fout << time.at(i) << ' ';
141 }
142 fout << '\n';
143}
145 int i, num;
146 double temp_x;
149 for(i = 0; i < num; i++){
150 fin >> temp_x;
151 par_history.push_back(temp_x);
152 }
153 fin >> num;
154 for(i = 0; i < num; i++){
155 fin >> temp_x;
156 time.push_back(temp_x);
157 }
158}
document e
void retrieveDisplayParameterValueRateFromFile(std::ifstream &)
void readInfoFromFileWithoutDisplayName(std::ifstream &)
void saveDisplayParameterValueRateToFile(std::ofstream &)
void copyDisplayParameterValueRate(DisplayParameterValueRate &)
void readInfoFromFile(std::ifstream &)
void saveDisplayParameterValueToFile(std::ofstream &)
void copyDisplayParameterValue(DisplayParameterValue &)
void readInfoFromFile(std::ifstream &)
void readInfoFromFileWithoutDisplayName(std::ifstream &)
void retrieveDisplayParameterValueFromFile(std::ifstream &)
double getCorrespondingSystemParameterValue()
void setTypeOfDisplay(DisplayType type)
int getFunctionalState()
struct @0 r5pars_
constexpr int Succeed
Definition: SimConstants.h:104