← Documentation
ADS-IDAC Engine 5.0.0
DecisionAction.cpp
Go to the documentation of this file.
1// DecisionAction.cpp: implementation of the DecisionAction class.
2//
4
5#include <math.h>
6#include <boost/serialization/export.hpp>
7
8#include "DecisionAction.h"
9#include <boost/archive/binary_oarchive.hpp>
10#include <boost/archive/binary_iarchive.hpp>
11BOOST_CLASS_EXPORT_IMPLEMENT(DecisionAction)
12using namespace std;
13
14
16// Construction/Destruction
18
20{
21 action_name = "NONE";
23}
24
26{
27
28}
32 this->copyMentalControl(_dap);
33 this->copyStateOfActivation(_dap);
35}
39 this->setPerceivedControlValue(perceived_control_value);
40}
41int DecisionAction::checkForMatch(string _action_name, double _action_value){
42 int n_return = 0;
43 int activated_state;
44 double control_value;
46 if(_action_name.compare(action_name) == 0){
47 activated_state = this->getStateOfActivation();
48 if (fabs(control_value - _action_value) < 0.00001){
50 if(activated_state == sim::State::Succeed){
51 n_return = 0;}
52 else if(activated_state == sim::State::Failed){
53 n_return = 2;}
54 else{
55 n_return = 1;
56 }
57 }
58 else{
60 if(activated_state == sim::State::Succeed){
61 n_return = -2;}
62 else if(activated_state == sim::State::Failed){
63 n_return = 0;}
64 else{
65 n_return = -1;
66 }
67 }
68 }
69 else{
70 n_return = 0;
71 }
72 return n_return;
73}
75 fout << action_name << '\n';
76 this->saveMentalControlToFile(fout);
78}
80 fin >> action_name;
83}
85 bool matched = true;
87 action_name != _da.getActionName()){
88 matched = false;
89 }
90 return matched;
91}
double control_value
std::string action_name
std::string getActionName()
void retrieveDecisionActionFromFile(std::ifstream &)
int checkForMatch(std::string, double)
virtual ~DecisionAction()
bool checkIfIsIdenticalDecisionAction(DecisionAction &)
void copyDecisionAction(DecisionAction &)
void saveDecisionActionToFile(std::ofstream &)
void readInfoFromFile(std::ifstream &)
void setActionName(std::string)
void copyMentalControl(MentalControl &)
void retrieveMentalControlFromFile(std::ifstream &)
void setPerceivedControlValue(double)
void saveMentalControlToFile(std::ofstream &)
double getPerceivedControlValue()
double perceived_control_value
Definition: MentalControl.h:44
bool checkIfIsIdenticalMentalControl(MentalControl &)
void setTypeOfMentalInfo(int)
Definition: MentalInfo.cpp:28
bool checkIfIsIdenticalStateOfActivation(StateOfActivation &)
void setStateOfActivation(int)
void saveStateOfActivationToFile(std::ofstream &)
void retrieveStateOfActivationFromFile(std::ifstream &)
void copyStateOfActivation(StateOfActivation &)
constexpr int Action
Definition: SimConstants.h:199
constexpr int Failed
Definition: SimConstants.h:103
constexpr int Succeed
Definition: SimConstants.h:104