Skip to content

Commit 038c99a

Browse files
committed
excitation: allow to enable/disable an excitation
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
1 parent 40c4042 commit 038c99a

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

python/CSXCAD/CSProperties.pxd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ cdef extern from "CSXCAD/CSPropExcitation.h":
183183
void SetExcitation(double val, int Component)
184184
double GetExcitation(int Component)
185185

186+
void SetEnabled(bool val)
187+
bool GetEnabled()
188+
186189
void SetPropagationDir(double val, int Component)
187190
double GetPropagationDir(int Component)
188191

python/CSXCAD/CSProperties.pyx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,15 @@ cdef class CSPropExcitation(CSProperties):
909909
"""
910910
return (<_CSPropExcitation*>self.thisptr).GetExcitType()
911911

912+
913+
def SetEnabled(self, val):
914+
""" Enable/Disable the excitation"""
915+
(<_CSPropExcitation*>self.thisptr).SetEnabled(val)
916+
917+
def GetEnabled(self):
918+
""" Get enable/disable state of the excitation"""
919+
return (<_CSPropExcitation*>self.thisptr).GetEnabled()
920+
912921
def SetExcitation(self, val):
913922
""" SetExcitation(val)
914923

src/CSPropExcitation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ CSPropExcitation::CSPropExcitation(CSPropExcitation* prop, bool copyPrim) : CSPr
2626
Init();
2727
uiNumber=prop->uiNumber;
2828
iExcitType=prop->iExcitType;
29+
m_enabled=prop->m_enabled;
2930
coordInputType=prop->coordInputType;
3031
m_Frequency.Copy(&prop->m_Frequency);
3132
Delay.Copy(&prop->Delay);
@@ -140,6 +141,7 @@ void CSPropExcitation::Init()
140141
{
141142
uiNumber=0;
142143
iExcitType=1;
144+
m_enabled=true;
143145
coordInputType=UNDEFINED_CS;
144146
m_Frequency.SetValue(0.0);
145147
Delay.SetValue(0.0);
@@ -232,6 +234,7 @@ bool CSPropExcitation::Write2XML(TiXmlNode& root, bool parameterised, bool spars
232234
if (prop==NULL) return false;
233235

234236
prop->SetAttribute("Number",(int)uiNumber);
237+
prop->SetAttribute("Enabled",m_enabled);
235238
WriteTerm(m_Frequency,*prop,"Frequency",parameterised);
236239
WriteTerm(Delay,*prop,"Delay",parameterised);
237240

@@ -260,6 +263,8 @@ bool CSPropExcitation::ReadFromXML(TiXmlNode &root)
260263
if (prop->QueryIntAttribute("Number",&iHelp)!=TIXML_SUCCESS) uiNumber=0;
261264
else uiNumber=(unsigned int)iHelp;
262265

266+
prop->QueryBoolAttribute("Enabled",&m_enabled);
267+
263268
if (prop->QueryIntAttribute("Type",&iExcitType)!=TIXML_SUCCESS) return false;
264269

265270
if (ReadVectorTerm(Excitation,*prop,"Excite",0.0)==false) return false;
@@ -285,6 +290,7 @@ void CSPropExcitation::ShowPropertyStatus(std::ostream& stream)
285290
CSProperties::ShowPropertyStatus(stream);
286291
stream << " --- Excitation Properties --- " << std::endl;
287292
stream << " Type: " << iExcitType << std::endl;
293+
stream << " Enabled: " << m_enabled << std::endl;
288294
stream << " Active directions: " << ActiveDir[0] << "," << ActiveDir[1] << "," << ActiveDir[2] << std::endl;
289295
stream << " Excitation\t: " << Excitation[0].GetValueString() << ", " << Excitation[1].GetValueString() << ", " << Excitation[2].GetValueString() << std::endl;
290296
stream << " Weighting\t: " << WeightFct[0].GetValueString() << ", " << WeightFct[1].GetValueString() << ", " << WeightFct[2].GetValueString() << std::endl;

src/CSPropExcitation.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class CSXCAD_EXPORT CSPropExcitation : public CSProperties
6161
//! Get the excitation frequency as a string
6262
const std::string GetFrequencyString() {return m_Frequency.GetValueString();}
6363

64+
//! Set this excitation to be enabled or not
65+
void SetEnabled(bool val) {m_enabled=val;}
66+
//! Get if this excitation is enabled or not
67+
bool GetEnabled() {return m_enabled;}
68+
6469
//! Set the excitation amplitude for a given component
6570
void SetExcitation(double val, int Component=0);
6671
//! Set the excitation amplitude for a given component
@@ -108,6 +113,7 @@ class CSXCAD_EXPORT CSPropExcitation : public CSProperties
108113
protected:
109114
unsigned int uiNumber;
110115
int iExcitType;
116+
bool m_enabled;
111117
bool ActiveDir[3];
112118
ParameterScalar m_Frequency;
113119
ParameterScalar Excitation[3]; // excitation amplitude vector

0 commit comments

Comments
 (0)