← Documentation
ADS-IDAC Engine 5.0.0
AlarmComponent.cpp
Go to the documentation of this file.
1// AlarmComponent.cpp: implementation of the AlarmComponent class.
2//
4
5#include "AlarmComponent.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(AlarmComponent)
12using namespace std;
13
14
16// Construction/Destruction
18
20{
23}
24
26{
27
28}
32 string str, str1;
34 fin >> str;
35 if(str == "ON"){
37 else if(str == "OFF"){
39 else if(str == "OPEN"){
41 else if(str == "CLOSE"){
43 else{
44 ofstream fout("err messages.txt", ios::app);
45 cout << " AlarmComponent::readInfoFromFile Alarm " << this->getAlarmName() << " whose component_state_that_activate_the_alarm "
46 << component_state_that_activate_the_alarm << " can not be recognized." << endl;
47 fout << r5pars_.timesno << " AlarmComponent::readInfoFromFile Alarm " << this->getAlarmName() << " whose component_state_that_activate_the_alarm "
48 << component_state_that_activate_the_alarm << " can not be recognized.\n";
49 fout.close();
50 r5pars_.sim_err = true;
51 str1 = this->getAlarmName();
52 g_sim.Branch_center.setTempESMessage("AlarmComponent::readInfoFromFile err");
54 }
55}
56//**********************************************
57// updateDisplayedAlarmState dtermines the final alarm display state with
58// consideration of alarm functional state, alarm activation state from the system, and the operator control state
59//**********************************************
61 DisplayComponentState *dcs_ptr;
62 int ctrl_state;
63 if(this->getPtrToCorrespondingIndicator() == 0){
64 this->setPtrToCorrespondingIndicator((SystemDisplay *) _cpd.getDisplayFromMap(this->getCorrespondingIndicatorName()));
65 }
66 if (this->getPtrToCorrespondingIndicator() != 0){
67 ctrl_state = this->getDisplayedOperatorControlState();
70 switch (ctrl_state){
71 case sim::State::Off:
73 break;
78 }
79 break;
84 }
85 else{
87 }
88 break;
89 default:
90 r5pars_.sim_err = true;
91 ofstream fout("err messages.txt", ios::app);
92 cout << "AlarmComponent::updateDisplayedAlarmState " << this->getAlarmName() << " its control state "
93 << ctrl_state << " can not be recognized!" << endl;
94 fout << r5pars_.timesno << " AlarmComponent::updateDisplayedAlarmState " << this->getAlarmName() << " its control state "
95 << ctrl_state << " can not be recognized!\n";
96 fout.close();
97 g_sim.Branch_center.setTempESMessage("AlarmComponent::updateDisplayedAlarmState err");
99 break;
100 }
101 }
102 else{//alarm fails
103 if (ctrl_state == sim::State::Off && this->getDisplayedAlarmState() != sim::State::Off){
105 }
106 else{
109 }
110 }
111 }
112 }
113 else{
114 r5pars_.sim_err = true;
115 g_sim.Branch_center.setTempESMessage("AlarmComponent::updateDisplayedAlarmState err");
117 ofstream fout("err messages.txt", ios::app);
118 cout << "AlarmComponent::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its corresponding display "
119 << this->getCorrespondingIndicatorName() << " can not be found!" << endl;
120 fout << r5pars_.timesno << " AlarmComponent::updateDisplayedAlarmState: Alarm " << this->getAlarmName() << " its corresponding display "
121 << this->getCorrespondingIndicatorName() << " can not be found!\n";
122 fout.close();
123 }
124 return this->getDisplayedAlarmState();
125}
128 this->copyAlarmControlPanelUnit(_ac);
129}
133}
137}
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
virtual ~AlarmComponent()
void copyAlarmComponent(AlarmComponent &)
void retrieveAlarmComponentFromFile(std::ifstream &)
int getComponentStateThatActivateTheAlarm()
void saveAlarmComponentToFile(std::ofstream &)
void setComponentStateThatActivateTheAlarm(int state)
int updateDisplayedAlarmState(ControlPanelDisplay &)
void readInfoFromFile(std::ifstream &)
int component_state_that_activate_the_alarm
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 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 Open
Definition: SimConstants.h:116
constexpr int Auto
Definition: SimConstants.h:112
constexpr int Close
Definition: SimConstants.h:117
constexpr int Reset
Definition: SimConstants.h:113
constexpr int Unknown
Definition: SimConstants.h:120
BranchRecord Branch_center
Dynamic event tree state.