← 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>
14BOOST_CLASS_EXPORT_IMPLEMENT(SystemControl)
15using namespace std;
16
17
19// Construction/Destruction
21
23{
27}
28
30{
31
32}
33
40
42 this->copyControlElement(_sc);
43 this->copyProbability(_sc);
46}
47
48void 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
56 // Note: This function should be replaced or supplemented by Boost serialization for file operations.
59 { int tc; fin >> tc >> functional_state; type_of_control = static_cast<DisplayType>(tc); }
60}
61
63 InteractiveVariable *iv_ptr;
65 if (iv_ptr == nullptr) {
66 this->setPtrToCorrespondingInteractiveVariable(static_cast<InteractiveVariable *>(g_sim.Plant.getComponentFromSystemMap(this->getCorrespondingComponentNameOfControl())));
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.");
81 }
82}
DisplayType
Definition: SimConstants.h:41
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void setControlValue(double)
void saveControlElementToFile(std::ofstream &)
void retrieveControlElementFromFile(std::ifstream &)
void copyControlElement(ControlElement &)
void copyProbability(Probability &)
Definition: Probability.cpp:28
void saveProbabilityToFile(std::ofstream &)
Definition: Probability.cpp:34
void retrieveProbabilityFromFile(std::ifstream &)
Definition: Probability.cpp:39
InteractiveVariable * getPtrToCorrespondingInteractiveVariable()
virtual ~SystemControl()
void setFunctionalState(int)
InteractiveVariable * ptr_to_corresponding_interactive_variable
Definition: SystemControl.h:37
DisplayType getTypeOfControl()
void setPtrToCorrespondingInteractiveVariable(InteractiveVariable *)
DisplayType type_of_control
Definition: SystemControl.h:35
void setTypeOfControl(DisplayType)
void saveSystemControlToFile(std::ofstream &)
int getFunctionalState()
void initiateControlValue()
void retrieveSystemControlFromFile(std::ifstream &)
void copySystemControl(SystemControl &)
THElement * getComponentFromSystemMap(std::string)
std::string getName()
Definition: THElement.cpp:27
struct @0 r5pars_
constexpr int Succeed
Definition: SimConstants.h:104
constexpr int None
Definition: SimConstants.h:75
SystemModule Plant
Maps RELAP5 card numbers to C++ objects.
BranchRecord Branch_center
Dynamic event tree state.