← Documentation
ADS-IDAC Engine 5.0.0
BranchProcedureControlValue.cpp
Go to the documentation of this file.
1// BranchProcedureControlValue.cpp: implementation of the BranchProcedureControlValue class.
2//
4
6#include "../Global/SimulationContext.h"
7#include <boost/serialization/export.hpp>
8#include <boost/archive/binary_oarchive.hpp>
9#include <boost/archive/binary_iarchive.hpp>
10BOOST_CLASS_EXPORT_IMPLEMENT(BranchProcedureControlValue)
11using namespace std;
12
14// Construction/Destruction
16
18{
19
20}
21
23{
25}
26
28{
30 bool found_bpcvu = false;
31 auto bp_cvu_itr = this->control_value_branches.begin();
32 while (bp_cvu_itr != this->control_value_branches.end() && !found_bpcvu)
33 {
34 found_bpcvu = (*bp_cvu_itr)->checkIfControlValueBranchNeedsToBeGenerated(_procedure, _step, _action);
35 if(found_bpcvu){
36 bpcvu_pt = bp_cvu_itr->get();
37 }
38 else{
39 bp_cvu_itr++;
40 }
41 }
42
43 return bpcvu_pt;
44}
46{
47 this->control_value_branches.clear();
48}
49
51{
52 for (auto &src : _bpcv.control_value_branches)
53 {
54 auto p = make_unique<BranchProcedureControlValueUnit>();
55 p->copyBranchProcedureControlValueUnit(*src);
56 this->control_value_branches.push_back(std::move(p));
57 }
58}
59
61{
62 string file_name, str;
63 int num_obj, i;
64 file_name = g_sim.SScheduler.getEOPDirectory();
65 file_name += "ProcedureControlValueBranches.txt";
66 ifstream fin(file_name.c_str(), ios::in);
67 if(fin.is_open()){
68 fin >> str >> num_obj;
69 for (i = 0 ; i < num_obj; i++){
70 auto p = make_unique<BranchProcedureControlValueUnit>();
71 p->readInfoFromFile(fin);
72 this->control_value_branches.push_back(std::move(p));
73 }
74 fin.close();
75 }
76 else
77 {
78 cout << "File: " << file_name << " cound not be found" << endl;
79 ofstream fout("err messages.txt", ios::app);
80 fout << r5pars_.timesno << " File: " << file_name << " cound not be found\n";
81 fout.close();
82 }
83}
84
86{
87 fout << "BranchProcedureControlValue" << ' '
88 << this->control_value_branches.size() << '\n';
89 for(auto &p : this->control_value_branches)
90 {
91 p->saveBranchProcedureControlValueUnitToFile(fout);
92 }
93}
94
96{
97 string str;
98 int num_obj, i;
99 fin >> str >> num_obj;
100 for (i = 0; i != num_obj; i ++ )
101 {
102 auto p = make_unique<BranchProcedureControlValueUnit>();
103 p->retrieveBranchProcedureControlValueUnitFromFile(fin);
104 this->control_value_branches.push_back(std::move(p));
105 }
106}
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Table of procedure actions that branch on the control value they set.
std::vector< std::unique_ptr< BranchProcedureControlValueUnit > > control_value_branches
The entries, in file order.
void copyBranchProcedureControlValue(BranchProcedureControlValue &)
Appends deep copies of the entries of another table. Existing entries are kept, so call it on an empt...
void saveBranchProcedureControlValueToFile(std::ofstream &)
Writes the label BranchProcedureControlValue, the entry count and every entry to a text restart strea...
void readInfoFromFile()
Loads ProcedureControlValueBranches.txt from the EOP directory (Scheduler::getEOPDirectory()) and app...
BranchProcedureControlValueUnit * checkToGenerateControlValueBranches(std::string, std::string, std::string)
Looks up the control value branch definition of a procedure action.
void retreiveBranchProcedureControlValueFromFile(std::ifstream &)
Reads the layout written by saveBranchProcedureControlValueToFile and appends the entries it reads.
void clearBranchProcedureControlValue()
Removes every entry.
std::string getEOPDirectory()
Definition: Scheduler.cpp:616
struct @0 r5pars_
Scheduler SScheduler
Simulation scheduling, parses CLI options.