← Documentation
ADS-IDAC Engine 5.0.0
HardWiredControlActivity.cpp
Go to the documentation of this file.
1// HardWiredControlActivity.cpp: implementation of the HardWiredControlActivity class.
2//
4
5#include <math.h>
6
8#include "../Branch/BranchRecord.h"
9#include <boost/serialization/export.hpp>
10#include "../Global/SimulationContext.h"
11#include <boost/archive/binary_oarchive.hpp>
12#include <boost/archive/binary_iarchive.hpp>
13BOOST_CLASS_EXPORT_IMPLEMENT(HardWiredControlActivity)
14using namespace std;
15
16
18// Construction/Destruction
20
22{
23 this->setTypeOfExpectation(static_cast<int>(DisplayType::ControlValue));
24 expected_value = -999.0;
25}
26
28{
29
30}
32 this->copyExpectationElement(_hca);
33 this->copyKBElement(_hca);
35}
39 string str;
40 fin >> str >> expected_value;
41 this->setInfoName(str);
42}
43int HardWiredControlActivity::checkForMatch(string _name, double _value){
44 string str = this->getInfoName();
45 int n_return = 0;
46 if(_name.compare(str) == 0){
47 if(fabs(_value - 9999.0) < 0.001){ //if expected_value is set to 9999, only action is needed for success (control value not needed)
49 }
50 else{
51 if (fabs(expected_value - _value) < 0.001){
53 }
54 else{
56 }
57 }
58 }
59 else{
60 n_return = 0;
61 }
62 return n_return;
63}
65 fout << "HardWiredControlActivity " << expected_value << '\n';
66 this->saveKBElementToFile(fout);
68}
70 string str;
71 fin >> str >> expected_value;
72 if (str != "HardWiredControlActivity"){
73 ofstream fout("err messages.txt", ios::app);
74 cout << "HardWiredControlActivity::retrieveHardWiredControlActivityFromFile in previous function" << endl;
75 fout << r5pars_.timesno << " HardWiredControlActivity::retrieveHardWiredControlActivityFromFile error in previous function\n";
76 fout.close();
77 r5pars_.sim_err = true;
78 g_sim.Branch_center.setTempESMessage("HardWiredControlActivity::retrieveHardWiredControlActivityFromFile Prior error");
80 return;
81 }
84}
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 saveExpectationElementToFile(std::ofstream &)
void retrieveExpectationElementFromFile(std::ifstream &)
void copyExpectationElement(ExpectationElement &)
void saveHardWiredControlActivityToFile(std::ofstream &)
int checkForMatch(std::string, double)
void retrieveHardWiredControlActivityFromFile(std::ifstream &)
void readInfoFromFile(std::ifstream &)
void copyHardWiredControlActivity(HardWiredControlActivity &)
void setInfoName(std::string)
Definition: KBElement.cpp:25
void retrieveKBElementFromFile(std::ifstream &)
Definition: KBElement.cpp:36
void saveKBElementToFile(std::ofstream &)
Definition: KBElement.cpp:33
void copyKBElement(KBElement &)
Definition: KBElement.cpp:30
std::string getInfoName()
Definition: KBElement.cpp:26
struct @0 r5pars_
constexpr int Failed
Definition: SimConstants.h:103
constexpr int Succeed
Definition: SimConstants.h:104
BranchRecord Branch_center
Dynamic event tree state.