← Documentation
ADS-IDAC Engine 5.0.0
AlarmParameter.cpp
Go to the documentation of this file.
1// AlarmParameter.cpp: implementation of the AlarmParameter class.
2//
4
5#include "AlarmParameter.h"
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(AlarmParameter)
12using namespace std;
13
14
16// Construction/Destruction
18
20{
24}
25
27{
28
29}
31 string str;
34
35 if (str == "GT") {
37 }
38 else if(str == "GE"){
40 }
41 else if(str == "EQ"){
43 }
44 else if(str == "LE"){
46 }
47 else if(str == "LT"){
49 }
50 else{
51 r5pars_.sim_err = true;
52 g_sim.Branch_center.setTempESMessage("AlarmParameter::readInfoFromFile err");
54 ofstream fout("err messages.txt", ios::app);
55 cout << "AlarmParameter::readInfoFromFile: Alarm " << this->getAlarmName() << " its relational operator "
56 << str << " can not be recognized!" << endl;
57 fout << r5pars_.timesno << " AlarmParameter::readInfoFromFile: Alarm " << this->getAlarmName() << " its relational operator "
58 << str << " can not be recognized!\n";
59 fout.close();
60 }
61}
67 DisplayParameterValue *dpv_ptr;
68 SystemDisplay *d_element;
69 double parameter_value;
70 int ctrl_state;
71 d_element = 0;
72 if(this->getPtrToCorrespondingIndicator() == 0){
73 this->setPtrToCorrespondingIndicator((SystemDisplay *) _cp.getDisplayFromMap(this->getCorrespondingIndicatorName()));
74 }
75 if (this->getPtrToCorrespondingIndicator() != 0){
76 ctrl_state = this->getDisplayedOperatorControlState();
79 parameter_value = dpv_ptr->getDisplayedParameterValue();
80 if(ctrl_state == sim::State::Off){
82 }
83 else if(ctrl_state == sim::State::Auto){
86 if(parameter_value > threshold_value_that_activate_the_alarm){
89 }
90 break;
92 if(parameter_value >= threshold_value_that_activate_the_alarm){
95 }
96 break;
98 if(parameter_value == threshold_value_that_activate_the_alarm){
101 }
102 break;
103 case sim::Compare::LE:
104 if(parameter_value <= threshold_value_that_activate_the_alarm){
107 }
108 break;
109 case sim::Compare::LT:
110 if(parameter_value < threshold_value_that_activate_the_alarm){
113 }
114 break;
115 default:
116 r5pars_.sim_err = true;
117 g_sim.Branch_center.setTempESMessage("AlarmParameter::updateDisplayedAlarmState err");
119 ofstream fout("err messages.txt", ios::app);
120 cout << "AlarmParameter::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its relational operator "
121 << relational_operator_to_activate_the_alarm << " can not be recognized!" << endl;
122 fout << r5pars_.timesno << " AlarmParameter::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its relational operator "
123 << relational_operator_to_activate_the_alarm << " can not be recognized!\n";
124 fout.close();
125 break;
126 }
127 }
128 else if (ctrl_state == sim::State::Reset){
130 case sim::Compare::GT:
131 if(parameter_value > threshold_value_that_activate_the_alarm){
134 }
135 // allow alarm reset
136 else{
138 }
139 break;
140 case sim::Compare::GE:
141 if(parameter_value >= threshold_value_that_activate_the_alarm){
144 }
145 else{
147 }
148 break;
149 case sim::Compare::EQ:
150 if(parameter_value == threshold_value_that_activate_the_alarm){
153 }
154 else{
156 }
157 break;
158 case sim::Compare::LE:
159 if(parameter_value <= threshold_value_that_activate_the_alarm){
162 }
163 else{
165 }
166 break;
167 case sim::Compare::LT:
168 if(parameter_value < threshold_value_that_activate_the_alarm){
171 }
172 else{
174 }
175 break;
176 default:
177 r5pars_.sim_err = true;
178 g_sim.Branch_center.setTempESMessage("AlarmParameter::updateDisplayedAlarmState err");
180 ofstream fout("err messages.txt", ios::app);
181 cout << "AlarmParameter::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its relational operator "
182 << relational_operator_to_activate_the_alarm << " can not be recognized!" << endl;
183 fout << r5pars_.timesno << " AlarmParameter::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its relational operator "
184 << relational_operator_to_activate_the_alarm << " can not be recognized!\n";
185 fout.close();
186 break;
187 }
188 }
189 else{}
190 }
191 else{//alarm fails
192 if (ctrl_state == sim::State::Off && this->getDisplayedAlarmState() != sim::State::Off){
194 }
195 else{
198 }
199 }
200 }
201 }
202 else{
203 r5pars_.sim_err = true;
204 g_sim.Branch_center.setTempESMessage("AlarmParameter::updateDisplayedAlarmState err");
206 ofstream fout("err messages.txt", ios::app);
207 cout << "AlarmParameter::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its corresponding display "
208 << this->getCorrespondingIndicatorName() << " can not be found!" << endl;
209 fout << r5pars_.timesno << " AlarmParameter::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its corresponding display "
210 << this->getCorrespondingIndicatorName() << " can not be found!\n";
211 fout.close();
212 }
213 return this->getDisplayedAlarmState();
214}
219}
224}
228}
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()
double getThresholdValueThatActivateTheAlarm()
double threshold_value_that_activate_the_alarm
void readInfoFromFile(std::ifstream &)
void retrieveAlarmParameterFromFile(std::ifstream &)
int getRelationalOperatorToActivateTheAlarm()
int relational_operator_to_activate_the_alarm
void saveAlarmParameterToFile(std::ofstream &)
virtual ~AlarmParameter()
void setRelationalOperatorToActivateTheAlarm(int)
int updateDisplayedAlarmState(ControlPanelDisplay &)
void setThresholdValueThatActivateTheAlarm(double)
void copyAlarmParameter(AlarmParameter &)
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 GE
Definition: SimConstants.h:88
constexpr int GT
Definition: SimConstants.h:87
constexpr int LE
Definition: SimConstants.h:90
constexpr int LT
Definition: SimConstants.h:91
constexpr int EQ
Definition: SimConstants.h:89
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
constexpr int Unknown
Definition: SimConstants.h:120
BranchRecord Branch_center
Dynamic event tree state.