← Documentation
ADS-IDAC Engine 5.0.0
BranchUnit.cpp
Go to the documentation of this file.
1// BranchUnit.cpp: implementation of the BranchUnit class.
2//
4
5#include "BranchUnit.h"
6#include <boost/serialization/export.hpp>
7#include <boost/archive/binary_oarchive.hpp>
8#include <boost/archive/binary_iarchive.hpp>
9BOOST_CLASS_EXPORT_IMPLEMENT(BranchUnit)
10using namespace std;
11
13// Construction/Destruction
15
18}
19
21 //unique_ptr handles deletion automatically
22}
25 bool zero_branch = true;
26 if (goal.size() > 0) {
28 zero_branch = false;
29 }
30 if (strategy.size() > 0) {
32 zero_branch = false;
33 }
34 if (subgoal.size() > 0) {
36 zero_branch = false;
37 }
38 if (diagnosis.size() > 0) {
40 zero_branch = false;
41 }
42 if (action_objective.size() > 0) {
44 zero_branch = false;
45 }
46 if (action_pack.size() > 0) {
48 zero_branch = false;
49 }
50 if (action.size() > 0) {
52 zero_branch = false;
53 }
54 if (alarm_state.size() > 0) {
56 zero_branch = false;
57 }
58 if (component_state.size() > 0) {
60 zero_branch = false;
61 }
62 if (support_system_state.size() > 0) {
64 zero_branch = false;
65 }
66 if (parameter_trend.size() > 0) {
68 zero_branch = false;
69 }
70 if (parameter_value.size() > 0) {
72 zero_branch = false;
73 }
74 if (parameter_difference.size() > 0) {
76 zero_branch = false;
77 }
78 if (scanned_parameter.size() > 0) {
80 zero_branch = false;
81 }
82 if (procedure_step.size() > 0) {
84 zero_branch = false;
85 }
86 if (instinctive_response_procedure.size() > 0) {
88 zero_branch = false;
89 }
90//
91 if (info_gather_mode.size() > 0) {
93 zero_branch = false;
94 }
95 if (mental_belief.size() > 0) {
97 zero_branch = false;
98//
99 }
100 if (zero_branch) number_of_combination = 0;
101}
103 if (number_of_combination == 0) {
105 }
107}
109 goal.clear();
110 strategy.clear();
111 subgoal.clear();
112 diagnosis.clear();
113 action_objective.clear();
114 action_pack.clear();
115 action.clear();
116 alarm_state.clear();
117 component_state.clear();
118 support_system_state.clear();
119 parameter_trend.clear();
120 parameter_value.clear();
121 parameter_difference.clear();
122 procedure_step.clear();
124 info_gather_mode.clear();
125 mental_belief.clear();
126 scanned_parameter.clear();
127}
129 // Release ownership without destroying objects (used for non-owning staging vectors)
130 goal.clear();
131 strategy.clear();
132 subgoal.clear();
133 diagnosis.clear();
134 action_objective.clear();
135 action_pack.clear();
136 action.clear();
137 alarm_state.clear();
138 component_state.clear();
139 support_system_state.clear();
140 parameter_trend.clear();
141 parameter_value.clear();
142 parameter_difference.clear();
143 procedure_step.clear();
145 info_gather_mode.clear();
146 mental_belief.clear();
147 scanned_parameter.clear();
148}
150 int n_return;
151 n_return = goal.size() + strategy.size() + subgoal.size() + diagnosis.size() +
152 action_objective.size() + action_pack.size() + action.size() + alarm_state.size() +
155 + info_gather_mode.size() + mental_belief.size() + scanned_parameter.size();
156 return n_return;
157}
159 for (auto &src : _bu.goal) {
160 auto p = make_shared<BranchGoal>();
161 p->copyBranchGoal(*src);
162 this->goal.push_back(std::move(p));
163 }
164 for (auto &src : _bu.strategy) {
165 auto p = make_shared<BranchStrategy>();
166 p->copyBranchStrategy(*src);
167 this->strategy.push_back(std::move(p));
168 }
169 for (auto &src : _bu.subgoal) {
170 auto p = make_shared<BranchSubGoal>();
171 p->copyBranchSubGoal(*src);
172 this->subgoal.push_back(std::move(p));
173 }
174 for (auto &src : _bu.diagnosis) {
175 auto p = make_shared<BranchDiagnosis>();
176 p->copyBranchDiagnosis(*src);
177 this->diagnosis.push_back(std::move(p));
178 }
179 for (auto &src : _bu.action_objective) {
180 auto p = make_shared<BranchActionObjective>();
181 p->copyBranchActionObjective(*src);
182 this->action_objective.push_back(std::move(p));
183 }
184 for (auto &src : _bu.action_pack) {
185 auto p = make_shared<BranchActionPack>();
186 p->copyBranchActionPack(*src);
187 this->action_pack.push_back(std::move(p));
188 }
189 for (auto &src : _bu.action) {
190 auto p = make_shared<BranchAction>();
191 p->copyBranchAction(*src);
192 this->action.push_back(std::move(p));
193 }
194 for (auto &src : _bu.alarm_state) {
195 auto p = make_shared<BranchExpectedAlarmState>();
196 p->copyBranchExpectedAlarmState(*src);
197 this->alarm_state.push_back(std::move(p));
198 }
199 for (auto &src : _bu.component_state) {
200 auto p = make_shared<BranchExpectedComponentState>();
201 p->copyBranchExpectedComponentState(*src);
202 this->component_state.push_back(std::move(p));
203 }
204 for (auto &src : _bu.support_system_state) {
205 auto p = make_shared<BranchExpectedSupportSystemState>();
206 p->copyBranchExpectedSupportSystemState(*src);
207 this->support_system_state.push_back(std::move(p));
208 }
209 for (auto &src : _bu.parameter_trend) {
210 auto p = make_shared<BranchExpectedParameterTrend>();
211 p->copyBranchExpectedParameterTrend(*src);
212 this->parameter_trend.push_back(std::move(p));
213 }
214 for (auto &src : _bu.parameter_value) {
215 auto p = make_shared<BranchExpectedParameterValue>();
216 p->copyBranchExpectedParameterValue(*src);
217 this->parameter_value.push_back(std::move(p));
218 }
219 for (auto &src : _bu.parameter_difference) {
220 auto p = make_shared<BranchExpectedParameterDifference>();
221 p->copyBranchExpectedParameterDifference(*src);
222 this->parameter_difference.push_back(std::move(p));
223 }
224 for (auto &src : _bu.procedure_step) {
225 auto p = make_shared<BranchProcedureStep>();
226 p->copyBranchProcedureStep(*src);
227 this->procedure_step.push_back(std::move(p));
228 }
229 for (auto &src : _bu.instinctive_response_procedure) {
230 auto p = make_shared<BranchProcedureStep>();
231 p->copyBranchProcedureStep(*src);
232 this->instinctive_response_procedure.push_back(std::move(p));
233 }
234 for (auto &src : _bu.info_gather_mode) {
235 auto p = make_shared<BranchInfoGatherMode>();
236 p->copyBranchInfoGatherMode(*src);
237 this->info_gather_mode.push_back(std::move(p));
238 }
239 for (auto &src : _bu.mental_belief) {
240 auto p = make_shared<BranchExpectedMentalBelief>();
241 p->copyBranchExpectedMentalBelief(*src);
242 this->mental_belief.push_back(std::move(p));
243 }
244 for (auto &src : _bu.scanned_parameter) {
245 auto p = make_shared<BranchScannedParameter>();
246 p->copyBranchScannedParameter(*src);
247 this->scanned_parameter.push_back(std::move(p));
248 }
250}
252 int n;
253 n = goal.size() + strategy.size() + subgoal.size() + diagnosis.size() +
254 action_objective.size() + action_pack.size() + action.size() +
255 alarm_state.size() + component_state.size() + support_system_state.size() + parameter_trend.size() +
256 parameter_value.size() + parameter_difference.size() + procedure_step.size() +
258 scanned_parameter.size();
259 return n;
260}
262 fout << number_of_combination << '\n';
263
264 fout << this->goal.size() << '\n';
265 for (auto &p : goal) { p->saveBranchGoalToFile(fout); }
266 fout << this->strategy.size() << '\n';
267 for (auto &p : strategy) { p->saveBranchStrategyToFile(fout); }
268 fout << this->subgoal.size() << '\n';
269 for (auto &p : subgoal) { p->saveBranchSubGoalToFile(fout); }
270 fout << this->diagnosis.size() << '\n';
271 for (auto &p : diagnosis) { p->saveBranchDiagnosisToFile(fout); }
272 fout << this->action_objective.size() << '\n';
273 for (auto &p : action_objective) { p->saveBranchActionObjectiveToFile(fout); }
274 fout << this->action_pack.size() << '\n';
275 for (auto &p : action_pack) { p->saveBranchActionPackToFile(fout); }
276 fout << this->action.size() << '\n';
277 for (auto &p : action) { p->saveBranchActionToFile(fout); }
278 fout << this->alarm_state.size() << '\n';
279 for (auto &p : alarm_state) { p->saveBranchExpectedAlarmStateToFile(fout); }
280 fout << this->component_state.size() << '\n';
281 for (auto &p : component_state) { p->saveBranchExpectedComponentStateToFile(fout); }
282 fout << this->support_system_state.size() << '\n';
283 for (auto &p : support_system_state) { p->saveBranchExpectedSupportSystemStateToFile(fout); }
284 fout << this->parameter_trend.size() << '\n';
285 for (auto &p : parameter_trend) { p->saveBranchExpectedParameterTrendToFile(fout); }
286 fout << this->parameter_value.size() << '\n';
287 for (auto &p : parameter_value) { p->saveBranchExpectedParameterValueToFile(fout); }
288 fout << this->parameter_difference.size() << '\n';
289 for (auto &p : parameter_difference) { p->saveBranchExpectedParameterDifferenceToFile(fout); }
290 fout << this->procedure_step.size() << '\n';
291 for (auto &p : procedure_step) { p->saveBranchProcedureStepToFile(fout); }
292 fout << this->instinctive_response_procedure.size() << '\n';
293 for (auto &p : instinctive_response_procedure) { p->saveBranchProcedureStepToFile(fout); }
294 fout << this->info_gather_mode.size() << '\n';
295 for (auto &p : info_gather_mode) { p->saveBranchInfoGatherModeToFile(fout); }
296 fout << this->mental_belief.size() << '\n';
297 for (auto &p : mental_belief) { p->saveBranchExpectedMentalBeliefToFile(fout); }
298 fout << this->scanned_parameter.size() << '\n';
299 for (auto &p : scanned_parameter) { p->saveBranchScannedParameterToFile(fout); }
300}
302 int i, num;
303//
305 fin >> num;
306 for (i = 0; i < num; i++) {
307 auto p = make_shared<BranchGoal>();
308 p->retrieveBranchGoalFromFile(fin);
309 this->goal.push_back(std::move(p));
310 }
311 fin >> num;
312 for (i = 0; i < num; i++) {
313 auto p = make_shared<BranchStrategy>();
314 p->retrieveBranchStrategyFromFile(fin);
315 this->strategy.push_back(std::move(p));
316 }
317 fin >> num;
318 for (i = 0; i < num; i++) {
319 auto p = make_shared<BranchSubGoal>();
320 p->retrieveBranchSubGoalFromFile(fin);
321 this->subgoal.push_back(std::move(p));
322 }
323 fin >> num;
324 for (i = 0; i < num; i++) {
325 auto p = make_shared<BranchDiagnosis>();
326 p->retrieveBranchDiagnosisFromFile(fin);
327 this->diagnosis.push_back(std::move(p));
328 }
329 fin >> num;
330 for (i = 0; i < num; i++) {
331 auto p = make_shared<BranchActionObjective>();
332 p->retrieveBranchActionObjectiveFromFile(fin);
333 this->action_objective.push_back(std::move(p));
334 }
335 fin >> num;
336 for (i = 0; i < num; i++) {
337 auto p = make_shared<BranchActionPack>();
338 p->retrieveBranchActionPackFromFile(fin);
339 this->action_pack.push_back(std::move(p));
340 }
341 fin >> num;
342 for (i = 0; i < num; i++) {
343 auto p = make_shared<BranchAction>();
344 p->retrieveBranchActionFromFile(fin);
345 this->action.push_back(std::move(p));
346 }
347 fin >> num;
348 for (i = 0; i < num; i++) {
349 auto p = make_shared<BranchExpectedAlarmState>();
350 p->retrieveBranchExpectedAlarmStateFromFile(fin);
351 this->alarm_state.push_back(std::move(p));
352 }
353 fin >> num;
354 for (i = 0; i < num; i++) {
355 auto p = make_shared<BranchExpectedComponentState>();
356 p->retrieveBranchExpectedComponentStateFromFile(fin);
357 this->component_state.push_back(std::move(p));
358 }
359 fin >> num;
360 for (i = 0; i < num; i++) {
361 auto p = make_shared<BranchExpectedSupportSystemState>();
362 p->retrieveBranchExpectedSupportSystemStateFromFile(fin);
363 this->support_system_state.push_back(std::move(p));
364 }
365 fin >> num;
366 for (i = 0; i < num; i++) {
367 auto p = make_shared<BranchExpectedParameterTrend>();
368 p->retrieveBranchExpectedParameterTrendFromFile(fin);
369 this->parameter_trend.push_back(std::move(p));
370 }
371 fin >> num;
372 for (i = 0; i < num; i++) {
373 auto p = make_shared<BranchExpectedParameterValue>();
374 p->retrieveBranchExpectedParameterValueFromFile(fin);
375 this->parameter_value.push_back(std::move(p));
376 }
377 fin >> num;
378 for (i = 0; i < num; i++) {
379 auto p = make_shared<BranchExpectedParameterDifference>();
380 p->retrieveBranchExpectedParameterDifferenceFromFile(fin);
381 this->parameter_difference.push_back(std::move(p));
382 }
383 fin >> num;
384 for (i = 0; i < num; i++) {
385 auto p = make_shared<BranchProcedureStep>();
386 p->retrieveBranchProcedureStepFromFile(fin);
387 this->procedure_step.push_back(std::move(p));
388 }
389 fin >> num;
390 for (i = 0; i < num; i++) {
391 auto p = make_shared<BranchProcedureStep>();
392 p->retrieveBranchProcedureStepFromFile(fin);
393 this->instinctive_response_procedure.push_back(std::move(p));
394 }
395 fin >> num;
396 for (i = 0; i < num; i++) {
397 auto p = make_shared<BranchInfoGatherMode>();
398 p->retrieveBranchInfoGatherModeFromFile(fin);
399 this->info_gather_mode.push_back(std::move(p));
400 }
401 fin >> num;
402 for (i = 0; i < num; i++) {
403 auto p = make_shared<BranchExpectedMentalBelief>();
404 p->retrieveBranchExpectedMentalBeliefFromFile(fin);
405 this->mental_belief.push_back(std::move(p));
406 }
407 fin >> num;
408 for (i = 0; i < num; i++) {
409 auto p = make_shared<BranchScannedParameter>();
410 p->retrieveBranchScannedParameterFromFile(fin);
411 this->scanned_parameter.push_back(std::move(p));
412 }
413}
A single branch alternative — holds all crew/system state deltas for one branch.
std::vector< std::shared_ptr< BranchSubGoal > > subgoal
Definition: BranchUnit.h:55
void copyBranchUnit(BranchUnit &)
Definition: BranchUnit.cpp:158
std::vector< std::shared_ptr< BranchExpectedParameterTrend > > parameter_trend
Definition: BranchUnit.h:63
std::vector< std::shared_ptr< BranchInfoGatherMode > > info_gather_mode
Definition: BranchUnit.h:68
std::vector< std::shared_ptr< BranchProcedureStep > > instinctive_response_procedure
Definition: BranchUnit.h:67
std::vector< std::shared_ptr< BranchGoal > > goal
Definition: BranchUnit.h:53
void clearBranchUnitAllPointers()
Definition: BranchUnit.cpp:128
std::vector< std::shared_ptr< BranchActionPack > > action_pack
Definition: BranchUnit.h:58
virtual ~BranchUnit()
Definition: BranchUnit.cpp:20
void calculateNumberOfCombination()
Definition: BranchUnit.cpp:23
std::vector< std::shared_ptr< BranchExpectedSupportSystemState > > support_system_state
Definition: BranchUnit.h:62
std::vector< std::shared_ptr< BranchExpectedParameterDifference > > parameter_difference
Definition: BranchUnit.h:65
std::vector< std::shared_ptr< BranchDiagnosis > > diagnosis
Definition: BranchUnit.h:56
int getNumberOfItemInBranchUnit()
Definition: BranchUnit.cpp:251
std::vector< std::shared_ptr< BranchExpectedMentalBelief > > mental_belief
Definition: BranchUnit.h:69
std::vector< std::shared_ptr< BranchExpectedParameterValue > > parameter_value
Definition: BranchUnit.h:64
int getNumberOfCombination()
Definition: BranchUnit.cpp:102
std::vector< std::shared_ptr< BranchScannedParameter > > scanned_parameter
Definition: BranchUnit.h:70
void clearBranchUnit()
Definition: BranchUnit.cpp:108
int number_of_combination
Definition: BranchUnit.h:96
std::vector< std::shared_ptr< BranchExpectedComponentState > > component_state
Definition: BranchUnit.h:61
std::vector< std::shared_ptr< BranchStrategy > > strategy
Definition: BranchUnit.h:54
void saveBranchUnitToFile(std::ofstream &)
Definition: BranchUnit.cpp:261
std::vector< std::shared_ptr< BranchProcedureStep > > procedure_step
Definition: BranchUnit.h:66
int getTotalPiecesOfInfo()
Definition: BranchUnit.cpp:149
std::vector< std::shared_ptr< BranchExpectedAlarmState > > alarm_state
Definition: BranchUnit.h:60
std::vector< std::shared_ptr< BranchAction > > action
Definition: BranchUnit.h:59
std::vector< std::shared_ptr< BranchActionObjective > > action_objective
Definition: BranchUnit.h:57
void retrieveBranchUnitFromFile(std::ifstream &)
Definition: BranchUnit.cpp:301