←
Documentation
ADS-IDAC Engine
5.0.0
BranchExpectedComponentState.cpp
Go to the documentation of this file.
1
// BranchExpectedComponentState.cpp: implementation of the BranchExpectedComponentState class.
2
//
4
5
#include <sstream>
6
#include "
BranchExpectedComponentState.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(
BranchExpectedComponentState
)
13
using namespace
std;
14
15
17
// Construction/Destruction
19
20
BranchExpectedComponentState::BranchExpectedComponentState
() {
21
22
}
23
24
BranchExpectedComponentState::~BranchExpectedComponentState
() {
25
26
}
27
void
BranchExpectedComponentState::copyBranchExpectedComponentState
(
BranchExpectedComponentState
&_bcp) {
28
DecisionExpectedComponentState::copyDecisionExpectedComponentState
((
DecisionExpectedComponentState
&) _bcp);
29
TimerAndProbability::copyTimerAndProbability
((
TimerAndProbability
&) _bcp);
30
Communication::copyCommunication
((
Communication
&) _bcp);
31
}
32
string
BranchExpectedComponentState::translateMessage
() {
33
string
str;
34
str =
"Component: Sender: "
;
35
str +=
g_sim
.
Translator
.
getString
(this->
getSender
());
36
str +=
"; Receiver: "
;
37
str +=
g_sim
.
Translator
.
getString
(this->
getIntendedReceiver
());
38
str +=
"; Component: "
;
39
str += this->
getDisplayName
();
40
str +=
"; Status: "
;
41
str +=
g_sim
.
Translator
.
getString
(this->
getStateOfExpectation
());
42
str +=
"; Exp State: "
;
43
str +=
g_sim
.
Translator
.
getString
(this->
getExpectedState
());
44
str +=
"; Observed State: "
;
45
str +=
g_sim
.
Translator
.
getString
(this->
getObservedComponentState
());
46
if
(this->
getStateOfActivation
() ==
sim::State::OldInfo
) {
47
str +=
";Use of Memorized Info"
;
48
}
49
str +=
"; New Probability: "
;
50
std::ostringstream streamObj;
51
streamObj << this->
getProbability
();
52
str += streamObj.str();
53
return
str;
54
}
55
void
BranchExpectedComponentState::saveInfoToFile
(ostream &fout) {
56
string
str;
57
str =
"Status:"
;
58
str +=
g_sim
.
Translator
.
getString
(this->
getStateOfExpectation
());
59
str +=
";_Exp_State:"
;
60
str +=
g_sim
.
Translator
.
getString
(this->
getExpectedState
());
61
str +=
";_Observed_State:"
;
62
str +=
g_sim
.
Translator
.
getString
(this->
getObservedComponentState
());
63
if
(this->
getStateOfActivation
() ==
sim::State::OldInfo
) {
64
str +=
";_Use_of_Memorized_Info"
;
65
}
66
fout <<
' '
<< this->
getSender
() <<
' '
<<
sim::Action::SendInfo
<<
' '
<< this->
getObservedComponentState
() <<
' '
67
<< this->
getInfoName
() <<
' '
<< this->
getProbability
() <<
' '
68
<< this->
getTimeOfCommunication
() <<
' '
<< this->
getRemainingTime
() <<
" 0.0 "
<< this->
getStateOfExpectation
()
69
<<
' '
70
<<
'"'
<<
"Intended_Receiver:"
<<
g_sim
.
Translator
.
getString
(this->
getIntendedReceiver
()) <<
';'
<< str <<
'"'
<<
'\n'
;
71
}
72
void
BranchExpectedComponentState::saveBranchExpectedComponentStateToFile
(ofstream &fout) {
73
this->
saveDecisionExpectedComponentStateToFile
(fout);
74
this->
saveTimerAndProbabilityToFile
(fout);
75
this->
saveCommunicationToFile
(fout);
76
}
77
void
BranchExpectedComponentState::retrieveBranchExpectedComponentStateFromFile
(ifstream &fin) {
78
this->
retrieveDecisionExpectedComponentStateFromFile
(fin);
79
this->
retrieveTimerAndProbabilityFromFile
(fin);
80
this->
retrieveCommunicationFromFile
(fin);
81
}
BranchExpectedComponentState.h
g_sim
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Definition:
SimulationContext.cpp:7
BranchExpectedComponentState
Definition:
BranchExpectedComponentState.h:20
BranchExpectedComponentState::~BranchExpectedComponentState
virtual ~BranchExpectedComponentState()
Definition:
BranchExpectedComponentState.cpp:24
BranchExpectedComponentState::retrieveBranchExpectedComponentStateFromFile
void retrieveBranchExpectedComponentStateFromFile(std::ifstream &)
Definition:
BranchExpectedComponentState.cpp:77
BranchExpectedComponentState::saveInfoToFile
void saveInfoToFile(std::ostream &)
Definition:
BranchExpectedComponentState.cpp:55
BranchExpectedComponentState::copyBranchExpectedComponentState
void copyBranchExpectedComponentState(BranchExpectedComponentState &)
Definition:
BranchExpectedComponentState.cpp:27
BranchExpectedComponentState::BranchExpectedComponentState
BranchExpectedComponentState()
Definition:
BranchExpectedComponentState.cpp:20
BranchExpectedComponentState::translateMessage
std::string translateMessage()
Definition:
BranchExpectedComponentState.cpp:32
BranchExpectedComponentState::saveBranchExpectedComponentStateToFile
void saveBranchExpectedComponentStateToFile(std::ofstream &)
Definition:
BranchExpectedComponentState.cpp:72
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
DecisionExpectedComponentState
Definition:
DecisionExpectedComponentState.h:20
DecisionExpectedComponentState::retrieveDecisionExpectedComponentStateFromFile
void retrieveDecisionExpectedComponentStateFromFile(std::ifstream &)
Definition:
DecisionExpectedComponentState.cpp:35
DecisionExpectedComponentState::copyDecisionExpectedComponentState
void copyDecisionExpectedComponentState(DecisionExpectedComponentState &)
Definition:
DecisionExpectedComponentState.cpp:25
DecisionExpectedComponentState::saveDecisionExpectedComponentStateToFile
void saveDecisionExpectedComponentStateToFile(std::ofstream &)
Definition:
DecisionExpectedComponentState.cpp:30
DisplayElement::getDisplayName
std::string getDisplayName()
Definition:
DisplayElement.cpp:30
ExpectationElement::getStateOfExpectation
int getStateOfExpectation()
Definition:
ExpectationElement.cpp:28
KBElement::getInfoName
std::string getInfoName()
Definition:
KBElement.cpp:26
KBExpectedComponentStateUnit::getExpectedState
int getExpectedState()
Definition:
KBExpectedComponentStateUnit.cpp:57
MentalComponentState::getObservedComponentState
int getObservedComponentState()
Definition:
MentalComponentState.cpp:28
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::State::OldInfo
constexpr int OldInfo
Definition:
SimConstants.h:126
SimulationContext::Translator
ConvertToString Translator
Parameter name/value conversion.
Definition:
SimulationContext.h:52
src
ADSIDAC
Branch
BranchExpectedComponentState.cpp
Generated by
1.9.4