← Documentation
ADS-IDAC Engine 5.0.0
ManeuverActionUnit.cpp
Go to the documentation of this file.
1// ManeuverActionUnit.cpp: implementation of the ManeuverActionUnit class.
2//
4
6#include "Operator.h"
7#include "../ControlPanel/ControlPanelControl.h"
8#include "../ControlPanel/ControlPanel.h"
9#include "../Global/fmodule.h"
10#include "../Branch/BranchSystemAction.h"
11#include "../Branch/BranchRecord.h"
12#include "../ControlPanel/DisplayParameterValue.h"
14#include "../Global/SimulationContext.h"
15using namespace std;
16
17
19// Construction/Destruction
21
23{
24 maneuver_name = "NONE";
30 LB_target_value = 0.0;
31 UB_target_value = 0.0;
32 target_value = 0.0;
40 first_maneuver_time = -1.0e6;
41}
42
44{
45 this->three_by_three_maneuver.clear();
46}
79
81 vector<double>::iterator d_itr;
99 for(d_itr = _pmu.three_by_three_maneuver.begin(); d_itr != _pmu.three_by_three_maneuver.end(); d_itr++){
100 this->three_by_three_maneuver.push_back(*d_itr);
101 }
102}
104 string str;
105 int i;
106 double d1, d2, d3;
107 fin >> str >> maneuver_name
112 >> str >> LB_change_rate >> UB_change_rate
113 >> str;
114 for(i = 0; i < 3; i++){
115 fin >> str >> d1 >> d2 >> d3;
116 this->three_by_three_maneuver.push_back(d1);
117 this->three_by_three_maneuver.push_back(d2);
118 this->three_by_three_maneuver.push_back(d3);
119 }
120 fin >> str >> maneuver_time_interval
121 >> str >> maneuver_total_duration;
122}
124 int i;
126 fout << maneuver_name << ' '
128 << LB_interactive_control << ' '
129 << UB_interactive_control << ' '
130 << previous_control_value << ' '
132 << LB_target_value << ' '
133 << UB_target_value << ' '
134 << target_value << ' '
136 << LB_change_rate << ' '
137 << UB_change_rate << ' '
138 << maneuver_time_interval << ' '
140 << previous_maneuver_time << ' '
141 << first_maneuver_time << ' '
142 << this->three_by_three_maneuver.size() << ' ';
143 for(i = 0; i < this->three_by_three_maneuver.size(); i++){
144 fout << this->three_by_three_maneuver.at(i) << ' ';
145 }
146 fout << '\n';
147}
149 int i, num;
150 double d_value;
152 fin >> maneuver_name
160 >> target_value
168 >> num;
169 for(i = 0; i < num; i++){
170 fin >> d_value;
171 this->three_by_three_maneuver.push_back(d_value);
172 }
173}
176 double current_parameter_value;
177 double current_parameter_change_rate;
178 double current_control_value;
179 double percentage_change_in_control_value;
180 BranchSystemAction *bsa_success;
181 DisplayParameterValue *dpv_pt, *dpvr_pt;
182 //determine the need to maneuver based on the time of previous activity
185 }
186 else{
187 return;
188 }
189//check and assign the pointers pointing to the corresponding parameters
192 }
195 }
198 }
199 //pointer search error management is handled in the ControlPanel::indicators and ControlPanel::conntrols. No need to do error control here
201 return;
202 }
204 return;
205 }
206//set first amneuver time and check total action duration time
207 if(first_maneuver_time < 0){
209 }
212 first_maneuver_time = -1.0e6;
213 previous_maneuver_time = -1.0e6;
214 return;
215 }
216//perform control: first get change in control rate in percentage
220 current_parameter_value = dpv_pt->getDisplayedParameterValue();
221 current_parameter_change_rate = dpvr_pt->getDisplayedParameterValue();
222 //
223 if(current_parameter_change_rate < LB_change_rate){
224 if(current_parameter_value < LB_target_value){
225 percentage_change_in_control_value = this->three_by_three_maneuver.at(0);
226 }
227 else if (current_parameter_value > UB_target_value){
228 percentage_change_in_control_value = this->three_by_three_maneuver.at(2);
229 }
230 else{
231 percentage_change_in_control_value = this->three_by_three_maneuver.at(1);
232 }
233 }
234 else if(current_parameter_change_rate > UB_change_rate){
235 if(current_parameter_value < LB_target_value){
236 percentage_change_in_control_value = this->three_by_three_maneuver.at(6);
237 }
238 else if (current_parameter_value > UB_target_value){
239 percentage_change_in_control_value = this->three_by_three_maneuver.at(8);
240 }
241 else{
242 percentage_change_in_control_value = this->three_by_three_maneuver.at(7);
243 }
244 }
245 else{
246 if(current_parameter_value < LB_target_value){
247 percentage_change_in_control_value = this->three_by_three_maneuver.at(3);
248 }
249 else if (current_parameter_value > UB_target_value){
250 percentage_change_in_control_value = this->three_by_three_maneuver.at(5);
251 }
252 else{
253 percentage_change_in_control_value = this->three_by_three_maneuver.at(4);
254 }
255 }
256//calculate final control rate
257 if (percentage_change_in_control_value > 1.0){//note at: this time the percentage_change_in_control_value is a positive value
258 current_control_value = previous_control_value + (UB_interactive_control - previous_control_value) * percentage_change_in_control_value / 100.0;
259 if((UB_interactive_control - current_control_value) < 0.01) {
260 current_control_value = UB_interactive_control;
261 }
262 ptr_to_corresponding_control->setControlValue(current_control_value);
263 bsa_success = new BranchSystemAction();
265 bsa_success->setControlValue(current_control_value);
268 bsa_success->setTimerAndProbability(0.0, 1.0 - _operator.hfe_bbn.getManeuverActionFailureProbability());
270 //
271 if ((current_control_value > (UB_interactive_control + 0.0001)) ||
272 (current_control_value < (LB_interactive_control - 0.0001))){
273 ofstream fout("err messages.txt", ios::app);
274 cout << "ManeuverActionUnit::executeManeuverControl " << this->getManeuverName() << " action: "
275 << this->getCorrespondingInteractiveControlName() << " whose control value: "
276 << current_control_value << " is out of bound" << endl;
277 fout << r5pars_.timesno << " ManeuverActionUnit::executeManeuverControl " << this->getManeuverName() << " action: "
278 << this->getCorrespondingInteractiveControlName() << " whose control value: "
279 << current_control_value << " is out of bound\n";
280 fout.close();
281 }
282 }
283 else if (percentage_change_in_control_value < -1.0){//note at: this time the percentage_change_in_control_value is a negative value
284 current_control_value = previous_control_value + (previous_control_value - LB_interactive_control) * percentage_change_in_control_value / 100.0;
285 if((current_control_value - LB_interactive_control) < 0.01) {
286 current_control_value = LB_interactive_control;
287 }
288 ptr_to_corresponding_control->setControlValue(current_control_value);
289 bsa_success = new BranchSystemAction();
291 bsa_success->setControlValue(current_control_value);
294 bsa_success->setTimerAndProbability(0.0, 1.0 - _operator.hfe_bbn.getManeuverActionFailureProbability());
296 //
297 if ((current_control_value > (UB_interactive_control + 0.0001)) ||
298 (current_control_value < (LB_interactive_control - 0.0001))){
299 ofstream fout("err messages.txt", ios::app);
300 cout << "ManeuverActionUnit::executeManeuverControl " << this->getManeuverName() << " action: "
301 << this->getCorrespondingInteractiveControlName() << " whose control value: "
302 << current_control_value << " is out of bound" << endl;
303 fout << r5pars_.timesno << " ManeuverActionUnit::executeManeuverControl " << this->getManeuverName() << " action: "
304 << this->getCorrespondingInteractiveControlName() << " whose control value: "
305 << current_control_value << " is out of bound\n";
306 fout.close();
307 }
308 }
309 else{
310 //do nothing
311 }
312}
Base class for all crew members — cognitive processing loops, mental model, and knowledge base.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void addHWReliabilityBranch(BranchSystemAction *, BranchSystemAction *)
Registers a hardware reliability fork with two alternatives (index 0 first). The record takes ownersh...
void setSenderAndReceiver(int, int)
void setControlValue(double)
double getControlValue()
void setDisplayName(std::string)
SystemControl * getControlFromMap(std::string)
SystemDisplay * getDisplayFromMap(std::string)
ControlPanelDisplay indicators
Definition: ControlPanel.h:53
ControlPanelControl controls
Definition: ControlPanel.h:54
void setUBChangeRate(double)
void setLBChangeRate(double)
void saveManeuverActionUnitToFile(std::ofstream &)
std::string targeted_parameter_name
void setManeuverTotalDuration(double)
void setManeuverTimeInterval(double)
std::string getCorrespondingInteractiveControlName()
void setTargetedParameterRateName(std::string)
void setUBTargetValue(double)
std::string targeted_parameter_rate_name
void setFirstManeuverTime(double)
void setCorrespondingInteractiveControlName(std::string)
void copyManeuverActionUnit(ManeuverActionUnit &)
void setManeuverName(std::string)
void setPreviousControlValue(double)
std::vector< double > three_by_three_maneuver
void setLBInteractiveControl(double)
std::string getTargetedParameterRateName()
void setUBInteractiveControl(double)
SystemDisplay * ptr_to_corresponding_indicator
void setpreviousManeuverTime(double)
void readInfoFromFile(std::ifstream &)
void setTargetedParameterName(std::string)
std::string corresponding_interactive_control_name
std::string getTargetedParameterName()
SystemDisplay * ptr_to_corresponding_rate_indicator
void setLBTargetValue(double)
std::string getManeuverName()
SystemControl * ptr_to_corresponding_control
void executeManeuverControl(Operator &)
void retrieveManeuverActionUnitFromFile(std::ifstream &)
int getTypeOfOperator()
Definition: Operator.cpp:59
HumanFailureEventsBBN hfe_bbn
Definition: Operator.h:136
void setStateOfActivation(int)
void saveStateOfActivationToFile(std::ofstream &)
void retrieveStateOfActivationFromFile(std::ifstream &)
void copyStateOfActivation(StateOfActivation &)
int getFunctionalState()
void setTimerAndProbability(double, double)
struct @0 r5pars_
constexpr int Plant
Definition: SimConstants.h:135
constexpr int FailedP
Definition: SimConstants.h:115
constexpr int Done
Definition: SimConstants.h:123
constexpr int Unknown
Definition: SimConstants.h:120
ControlPanel Indicator
Control room panel state.
BranchRecord Branch_center
Dynamic event tree state.