← Documentation
ADS-IDAC Engine 5.0.0
InitiatingEventController.cpp
Go to the documentation of this file.
1// InitiatingEventController.cpp: implementation of the InitiatingEventController class.
2//
4
6#include "../Branch/BranchRecord.h"
7#include <boost/serialization/export.hpp>
8#include "../Global/SimulationContext.h"
9#include <boost/archive/binary_oarchive.hpp>
10#include <boost/archive/binary_iarchive.hpp>
11BOOST_CLASS_EXPORT_IMPLEMENT(InitiatingEventController)
12using namespace std;
13
14
16// Construction/Destruction
18
21}
22
25}
27 string file_name, str;
28 int n_IE, n_IEFT, n_SSIE;
30 file_name += "Initiating_Event.txt";
31 ifstream fin(file_name.c_str(), ios::in);
32 if (!fin.is_open()) {
33 cout << "File: " << file_name << " cound not be found" << endl;
34 ofstream fout("err messages.txt", ios::app);
35 fout << r5pars_.timesno << " File: " << file_name << " cound not be found\n";
36 fout.close();
37 }
38 fin >> str >> n_IE;
39 for (int i = 0; i < n_IE; i++) {
40 auto ie_pt = make_unique<InitiatingEventUnit>();
41 ie_pt->readInfoFromFile(fin);
42 initiating_event.push_back(std::move(ie_pt));
43 } /*
44 fin >> str >> n_IEFT;
45 for (int i = 0; i < n_IEFT; i++) {
46 auto ieft_pt = make_unique<InitiatingEventFTUnit>();
47 ieft_pt->readInfoFromFile(fin);
48 initiating_event_ft.push_back(std::move(ieft_pt));
49 }*/
50 fin >> str >> n_SSIE;
51 for (int i = 0; i < n_SSIE; ++i) {
52 auto ssie_pt = make_unique<SupportSystemInitiatingEventUnit>();
53 ssie_pt->readInfoFromFile(fin);
54 support_system_initiating_event.push_back(std::move(ssie_pt));
55 }
56
57 fin.close();
58}
60 bool need_for_check = false;
61 double probability_of_event;
62 int r_value;
63 BranchSystemAction *bsa_pt;
66 for (auto& ie_itr : initiating_event) {
67 r_value = ie_itr->checkActivationState();
68 if (r_value == sim::None) { need_for_check = true; }
69 if (r_value == sim::Action::Direct) {//this g_sim.IE is actived at this moment
70 // calculate probability of event
71 probability_of_event = ie_itr->Failure_Probability.calculateProbability();
72 ie_itr->Failure_Probability.setProbability(probability_of_event);
73 //
74 bsa_pt = new BranchSystemAction();
76 bsa_pt->setTimerAndProbability(0.0, ie_itr->Failure_Probability.getProbability());
77 bsa_pt->setDisplayName(ie_itr->getInitiatingEventName());
78 bsa_pt->setCorrespondingComponentNameOfControl(ie_itr->getInteractiveControlName());
79 bsa_pt->setControlValue(ie_itr->getValueToActOnTheInteractiveControl());
82 }
83 }
84 for (auto& ieft_itr : initiating_event_ft) {
85 r_value = ieft_itr->checkActivationState();
86 if (r_value == sim::None) { need_for_check = true; }
87 if (r_value == sim::Action::Direct) {//this g_sim.IE is actived at this moment
88 // calculate probability of event
89 probability_of_event = ieft_itr->Failure_Probability.calculateProbability();
90 ieft_itr->Failure_Probability.setProbability(probability_of_event);
91 //
92 bsa_pt = new BranchSystemAction();
94 bsa_pt->setTimerAndProbability(0.0, ieft_itr->Failure_Probability.getProbability());
95 bsa_pt->setDisplayName(ieft_itr->getSystemFTTopNodeName());
96 bsa_pt->setCorrespondingComponentNameOfControl(ieft_itr->getSystemFTBasicEventNodeName());
97 bsa_pt->setControlValue(ieft_itr->getProbabilityValueToActOnTheSystemFTNode());
100 }
101 }
102 for (auto& ssie_itr : support_system_initiating_event) {
103 r_value = ssie_itr->checkActivationState();
104 if (r_value == sim::None) { need_for_check = true; }
105 if (r_value == sim::Action::Direct) {//this g_sim.IE is actived at this moment
106 // calculate probability of event
107 probability_of_event = ssie_itr->Failure_Probability.calculateProbability();
108 ssie_itr->Failure_Probability.setProbability(probability_of_event);
109 bssa_pt = new BranchSupportSystemAction();
111 bssa_pt->setTimerAndProbability(0.0, ssie_itr->Failure_Probability.getProbability());
112 bssa_pt->setDisplayName(ssie_itr->getInitiatingEventName());
113 bssa_pt->setCorrespondingComponentNameOfControl(ssie_itr->getSupportSystemBasicEventNodeName());
114 bssa_pt->setControlValue(ssie_itr->getProbabilityValueToActOnTheSupportSystemNode());
117 }
118 }
119 need_to_check_for_activation = need_for_check;
120 }
121}
123 this->readInfoFromFile();
124}
126 initiating_event.clear();
127 initiating_event_ft.clear();
130}
132 for (auto& src : _ie.initiating_event) {
133 auto ieu_pt = make_unique<InitiatingEventUnit>();
134 ieu_pt->copyInitiatingEventUnit(*src);
135 this->initiating_event.push_back(std::move(ieu_pt));
136 }
137 for (auto& src : _ie.initiating_event_ft) {
138 auto ieftu_pt = make_unique<InitiatingEventFTUnit>();
139 ieftu_pt->copyInitiatingEventFTUnit(*src);
140 this->initiating_event_ft.push_back(std::move(ieftu_pt));
141 }
142 for (auto& src : _ie.support_system_initiating_event) {
143 auto ssieu_pt = make_unique<SupportSystemInitiatingEventUnit>();
144 ssieu_pt->copySupportSystemInitiatingEventUnit(*src);
145 this->support_system_initiating_event.push_back(std::move(ssieu_pt));
146 }
148}
152 int i_need_to_check_for_activation;
154 i_need_to_check_for_activation = 1;
155 } else {
156 i_need_to_check_for_activation = 0;
157 }
158 fout << "InitiatingEventController\n" << i_need_to_check_for_activation << ' ' << initiating_event.size() << ' '
159 << initiating_event_ft.size() << ' ' << support_system_initiating_event.size() << '\n';
160 for (int i = 0; i < initiating_event.size(); i++) {
161 this->initiating_event.at(i)->saveInitiatingEventUnitToFile(fout);
162 }
163 for (int i = 0; i < initiating_event_ft.size(); i++) {
164 this->initiating_event_ft.at(i)->saveInitiatingEventFTUnitToFile(fout);
165 }
166 for (int i = 0; i < support_system_initiating_event.size(); ++i) {
167 this->support_system_initiating_event.at(i)->saveSupportSystemInitiatingEventUnitToFile(fout);
168 }
169}
171 int num1, num2, num3, i_need_to_check_for_activation;
172 string str;
173 //
174 fin >> str;
175 if (str != "InitiatingEventController") {
176 ofstream fout("err messages.txt", ios::app);
177 cout << "InfoChunkMental::retrieveInfoChunkMentalFromFile File retrieval error in previous function" << endl;
178 fout << r5pars_.timesno
179 << " InfoChunkMental::retrieveInfoChunkMentalFromFile File retrieval error in previous function\n";
180 fout.close();
181 r5pars_.sim_err = true;
182 g_sim.Branch_center.setTempESMessage("InitiatingEventController::saveInitiatingEventControllerToFile Prior error");
184 return;
185 }
186
187 fin >> i_need_to_check_for_activation >> num1 >> num2 >> num3;
188 if (i_need_to_check_for_activation == 1) {
190 } else {
192 }
193 for (int i = 0; i < num1; i++) {
194 auto initiating_event_pt = make_unique<InitiatingEventUnit>();
195 initiating_event_pt->retrieveInitiatingEventUnitFromFile(fin);
196 initiating_event.push_back(std::move(initiating_event_pt));
197 }
198 for (int i = 0; i < num2; i++) {
199 auto initiating_event_ft_pt = make_unique<InitiatingEventFTUnit>();
200 initiating_event_ft_pt->retrieveInitiatingEventFTUnitFromFile(fin);
201 initiating_event_ft.push_back(std::move(initiating_event_ft_pt));
202 }
203 for (int i = 0; i < num3; i++) {
204 auto support_system_initiating_event_pt = make_unique<SupportSystemInitiatingEventUnit>();
205 support_system_initiating_event_pt->retrieveSupportSystemInitiatingEventUnitFromFile(fin);
206 support_system_initiating_event.push_back(std::move(support_system_initiating_event_pt));
207 }
208}
Initiating event definition, timing, and execution control.
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 addSSReliabilityBranch(BranchSupportSystemAction *, BranchSupportSystemAction *)
Registers a support system reliability fork with two alternatives (index 0 first)....
void addHWReliabilityBranch(BranchSystemAction *, BranchSystemAction *)
Registers a hardware reliability fork with two alternatives (index 0 first). The record takes ownersh...
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void setSenderAndReceiver(int, int)
void setControlValue(double)
void setDisplayName(std::string)
void setCorrespondingComponentNameOfControl(std::string)
std::vector< std::unique_ptr< InitiatingEventFTUnit > > initiating_event_ft
std::vector< std::unique_ptr< InitiatingEventUnit > > initiating_event
std::vector< std::unique_ptr< SupportSystemInitiatingEventUnit > > support_system_initiating_event
void saveInitiatingEventControllerToFile(std::ofstream &)
void retrieveInitiatingEventControllerFromFile(std::ifstream &)
void copyInitiatingEventController(InitiatingEventController &)
double calculateProbability()
std::string getSystemDirectory()
Definition: Scheduler.cpp:637
void setTimerAndProbability(double, double)
struct @0 r5pars_
bool log
Enable/disable rank-specific logging.
constexpr int Direct
Definition: SimConstants.h:202
constexpr int FtPlant
Definition: SimConstants.h:266
constexpr int Plant
Definition: SimConstants.h:135
constexpr int Failed
Definition: SimConstants.h:103
constexpr int None
Definition: SimConstants.h:75
Scheduler SScheduler
Simulation scheduling, parses CLI options.
BranchRecord Branch_center
Dynamic event tree state.