← Documentation
ADS-IDAC Engine 5.0.0
ControlValue.cpp
Go to the documentation of this file.
1// ControlValue.cpp: implementation of the ControlValue class.
2//
4
5#include "ControlValue.h"
6#include "../Global/TermConversions.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(ControlValue)
13using namespace std;
14
15
17// Construction/Destruction
19
21{
25}
26
28{
29
30}
38}
40 InteractiveVariable *iv_ptr;
42 if(iv_ptr == 0){
45 }
46 if(iv_ptr != 0){
48 iv_ptr->setInputValue(_control_value);
49 this->setDisplayedControlValue(_control_value);
50 }
51 else{//control fails
53 }
54 }
55 else{
56 ofstream fout("err messages.txt", ios::app);
57 cout << " ControlState::updateDisplayedControlValue Component " << SystemControl::getCorrespondingComponentNameOfControl()
58 << " can not be located." << endl;
59 fout << r5pars_.timesno << " ControlState::updateDisplayedControlValue Component " << SystemControl::getCorrespondingComponentNameOfControl()
60 << " can not be located.\n";
61 fout.close();
62 r5pars_.sim_err = true;
63 g_sim.Branch_center.setTempESMessage("ControlValue::updateDisplayedControlValue err.");
65 }
66}
67void ControlValue::performControl(SystemModule &_th, double _control_value){
68 InteractiveVariable *iv_ptr;
70 if(iv_ptr == 0){
73 }
74 if(iv_ptr != 0){
75 iv_ptr->setInputValue(_control_value);
76 iv_ptr->setNeedToInteract(true);
77 this->setDisplayedControlValue(_control_value);
78 // update control value
79 this->setControlValue(_control_value);
80 //
81 }
82 else{
83 ofstream fout("err messages.txt", ios::app);
84 cout << " ControlState::updateDisplayedControlValue Component " << SystemControl::getCorrespondingComponentNameOfControl()
85 << " can not be located." << endl;
86 fout << r5pars_.timesno << " ControlState::updateDisplayedControlValue Component " << SystemControl::getCorrespondingComponentNameOfControl()
87 << " can not be located.\n";
88 fout.close();
89 r5pars_.sim_err = true;
90 g_sim.Branch_center.setTempESMessage("ControlValue::performControl err.");
92 }
93}
97 this->copySystemControl(_cv);
98}
100 this->saveSystemControlToFile(fout);
102}
106}
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)
std::string getCorrespondingComponentNameOfControl()
void readInfoFromFile(std::ifstream &)
double displayed_control_value
Definition: ControlValue.h:37
double getDisplayedControlValue()
void saveControlValueToFile(std::ofstream &)
void retrieveControlValueFromFile(std::ifstream &)
void setDisplayedControlValue(double)
void readInfoFromFile(std::ifstream &)
void updateDisplayedControlValue(SystemModule &, double)
double displayed_control_value_when_fail
Definition: ControlValue.h:37
virtual ~ControlValue()
double getDisplayedControlValueWhenFail()
void copyControlValue(ControlValue &)
void performControl(SystemModule &, double)
void setDisplayedControlValueWhenFail(double)
void setInputValue(double val)
void setNeedToInteract(bool flag)
InteractiveVariable * getPtrToCorrespondingInteractiveVariable()
void setPtrToCorrespondingInteractiveVariable(InteractiveVariable *)
void setTypeOfControl(DisplayType)
void saveSystemControlToFile(std::ofstream &)
int getFunctionalState()
void retrieveSystemControlFromFile(std::ifstream &)
void copySystemControl(SystemControl &)
THElement * getComponentFromSystemMap(std::string)
struct @0 r5pars_
constexpr int Succeed
Definition: SimConstants.h:104
BranchRecord Branch_center
Dynamic event tree state.