← Documentation
ADS-IDAC Engine 5.0.0
AlarmTwoParameterDifference.cpp
Go to the documentation of this file.
1// AlarmTwoParameter.cpp: implementation of the AlarmTwoParameter class.
2//
4
6#include "../Branch/BranchRecord.h"
7#include <boost/serialization/export.hpp>
8#include "../Global/SimulationContext.h"
9#include <boost/archive/binary_oarchive.hpp>
10#include <boost/archive/binary_iarchive.hpp>
11BOOST_CLASS_EXPORT_IMPLEMENT(AlarmTwoParameterDifference)
12using namespace std;
13
14
16// Construction/Destruction
18
20{
25}
26
28{
29
30}
38}
40 DisplayParameterValue *dpv_ptr, *dpv_ptr2;
41 double parameter_value, parameter_value2;
42 int ctrl_state;
43 if(this->getPtrToCorrespondingIndicator() == 0){
44 this->setPtrToCorrespondingIndicator((SystemDisplay *) _cp.getDisplayFromMap(this->getCorrespondingIndicatorName()));
45 }
48 }
50 ctrl_state = this->getDisplayedOperatorControlState();
54 parameter_value = dpv_ptr->getDisplayedParameterValue();
55 parameter_value2 = dpv_ptr2->getDisplayedParameterValue();
56 if(ctrl_state == sim::State::Off){
58 }
59 else if(ctrl_state == sim::State::Auto){
60// the comparison is signed (first parameter minus second), not an absolute difference
61// if(abs(parameter_value - parameter_value2) >= threshold_value_that_activate_the_alarm){
62 if((parameter_value - parameter_value2) >= threshold_value_that_activate_the_alarm){
65 }
66 }
67 else if(ctrl_state == sim::State::Reset){
68// the comparison is signed (first parameter minus second), not an absolute difference
69// if(abs(parameter_value - parameter_value2) >= threshold_value_that_activate_the_alarm){
70 if((parameter_value - parameter_value2) >= threshold_value_that_activate_the_alarm){
73 }
74//The following lines are modeling the operator acknowledging the existance of the alarm
75 else{
77 }
78 }
79 else{}
80 }
81 else{//alarm fails
82 if (ctrl_state == sim::State::Off && this->getDisplayedAlarmState() != sim::State::Off){
84 }
85 else{
88 }
89 }
90 }
91 }
92 else{
93 r5pars_.sim_err = true;
94 g_sim.Branch_center.setTempESMessage("AlarmTwoParameterDifference::updateDisplayedAlarmState err");
96 ofstream fout("err messages.txt", ios::app);
97 cout << "AlarmTwoParameterDifference::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " either its corresponding display "
98 << this->getCorrespondingIndicatorName() << " or " << this->getSecondCorrespondingIndicatorName() << " can not be found!" << endl;
99 fout << r5pars_.timesno << " AlarmTwoParameterDifference::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " either its corresponding display "
100 << this->getCorrespondingIndicatorName() << " or " << second_corresponding_indicator_name << " can not be found!\n";
101 fout.close();
102 }
103 return this->getDisplayedAlarmState();
104}
109}
113}
117}
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void retrieveAlarmControlPanelUnitFromFile(std::ifstream &)
void setPtrToCorrespondingIndicator(SystemDisplay *ptr)
void saveAlarmControlPanelUnitToFile(std::ofstream &)
SystemDisplay * getPtrToCorrespondingIndicator()
void readInfoFromFile(std::ifstream &)
void copyAlarmControlPanelUnit(AlarmControlPanelUnit &)
void setTimeAtWhichThisAlarmIsActivated(double)
std::string getCorrespondingIndicatorName()
void setDisplayedAlarmState(int)
std::string getAlarmName()
int getDisplayedOperatorControlState()
int getDisplayedAlarmState()
void saveAlarmTwoParameterDifferenceToFile(std::ofstream &)
void setThresholdValueThatActivateTheAlarm(double value)
void copyAlarmTwoParameterDifference(AlarmTwoParameterDifference &)
void setSecondCorrespondingIndicatorName(std::string name)
void retrieveAlarmTwoParameterDifferenceFromFile(std::ifstream &)
int updateDisplayedAlarmState(ControlPanelDisplay &)
DisplayElement * ptr_to_second_corresponding_indicator
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
SystemDisplay * getDisplayFromMap(std::string)
void setTypeOfAlarm(DisplayType type)
Definition: SystemAlarm.cpp:27
struct @0 r5pars_
constexpr int On
Definition: SimConstants.h:105
constexpr int Off
Definition: SimConstants.h:106
constexpr int Succeed
Definition: SimConstants.h:104
constexpr int Auto
Definition: SimConstants.h:112
constexpr int Reset
Definition: SimConstants.h:113
BranchRecord Branch_center
Dynamic event tree state.