12#include "../Crew/Operator.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"
38 type_of_exp = src->getTypeOfExpectation();
40 auto ptr = make_unique<ProcedureExpectedAlarmStateUnit>();
44 auto ptr = make_unique<ProcedureExpectedComponentStateUnit>();
48 auto ptr = make_unique<ProcedureExpectedSupportSystemStateUnit>();
52 auto ptr = make_unique<ProcedureExpectedParameterValueUnit>();
56 auto ptr = make_unique<ProcedureExpectedParameterDifferenceUnit>();
60 auto ptr = make_unique<ProcedureExpectedParameterTrendUnit>();
64 auto ptr = make_unique<ExpectedMentalBelief>();
68 ofstream fout(
"err messages.txt", ios::app);
69 cout <<
"ExpectationORUnit::copyExpectationORUnit Type_of_exp: " << type_of_exp <<
" can not be recognized"
71 fout <<
r5pars_.timesno <<
" ExpectationORUnit::copyExpectationORUnit Type_of_exp: " << type_of_exp
72 <<
" can not be recognized\n";
81 bool found_exp =
false;
82 bool branch_generated =
false;
83 bool use_old_info =
false;
84 bool recent_info =
false;
87 int exp_state, type_of_exp, r_state, n_count, observation;
116 exp_state = (*exp_itr)->getStateOfExpectation();
119 type_of_exp = (*exp_itr)->getTypeOfExpectation();
133 (*exp_itr)->setStateOfExpectation(observation);
145 branch_generated =
true;
163 branch_generated =
true;
168 use_old_info =
false;
179 (*exp_itr)->setStateOfExpectation(observation);
190 branch_generated =
true;
205 branch_generated =
true;
210 use_old_info =
false;
221 (*exp_itr)->setStateOfExpectation(observation);
225 b_support_system_state->
copyTimer(*ss_pt);
231 std::cout <<
"Created support system state: " << b_support_system_state->
getDisplayName() << std::endl;
233 branch_generated =
true;
239 b_support_system_state->
copyTimer(*ss_pt);
247 std::cout <<
"Created support system state: " << b_support_system_state->
getDisplayName() << std::endl;
249 branch_generated =
true;
254 use_old_info =
false;
261 (*exp_itr)->setStateOfExpectation(observation);
264 b_parameter_value->
copyTimer(*par_value_pt);
272 branch_generated =
true;
278 b_parameter_value->
copyTimer(*par_value_pt);
286 branch_generated =
true;
294 use_old_info =
false;
306 (*exp_itr)->setStateOfExpectation(observation);
311 b_parameter_difference->
copyTimer(*par_diff_pt);
318 branch_generated =
true;
324 b_parameter_difference->
copyTimer(*par_diff_pt);
333 branch_generated =
true;
371 if (mental_belief_pt1 != 0) {
383 branch_generated =
true;
395 branch_generated =
true;
398 ofstream fout(
"err messages.txt", ios::app);
399 cout <<
"ExpectationORUnit::assessExpectation: mental belief expectation name: "
400 << mental_belief_pt->
getInfoName() <<
" can not be found." << endl;
401 fout <<
r5pars_.timesno <<
" ExpectationORUnit::assessExpectation: mental belief expectation name: "
402 << mental_belief_pt->
getInfoName() <<
" can not be found.\n";
409 ofstream fout(
"err messages.txt", ios::app);
410 cout <<
"ExpectationORUnit::assessExpectation: expectation type: " << type_of_exp <<
" can not be recognized."
412 fout <<
r5pars_.timesno <<
" ExpectationORUnit::assessExpectation: expectation type: " << type_of_exp
413 <<
" can not be recognized.\n";
421 type_of_exp = (*exp_itr)->getTypeOfExpectation();
427 (*exp_itr)->setStateOfExpectation(r_state);
442 branch_generated =
true;
443 }
else if (ma_pt != 0) {
455 branch_generated =
true;
467 branch_generated =
true;
474 (*exp_itr)->setStateOfExpectation(r_state);
489 branch_generated =
true;
490 }
else if (mcs_pt != 0) {
503 branch_generated =
true;
516 branch_generated =
true;
523 (*exp_itr)->setStateOfExpectation(r_state);
529 b_support_system_state->
copyTimer(*ss_pt);
537 std::cout <<
"Created support system state: " << b_support_system_state->
getDisplayName() << std::endl;
539 branch_generated =
true;
540 }
else if (msss_pt != 0) {
544 b_support_system_state->
copyTimer(*ss_pt);
552 std::cout <<
"Created support system state: " << b_support_system_state->
getDisplayName() << std::endl;
554 branch_generated =
true;
559 b_support_system_state->
copyTimer(*ss_pt);
566 std::cout <<
"Created support system state: " << b_support_system_state->
getDisplayName() << std::endl;
568 branch_generated =
true;
575 (*exp_itr)->setStateOfExpectation(r_state);
581 b_parameter_value->
copyTimer(*par_value_pt);
588 branch_generated =
true;
589 }
else if (mpv_pt != 0) {
593 b_parameter_value->
copyTimer(*par_value_pt);
600 branch_generated =
true;
605 b_parameter_value->
copyTimer(*par_value_pt);
612 branch_generated =
true;
622 (*exp_itr)->setStateOfExpectation(r_state);
628 b_parameter_difference->
copyTimer(*par_diff_pt);
635 branch_generated =
true;
636 }
else if (mpv_pt1 != 0 && mpv_pt2 != 0) {
640 b_parameter_difference->
copyTimer(*par_diff_pt);
648 branch_generated =
true;
653 b_parameter_difference->
copyTimer(*par_diff_pt);
659 branch_generated =
true;
703 ofstream fout(
"err messages.txt", ios::app);
704 cout <<
"ExpectationORUnit::assessExpectation: expectation type: " << type_of_exp <<
" can not be recognized1."
706 fout <<
r5pars_.timesno <<
" ExpectationORUnit::assessExpectation: expectation type: " << type_of_exp
707 <<
" can not be recognized1.\n";
724 return branch_generated;
731 obj_type =
e->getTypeOfExpectation();
732 fout << obj_type <<
' ';
748 ofstream fout(
"err messages.txt", ios::app);
749 cout <<
"ExpectationORUnit::saveExpectationORUnitToFile: expectation body obj_type:" << obj_type
750 <<
" cannot be recognized" << endl;
751 fout <<
r5pars_.timesno <<
" ExpectationORUnit::saveExpectationORUnitToFile: expectation body obj_type:"
752 << obj_type <<
" cannot be recognized\n";
761 int obj_type, i, n_expectation;
762 unique_ptr<ExpectationElement> exp_pt;
765 fin >> n_expectation;
767 for (i = 0; i < n_expectation; i++) {
770 auto p = make_unique<ProcedureExpectedAlarmStateUnit>();
771 p->retrieveProcedureExpectedAlarmStateUnitFromFile(fin);
772 exp_pt = std::move(p);
774 auto p = make_unique<ProcedureExpectedComponentStateUnit>();
775 p->retrieveProcedureExpectedComponentStateUnitFromFile(fin);
776 exp_pt = std::move(p);
778 auto p = make_unique<ProcedureExpectedSupportSystemStateUnit>();
779 p->retrieveProcedureExpectedSupportSystemStateUnitFromFile(fin);
780 exp_pt = std::move(p);
782 auto p = make_unique<ProcedureExpectedParameterValueUnit>();
783 p->retrieveProcedureExpectedParameterValueUnitFromFile(fin);
784 exp_pt = std::move(p);
786 auto p = make_unique<ProcedureExpectedParameterDifferenceUnit>();
787 p->retrieveProcedureExpectedParameterDifferenceUnitFromFile(fin);
788 exp_pt = std::move(p);
790 auto p = make_unique<ProcedureExpectedParameterTrendUnit>();
791 p->retrieveProcedureExpectedParameterTrendUnitFromFile(fin);
792 exp_pt = std::move(p);
794 auto p = make_unique<ExpectedMentalBelief>();
795 p->retrieveExpectedMentalBeliefFromFile(fin);
796 exp_pt = std::move(p);
798 ofstream fout(
"err messages.txt", ios::app);
799 cout <<
"ExpectationORUnit::retrieveExpectationORUnitFromFile: expectation body obj_type:" << obj_type
800 <<
" cannot be recognized" << endl;
801 fout <<
r5pars_.timesno <<
" ExpectationORUnit::retrieveExpectationORUnitFromFile: expectation body obj_type:"
802 << obj_type <<
" cannot be recognized\n";
812#include <boost/archive/binary_oarchive.hpp>
813#include <boost/archive/binary_iarchive.hpp>
831 throw std::runtime_error(
832 "expectation state overlay: element count mismatch against the seeded book");
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void setAlarmName(std::string)
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void addComponentState(int, BranchExpectedComponentState *)
void addParameterValue(int, BranchExpectedParameterValue *)
void addParameterDifference(int, BranchExpectedParameterDifference *)
void addSupportSystemState(int, BranchExpectedSupportSystemState *)
void addMentalBelief(int, BranchExpectedMentalBelief *)
Crew fork registration for a mental belief; same contract as addGoal().
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void addAlarmState(int, BranchExpectedAlarmState *)
void setSenderAndReceiver(int, int)
void setTypeOfPauseActivity(int)
MentalParameterValue second_mental_parameter
MentalParameterValue first_mental_parameter
std::string getDisplayName()
void setDisplayName(std::string)
void setStateOfExpectation(int)
void state_load(boost::archive::binary_iarchive &ar)
void state_save(boost::archive::binary_oarchive &ar) const
void add(ExpectationElement *)
bool assessExpectation(Operator &, ShortTermMemory &, int)
void saveExpectationORUnitToFile(std::ofstream &)
std::vector< std::unique_ptr< ExpectationElement > > expectation_OR
virtual ~ExpectationORUnit()
void retrieveExpectationORUnitFromFile(std::ifstream &)
void copyExpectationORUnit(ExpectationORUnit &)
void copyExpectedMentalBelief(ExpectedMentalBelief &)
double getProcedureInterpretationFailureProbability()
double getMentalProcedureFailureProbability()
MentalParameterValue * checkExistanceOfPerceivedParameterValue(std::string)
MentalAlarm * checkExistanceOfPerceivedAlarms(std::string)
int checkWhetherExpectedParameterValueMatchObservation(KBExpectedParameterValueUnit *)
MentalComponentState * checkExistanceOfPerceivedComponentState(std::string)
int checkWhetherExpectedAlarmMatchObservation(KBExpectedAlarmStateUnit *)
int checkWhetherExpectedComponentStateMatchObservation(KBExpectedComponentStateUnit *)
int checkWhetherExpectedSupportSystemStateMatchObservation(KBExpectedSupportSystemStateUnit *)
int checkWhetherExpectedParameterDifferenceMatchObservation(KBExpectedParameterDifferenceUnit *)
MentalSupportSystemState * checkExistanceOfPerceivedSupportSystemState(std::string)
ExpectedMentalBelief * checkExistanceOfMentalBelief(std::string)
void setInfoName(std::string)
std::string getInfoName()
void copyKBExpectedAlarmStateUnit(KBExpectedAlarmStateUnit &)
void setExpectedState(int)
void copyKBExpectedComponentStateUnit(KBExpectedComponentStateUnit &)
void setExpectedState(int)
KBElement first_indicator
void copyKBExpectedParameterDifferenceUnit(KBExpectedParameterDifferenceUnit &)
KBElement second_indicator
void copyKBExpectedParameterValueUnit(KBExpectedParameterValueUnit &)
void copyKBExpectedSupportSystemStateUnit(KBExpectedSupportSystemStateUnit &)
void setExpectedState(int)
void copyMentalAlarm(MentalAlarm &)
int getObservedAlarmState()
int getObservedComponentState()
void copyMentalComponentState(MentalComponentState &)
double getTimeAtWhichThisInfoIsPerceived()
void copyMentalParameterValue(MentalParameterValue &)
void copyMentalSupportSystemState(MentalSupportSystemState &)
int getObservedSupportSystemState()
HumanFailureEventsBBN hfe_bbn
void setProbability(double)
Timer support_system_update_time
Timer parameter_update_time
Timer component_update_time
void setStateOfActivation(int)
void saveStateOfActivationToFile(std::ofstream &)
int getStateOfActivation()
void retrieveStateOfActivationFromFile(std::ifstream &)
void copyStateOfActivation(StateOfActivation &)
void setTimerAndProbability(double, double)
void setBothTotalTimeRequiredAndRemainingTime(double)
double calculateRequiredTime()
constexpr int MentalBelief
constexpr int ParameterDifference
constexpr int ParameterTrend
constexpr int SupportSystemState
constexpr int ComponentState
constexpr int ParameterValue
BranchRecord Branch_center
Dynamic event tree state.