6#include "../Scheduler/Scheduler.h"
7#include "../Global/fmodule.h"
8#include "../ControlPanel/ControlPanel.h"
9#include "../Branch/BranchRecord.h"
10#include "../Branch/BranchExpectedMentalBelief.h"
11#include "../Crew/OperatorDM.h"
13#include <boost/serialization/export.hpp>
14#include <boost/archive/binary_oarchive.hpp>
15#include <boost/archive/binary_iarchive.hpp>
16#include "../Global/SimulationContext.h"
63 string file_directory_and_name, str, sub_str;
65 int i, n_procedure_step_unit;
67 int num_quotation = 0;
69 file_directory_and_name +=
"ZProcedure_";
70 file_directory_and_name += _procedure_name;
71 file_directory_and_name +=
'_';
72 file_directory_and_name += _step_name;
73 file_directory_and_name +=
".txt";
75 fin.open(file_directory_and_name.c_str(), ios::in);
77 cout <<
"File: " << file_directory_and_name <<
" cound not be found" << endl;
78 ofstream fout(
"err messages.txt", ios::app);
79 fout <<
r5pars_.timesno <<
" File: " << file_directory_and_name <<
" cound not be found\n";
92 ofstream fout(
"err messages.txt", ios::app);
93 cout <<
"ProcedureStep::readInfoFromFile File: " << _procedure_name <<
' ' << _step_name <<
" input file has incorrect procedure or step name" << endl;
94 fout <<
r5pars_.timesno <<
" ProcedureStep::readInfoFromFile File: " << _procedure_name <<
' ' << _step_name <<
" input file has incorrect procedure or step name\n";
102 ofstream fout(
"err messages.txt", ios::app);
103 cout <<
"ProcedureStep::readInfoFromFile File: " << _procedure_name <<
' ' << _step_name <<
" has incorrect quotation mark." << endl;
104 fout <<
r5pars_.timesno <<
" ProcedureStep::readInfoFromFile File: " << _procedure_name <<
' ' << _step_name <<
" has incorrect quotation mark.\n";
115 >> n_procedure_step_unit;
116 for(i = 0; i < n_procedure_step_unit; i++){
117 auto ps_pt = make_unique<ProcedureStepUnit>();
118 if(ps_pt->readInfofromFile(fin) ==
false)
130 while (ch !=
'"' && !fin.eof()){
136 }
while(ch !=
'"' && !fin.eof());
150 auto ptr = make_unique<ProcedureStepUnit>();
151 ptr->copyProcedureStepUnit(*src);
159 bool next_is_a_mental_procedure =
false;
160 bool this_is_a_mental_procedure =
false;
161 bool branch_generated =
false;
162 bool found_ps_unit =
false;
164 double static_HEP_multiplier;
192 found_ps_unit =
true;
193 ps_unit_pt = ps_unit_itr->get();
197 if (ps_unit_pt != 0){
218 branch_generated =
true;
219 return branch_generated;
227 static_HEP_multiplier);
233 str=
"Procedure: Skipped Step Action";
244 str=
"Procedure: Skipped Step Action";
267 str=
"Procedure: Skipped Non-Response Action";
277 message =
"Sequence_terminated_by_non-response_action_(STOP):_Procedure:_";
279 message +=
" - Step: ";
309 branch_generated =
true;
326 return branch_generated;
330 vector<unique_ptr<ExpectationORUnit>>::iterator expectation_itr;
331 vector<unique_ptr<ExpectationElement>>::iterator expectation_OR_itr;
334 (*procedure_step_unit_itr)->setStateOfActivation(
sim::None);
335 (*procedure_step_unit_itr)->setStateOfAction(
sim::None);
336 (*procedure_step_unit_itr)->setStateOfExpectation(
sim::None);
337 (*procedure_step_unit_itr)->setStateOfNonResponseAction(
sim::None);
339 for(expectation_itr = (*procedure_step_unit_itr)->expectation.begin();expectation_itr!=(*procedure_step_unit_itr)->expectation.end();expectation_itr++){
340 (*expectation_itr)->setStateOfActivation(
sim::None);
341 for(expectation_OR_itr = (*expectation_itr)->expectation_OR.begin(); expectation_OR_itr != (*expectation_itr)->expectation_OR.end(); expectation_OR_itr++){
342 (*expectation_OR_itr)->setStateOfExpectation(
sim::None);
349 bool next_is_a_mental_procedure =
false;
350 bool next_is_a_functional_recovery_guideline =
false;
351 bool this_is_a_mental_procedure =
false;
352 bool branch_generated =
false;
353 bool found_ps_unit =
false;
354 bool command_action =
false;
355 double static_HEP_multiplier;
356 string str, sub_str, active_procedure_name, active_step_name, active_combined_name;
361 map<string, ProcedureStep *>::iterator procedure_map_itr;
370 found_ps_unit =
true;
371 ps_unit_pt = ps_unit_itr->get();
375 if (ps_unit_pt != 0){
379 if (sub_str ==
"MPBG_"){
380 next_is_a_mental_procedure =
true;
387 if (sub_str ==
"FRG_"){
388 next_is_a_functional_recovery_guideline =
true;
396 command_action =
true;
415 static_HEP_multiplier);
421 str=
"Procedure: Skipped Step Action";
433 str=
"Procedure: Skipped Step Action";
468 str=
"Procedure: Skipped Non-Response Action";
506 return branch_generated;
511 string str, sub_str, active_procedure_name, active_step_name, active_combined_name;
512 bool next_is_a_mental_procedure =
false;
513 bool next_is_a_functional_recovery_guideline =
false;
514 bool branch_generated =
false;
516 map<string, ProcedureStep *>::iterator procedure_map_itr;
523 if (sub_str ==
"MPBG_"){
524 next_is_a_mental_procedure =
true;
531 if (sub_str ==
"FRG_"){
532 next_is_a_functional_recovery_guideline =
true;
541 active_combined_name = active_procedure_name + active_step_name;
544 ps_pt = procedure_map_itr->second;
551 if (next_is_a_functional_recovery_guideline) {
601 else if (next_is_a_functional_recovery_guideline)
615 if (next_is_a_mental_procedure) {
618 branch_generated =
true;
630 ofstream fout(
"err messages.txt", ios::app);
648 return branch_generated;
653 bool this_is_a_mental_procedure =
false;
654 if (_procedure_name.size() >= 5){
655 str = _procedure_name.substr(0, 5);
656 if(str ==
"MPBG_") this_is_a_mental_procedure =
true;
658 return this_is_a_mental_procedure;
662 double multiplier = 1.0;
686 ofstream fout(
"err messages.txt", ios::app);
712 ofstream fout(
"err messages.txt", ios::app);
741 for(i = 0; i < num; i++){
754 for(i = 0; i < num; i++){
755 auto procedure_step_unit_pt = make_unique<ProcedureStepUnit>();
756 procedure_step_unit_pt->retrieveProcedureStepUnitFromFile(fin);
Emergency Operating Procedure (EOP) management — step execution and procedure flow.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void addRecord(std::string, int)
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void addProcedureStep(int, BranchProcedureStep *)
void addInstinctiveResponseProcedure(int, BranchProcedureStep *)
int getIDOfRecentGeneratedBranch()
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void displayInformation(std::string strInformation)
void setSenderAndReceiver(int, int)
void setTypeOfPauseActivity(int)
void setStepName(std::string)
void setLastProcedureName(std::string)
void setLastStepName(std::string)
void setProcedureName(std::string)
double getProcedureStepFailureProbability()
double getProcedureInterpretationFailureProbability()
void interruptCurrentProcedureStep()
std::string getCurrentProceduralStepName()
std::string getCurrentProcedureName()
void setStateOfAProcedureStep(std::string, std::string, int)
int getMentalPriorityOfAProcedureStep(std::string, std::string)
void KBcheckHardWiredMatchForProcedureActivity(std::string, int)
void setPauseActivity(bool)
HumanFailureEventsBBN hfe_bbn
bool executeExpectation(Operator &, ShortTermMemory &, int)
int getNumberOfANDExpectation()
int getTypeOfNonResponseAction()
void setStateOfNonResponseAction(int)
int getStateOfNonResponseAction()
bool hasNonResponseAction() const
bool executeAction(Operator &, ShortTermMemory &, int, std::string, std::string, std::string, double, double)
void setStateOfExpectation(int)
bool executeNonResponseAction(Operator &, ShortTermMemory &, int, std::string, std::string, double, double)
int getStateOfExpectation()
std::string next_procedure_name
std::vector< std::unique_ptr< ProcedureStepUnit > > procedure_step_unit
std::string current_procedure_name
int getProcedureStepCharacteristics()
std::string next_step_name
void setNextStepName(std::string name)
bool checkWhetherThisIsAMentalProcedure(std::string)
double calculateProcedureStepStaticHEPMultiplier()
void setProcedureStepComplexity(double complexity)
std::string getNextProcedureName()
std::string current_step_name
void copyProcedureStep(ProcedureStep &)
bool oneThroughProcessForProcedureStep(Operator &, double, double, bool, ShortTermMemory &)
double procedure_step_complexity
std::string getCurrentProcedureName()
void readDescriptionFromFile(std::ifstream &)
void saveProcedureStepToFile(std::ofstream &)
void setDescription(std::string desc)
void setBranchControlFlag(int flag)
void retrieveProcedureStepFromFile(std::ifstream &)
std::string getCurrentStepName()
int getBranchControlFlag()
bool readInfoFromFile(std::string, std::string)
void setCurrentProcedureName(std::string name)
void setCurrentStepName(std::string name)
bool oneThroughProcessForInstinctiveResponseProcedure(Operator &, double, double, bool, ShortTermMemory &)
void setNextProcedureName(std::string name)
int procedure_step_characteristics
bool executeInstinctiveResponseProcedureTransfer(Operator &, ShortTermMemory &)
std::string getDescription()
void setProcedureStepCharacteristics(int characteristics)
void setProcedureType(int type)
std::string getNextStepName()
void resetStateOfActivation()
double getProcedureStepComplexity()
double getVerificationStepMultiplier()
double getDiagnosisStepMultiplier()
double getObjectiveStepMultiplier()
double getPrerequisiteStepMultiplier()
double getMentalProcedureMultiplier()
double getNormalProcedureMultiplier()
std::map< std::string, ProcedureStep * > procedure_map
double getProcedureTransferTime()
double getAbnormalProcedureMultiplier()
double getOptimalRecoveryProcedureMultiplier()
double getFunctionalRecoveryProcedureMultipler()
double getMonitoringStepMultiplier()
double getStepTransferTime()
void setInfoSequenceTerminatedByNonResponseAction(std::string)
void setSequenceTerminatedByNonResponseAction(bool)
std::string getEOPDirectory()
void setStateOfActivation(int)
void saveStateOfActivationToFile(std::ofstream &)
void retrieveStateOfActivationFromFile(std::ifstream &)
void copyStateOfActivation(StateOfActivation &)
void setTimerAndProbability(double, double)
constexpr int ProcedureTransfer
constexpr int ProcedureXfr
constexpr int ParameterControl
constexpr int MentalProcedure
constexpr int VerificationStep
constexpr int ObjectiveRelated
constexpr int DiagnosisStep
constexpr int MonitoringStep
constexpr int PrerequisiteAction
constexpr int Interrupted
constexpr int InstinctiveResponse
constexpr int FollowProcedure
constexpr int FollowInstruction
Scheduler SScheduler
Simulation scheduling, parses CLI options.
Procedures All_procedure
Emergency operating procedures.
OperatorAT Action_Taker
Crew action execution model.
OperatorDM Decision_Maker
Crew decision-making model.
CommandControlCenter Command_handler
Command/control dispatch.
AnalysisInfoContainer Aux_info
Analysis records.
BranchRecord Branch_center
Dynamic event tree state.