diag_attrdiagstate.cpp
Go to the documentation of this file.
1/** @file diag_attrdiagstate.cpp
2Implements state estimates for the current status of the generator (as state attributes).
3*/
4
6
7using namespace std;
8
9namespace faudes {
10
11// faudes type std
12FAUDES_TYPE_IMPLEMENTATION(Void,AttributeDiagnoserState,AttributeFlags)
13
14// consruct
16 // our map type is not in the registry, so we need to configure manually
17 mDiagnoserStateMap.ElementTag("TargetState");
18 mDiagnoserStateMap.Name("TargetStateEstimates");
19 mDiagnoserStateMap.TypeName("TargetStateEstimates");
20}
21
22// destruct
24
25
26// copy my members
31
32// IsDefault()
34 return mDiagnoserStateMap.Empty();
35}
36
37// Clear()
41
42// DiagnoserStateMap()
46
47// DiagnoserStateMapp()
51
52// DiagnoserStateMap()
54 mDiagnoserStateMap = newDiagStateMap;
55}
56
57// AddStateLabelMapping()
59 DiagLabelSet hset;
60
61 // if gstate is already mapped from, the corresponding DiagLabelSet is loaded
62 if(mDiagnoserStateMap.Exists(gstate)) {
63 hset = mDiagnoserStateMap.Attribute(gstate);
64 }
65 // and the new mapping is added
66 hset.mDiagLabels.Insert(label);
67 mDiagnoserStateMap.Insert(gstate,hset);
68}
69
70// AddStateLabelMap()
72 NameSet::Iterator it;
73 DiagLabelSet hset;
74
75 // if gstate is already mapped from, the corresponding DiagLabelSet is loaded
76 if(mDiagnoserStateMap.Exists(gstate)) {
77 hset = mDiagnoserStateMap.Attribute(gstate);
78 }
79 // add labels
80 for(it = labels.mDiagLabels.Begin(); it != labels.mDiagLabels.End(); it++) {
81 hset.mDiagLabels.Insert(*it);
82 }
83 // set
84 mDiagnoserStateMap.Insert(gstate,hset);
85}
86
87// Str()
88string AttributeDiagnoserState::Str(void) const {
89 TaIndexSet<DiagLabelSet>::Iterator it;
90 string str;
91 DiagLabelSet label;
92
93 for (it = mDiagnoserStateMap.Begin(); it != mDiagnoserStateMap.End(); it++) {
94 label = mDiagnoserStateMap.Attribute(*it);
95 if (it != mDiagnoserStateMap.Begin()) {
96 str += " ";
97 }
98 str += ToStringInteger(*it);
99 str += label.Str();
100 }
101 return str;
102}
103
104// ExistsState()
105// not used
107 return mDiagnoserStateMap.Exists(state);
108}
109
110// DoWrite()
111void AttributeDiagnoserState::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
112 if(IsDefault()) return;
113 mDiagnoserStateMap.Write(rTw,"StateEstimates", pContext);
114}
115
116// DoXWrite()
117void AttributeDiagnoserState::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
118 if(IsDefault()) return;
119 mDiagnoserStateMap.XWrite(rTw,"TargetStateEstimates", pContext);
120}
121
122//DoRead()
123void AttributeDiagnoserState::DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext) {
124 mDiagnoserStateMap.Clear();
125 Token token;
126 rTr.Peek(token);
127 // native faudes
128 if(token.IsBegin("StateEstimates"))
129 mDiagnoserStateMap.Read(rTr,"",pContext);
130 // XML format
131 if(token.IsBegin("TargetStateEstimates"))
132 mDiagnoserStateMap.Read(rTr,"",pContext);
133}
134
135// Equality
137 // equal set
138 if(mDiagnoserStateMap != rOtherAttribute.mDiagnoserStateMap) return false;
139 // equal attributes
140 if(!mDiagnoserStateMap.EqualAttributes(rOtherAttribute.mDiagnoserStateMap)) return false;
141 // pass
142 return true;
143}
144
145
146} // namespace faudes
147
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:958
void DoWrite(TokenWriter &rTw, const std::string &rLabel, const Type *pContext) const
void AddStateLabelMapping(Idx state, Idx label)
bool DoEqual(const AttributeDiagnoserState &rOther) const
void DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext)
const TaIndexSet< DiagLabelSet > * DiagnoserStateMapp(void) const
const TaIndexSet< DiagLabelSet > & DiagnoserStateMap(void) const
void AddStateLabelMap(Idx gstate, const DiagLabelSet &labels)
void DoXWrite(TokenWriter &rTw, const std::string &rLabel, const Type *pContext) const
TaIndexSet< DiagLabelSet > mDiagnoserStateMap
void DoAssign(const AttributeDiagnoserState &rSrc)
void DoAssign(const AttributeFlags &rSrcAttr)
std::string Str(void) const
bool Insert(const Idx &rIndex)
bool Peek(Token &token)
bool IsBegin(void) const
virtual void Name(const std::string &rName)
Iterator End(void) const
Iterator Begin(void) const
uint32_t Idx
std::string ToStringInteger(Int number)
Definition cfl_utils.cpp:43

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen