←
Documentation
ADS-IDAC Engine
5.0.0
BranchExpectedParameterTrend.cpp
Go to the documentation of this file.
1
// BranchExpectedParameterTrend.cpp: implementation of the BranchExpectedParameterTrend class.
2
//
4
5
#include <sstream>
6
#include "
BranchExpectedParameterTrend.h
"
7
#include "../Global/ConvertToString.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>
12
BOOST_CLASS_EXPORT_IMPLEMENT(
BranchExpectedParameterTrend
)
13
using namespace
std;
14
15
17
// Construction/Destruction
19
20
BranchExpectedParameterTrend::BranchExpectedParameterTrend
() {
21
22
}
23
24
BranchExpectedParameterTrend::~BranchExpectedParameterTrend
() {
25
26
}
27
void
BranchExpectedParameterTrend::copyBranchExpectedParameterTrend
(
BranchExpectedParameterTrend
&_bep) {
28
DecisionExpectedParameterTrend::copyDecisionExpectedParameterTrend
((
DecisionExpectedParameterTrend
&) _bep);
29
TimerAndProbability::copyTimerAndProbability
((
TimerAndProbability
&) _bep);
30
Communication::copyCommunication
((
Communication
&) _bep);
31
}
32
void
BranchExpectedParameterTrend::saveInfoToFile
(ostream &fout) {
33
// fout << ' ' << this->getSender() << ' ' << sim::Action::SendInfo << ' ' << sim::None << ' ' << this->getDisplayName() << ' ' << this->getProbability() << ' '
34
// << this->getTimeOfCommunication() << ' ' << this->getRemainingTime() << ' ' << this->getObservedParameterRateOfChange() << " 0 "
35
// << '"' << "Intended_Receiver:" << Translator.getString(this->getIntendedReceiver()) << '"' << '\n';
36
37
// char ch1[50], ch2[50], ch3[50];
38
double
v1, v2, v3;
39
string
str;
40
str +=
"Status:"
;
41
str +=
g_sim
.
Translator
.
getString
(this->
getStateOfExpectation
());
42
str +=
";_Exp_State:"
;
43
str +=
g_sim
.
Translator
.
getString
(this->
getLogicalRelation
());
44
if
(this->
getLogicalRelation
() !=
sim::Compare::Between
) {
45
v1 = this->
getExpectedValue1
();
46
// _gcvt(v1, 12, ch1);
47
str += to_string(v1);
48
}
else
{
49
v1 = this->
getExpectedValue1
();
50
v2 = this->
getExpectedValue2
();
51
// _gcvt(v1, 12, ch1);
52
// _gcvt(v2, 12, ch2);
53
str +=
'_'
;
54
str += to_string(v1);
55
str +=
"_and_"
;
56
str += to_string(v2);
57
}
58
str +=
";_Observed_value:"
;
59
v3 = this->
getObservedParameterRateOfChange
();
60
// _gcvt(v3, 12, ch3);
61
str += to_string(v3);
62
if
(this->
getStateOfActivation
() ==
sim::State::OldInfo
) {
63
str +=
";_Use_of_memorized_info"
;
64
}
65
fout <<
' '
<< this->
getSender
() <<
' '
<<
sim::Action::SendInfo
<<
' '
<<
sim::None
<<
' '
<< this->
getDisplayName
() <<
' '
66
<< this->
getProbability
() <<
' '
67
<< this->
getTimeOfCommunication
() <<
' '
<< this->
getRemainingTime
() <<
' '
68
<< this->
getObservedParameterRateOfChange
() <<
" 0 "
69
<<
'"'
<<
"Intended_Receiver:"
<<
g_sim
.
Translator
.
getString
(this->
getIntendedReceiver
()) <<
';'
<< str <<
'"'
<<
'\n'
;
70
}
71
string
BranchExpectedParameterTrend::translateMessage
() {
72
string
str;
73
std::ostringstream streamObj;
74
str =
"Parameter_Trend: Sender: "
;
75
str +=
g_sim
.
Translator
.
getString
(this->
getSender
());
76
str +=
"; Receiver: "
;
77
str +=
g_sim
.
Translator
.
getString
(this->
getIntendedReceiver
());
78
str +=
"; Parameter_Trend: "
;
79
str += this->
getDisplayName
();
80
str +=
"; Status: "
;
81
str +=
g_sim
.
Translator
.
getString
(this->
getStateOfExpectation
());
82
str +=
"; Exp State: "
;
83
str +=
g_sim
.
Translator
.
getString
(this->
getLogicalRelation
());
84
str +=
' '
;
85
if
(this->
getLogicalRelation
() !=
sim::Compare::Between
) {
86
streamObj << this->
getExpectedValue1
();
87
str += streamObj.str();
88
}
else
{
89
streamObj << this->
getExpectedValue1
();
90
str += streamObj.str();
91
streamObj.str(
""
);
92
str +=
" and "
;
93
streamObj << this->
getExpectedValue2
();
94
str += streamObj.str();
95
streamObj.str(
""
);
96
}
97
str +=
"; Observed value: "
;
98
streamObj << this->
getObservedParameterRateOfChange
();
99
str += streamObj.str();
100
streamObj.str(
""
);
101
if
(this->
getStateOfActivation
() ==
sim::State::OldInfo
) {
102
str +=
"; Use of memorized info"
;
103
}
104
str +=
"; New Probability: "
;
105
streamObj << this->
getProbability
();
106
str += streamObj.str();
107
return
str;
108
}
109
void
BranchExpectedParameterTrend::saveBranchExpectedParameterTrendToFile
(ofstream &fout) {
110
this->
saveDecisionExpectedParameterTrendToFile
(fout);
111
this->
saveTimerAndProbabilityToFile
(fout);
112
this->
saveCommunicationToFile
(fout);
113
}
114
void
BranchExpectedParameterTrend::retrieveBranchExpectedParameterTrendFromFile
(ifstream &fin) {
115
this->
retrieveDecisionExpectedParameterTrendFromFile
(fin);
116
this->
retrieveTimerAndProbabilityFromFile
(fin);
117
this->
retrieveCommunicationFromFile
(fin);
118
}
BranchExpectedParameterTrend.h
g_sim
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Definition:
SimulationContext.cpp:7
BranchExpectedParameterTrend
Definition:
BranchExpectedParameterTrend.h:23
BranchExpectedParameterTrend::~BranchExpectedParameterTrend
virtual ~BranchExpectedParameterTrend()
Definition:
BranchExpectedParameterTrend.cpp:24
BranchExpectedParameterTrend::saveInfoToFile
void saveInfoToFile(std::ostream &)
Definition:
BranchExpectedParameterTrend.cpp:32
BranchExpectedParameterTrend::retrieveBranchExpectedParameterTrendFromFile
void retrieveBranchExpectedParameterTrendFromFile(std::ifstream &)
Definition:
BranchExpectedParameterTrend.cpp:114
BranchExpectedParameterTrend::copyBranchExpectedParameterTrend
void copyBranchExpectedParameterTrend(BranchExpectedParameterTrend &)
Definition:
BranchExpectedParameterTrend.cpp:27
BranchExpectedParameterTrend::BranchExpectedParameterTrend
BranchExpectedParameterTrend()
Definition:
BranchExpectedParameterTrend.cpp:20
BranchExpectedParameterTrend::translateMessage
std::string translateMessage()
Definition:
BranchExpectedParameterTrend.cpp:71
BranchExpectedParameterTrend::saveBranchExpectedParameterTrendToFile
void saveBranchExpectedParameterTrendToFile(std::ofstream &)
Definition:
BranchExpectedParameterTrend.cpp:109
Communication
Definition:
Communication.h:20
Communication::getSender
int getSender()
Definition:
Communication.cpp:43
Communication::getTimeOfCommunication
double getTimeOfCommunication()
Definition:
Communication.cpp:47
Communication::saveCommunicationToFile
void saveCommunicationToFile(std::ofstream &)
Definition:
Communication.cpp:60
Communication::getIntendedReceiver
int getIntendedReceiver()
Definition:
Communication.cpp:44
Communication::retrieveCommunicationFromFile
void retrieveCommunicationFromFile(std::ifstream &)
Definition:
Communication.cpp:65
Communication::copyCommunication
void copyCommunication(Communication &)
Definition:
Communication.cpp:52
ConvertToString::getString
std::string getString(int) const
Definition:
ConvertToString.cpp:190
DecisionExpectedParameterTrend
Definition:
DecisionExpectedParameterTrend.h:21
DecisionExpectedParameterTrend::saveDecisionExpectedParameterTrendToFile
void saveDecisionExpectedParameterTrendToFile(std::ofstream &)
Definition:
DecisionExpectedParameterTrend.cpp:31
DecisionExpectedParameterTrend::retrieveDecisionExpectedParameterTrendFromFile
void retrieveDecisionExpectedParameterTrendFromFile(std::ifstream &)
Definition:
DecisionExpectedParameterTrend.cpp:36
DecisionExpectedParameterTrend::copyDecisionExpectedParameterTrend
void copyDecisionExpectedParameterTrend(DecisionExpectedParameterTrend &)
Definition:
DecisionExpectedParameterTrend.cpp:26
DisplayElement::getDisplayName
std::string getDisplayName()
Definition:
DisplayElement.cpp:30
ExpectationElement::getStateOfExpectation
int getStateOfExpectation()
Definition:
ExpectationElement.cpp:28
KBExpectedParameterValueUnit::getExpectedValue2
double getExpectedValue2()
Definition:
KBExpectedParameterValueUnit.cpp:64
KBExpectedParameterValueUnit::getExpectedValue1
double getExpectedValue1()
Definition:
KBExpectedParameterValueUnit.cpp:63
KBExpectedParameterValueUnit::getLogicalRelation
int getLogicalRelation()
Definition:
KBExpectedParameterValueUnit.cpp:62
MentalParameterTrend::getObservedParameterRateOfChange
double getObservedParameterRateOfChange()
Definition:
MentalParameterTrend.cpp:29
Probability::getProbability
double getProbability()
Definition:
Probability.cpp:27
StateOfActivation::getStateOfActivation
int getStateOfActivation()
Definition:
StateOfActivation.cpp:25
TimerAndProbability
Definition:
TimerAndProbability.h:21
TimerAndProbability::saveTimerAndProbabilityToFile
void saveTimerAndProbabilityToFile(std::ofstream &)
Definition:
TimerAndProbability.cpp:34
TimerAndProbability::copyTimerAndProbability
void copyTimerAndProbability(TimerAndProbability &)
Definition:
TimerAndProbability.cpp:30
TimerAndProbability::retrieveTimerAndProbabilityFromFile
void retrieveTimerAndProbabilityFromFile(std::ifstream &)
Definition:
TimerAndProbability.cpp:38
Timer::getRemainingTime
double getRemainingTime()
Definition:
Timer.cpp:31
sim::Action::SendInfo
constexpr int SendInfo
Definition:
SimConstants.h:204
sim::Compare::Between
constexpr int Between
Definition:
SimConstants.h:92
sim::State::OldInfo
constexpr int OldInfo
Definition:
SimConstants.h:126
sim::None
constexpr int None
Definition:
SimConstants.h:75
SimulationContext::Translator
ConvertToString Translator
Parameter name/value conversion.
Definition:
SimulationContext.h:52
src
ADSIDAC
Branch
BranchExpectedParameterTrend.cpp
Generated by
1.9.4