← Documentation
ADS-IDAC Engine 5.0.0
SPDSUnit.cpp
Go to the documentation of this file.
1// SPDSUnit.cpp: implementation of the SPDSUnit class.
2//
4
5#include "SPDSUnit.h"
6#include "../ControlPanel/ControlPanel.h"
7#include "../Branch/BranchRecord.h"
8#include <boost/serialization/export.hpp>
9#include "../Global/SimulationContext.h"
10#include <boost/archive/binary_oarchive.hpp>
11#include <boost/archive/binary_iarchive.hpp>
12BOOST_CLASS_EXPORT_IMPLEMENT(SPDSUnit)
13using namespace std;
14
15
17// Construction/Destruction
19
21{
22 LL_threshold = 0.0;
23 L_threshold = 0.0;
24 H_threshold = 0.0;
25 HH_threshold = 0.0;
26 SPDS_unit_weight = 0.0;
27 SPDS_unit_value = 0.0;
28 SPDS_unit_name = "NONE";
31}
32
34{
35
36}
48
49void SPDSUnit::readInfoFromFile(ifstream &fin){
52}
53void SPDSUnit::calculateSPDSUnitValue(InfoChunk * _perceived_info_ptr){
54 double current_value;
55 //get value
56 //DisplayParameterValue *dpv_ptr;
57 MentalParameterValue *mpv_ptr = 0;
58 //SystemDisplay *d_element;
59 mpv_ptr = (*_perceived_info_ptr).checkExistanceOfPerceivedParameterValue(this->getCorrespondingIndicatorName());
60 if (mpv_ptr != 0) {
61 current_value = (*mpv_ptr).getObservedParameterValue();
62// d_element = 0;
63// if(this->getPtrToCorrespondingIndicator() == 0){
64// this->setPtrToCorrespondingIndicator((SystemDisplay *) Indicator.indicators.getDisplayFromMap(this->getCorrespondingIndicatorName()));
65// }
66// if (this->getPtrToCorrespondingIndicator() != 0){
67// dpv_ptr = (DisplayParameterValue *) this->getPtrToCorrespondingIndicator();
68// current_value = dpv_ptr->getDisplayedParameterValue();
69// }
70// else{
71// cout << "SPDSUnit::calculateSPDSUnitValue could not find SPDS corresponding parameter " << this->getCorrespondingIndicatorName() << endl;
72// ofstream fout("err messages.txt", ios::app);
73// fout << r5pars_.timesno << " SPDSUnit::calculateSPDSUnitValue could not find SPDS corresponding parameter " << this->getCorrespondingIndicatorName() << '\n';
74// fout.close();
75// r5pars_.sim_err = true;
76// Branch_center.setTempESMessage("ProcedureStepUnit::saveProcedureStepUnitNonResponseActionToFile err.");
77// Branch_center.setTempTypeOfConsequence(Consequence::AdsSimErr);
78// }
79 if(current_value < LL_threshold || current_value > HH_threshold){
80 SPDS_unit_value = 10.0;
81 }
82 else if((current_value > L_threshold) && (current_value < H_threshold)){
83 SPDS_unit_value = 0.0;
84 }
85 else if (current_value <= L_threshold){
86 SPDS_unit_value = 10.0 * (L_threshold - current_value)/(L_threshold - LL_threshold);
87 }
88 else{
89 SPDS_unit_value = 10.0 * (current_value - H_threshold)/(HH_threshold - H_threshold);
90 }
91 }
92 else {
93 SPDS_unit_value = 0.0; // if no information perceived, set SPDS value to 0.0
94 }
95}
98 L_threshold = _spds.getLThreshold();
99 H_threshold = _spds.getHThreshold();
100 HH_threshold = _spds.getHHThreshold();
105
106}
113 ptr_to_corresponding_indicator = _display_element;
114}
115
116void SPDSUnit::saveSPDSUnitToFile(ofstream &fout){
117 fout << LL_threshold << ' '
118 << L_threshold << ' '
119 << H_threshold << ' '
120 << HH_threshold << ' '
121 << SPDS_unit_weight << ' '
122 << SPDS_unit_value << ' '
123 << SPDS_unit_name << ' '
125}
127 fin >> LL_threshold
128 >> L_threshold
129 >> H_threshold
130 >> HH_threshold
136}
void setHHThreshold(double)
Definition: SPDSUnit.cpp:45
double LL_threshold
Definition: SPDSUnit.h:59
double H_threshold
Definition: SPDSUnit.h:59
void setSPDSUnitWeight(double)
Definition: SPDSUnit.cpp:46
double getSPDSUnitWeight()
Definition: SPDSUnit.cpp:41
SystemDisplay * getPtrToCorrespondingIndicator()
Definition: SPDSUnit.cpp:111
void setHThreshold(double)
Definition: SPDSUnit.cpp:44
void calculateSPDSUnitValue(InfoChunk *)
Definition: SPDSUnit.cpp:53
double L_threshold
Definition: SPDSUnit.h:59
std::string SPDS_unit_name
Definition: SPDSUnit.h:61
double getLLThreshold()
Definition: SPDSUnit.cpp:37
void copySPDSUnit(SPDSUnit &)
Definition: SPDSUnit.cpp:96
std::string corresponding_indicator_name
Definition: SPDSUnit.h:61
double getLThreshold()
Definition: SPDSUnit.cpp:38
double SPDS_unit_weight
Definition: SPDSUnit.h:60
std::string getSPDSUnitName()
Definition: SPDSUnit.cpp:110
void setPtrToCorrespondingIndicator(SystemDisplay *)
Definition: SPDSUnit.cpp:112
void setLThreshold(double)
Definition: SPDSUnit.cpp:43
void setSPDSUnitName(std::string)
Definition: SPDSUnit.cpp:109
void setCorrespondingIndicatorName(std::string)
Definition: SPDSUnit.cpp:107
void retrieveSPDSUnitFromFile(std::ifstream &)
Definition: SPDSUnit.cpp:126
std::string getCorrespondingIndicatorName()
Definition: SPDSUnit.cpp:108
void saveSPDSUnitToFile(std::ofstream &)
Definition: SPDSUnit.cpp:116
virtual ~SPDSUnit()
Definition: SPDSUnit.cpp:33
SPDSUnit()
Definition: SPDSUnit.cpp:20
double getSPDSUnitValue()
Definition: SPDSUnit.cpp:47
double HH_threshold
Definition: SPDSUnit.h:59
void setLLThreshold(double)
Definition: SPDSUnit.cpp:42
void readInfoFromFile(std::ifstream &)
Definition: SPDSUnit.cpp:49
double SPDS_unit_value
Definition: SPDSUnit.h:60
double getHHThreshold()
Definition: SPDSUnit.cpp:39
SystemDisplay * ptr_to_corresponding_indicator
Definition: SPDSUnit.h:62
double getHThreshold()
Definition: SPDSUnit.cpp:40