←
Documentation
ADS-IDAC Engine
5.0.0
SystemControl.cpp
Go to the documentation of this file.
1
// SystemControl.cpp: implementation of the SystemControl class.
2
//
4
5
#include "
SystemControl.h
"
6
#include "../Branch/BranchRecord.h"
7
#include "../System/SystemModule.h"
8
#include <boost/serialization/export.hpp>
9
#include <iostream>
10
#include <fstream>
11
#include "../Global/SimulationContext.h"
12
#include <boost/archive/binary_oarchive.hpp>
13
#include <boost/archive/binary_iarchive.hpp>
14
BOOST_CLASS_EXPORT_IMPLEMENT(
SystemControl
)
15
using namespace
std;
16
17
19
// Construction/Destruction
21
22
SystemControl::SystemControl
()
23
{
24
ptr_to_corresponding_interactive_variable
=
nullptr
;
25
type_of_control
=
static_cast<
DisplayType
>
(
sim::None
);
26
functional_state
=
sim::State::Succeed
;
27
}
28
29
SystemControl::~SystemControl
()
30
{
31
32
}
33
34
void
SystemControl::setFunctionalState
(
int
n) {
functional_state
= n; }
35
void
SystemControl::setTypeOfControl
(
DisplayType
n) {
type_of_control
= n; }
36
void
SystemControl::setPtrToCorrespondingInteractiveVariable
(
InteractiveVariable
*iv) {
ptr_to_corresponding_interactive_variable
= iv; }
37
int
SystemControl::getFunctionalState
() {
return
functional_state
; }
38
DisplayType
SystemControl::getTypeOfControl
() {
return
type_of_control
; }
39
InteractiveVariable
*
SystemControl::getPtrToCorrespondingInteractiveVariable
() {
return
ptr_to_corresponding_interactive_variable
; }
40
41
void
SystemControl::copySystemControl
(
SystemControl
&_sc) {
42
this->
copyControlElement
(_sc);
43
this->
copyProbability
(_sc);
44
type_of_control
= _sc.
getTypeOfControl
();
45
functional_state
= _sc.
getFunctionalState
();
46
}
47
48
void
SystemControl::saveSystemControlToFile
(std::ofstream &fout) {
49
// Note: This function should be replaced or supplemented by Boost serialization for file operations.
50
this->
saveControlElementToFile
(fout);
51
this->
saveProbabilityToFile
(fout);
52
fout << static_cast<int>(
type_of_control
) <<
' '
<<
functional_state
<<
'\n'
;
53
}
54
55
void
SystemControl::retrieveSystemControlFromFile
(std::ifstream &fin) {
56
// Note: This function should be replaced or supplemented by Boost serialization for file operations.
57
this->
retrieveControlElementFromFile
(fin);
58
this->
retrieveProbabilityFromFile
(fin);
59
{
int
tc; fin >> tc >>
functional_state
;
type_of_control
=
static_cast<
DisplayType
>
(tc); }
60
}
61
62
void
SystemControl::initiateControlValue
() {
63
InteractiveVariable
*iv_ptr;
64
iv_ptr =
SystemControl::getPtrToCorrespondingInteractiveVariable
();
65
if
(iv_ptr ==
nullptr
) {
66
this->
setPtrToCorrespondingInteractiveVariable
(
static_cast<
InteractiveVariable
*
>
(
g_sim
.
Plant
.
getComponentFromSystemMap
(this->getCorrespondingComponentNameOfControl())));
67
iv_ptr =
SystemControl::getPtrToCorrespondingInteractiveVariable
();
68
}
69
if
(iv_ptr !=
nullptr
) {
70
this->
setControlValue
(iv_ptr->
getDisplayValue
());
71
}
else
{
72
std::ofstream fout(
"err_messages.txt"
, std::ios::app);
73
std::cout <<
"SystemControl::initiateControlValue TH element "
<< iv_ptr->
getName
()
74
<<
" cannot be located."
<< std::endl;
75
fout <<
r5pars_
.timesno <<
" SystemControl::initiateControlValue TH element "
<< iv_ptr->
getName
()
76
<<
" cannot be located.\n"
;
77
fout.close();
78
r5pars_
.sim_err =
true
;
79
g_sim
.
Branch_center
.
setTempESMessage
(
"SystemControl::initiateControlValue err."
);
80
g_sim
.
Branch_center
.
setTempTypeOfConsequence
(
Consequence::AdsSimErr
);
81
}
82
}
DisplayType
DisplayType
Definition:
SimConstants.h:41
Consequence::AdsSimErr
@ AdsSimErr
g_sim
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Definition:
SimulationContext.cpp:7
SystemControl.h
BranchRecord::setTempTypeOfConsequence
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
Definition:
BranchRecord.cpp:1641
BranchRecord::setTempESMessage
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
Definition:
BranchRecord.cpp:1640
ControlElement::setControlValue
void setControlValue(double)
Definition:
ControlElement.cpp:63
ControlElement::saveControlElementToFile
void saveControlElementToFile(std::ofstream &)
Definition:
ControlElement.cpp:65
ControlElement::retrieveControlElementFromFile
void retrieveControlElementFromFile(std::ifstream &)
Definition:
ControlElement.cpp:70
ControlElement::copyControlElement
void copyControlElement(ControlElement &)
Definition:
ControlElement.cpp:52
InteractiveVariable
Definition:
InteractiveVariable.h:16
InteractiveVariable::getDisplayValue
double getDisplayValue()
Definition:
InteractiveVariable.cpp:35
Probability::copyProbability
void copyProbability(Probability &)
Definition:
Probability.cpp:28
Probability::saveProbabilityToFile
void saveProbabilityToFile(std::ofstream &)
Definition:
Probability.cpp:34
Probability::retrieveProbabilityFromFile
void retrieveProbabilityFromFile(std::ifstream &)
Definition:
Probability.cpp:39
SystemControl
Definition:
SystemControl.h:20
SystemControl::getPtrToCorrespondingInteractiveVariable
InteractiveVariable * getPtrToCorrespondingInteractiveVariable()
Definition:
SystemControl.cpp:39
SystemControl::~SystemControl
virtual ~SystemControl()
Definition:
SystemControl.cpp:29
SystemControl::setFunctionalState
void setFunctionalState(int)
Definition:
SystemControl.cpp:34
SystemControl::ptr_to_corresponding_interactive_variable
InteractiveVariable * ptr_to_corresponding_interactive_variable
Definition:
SystemControl.h:37
SystemControl::getTypeOfControl
DisplayType getTypeOfControl()
Definition:
SystemControl.cpp:38
SystemControl::setPtrToCorrespondingInteractiveVariable
void setPtrToCorrespondingInteractiveVariable(InteractiveVariable *)
Definition:
SystemControl.cpp:36
SystemControl::type_of_control
DisplayType type_of_control
Definition:
SystemControl.h:35
SystemControl::setTypeOfControl
void setTypeOfControl(DisplayType)
Definition:
SystemControl.cpp:35
SystemControl::functional_state
int functional_state
Definition:
SystemControl.h:36
SystemControl::saveSystemControlToFile
void saveSystemControlToFile(std::ofstream &)
Definition:
SystemControl.cpp:48
SystemControl::getFunctionalState
int getFunctionalState()
Definition:
SystemControl.cpp:37
SystemControl::SystemControl
SystemControl()
Definition:
SystemControl.cpp:22
SystemControl::initiateControlValue
void initiateControlValue()
Definition:
SystemControl.cpp:62
SystemControl::retrieveSystemControlFromFile
void retrieveSystemControlFromFile(std::ifstream &)
Definition:
SystemControl.cpp:55
SystemControl::copySystemControl
void copySystemControl(SystemControl &)
Definition:
SystemControl.cpp:41
SystemModule::getComponentFromSystemMap
THElement * getComponentFromSystemMap(std::string)
Definition:
SystemModule.cpp:501
THElement::getName
std::string getName()
Definition:
THElement.cpp:27
r5pars_
struct @0 r5pars_
sim::State::Succeed
constexpr int Succeed
Definition:
SimConstants.h:104
sim::None
constexpr int None
Definition:
SimConstants.h:75
SimulationContext::Plant
SystemModule Plant
Maps RELAP5 card numbers to C++ objects.
Definition:
SimulationContext.h:40
SimulationContext::Branch_center
BranchRecord Branch_center
Dynamic event tree state.
Definition:
SimulationContext.h:45
src
ADSIDAC
ControlPanel
SystemControl.cpp
Generated by
1.9.4