← Documentation
ADS-IDAC Engine 5.0.0
CommandControlUnit.cpp
Go to the documentation of this file.
1// CommandControlUnit.cpp: implementation of the CommandControlUnit class.
2//
4
6using namespace std;
8// Construction/Destruction
10
13}
14
16 //memory is controlled in program; do nothing here
17}
19 this->copyTimer(_cu);
20 this->copyStateOfActivation(_cu);
22 if (_cu.goal) {
23 goal = make_shared<BranchGoal>();
24 goal->copyBranchGoal(*(_cu.goal));
25 return;
26 }
27 if (_cu.strategy) {
28 strategy = make_shared<BranchStrategy>();
29 strategy->copyBranchStrategy(*(_cu.strategy));
30 return;
31 }
32 if (_cu.subgoal) {
33 subgoal = make_shared<BranchSubGoal>();
34 subgoal->copyBranchSubGoal(*(_cu.subgoal));
35 return;
36 }
37 if (_cu.diagnosis) {
38 diagnosis = make_shared<BranchDiagnosis>();
39 diagnosis->copyBranchDiagnosis(*(_cu.diagnosis));
40 return;
41 }
42 if (_cu.action_objective) {
43 action_objective = make_shared<BranchActionObjective>();
44 action_objective->copyBranchActionObjective(*(_cu.action_objective));
45 return;
46 }
47 if (_cu.action_pack) {
48 action_pack = make_shared<BranchActionPack>();
49 action_pack->copyBranchActionPack(*(_cu.action_pack));
50 return;
51 }
52 if (_cu.action) {
53 action = make_shared<BranchAction>();
54 action->copyBranchAction(*(_cu.action));
55 return;
56 }
57 if (_cu.alarm_state) {
58 alarm_state = make_shared<BranchExpectedAlarmState>();
59 alarm_state->copyBranchExpectedAlarmState(*(_cu.alarm_state));
60 return;
61 }
62 if (_cu.component_state) {
63 component_state = make_shared<BranchExpectedComponentState>();
64 component_state->copyBranchExpectedComponentState(*(_cu.component_state));
65 return;
66 }
67 if (_cu.support_system_state) {
68 support_system_state = make_shared<BranchExpectedSupportSystemState>();
69 support_system_state->copyBranchExpectedSupportSystemState(*(_cu.support_system_state));
70 return;
71 }
72 if (_cu.parameter_trend) {
73 parameter_trend = make_shared<BranchExpectedParameterTrend>();
74 parameter_trend->copyBranchExpectedParameterTrend(*(_cu.parameter_trend));
75 return;
76 }
77 if (_cu.parameter_value) {
78 parameter_value = make_shared<BranchExpectedParameterValue>();
79 parameter_value->copyBranchExpectedParameterValue(*(_cu.parameter_value));
80 return;
81 }
82 if (_cu.parameter_difference) {
83 parameter_difference = make_shared<BranchExpectedParameterDifference>();
84 parameter_difference->copyBranchExpectedParameterDifference(*(_cu.parameter_difference));
85 return;
86 }
87 if (_cu.procedure_step) {
88 procedure_step = make_shared<BranchProcedureStep>();
89 procedure_step->copyBranchProcedureStep(*(_cu.procedure_step));
90 return;
91 }
93 instinctive_response_procedure = make_shared<BranchProcedureStep>();
95 return;
96 }
97 if (_cu.info_gather_mode) {
98 info_gather_mode = make_shared<BranchInfoGatherMode>();
99 info_gather_mode->copyBranchInfoGatherMode(*(_cu.info_gather_mode));
100 return;
101 }
102 if (_cu.HW_reliability) {
103 HW_reliability = make_shared<BranchSystemAction>();
104 HW_reliability->copyBranchSystemAction(*(_cu.HW_reliability));
105 return;
106 }
107 if (_cu.SS_reliability) {
108 SS_reliability = make_shared<BranchSupportSystemAction>();
109 SS_reliability->copyBranchSupportSystemAction(*(_cu.SS_reliability));
110 return;
111 }
112 if (_cu.new_alarm) {
113 new_alarm = make_shared<BranchSystemAlarmState>();
114 new_alarm->copyBranchSystemAlarmState(*(_cu.new_alarm));
115 return;
116 }
117 if (_cu.mental_belief) {
118 mental_belief = make_shared<BranchExpectedMentalBelief>();
119 mental_belief->copyBranchExpectedMentalBelief(*(_cu.mental_belief));
120 return;
121 }
122 if (_cu.scanned_parameter) {
123 scanned_parameter = make_shared<BranchScannedParameter>();
124 scanned_parameter->copyBranchScannedParameter(*_cu.scanned_parameter);
125 return;
126 }
127}
129 goal.reset();
130 strategy.reset();
131 subgoal.reset();
132 diagnosis.reset();
133 action_objective.reset();
134 action_pack.reset();
135 action.reset();
136 alarm_state.reset();
137 component_state.reset();
138 support_system_state.reset();
139 parameter_trend.reset();
140 parameter_value.reset();
141 parameter_difference.reset();
142 procedure_step.reset();
144 info_gather_mode.reset();
145 HW_reliability.reset();
146 SS_reliability.reset();
147 new_alarm.reset();
148 mental_belief.reset();
149 scanned_parameter.reset();
150}
154 goal.reset(); strategy.reset(); subgoal.reset(); diagnosis.reset();
155 action_objective.reset(); action_pack.reset(); action.reset();
156 alarm_state.reset(); component_state.reset(); support_system_state.reset();
157 parameter_trend.reset(); parameter_value.reset(); parameter_difference.reset();
159 info_gather_mode.reset(); HW_reliability.reset(); SS_reliability.reset();
160 new_alarm.reset(); mental_belief.reset(); scanned_parameter.reset();
161}
163 fout << "CommandControlUnit\n";
164 this->saveTimerToFile(fout);
165 this->saveStateOfActivationToFile(fout);
166 fout << '\n' << associated_branch_ID << ' ';
167 if (goal != 0) {
168 fout << "1 ";
169 goal->saveBranchGoalToFile(fout);
170 } else {
171 fout << "0 ";
172 }
173 if (strategy != 0) {
174 fout << "1 ";
175 strategy->saveBranchStrategyToFile(fout);
176 } else {
177 fout << "0 ";
178 }
179 if (subgoal != 0) {
180 fout << "1 ";
181 subgoal->saveBranchSubGoalToFile(fout);
182 } else {
183 fout << "0 ";
184 }
185 if (diagnosis != 0) {
186 fout << "1 ";
187 diagnosis->saveBranchDiagnosisToFile(fout);
188 } else {
189 fout << "0 ";
190 }
191 if (action_objective != 0) {
192 fout << "1 ";
193 action_objective->saveBranchActionObjectiveToFile(fout);
194 } else {
195 fout << "0 ";
196 }
197 if (action_pack != 0) {
198 fout << "1 ";
199 action_pack->saveBranchActionPackToFile(fout);
200 } else {
201 fout << "0 ";
202 }
203 if (action != 0) {
204 fout << "1 ";
205 action->saveBranchActionToFile(fout);
206 } else {
207 fout << "0 ";
208 }
209 if (alarm_state != 0) {
210 fout << "1 ";
211 alarm_state->saveBranchExpectedAlarmStateToFile(fout);
212 } else {
213 fout << "0 ";
214 }
215 if (component_state != 0) {
216 fout << "1 ";
217 component_state->saveBranchExpectedComponentStateToFile(fout);
218 } else {
219 fout << "0 ";
220 }
221 if (support_system_state != 0) {
222 fout << "1 ";
223 support_system_state->saveBranchExpectedSupportSystemStateToFile(fout);
224 } else {
225 fout << "0 ";
226 }
227 if (parameter_trend != 0) {
228 fout << "1 ";
229 parameter_trend->saveBranchExpectedParameterTrendToFile(fout);
230 } else {
231 fout << "0 ";
232 }
233 if (parameter_value != 0) {
234 fout << "1 ";
235 parameter_value->saveBranchExpectedParameterValueToFile(fout);
236 } else {
237 fout << "0 ";
238 }
239 if (parameter_difference != 0) {
240 fout << "1 ";
241 parameter_difference->saveBranchExpectedParameterDifferenceToFile(fout);
242 } else {
243 fout << "0 ";
244 }
245 if (procedure_step != 0) {
246 fout << "1 ";
247 procedure_step->saveBranchProcedureStepToFile(fout);
248 } else {
249 fout << "0 ";
250 }
252 fout << "1 ";
253 instinctive_response_procedure->saveBranchProcedureStepToFile(fout);
254 } else {
255 fout << "0 ";
256 }
257 if (info_gather_mode != 0) {
258 fout << "1 ";
259 info_gather_mode->saveBranchInfoGatherModeToFile(fout);
260 } else {
261 fout << "0 ";
262 }
263 if (HW_reliability != 0) {
264 fout << "1 ";
265 HW_reliability->saveBranchSystemActionToFile(fout);
266 } else {
267 fout << "0 ";
268 }
269 if (SS_reliability != 0) {
270 fout << "1 ";
271 SS_reliability->saveBranchSupportSystemActionToFile(fout);
272 } else {
273 fout << "0 ";
274 }
275 if (new_alarm != 0) {
276 fout << "1 ";
277 new_alarm->saveBranchSystemAlarmStateToFile(fout);
278 } else {
279 fout << "0 ";
280 }
281 if (mental_belief != 0) {
282 fout << "1 ";
283 mental_belief->saveBranchExpectedMentalBeliefToFile(fout);
284 } else {
285 fout << "0 ";
286 }
287 if (scanned_parameter != 0) {
288 fout << "1 ";
289 scanned_parameter->saveBranchScannedParameterToFile(fout);
290 } else {
291 fout << "0 ";
292 }
293}
295 int num;
296 string str;
297//
298 fin >> str;
299 this->retrieveTimerFromFile(fin);
301
303 fin >> num;
304 if (num == 1) {
305 goal = make_shared<BranchGoal>();
306 goal->retrieveBranchGoalFromFile(fin);
307 }
308 fin >> num;
309 if (num == 1) {
310 strategy = make_shared<BranchStrategy>();
311 strategy->retrieveBranchStrategyFromFile(fin);
312 }
313 fin >> num;
314 if (num == 1) {
315 subgoal = make_shared<BranchSubGoal>();
316 subgoal->retrieveBranchSubGoalFromFile(fin);
317 }
318 fin >> num;
319 if (num == 1) {
320 diagnosis = make_shared<BranchDiagnosis>();
321 diagnosis->retrieveBranchDiagnosisFromFile(fin);
322 }
323 fin >> num;
324 if (num == 1) {
325 action_objective = make_shared<BranchActionObjective>();
326 action_objective->retrieveBranchActionObjectiveFromFile(fin);
327 }
328 fin >> num;
329 if (num == 1) {
330 action_pack = make_shared<BranchActionPack>();
331 action_pack->retrieveBranchActionPackFromFile(fin);
332 }
333 fin >> num;
334 if (num == 1) {
335 action = make_shared<BranchAction>();
336 action->retrieveBranchActionFromFile(fin);
337 }
338 fin >> num;
339 if (num == 1) {
340 alarm_state = make_shared<BranchExpectedAlarmState>();
341 alarm_state->retrieveBranchExpectedAlarmStateFromFile(fin);;
342 }
343 fin >> num;
344 if (num == 1) {
345 component_state = make_shared<BranchExpectedComponentState>();
346 component_state->retrieveBranchExpectedComponentStateFromFile(fin);
347 }
348 fin >> num;
349 if (num == 1) {
350 support_system_state = make_shared<BranchExpectedSupportSystemState>();
351 support_system_state->retrieveBranchExpectedSupportSystemStateFromFile(fin);
352 }
353 fin >> num;
354 if (num == 1) {
355 parameter_trend = make_shared<BranchExpectedParameterTrend>();
356 parameter_trend->retrieveBranchExpectedParameterTrendFromFile(fin);
357 }
358 fin >> num;
359 if (num == 1) {
360 parameter_value = make_shared<BranchExpectedParameterValue>();
361 parameter_value->retrieveBranchExpectedParameterValueFromFile(fin);
362 }
363 fin >> num;
364 if (num == 1) {
365 parameter_difference = make_shared<BranchExpectedParameterDifference>();
366 parameter_difference->retrieveBranchExpectedParameterDifferenceFromFile(fin);
367 }
368 fin >> num;
369 if (num == 1) {
370 procedure_step = make_shared<BranchProcedureStep>();
371 procedure_step->retrieveBranchProcedureStepFromFile(fin);
372 }
373 fin >> num;
374 if (num == 1) {
375 instinctive_response_procedure = make_shared<BranchProcedureStep>();
376 instinctive_response_procedure->retrieveBranchProcedureStepFromFile(fin);
377 }
378 fin >> num;
379 if (num == 1) {
380 info_gather_mode = make_shared<BranchInfoGatherMode>();
381 info_gather_mode->retrieveBranchInfoGatherModeFromFile(fin);
382 }
383 fin >> num;
384 if (num == 1) {
385 HW_reliability = make_shared<BranchSystemAction>();
386 HW_reliability->retrieveBranchSystemActionFromFile(fin);
387 }
388 fin >> num;
389 if (num == 1) {
390 SS_reliability = make_shared<BranchSupportSystemAction>();
391 SS_reliability->retrieveBranchSupportSystemActionFromFile(fin);
392 }
393 fin >> num;
394 if (num == 1) {
395 new_alarm = make_shared<BranchSystemAlarmState>();
396 new_alarm->retrieveBranchSystemAlarmStateFromFile(fin);
397 }
398 fin >> num;
399 if (num == 1) {
400 mental_belief = make_shared<BranchExpectedMentalBelief>();
401 mental_belief->retrieveBranchExpectedMentalBeliefFromFile(fin);
402 }
403 fin >> num;
404 if (num == 1) {
405 scanned_parameter = make_shared<BranchScannedParameter>();
406 scanned_parameter->retrieveBranchScannedParameterFromFile(fin);
407 }
408}
std::shared_ptr< BranchStrategy > strategy
std::shared_ptr< BranchProcedureStep > procedure_step
std::shared_ptr< BranchExpectedComponentState > component_state
std::shared_ptr< BranchProcedureStep > instinctive_response_procedure
std::shared_ptr< BranchGoal > goal
void saveCommandControlUnitToFile(std::ofstream &)
void copyCommandControlUnit(CommandControlUnit &)
std::shared_ptr< BranchScannedParameter > scanned_parameter
std::shared_ptr< BranchSubGoal > subgoal
std::shared_ptr< BranchExpectedSupportSystemState > support_system_state
std::shared_ptr< BranchExpectedParameterValue > parameter_value
std::shared_ptr< BranchExpectedAlarmState > alarm_state
void retrieveCommandControlUnitFromFile(std::ifstream &)
std::shared_ptr< BranchActionObjective > action_objective
std::shared_ptr< BranchAction > action
std::shared_ptr< BranchSystemAction > HW_reliability
std::shared_ptr< BranchExpectedParameterDifference > parameter_difference
std::shared_ptr< BranchInfoGatherMode > info_gather_mode
std::shared_ptr< BranchExpectedMentalBelief > mental_belief
std::shared_ptr< BranchDiagnosis > diagnosis
std::shared_ptr< BranchSupportSystemAction > SS_reliability
std::shared_ptr< BranchSystemAlarmState > new_alarm
std::shared_ptr< BranchExpectedParameterTrend > parameter_trend
std::shared_ptr< BranchActionPack > action_pack
void saveStateOfActivationToFile(std::ofstream &)
void retrieveStateOfActivationFromFile(std::ifstream &)
void copyStateOfActivation(StateOfActivation &)
void saveTimerToFile(std::ofstream &)
Definition: Timer.cpp:54
void retrieveTimerFromFile(std::ifstream &)
Definition: Timer.cpp:59
void copyTimer(Timer &)
Definition: Timer.cpp:44