← Documentation
ADS-IDAC Engine 5.0.0
ProximityModel.cpp
Go to the documentation of this file.
1// ProximityModel.cpp: implementation of the ProximityModel class.
2//
4
5#include "ProximityModel.h"
6#include "ReasonMachine.h"
7#include "../Crew/OperatorDM.h"
8#include "../Crew/OperatorAT.h"
9#include "../Branch/BranchRecord.h"
10#include "../Global/SimulationContext.h"
11using namespace std;
12
14// Construction/Destruction
16
18{
19
20}
21
23{
24
25}
26
28{
29 string directory, str, str_name, file_name;
30 ifstream fin;
31 int n_Unit, n_member, i, j;
32 string err_mes;
33 ProximityGroupUnit * pu_pt;
34
35 //get the input file directory
36 if (this->m_operator == sim::Operator::ODM)
37 {file_name = g_sim.SScheduler.getODMDirectory();
38 file_name += "RM//";
39 file_name += "KB_ODM_Control_Panel_Proximity.txt";}
40 else if (this->m_operator == sim::Operator::OAT)
41 {file_name = g_sim.SScheduler.getOATDirectory();
42 file_name += "RM//";
43 file_name += "KB_OAT_Control_Panel_Proximity.txt";}
44 else
45 {}//error message
46
47 fin.open(file_name.c_str(), ios::in);
48 if(!fin.is_open())
49 {
50 err_mes = "could not open file: " + file_name;
51 this->ErrorMessage(err_mes);
52 return;
53
54 }
55 else
56 {
57 fin >> str >> n_Unit;
58 if(str.compare("No_of_Proximity_Groups:") != 0)
59 {
60 err_mes = "No_of_Proximity_Groups: is missing in proximity model txt file";
61 this->ErrorMessage(err_mes);
62 return;
63 }
64
65 for(i=0; i<n_Unit; i++)
66 {
67 fin >> str >> n_member;
68 if(str.compare("No_of_members_in_this_group:") != 0)
69 {
70 err_mes = "No_of_members_in_this_group: is missing in proximity model txt file";
71 this->ErrorMessage(err_mes);
72 return;
73 }
74
75 auto pu_owned = std::make_unique<ProximityGroupUnit>();
76 pu_owned->m_n_members = n_member;
77 for(j = 0; j<n_member; j++)
78 {
79 fin >> str;
80 pu_owned->indication_concept_ID_list.push_back(str);
81 }
82 this->m_prox_unit_list.push_back(std::move(pu_owned));
83 }
84
85 fin.close();
86 }
87
88}
89
91{
92 cout << r5pars_.timesno << " " << str << " in ProximityModel.cpp" << '\n';
93 ofstream fout("err messages.txt", ios::app);
94 fout << r5pars_.timesno << " " << str << '\n';
95 fout.close();
96 //r5pars_.terminateall = true;
97}
98
100{
101 ProximityGroupUnit * pu_pt;
102 if(this->m_prox_unit_list.size() > 0)
103 {this->ErrorMessage("this->m_prox_unit_list.size() > 0");}
104
105 this->m_operator = _pm_pt->m_operator;
106 for(auto &e : _pm_pt->m_prox_unit_list)
107 {
108 auto pu_owned = std::make_unique<ProximityGroupUnit>();
109 pu_owned->CopyProximityGroupUnitInfoFromAnother(e.get());
110 this->m_prox_unit_list.push_back(std::move(pu_owned));
111 }
112}
113
115{
116 //assumption, one indication can only appear at most in one group
117 ProximityGroupUnit * pu_pt = NULL;
118
119 for(auto &e : this->m_prox_unit_list)
120 {
121 if(pu_pt != NULL) break;
122 if(e->WhetherContainOneName(name) == true)
123 {pu_pt = e.get();}
124 }
125 return pu_pt;
126}
Diagnostic reasoning engine — knowledge representation, mental model, and inference.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
document e
void ReadProximityModelFromInputFile()
std::vector< std::unique_ptr< ProximityGroupUnit > > m_prox_unit_list
void ErrorMessage(std::string str)
virtual ~ProximityModel()
ProximityGroupUnit * FindAProximityGroupUnitByOneMemberName(std::string name)
void CopyProximityModelFromAnother(ProximityModel *_pm_pt)
std::string getOATDirectory()
Definition: Scheduler.cpp:622
std::string getODMDirectory()
Definition: Scheduler.cpp:619
struct @0 r5pars_
constexpr int ODM
Definition: SimConstants.h:145
constexpr int OAT
Definition: SimConstants.h:144
Scheduler SScheduler
Simulation scheduling, parses CLI options.