Detailed Description

Attribute for a simulation condition.

In order to extract statistical data from a simulation by a LoggingExecutor or some derived class, so called simulation conditions are defined. At any instance of time, a condition is satisfied or dissatisfied. Statistical data can then be requested regarding the period and duration of each condition. Currently, two types of conditions are available:

A Condition may be flagged as a break condition to halt simulation when satisfied. A condition may be enabled for tracking or not.

The class AttributeSimCondition summarizes all data to represent faudes simulation conditions. It also holds some state of the condition wrt execution and provides an interface for sampling. The latter may be seperated to a different class in a future revision. The class AttributeSimCondition does, however, not implement any test whether or not a condition is satisfied. This is done by the LoggingExecutor.

As a faudes attribute, conditions can be referenced by names via the std faudes container TaNameSet. For token io, a ParallelExecutor should be provided as context to access symbolic state names. The file format of a set of events equipped with condition attributes is illustrated by the below example to monitor some performance aspects of one simple machine:

<Conditions>
% monitor when the machine is idle
"IdleCond"
<StateSet> "idle" </StateSet>
% halt simulation when the machine is down
% however, the condition is disabled
"DownCond"
+Break+
+Disabled+
<StateSet> "down" </StateSet>
% monitor how long the prozessing one work piece takes
"OperationCond"
<StartEvents> "alpha" </StartEvents>
<StopEvents> "beta" </StopEvents>
</Conditions>
const SimEventCondition & EventCondition(void) const
Get event condition.
const SimStateCondition & StateCondition(void) const
Get state condition.
IndexSet StateSet
Definition: cfl_indexset.h:271

Definition at line 134 of file sp_simconditionset.h.

#include <sp_simconditionset.h>

Public Types

typedef std::vector< StateSet >::iterator Iterator
 Convenience typedef. More...
 
typedef std::vector< StateSet >::const_iterator CIterator
 

Public Member Functions

 AttributeSimCondition (void)
 Default constructor. More...
 
 AttributeSimCondition (const AttributeSimCondition &rOther)
 Copy constructor. More...
 
virtual bool IsDefault (void) const
 Test for default value. More...
 
bool IsStateCondition (void) const
 Test for state condition. More...
 
bool IsEventCondition (void) const
 Test for event condition. More...
 
bool Breakpoint (void) const
 Test for break condition. More...
 
bool Enabled (void) const
 Test whether condition is enabled. More...
 
void StateCondition (const SimStateCondition &rStateConditionAttribute)
 Set state condition attribute. More...
 
void EventCondition (const SimEventCondition &rEventConditionAttribute)
 Set event condition attribute. More...
 
void Breakpoint (bool on)
 Set break flag. More...
 
void Enabled (bool on)
 Set enabled flag. More...
 
const SimEventConditionEventCondition (void) const
 Get event condition. More...
 
const SimStateConditionStateCondition (void) const
 Get state condition. More...
 
void Reset (void)
 Reset conditions execution state. More...
 
bool Satisfied (void) const
 Test whether the condition is currently satisfied. More...
 
void Satisfied (bool on, Time::Type now)
 Set the condition to be satisfied. More...
 
- Public Member Functions inherited from faudes::AttributeFlags
 AttributeFlags (void)
 Default constructor. More...
 
 AttributeFlags (const AttributeFlags &rOther)
 Copy constructor. More...
 
virtual ~AttributeFlags (void)
 Destructor. More...
 
bool Test (fType mask) const
 Test a flag. More...
 
bool TestAll (fType mask) const
 Test multible flags, combine by "and". More...
 
bool TestSome (fType mask) const
 Test multible flags, combine by "or". More...
 
bool TestNone (fType mask) const
 Test multible flags, combine by "not or". More...
 
void Set (fType mask)
 Set multiple flags. More...
 
void Clr (fType mask)
 Clear multiple flags. More...
 
- Public Member Functions inherited from faudes::AttributeVoid
 AttributeVoid (void)
 Constructor. More...
 
 AttributeVoid (const AttributeVoid &rSrcAttr)
 Copy Constructor. More...
 
virtual ~AttributeVoid (void)
 Destructor. More...
 
virtual void SetDefault (void)
 Set to default value. More...
 
virtual void Clear (void)
 Synonym for SetDefault to match std interface. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void Name (const std::string &rName)
 Set the objects's name. More...
 
virtual const std::string & Name (void) const
 Get objects's name. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Public Attributes

SampledDensityFunction mSamplesPeriod
 Sampled period, at which this condition becomes satisfied. More...
 
SampledDensityFunction mSamplesDuration
 Sampled durations, for which this condition remains satisfied. More...
 
- Public Attributes inherited from faudes::AttributeFlags
fType mFlags
 Flags (public access for convenience)
More...
 

Static Public Attributes

static const fType mEnabledFlag =0x01
 
static const fType mBreakpointFlag =0x02
 
- Static Public Attributes inherited from faudes::AttributeFlags
static const fType mDefFlags =0x0
 

Protected Member Functions

void DoAssign (const AttributeSimCondition &rSrcAttr)
 Assignment method. More...
 
bool DoEqual (const AttributeSimCondition &rAttr) const
 Equality method. More...
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Reads the attribute from TokenReader, see AttributeVoid for public wrappers. More...
 
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Writes the attribute to TokenWriter, see AttributeVoid for public wrappers. More...
 
- Protected Member Functions inherited from faudes::AttributeFlags
void DoAssign (const AttributeFlags &rSrcAttr)
 Assignment method. More...
 
bool DoEqual (const AttributeFlags &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see Type for public wrappers. More...
 
- Protected Member Functions inherited from faudes::AttributeVoid
void DoAssign (const AttributeVoid &rSrcAttr)
 Assign attribute members. More...
 
bool DoEqual (const AttributeVoid &rOther) const
 Test equality of configuration data. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Actual write method to write the attribute to a TokenWriter. More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoSWrite (TokenWriter &rTw) const
 Write statistical data as a comment to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

bool mEventCondition
 Indicate precense of a event condition. More...
 
bool mStateCondition
 Indicate precense of a state condition. More...
 
SimEventCondition mEventConditionAttribute
 Event based condition data. More...
 
SimStateCondition mStateConditionAttribute
 State based condition data. More...
 
bool mSatisfied
 Condotion state: recorded as satisfied. More...
 
Time::Type mActivationTime
 Condition state: when last satisfied became true. More...
 

Static Private Attributes

static const fType mDefSCFlags =0x01
 Overall default value. More...
 
static const fType mAllSCFlags =0x03
 All flags used by CFlags. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from faudes::AttributeVoid
static void Skip (TokenReader &rTr)
 Skip attribute tokens. More...
 

Member Typedef Documentation

◆ CIterator

typedef std::vector<StateSet>::const_iterator faudes::AttributeSimCondition::CIterator

Definition at line 142 of file sp_simconditionset.h.

◆ Iterator

typedef std::vector<StateSet>::iterator faudes::AttributeSimCondition::Iterator

Convenience typedef.

Definition at line 141 of file sp_simconditionset.h.

Constructor & Destructor Documentation

◆ AttributeSimCondition() [1/2]

faudes::AttributeSimCondition::AttributeSimCondition ( void  )

Default constructor.

Constructs a AttributeSimCondition of with no type ie neither state condition nor event condition.

Definition at line 34 of file sp_simconditionset.cpp.

◆ AttributeSimCondition() [2/2]

faudes::AttributeSimCondition::AttributeSimCondition ( const AttributeSimCondition rOther)

Copy constructor.

with no type ie neither state condition nor event condition.

Definition at line 45 of file sp_simconditionset.cpp.

Member Function Documentation

◆ Breakpoint() [1/2]

void faudes::AttributeSimCondition::Breakpoint ( bool  on)
inline

Set break flag.

Parameters
onTrue, to indicate that this condition halts simulation.

Definition at line 227 of file sp_simconditionset.h.

◆ Breakpoint() [2/2]

bool faudes::AttributeSimCondition::Breakpoint ( void  ) const
inline

Test for break condition.

Returns
True, if this condition halts simulation.

Definition at line 188 of file sp_simconditionset.h.

◆ DoAssign()

void faudes::AttributeSimCondition::DoAssign ( const AttributeSimCondition rSrcAttr)
protected

Assignment method.

Parameters
rSrcAttrSource to assign from

Definition at line 55 of file sp_simconditionset.cpp.

◆ DoEqual()

bool faudes::AttributeSimCondition::DoEqual ( const AttributeSimCondition rAttr) const
protected

Equality method.

Parameters
rAttrSource to compare with

Definition at line 72 of file sp_simconditionset.cpp.

◆ DoRead()

void faudes::AttributeSimCondition::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Reads the attribute from TokenReader, see AttributeVoid for public wrappers.

If the current token indicates a condition section, the method reads the
condition data from that section. Else it does nothing. Exceptions may only be thrown on invalid data within the condition section. The label argiment is ignored, we use hardcoded labled "EventCondition" and "StateCondition" to figure the type of condition. When a ParallelExecutor is provided as context, it is used to interpret symbolc state names of a state condition.

Parameters
rTrTokenReader to read from
rLabelSection to read
pContextRead context to provide contextual information
Exceptions
Exception
  • IO error (id 1)

Reimplemented from faudes::AttributeFlags.

Definition at line 134 of file sp_simconditionset.cpp.

◆ DoWrite()

void faudes::AttributeSimCondition::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.

Writes a condition section to include data on state- or event-condition. The label argument is ignored, we use hardcoded keywords "EventCondition" and StateCondition". When a ParallelExecutor is provided as context, it state conditions are written with symbolic state names.

Parameters
rTwTokenWriter to write to
rLabelSection to write
pContextRead context to provide contextual information
Exceptions
Exception
  • IO error (id 2)

Reimplemented from faudes::AttributeFlags.

Definition at line 86 of file sp_simconditionset.cpp.

◆ Enabled() [1/2]

void faudes::AttributeSimCondition::Enabled ( bool  on)
inline

Set enabled flag.

Parameters
onTrue, to indicate that this condition is to be monitored during simulation.

Definition at line 235 of file sp_simconditionset.h.

◆ Enabled() [2/2]

bool faudes::AttributeSimCondition::Enabled ( void  ) const
inline

Test whether condition is enabled.

Returns
True, if this condition is monitored during simulation.

Definition at line 196 of file sp_simconditionset.h.

◆ EventCondition() [1/2]

void faudes::AttributeSimCondition::EventCondition ( const SimEventCondition rEventConditionAttribute)
inline

Set event condition attribute.

Define this attribute to represent the specified event condition.

Parameters
rEventConditionAttributeDefine event condition

Definition at line 218 of file sp_simconditionset.h.

◆ EventCondition() [2/2]

const SimEventCondition& faudes::AttributeSimCondition::EventCondition ( void  ) const
inline

Get event condition.

Note that the attribute can only return meaningful data if it actually is an event condition.

Returns
Defining data of this attribute's event condition.

Definition at line 245 of file sp_simconditionset.h.

◆ IsDefault()

virtual bool faudes::AttributeSimCondition::IsDefault ( void  ) const
inlinevirtual

Test for default value.

Returns
True, if this attribute has its default value

Reimplemented from faudes::AttributeFlags.

Definition at line 162 of file sp_simconditionset.h.

◆ IsEventCondition()

bool faudes::AttributeSimCondition::IsEventCondition ( void  ) const
inline

Test for event condition.

Returns
True, if this attribute defines an event condition

Definition at line 180 of file sp_simconditionset.h.

◆ IsStateCondition()

bool faudes::AttributeSimCondition::IsStateCondition ( void  ) const
inline

Test for state condition.

Returns
True, if this attribute defines a state condition

Definition at line 172 of file sp_simconditionset.h.

◆ Reset()

void faudes::AttributeSimCondition::Reset ( void  )
inline

Reset conditions execution state.

The execution state of a condition consists of all data accumulated during simulation eg statistical data and whether or not the condition is currently satisfied. The execution state resides in the attribute for pragmatic reasons only.

Definition at line 263 of file sp_simconditionset.h.

◆ Satisfied() [1/2]

void faudes::AttributeSimCondition::Satisfied ( bool  on,
Time::Type  now 
)

Set the condition to be satisfied.

This is part of the condition execution state. Since it is the executor that determines whether a condition is satisfied, and since the condition state resides in the attribute, the executor is meant to notify state changes.

Parameters
onTrue, if the conditions is considered satisfied
nowTime at which the state change occures

Definition at line 251 of file sp_simconditionset.cpp.

◆ Satisfied() [2/2]

bool faudes::AttributeSimCondition::Satisfied ( void  ) const
inline

Test whether the condition is currently satisfied.

This is part of the condition execution state.

Returns
True, if the conditions is considered satisfied

Definition at line 273 of file sp_simconditionset.h.

◆ StateCondition() [1/2]

void faudes::AttributeSimCondition::StateCondition ( const SimStateCondition rStateConditionAttribute)
inline

Set state condition attribute.

Define this attribute to represent the specified state condition.

Parameters
rStateConditionAttributeDefine state condition

Definition at line 205 of file sp_simconditionset.h.

◆ StateCondition() [2/2]

const SimStateCondition& faudes::AttributeSimCondition::StateCondition ( void  ) const
inline

Get state condition.

Note that the attribute can only return meaningful data if it actually is an state condition.

Returns
Defining data of this attribute's state condition.

Definition at line 255 of file sp_simconditionset.h.

Member Data Documentation

◆ mActivationTime

Time::Type faudes::AttributeSimCondition::mActivationTime
protected

Condition state: when last satisfied became true.

Definition at line 321 of file sp_simconditionset.h.

◆ mAllSCFlags

const fType faudes::AttributeSimCondition::mAllSCFlags =0x03
staticprivate

All flags used by CFlags.

Definition at line 390 of file sp_simconditionset.h.

◆ mBreakpointFlag

const fType faudes::AttributeSimCondition::mBreakpointFlag =0x02
static

Definition at line 301 of file sp_simconditionset.h.

◆ mDefSCFlags

const fType faudes::AttributeSimCondition::mDefSCFlags =0x01
staticprivate

Overall default value.

Definition at line 387 of file sp_simconditionset.h.

◆ mEnabledFlag

const fType faudes::AttributeSimCondition::mEnabledFlag =0x01
static

Definition at line 300 of file sp_simconditionset.h.

◆ mEventCondition

bool faudes::AttributeSimCondition::mEventCondition
protected

Indicate precense of a event condition.

Definition at line 306 of file sp_simconditionset.h.

◆ mEventConditionAttribute

SimEventCondition faudes::AttributeSimCondition::mEventConditionAttribute
protected

Event based condition data.

Definition at line 312 of file sp_simconditionset.h.

◆ mSamplesDuration

SampledDensityFunction faudes::AttributeSimCondition::mSamplesDuration

Sampled durations, for which this condition remains satisfied.

Definition at line 297 of file sp_simconditionset.h.

◆ mSamplesPeriod

SampledDensityFunction faudes::AttributeSimCondition::mSamplesPeriod

Sampled period, at which this condition becomes satisfied.

Definition at line 292 of file sp_simconditionset.h.

◆ mSatisfied

bool faudes::AttributeSimCondition::mSatisfied
protected

Condotion state: recorded as satisfied.

Definition at line 318 of file sp_simconditionset.h.

◆ mStateCondition

bool faudes::AttributeSimCondition::mStateCondition
protected

Indicate precense of a state condition.

Definition at line 309 of file sp_simconditionset.h.

◆ mStateConditionAttribute

SimStateCondition faudes::AttributeSimCondition::mStateConditionAttribute
protected

State based condition data.

Definition at line 315 of file sp_simconditionset.h.


The documentation for this class was generated from the following files:

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen