← Documentation
ADS-IDAC Engine 5.0.0
HWReliabilityModule.cpp
Go to the documentation of this file.
1// HWReliabilityModule.cpp: implementation of the HWReliabilityModule class.
2//
4
6#include "../Branch/BranchRecord.h"
7#include "../Scheduler/Scheduler.h"
8#include "../ControlPanel/ControlPanel.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(HWReliabilityModule)
14using namespace std;
15
17// Construction/Destruction
19
21}
22
24 this->clearForRestart();
25}
27 string file_name, str;
28
29//
31 file_name += "SystemReliability.txt";
32 ifstream fin(file_name.c_str(), ios::in);
33 if (!fin.is_open()) {
34 cout << "File: " << file_name << " cound not be found" << endl;
35 ofstream fout("err messages.txt", ios::app);
36 fout << r5pars_.timesno << " File: " << file_name << " cound not be found\n";
37 fout.close();
38 }
42 fin.close();
43}
44
46 int num = 0, i, failed_state, initial_state = 0;
47 string str, display_name, control_name;
48 double probability, control_value;
49 double failure_alpha_parameter, failure_beta_parameter;
50 double recovery_alpha_parameter, recovery_beta_parameter;
51 bool found_state;
52 bool found_value;
53 vector<unique_ptr<ControlState>>::iterator cs_itr;
54 vector<unique_ptr<ControlValue>>::iterator cv_itr;
56 ControlState *ctrl_state_pt;
57 ControlValue *ctrl_value_pt;
58
59 fin >> str >> num;
60 if (fin.fail()) {
61 // A count/content mismatch in SystemReliability.txt leaves the stream
62 // failed here. No units load past the malformed point, and the condition
63 // is reported on stdout and in "err messages.txt".
64 std::cout << "WARNING: SystemReliability.txt: malformed or unexpected content where "
65 << __func__ << " expected a section header — remaining failure models NOT loaded."
66 << std::endl;
67 std::ofstream ferr("err messages.txt", std::ios::app);
68 ferr << r5pars_.timesno << " WARNING: SystemReliability.txt malformed in " << __func__ << "\n";
69 return;
70 }
71 for (i = 0; i < num; i++) {
72 found_state = false;
73 found_value = false;
74 auto hwr_pt = make_unique<HWReliabilityUnit>();
75 fin >> display_name
76 >> control_name
77 >> failure_alpha_parameter
78 >> failure_beta_parameter
79 >> recovery_alpha_parameter
80 >> recovery_beta_parameter;
81// >> probability;
82 hwr_pt->setDisplayName(display_name);
83 hwr_pt->setCorrespondingComponentNameOfControl(control_name);
84 hwr_pt->setAlpha_Parameter(failure_alpha_parameter);
85 hwr_pt->setBeta_Parameter(failure_beta_parameter);
86 //
87 probability = hwr_pt->calculateProbability();
88 hwr_pt->setProbability(probability);
89 //
91 //ctrl_pt = (ControlState *) Indicator.controls.getControlFromMap(control_name);
92 if (dcs_pt == 0) {
93 ofstream fout("err messages.txt", ios::app);
94 cout << "HWReliabilityModule::readSystemReliabilityInfoFromFile: could not find display name: " << display_name
95 << endl;
96 fout << r5pars_.timesno
97 << " HWReliabilityModule::readSystemReliabilityInfoFromFile: could not find display name: "
98 << display_name << '\n';
99 fout.close();
100 r5pars_.sim_err = true;
101 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readSystemReliabilityInfoFromFile err.");
103 }
104 /*if(ctrl_pt == 0){
105 ofstream fout("err messages.txt", ios::app);
106 cout << "HWReliabilityModule::readInfoFromFile: could not find control name: " << control_name << endl;
107 fout << r5pars_.timesno << " HWReliabilityModule::readInfoFromFile: could not find control name: " << control_name << '\n';
108 fout.close();
109 r5pars_.sim_err = true;
110 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readInfoFromFile err.");
111 g_sim.Branch_center.setTempTypeOfConsequence(Consequence::NoKB);
112 } else {
113 // set recovery probability parameters for system control
114 ctrl_pt->setAlpha_Parameter(recovery_alpha_parameter);
115 ctrl_pt->setBeta_Parameter(recovery_beta_parameter);
116 }
117 */
118 initial_state = dcs_pt->getDisplayedComponentOperationalState();
119 hwr_pt->setInitialComponentState(initial_state);
120 //
121 //determine if failed component is a fine adjustment controller or a binary state controller
122 //
123 // check if control is a binary state controller
125 while (cs_itr != g_sim.Indicator.controls.control_state_array.end() && !found_state) {
126 if (control_name == (*cs_itr)->getDisplayName()) {
127 found_state = true;
128 }
129 cs_itr++;
130 }
131 //
132 // check if controller is a fine adjustment controller
134 while (cv_itr != g_sim.Indicator.controls.control_value_array.end() && !found_state && !found_value) {
135 if (control_name == (*cv_itr)->getDisplayName()) {
136 found_value = true;
137 }
138 cv_itr++;
139 }
140 //
141 if (found_state) {
142 ctrl_state_pt = (ControlState *) g_sim.Indicator.controls.getControlFromMap(control_name);
143 //failed_state = dcs_pt->getDisplayedComponentOperationalStateWhenFail();
144 failed_state = ctrl_state_pt->getDisplayedControlStateWhenFail();
145 if (failed_state == sim::State::On || failed_state == sim::State::Open) {
146 control_value = ctrl_state_pt->getValueForOnOrFullyOpen();
147 } else if (failed_state == sim::State::Off || failed_state == sim::State::Close) {
148 control_value = ctrl_state_pt->getValueForOffOrFullyClose();
149 } else {
150 control_value = ctrl_state_pt->getValueForNeutralState();
151 }
152 ctrl_state_pt->setAlpha_Parameter(recovery_alpha_parameter);
153 ctrl_state_pt->setBeta_Parameter(recovery_beta_parameter);
154 } else if (found_value) {
155 ctrl_value_pt = (ControlValue *) g_sim.Indicator.controls.getControlFromMap(control_name);
156 control_value = ctrl_value_pt->getDisplayedControlValueWhenFail();
157 ctrl_value_pt->setAlpha_Parameter(recovery_alpha_parameter);
158 ctrl_value_pt->setBeta_Parameter(recovery_beta_parameter);
159 } else {
160 //
161 // control not found
162 ofstream fout("err messages.txt", ios::app);
163 cout << "HWReliabilityModule::readSystemReliabilityInfoFromFile: could not find control name: " << control_name
164 << endl;
165 fout << r5pars_.timesno
166 << " HWReliabilityModule::readSystemReliabilityInfoFromFile: could not find control name: "
167 << control_name << '\n';
168 fout.close();
169 r5pars_.sim_err = true;
170 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readSystemReliabilityInfoFromFile err.");
172 }
173 //
174 hwr_pt->setControlValue(control_value);
175 hwr_pt->setBothTotalTimeRequiredAndRemainingTime(0.0);
176 hwr_pt->setSender(sim::Source::Reliability);
177 hwr_pt->setIntendedReceiver(sim::Source::Plant);
178 hwr_pt->setCorrespondingComponentPt(dcs_pt);
179 component_reliability.push_back(std::move(hwr_pt));
180 }
181}
183 //TODO:
184 //Check if the component is already defined to fail on demand
185 //if yes, add its new properties
186 //if no, add all its properties
187 int num = 0, i, failed_state, initial_state = 0, numberOfIntervals;
188 string str, display_name, control_name;
189 double probability, control_value;
190 double deltaT, failure_rate, recovery_alpha_parameter, recovery_beta_parameter;
191 bool found_state;
192 bool found_value;
193 vector<unique_ptr<ControlState>>::iterator cs_itr;
194 vector<unique_ptr<ControlValue>>::iterator cv_itr;
195 DisplayComponentState *dcs_pt;
196 ControlState *ctrl_state_pt;
197 ControlValue *ctrl_value_pt;
198
199 fin >> str >> num;
200 if (fin.fail()) {
201 // A count/content mismatch in SystemReliability.txt leaves the stream
202 // failed here. No units load past the malformed point, and the condition
203 // is reported on stdout and in "err messages.txt".
204 std::cout << "WARNING: SystemReliability.txt: malformed or unexpected content where "
205 << __func__ << " expected a section header — remaining failure models NOT loaded."
206 << std::endl;
207 std::ofstream ferr("err messages.txt", std::ios::app);
208 ferr << r5pars_.timesno << " WARNING: SystemReliability.txt malformed in " << __func__ << "\n";
209 return;
210 }
211 for (i = 0; i < num; i++) {
212 found_state = false;
213 found_value = false;
214 auto hwr_pt = make_unique<HWReliabilityUnit>();
215 fin >> display_name
216 >> control_name
217 >> failure_rate
218 >> deltaT
219 >> numberOfIntervals
220 >> recovery_alpha_parameter
221 >> recovery_beta_parameter;
222 hwr_pt->setDisplayName(display_name);
223 hwr_pt->setCorrespondingComponentNameOfControl(control_name);
224 hwr_pt->setFailureRate(failure_rate);
225 hwr_pt->setT_Minimum(deltaT);
226 hwr_pt->setNumberOfIntervals(numberOfIntervals);
227 //
228 probability = hwr_pt->calculateSurvivalProbability(hwr_pt->getT_Minimum());
229 hwr_pt->setProbability(1 - probability);
230 //
232 //ctrl_pt = (ControlState *) Indicator.controls.getControlFromMap(control_name);
233 if (dcs_pt == 0) {
234 ofstream fout("err messages.txt", ios::app);
235 cout << "HWReliabilityModule::readSystemOperationReliabilityInfoFromFile: could not find display name: "
236 << display_name << endl;
237 fout << r5pars_.timesno
238 << " HWReliabilityModule::readSystemOperationReliabilityInfoFromFile: could not find display name: "
239 << display_name << '\n';
240 fout.close();
241 r5pars_.sim_err = true;
242 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readSystemOperationReliabilityInfoFromFile err.");
244 }
245 initial_state = dcs_pt->getDisplayedComponentOperationalState();
246 hwr_pt->setInitialComponentState(initial_state);
247 //
248 //determine if failed component is a fine adjustment controller or a binary state controller
249 //
250 // check if control is a binary state controller
252 while (cs_itr != g_sim.Indicator.controls.control_state_array.end() && !found_state) {
253 if (control_name == (*cs_itr)->getDisplayName()) {
254 found_state = true;
255 }
256 cs_itr++;
257 }
258 //
259 // check if controller is a fine adjustment controller
261 while (cv_itr != g_sim.Indicator.controls.control_value_array.end() && !found_state && !found_value) {
262 if (control_name == (*cv_itr)->getDisplayName()) {
263 found_value = true;
264 }
265 cv_itr++;
266 }
267 //
268 if (found_state) {
269 ctrl_state_pt = (ControlState *) g_sim.Indicator.controls.getControlFromMap(control_name);
270 failed_state = ctrl_state_pt->getDisplayedControlStateWhenFail();
271 if (failed_state == sim::State::On || failed_state == sim::State::Open) {
272 control_value = ctrl_state_pt->getValueForOnOrFullyOpen();
273 } else if (failed_state == sim::State::Off || failed_state == sim::State::Close) {
274 control_value = ctrl_state_pt->getValueForOffOrFullyClose();
275 } else {
276 control_value = ctrl_state_pt->getValueForNeutralState();
277 }
278 ctrl_state_pt->setAlpha_Parameter(recovery_alpha_parameter);
279 ctrl_state_pt->setBeta_Parameter(recovery_beta_parameter);
280 } else if (found_value) {
281 ctrl_value_pt = (ControlValue *) g_sim.Indicator.controls.getControlFromMap(control_name);
282 control_value = ctrl_value_pt->getDisplayedControlValueWhenFail();
283 ctrl_value_pt->setAlpha_Parameter(recovery_alpha_parameter);
284 ctrl_value_pt->setBeta_Parameter(recovery_beta_parameter);
285 } else {
286 //
287 // control not found
288 ofstream fout("err messages.txt", ios::app);
289 cout << "HWReliabilityModule::readSystemOperationReliabilityInfoFromFile: could not find control name: "
290 << control_name << endl;
291 fout << r5pars_.timesno
292 << " HWReliabilityModule::readSystemOperationReliabilityInfoFromFile: could not find control name: "
293 << control_name << '\n';
294 fout.close();
295 r5pars_.sim_err = true;
296 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readSystemOperationReliabilityInfoFromFile err.");
298 }
299 //
300 hwr_pt->setControlValue(control_value);
301 hwr_pt->setBothTotalTimeRequiredAndRemainingTime(0.0);
302 hwr_pt->setSender(sim::Source::Reliability);
303 hwr_pt->setIntendedReceiver(sim::Source::Plant);
304 hwr_pt->setCorrespondingComponentPt(dcs_pt);
305 component_operation_reliability.push_back(std::move(hwr_pt));
306 }
307}
309 int num = 0, i, failed_state, initial_state = 0;
310 string str, display_name, control_name, top_node_name;
311 double control_value = 0.0;
312 bool found_state;
313 bool found_value;
314 vector<unique_ptr<ControlState>>::iterator cs_itr;
315 vector<unique_ptr<ControlValue>>::iterator cv_itr;
316 DisplayComponentState *dcs_pt;
317 ControlState *ctrl_state_pt;
318 ControlValue *ctrl_value_pt;
319
320 fin >> str >> num;
321 if (fin.fail()) {
322 // A count/content mismatch in SystemReliability.txt leaves the stream
323 // failed here. No units load past the malformed point, and the condition
324 // is reported on stdout and in "err messages.txt".
325 std::cout << "WARNING: SystemReliability.txt: malformed or unexpected content where "
326 << __func__ << " expected a section header — remaining failure models NOT loaded."
327 << std::endl;
328 std::ofstream ferr("err messages.txt", std::ios::app);
329 ferr << r5pars_.timesno << " WARNING: SystemReliability.txt malformed in " << __func__ << "\n";
330 return;
331 }
332 for (i = 0; i < num; i++) {
333 found_state = false;
334 found_value = false;
335 fin >> display_name
336 >> control_name
337 >> top_node_name;
338 auto hwr_pt = make_unique<HWReliabilityFTUnit>(top_node_name);
339 hwr_pt->setDisplayName(display_name);
340 hwr_pt->setCorrespondingComponentNameOfControl(control_name);
341 hwr_pt->updateFailureProbability();
343 if (dcs_pt == 0) {
344 ofstream fout("err messages.txt", ios::app);
345 cout << "HWReliabilityModule::readSystemReliabilityInfoFromFile: could not find display name: " << display_name
346 << endl;
347 fout << r5pars_.timesno
348 << " HWReliabilityModule::readSystemReliabilityInfoFromFile: could not find display name: "
349 << display_name << '\n';
350 fout.close();
351 r5pars_.sim_err = true;
352 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readSystemReliabilityInfoFromFile err.");
354 initial_state = 0;
355 } else {
356 initial_state = dcs_pt->getDisplayedComponentOperationalState();
357 }
358 hwr_pt->setInitialComponentState(initial_state);
360 while (cs_itr != g_sim.Indicator.controls.control_state_array.end() && !found_state) {
361 if (control_name == (*cs_itr)->getDisplayName()) {
362 found_state = true;
363 }
364 cs_itr++;
365 }
367 while (cv_itr != g_sim.Indicator.controls.control_value_array.end() && !found_state && !found_value) {
368 if (control_name == (*cv_itr)->getDisplayName()) {
369 found_value = true;
370 }
371 cv_itr++;
372 }
373 if (found_state) {
374 ctrl_state_pt = (ControlState *) g_sim.Indicator.controls.getControlFromMap(control_name);
375 failed_state = ctrl_state_pt->getDisplayedControlStateWhenFail();
376 if (failed_state == sim::State::On || failed_state == sim::State::Open) {
377 control_value = ctrl_state_pt->getValueForOnOrFullyOpen();
378 } else if (failed_state == sim::State::Off || failed_state == sim::State::Close) {
379 control_value = ctrl_state_pt->getValueForOffOrFullyClose();
380 } else {
381 control_value = ctrl_state_pt->getValueForNeutralState();
382 }
383 ctrl_state_pt->setAlpha_Parameter(100000.0);
384 ctrl_state_pt->setBeta_Parameter(1.0);
385 std::vector<string> nodes = hwr_pt->getBasicNodes();
386 for (std::vector<string>::iterator it = nodes.begin(); it != nodes.end(); ++it) {
387// std::cout << "**Basic Event:** " << *it
388// << std::endl;
389 }
390// std::cout << "Created SystemReliabilityFT: " << hwr_pt->getDisplayName()
391// << " with initial probability: " << hwr_pt->getProbability()
392// << " of type: " << ctrl_state_pt->getTypeOfControl()
393// << " with Control State: " << ctrl_state_pt->getDisplayName()
394// << std::endl;
395 } else if (found_value) {
396 ctrl_value_pt = (ControlValue *) g_sim.Indicator.controls.getControlFromMap(control_name);
397 control_value = ctrl_value_pt->getDisplayedControlValueWhenFail();
398 ctrl_value_pt->setAlpha_Parameter(100000.0);
399 ctrl_value_pt->setBeta_Parameter(1.0);
400 std::vector<string> nodes = hwr_pt->getBasicNodes();
401 for (std::vector<string>::iterator it = nodes.begin(); it != nodes.end(); ++it) {
402// std::cout << "**Basic Event:** " << *it
403// << std::endl;
404 }
405// std::cout << "Created SystemReliabilityFT: " << hwr_pt->getDisplayName()
406// << " with initial probability: " << hwr_pt->getProbability()
407// << " of type: " << ctrl_value_pt->getTypeOfControl()
408// << " with Control Value: " << ctrl_value_pt->getDisplayName()
409// << std::endl;
410 } else {
411 ofstream fout("err messages.txt", ios::app);
412 cout << "HWReliabilityModule::readSystemReliabilityFTInfoFromFile: could not find control name: " << control_name
413 << endl;
414 fout << r5pars_.timesno
415 << " HWReliabilityModule::readSystemReliabilityFTInfoFromFile: could not find control name: "
416 << control_name << '\n';
417 fout.close();
418 r5pars_.sim_err = true;
419 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::readSystemReliabilityFTInfoFromFile err.");
421 }
422 //
423 hwr_pt->setControlValue(control_value);
424 hwr_pt->setBothTotalTimeRequiredAndRemainingTime(0.0);
425 hwr_pt->setSender(sim::Source::Reliability);
426 hwr_pt->setIntendedReceiver(sim::Source::Plant);
427 hwr_pt->setCorrespondingComponentPt(dcs_pt);
428 component_reliability_FT.push_back(std::move(hwr_pt));
429 }
430}
432 bool need_to_check = false;
433 int activation_state;
434 double probability, waiting_time;
435 BranchSystemAction *bsa_success, *bsa_fail;
436 if (this->getStateOfActivation() == sim::State::Done) return;
437 for (auto& cr : component_reliability) {
438 activation_state = cr->checkAndActivateComponentFailure();
439 if (activation_state == sim::None) need_to_check = true;
440 if (activation_state == sim::State::Active) {
441 bsa_fail = new BranchSystemAction();
442 bsa_fail->copyBranchSystemAction(*cr);
445 bsa_fail->setTimerAndProbability(-1.0, cr->getProbability());
446 //
447 bsa_success = new BranchSystemAction();
448 bsa_success->copyBranchSystemAction(*cr);
451 bsa_success->setTimerAndProbability(-1.0, 1.0 - bsa_fail->getProbability());
452 for (auto& cor : component_operation_reliability) {
453 if (cr->getDisplayName() == cor->getDisplayName()) {
454 cor->setTimeAtDemand(r5pars_.timesno);
455 }
456 }
457 //
458 g_sim.Branch_center.addHWReliabilityBranch(bsa_success, bsa_fail);
459 }
460 }
461 for (auto& crft : component_reliability_FT) {
462 activation_state = crft->checkAndActivateComponentFailure();
463 if (activation_state == sim::None) need_to_check = true;
464 if (activation_state == sim::State::Active) {
465 bsa_fail = new BranchSystemAction();
466 bsa_fail->copyBranchSystemAction(*crft);
469 bsa_fail->setTimerAndProbability(-1.0, crft->getProbability());
470 //
471 bsa_success = new BranchSystemAction();
472 bsa_success->copyBranchSystemAction(*crft);
475 bsa_success->setTimerAndProbability(-1.0, 1.0 - bsa_fail->getProbability());
476 for (auto& cor : component_operation_reliability) {
477 if (crft->getDisplayName() == cor->getDisplayName()) {
478 cor->setTimeAtDemand(r5pars_.timesno);
479 }
480 }
481 //
482 g_sim.Branch_center.addHWReliabilityBranch(bsa_success, bsa_fail);
483 }
484 }
485 for (auto& cor : component_operation_reliability) {
486 activation_state = cor->checkAndActivateComponentFailure();
487 if (activation_state == sim::None) need_to_check = true;
488 // A running-failure unit is "activated" the moment its component state
489 // changes, but its interval branches come later. The module keeps
490 // checking while an operation unit has run-time failure intervals pending.
491 if (cor->getNumberOfIntervalsPassed() <= cor->getNumberOfIntervals()) need_to_check = true;
492 waiting_time =
493 cor->getTimeAtDemand() + cor->getNumberOfIntervalsPassed() * cor->getT_Minimum();
494 if (activation_state == sim::State::Done &&
495 r5pars_.timesno > waiting_time &&
496 cor->getNumberOfIntervalsPassed() <= cor->getNumberOfIntervals()) {
497 probability = cor->calculateSurvivalProbability(
498 cor->getNumberOfIntervalsPassed() * cor->getT_Minimum());
499 cor->setProbability(1 - probability);
500 bsa_fail = new BranchSystemAction();
501 bsa_fail->copyBranchSystemAction(*cor);
504 bsa_fail->setTimerAndProbability(-1.0, cor->getProbability());
505 //
506 bsa_success = new BranchSystemAction();
507 bsa_success->copyBranchSystemAction(*cor);
510 bsa_success->setTimerAndProbability(-1.0, 1.0 - bsa_fail->getProbability());
511 cor->setNumberOfIntervalsPassed(cor->getNumberOfIntervalsPassed() + 1);
512 //
513 g_sim.Branch_center.addHWReliabilityBranch(bsa_success, bsa_fail);
514 }
515 }
516 if (!need_to_check) this->setStateOfActivation(sim::State::Done);
517}
520 for (auto& src : _hwm.component_reliability) {
521 auto ptr = make_unique<HWReliabilityUnit>();
522 ptr->copyHWReliabilityUnit(*src);
523 component_reliability.push_back(std::move(ptr));
524 }
525 for (auto& src : _hwm.component_operation_reliability) {
526 auto ptr = make_unique<HWReliabilityUnit>();
527 ptr->copyHWReliabilityUnit(*src);
528 component_operation_reliability.push_back(std::move(ptr));
529 }
530 for (auto& src : _hwm.component_reliability_FT) {
531 auto ptr = make_unique<HWReliabilityFTUnit>();
532 ptr->setDisplayName(src->getTopNode());
533 ptr->copyHWReliabilityFTUnit(*src);
534 component_reliability_FT.push_back(std::move(ptr));
535 }
536}
538 component_reliability.clear();
542}
544 int i, num;
545 num = component_reliability.size();
546 fout << "HWReliabilityModule\n"
547 << num << '\n';
548 for (i = 0; i < num; i++) {
549 component_reliability.at(i)->saveHWReliabilityUnitToFile(fout);
550 }
552 fout << "HWOperationReliabilityModule\n"
553 << num << '\n';
554 for (i = 0; i < num; i++) {
555 component_operation_reliability.at(i)->saveHWReliabilityUnitToFile(fout);
556 }
557 this->saveStateOfActivationToFile(fout);
558}
560 int i, num;
561 string str;
562 fin >> str >> num;
563 if (str != "HWReliabilityModule") {
564 ofstream fout("err messages.txt", ios::app);
565 cout << "HWReliabilityModule::retrieveHWReliabilityModuleFromFile in previous function" << endl;
566 fout << r5pars_.timesno
567 << " HWReliabilityModule::retrieveHWReliabilityModuleFromFile errir in previous function\n";
568 fout.close();
569 r5pars_.sim_err = true;
570 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::retrieveHWReliabilityModuleFromFile Prior err.");
572 return;
573 }
574 fin >> str >> num;
575 if (str != "HWOperationReliabilityModule") {
576 ofstream fout("err messages.txt", ios::app);
577 cout << "HWReliabilityModule::retrieveHWReliabilityModuleFromFile in previous function" << endl;
578 fout << r5pars_.timesno
579 << " HWReliabilityModule::retrieveHWReliabilityModuleFromFile errir in previous function\n";
580 fout.close();
581 r5pars_.sim_err = true;
582 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::retrieveHWReliabilityModuleFromFile Prior err.");
584 return;
585 }
586 for (i = 0; i < num; i++) {
587 auto ptr = make_unique<HWReliabilityUnit>();
588 ptr->retrieveHWReliabilityUnitFromFile(fin);
589 component_operation_reliability.push_back(std::move(ptr));
590 }
592}
594 for(auto& p : component_reliability_FT){
595 if(p->getTopNode() == name){
596 return p.get();
597 }
598 }
599 ofstream fout("err messages.txt", ios::app);
600 cout << "HWReliabilityModule::getHWReliabilityFTUnit "
601 << name
602 << " can not be found." << endl;
603 fout << r5pars_.timesno << " HWReliabilityModule::getHWReliabilityFTUnit "
604 << name
605 << " can not be found.\n";
606 fout.close();
607 r5pars_.sim_err = true;
608 g_sim.Branch_center.setTempESMessage("HWReliabilityModule::getHWReliabilityFTUnit err.");
610 return nullptr;
611}
Hardware reliability model: failure on demand, fault tree failure on demand and failure while running...
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 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 copyBranchSystemAction(BranchSystemAction &)
void setSenderAndReceiver(int, int)
double getValueForNeutralState()
double getValueForOnOrFullyOpen()
double getValueForOffOrFullyClose()
std::vector< std::unique_ptr< ControlValue > > control_value_array
SystemControl * getControlFromMap(std::string)
std::vector< std::unique_ptr< ControlState > > control_state_array
SystemDisplay * getDisplayFromMap(std::string)
ControlPanelDisplay indicators
Definition: ControlPanel.h:53
ControlPanelControl controls
Definition: ControlPanel.h:54
int getDisplayedControlStateWhenFail()
double getDisplayedControlValueWhenFail()
void checkAndActiveComponentFailure()
Registers the hardware forks that are due at the current evaluation point.
std::vector< std::unique_ptr< HWReliabilityUnit > > component_reliability
Failure on demand units (alpha/beta probability model).
void readSystemOperationReliabilityInfoFromFile(std::ifstream &)
Reads the failure while running section into component_operation_reliability.
void copyHWReliabilityModule(HWReliabilityModule &)
Appends deep copies of the units of another module and copies its state of activation....
void readSystemReliabilityFTInfoFromFile(std::ifstream &)
Reads the fault tree failure on demand section into component_reliability_FT.
std::vector< std::unique_ptr< HWReliabilityUnit > > component_operation_reliability
Failure while running units (constant failure rate, evaluated per interval).
std::vector< std::unique_ptr< HWReliabilityFTUnit > > component_reliability_FT
Failure on demand units whose probability comes from a fault tree top node.
void readSystemReliabilityInfoFromFile(std::ifstream &)
Reads the failure on demand section into component_reliability.
void clearForRestart()
Removes all units and resets the state of activation.
void retrieveHWReliabilityModuleFromFile(std::ifstream &)
Reads a text restart stream: checks the two section labels, loads the failure while running units and...
HWReliabilityFTUnit * getHWReliabilityFTUnit(const std::string)
Finds the fault tree unit whose top node has the given name.
void saveHWReliabilityModuleToFile(std::ofstream &)
Writes the failure on demand units and the failure while running units, each under its own label and ...
void readInfoFromFile()
Loads SystemReliability.txt from the hardware reliability directory (Scheduler::getHardwareReliabilit...
double getProbability()
Definition: Probability.cpp:27
void setBeta_Parameter(double)
Definition: Probability.cpp:46
void setAlpha_Parameter(double)
Definition: Probability.cpp:44
std::string getHardwareReliabilityDirectory()
Definition: Scheduler.cpp:628
void setStateOfActivation(int)
void saveStateOfActivationToFile(std::ofstream &)
void retrieveStateOfActivationFromFile(std::ifstream &)
void copyStateOfActivation(StateOfActivation &)
void setTimerAndProbability(double, double)
struct @0 r5pars_
constexpr int Plant
Definition: SimConstants.h:135
constexpr int Reliability
Definition: SimConstants.h:139
constexpr int Failed
Definition: SimConstants.h:103
constexpr int On
Definition: SimConstants.h:105
constexpr int Off
Definition: SimConstants.h:106
constexpr int Succeed
Definition: SimConstants.h:104
constexpr int Done
Definition: SimConstants.h:123
constexpr int Open
Definition: SimConstants.h:116
constexpr int Active
Definition: SimConstants.h:118
constexpr int Close
Definition: SimConstants.h:117
constexpr int None
Definition: SimConstants.h:75
Scheduler SScheduler
Simulation scheduling, parses CLI options.
ControlPanel Indicator
Control room panel state.
BranchRecord Branch_center
Dynamic event tree state.