← Documentation
ADS-IDAC Engine 5.0.0
faulttree Namespace Reference

Namespaces

namespace  xml
 

Classes

class  FaultTree
 A fault tree: nodes keyed by name, plus a designated top event. More...
 
class  FaultTreeError
 Exception type of the fault tree model, the .fta reader and the quantifier. More...
 
struct  Node
 One fault tree node: a basic event or a gate, identified by name. More...
 
class  Quantifier
 Exact fault tree quantifier backed by a BNCore junction tree. More...
 

Enumerations

enum class  GateType {
  Basic , And , Or , KofN ,
  Not
}
 Kind of a fault tree node: a basic event or one of four gate types. More...
 

Functions

FaultTree parseFtaString (const std::string &text)
 Parses .fta content held in memory. More...
 
FaultTree parseFtaFile (const std::string &path)
 Parses a .fta file from disk. More...
 

Variables

constexpr std::size_t kMaxGateInputs = 20
 Largest number of inputs a single gate may have. More...
 

Enumeration Type Documentation

◆ GateType

enum class faulttree::GateType
strong

Kind of a fault tree node: a basic event or one of four gate types.

The .fta type codes in the enumerator comments are the codes the reader in fta_parser.hpp maps to each value. Codes 2 and 3 map to Basic, and code 4 (transfer gate) maps to And.

Enumerator
Basic 

basic event, quantified by probability

And 

fails when every input fails (.fta type 0)

Or 

fails when any input fails (.fta type 1)

KofN 

fails when at least k inputs fail (.fta type 6)

Not 

fails when its single input does not (.fta type 7)

Definition at line 48 of file fault_tree.hpp.

Function Documentation

◆ parseFtaFile()

FaultTree faulttree::parseFtaFile ( const std::string &  path)

Parses a .fta file from disk.

Reads the whole file and applies the same rules as parseFtaString(). Error messages that refer to the diagram as a whole name the path.

Parameters
pathPath of the .fta file.
Returns
The tree, with its top event set, after FaultTree::validate().
Exceptions
xml::XmlErrorif the file cannot be opened or is not well formed.
FaultTreeErrorfor the model problems listed at parseFtaString().

Definition at line 162 of file fta_parser.cpp.

References faulttree::xml::parseFile().

Here is the call graph for this function:

◆ parseFtaString()

FaultTree faulttree::parseFtaString ( const std::string &  text)

Parses .fta content held in memory.

The root element must be <ftaDiagram>. Every <ftaNode> child of the root is read recursively, and the <ftaNode> elements nested inside a gate are that gate's inputs, in document order. The reader applies these rules:

  • Node identity is the name attribute of the node's <node> child. An <ftaNode> whose name is already defined adds nothing; the enclosing gate references the existing node.
  • An <ftaNode> without an id attribute is skipped.
  • Types 2 and 3 are basic events. The probability is the failureProbability attribute (0 when the attribute is absent), read with std::stod. Characters after the number, other than whitespace, are an error.
  • Type 4 (transfer gate) becomes an And gate whose single input is the node named by the ref attribute of its <transferUpFTADiagram> child.
  • Type 5 (the diagram's transfer-up bookkeeping node) is skipped and adds no node.
  • Types 0, 1, 6 and 7 become And, Or, KofN and Not gates. Node::k is the integer value of the k attribute, or 0 when the attribute is absent or empty.
  • The top event is the first <ftaNode> under the root that yields a node. Later root-level nodes are subtrees that transfer gates refer to.

A gate is added to the tree after the inputs nested inside it, so FaultTree::nodes() lists inputs before the gate that first contains them.

Parameters
textComplete .fta XML document.
Returns
The tree, with its top event set, after FaultTree::validate().
Exceptions
xml::XmlErrorif the text is not well formed within the XML subset xml_lite.hpp accepts.
FaultTreeErrorif the root is not <ftaDiagram>, an <ftaNode> lacks its <node> child or a non-empty name, the type attribute is absent or not one of 0 to 7, a basic event has a <linkedBBN> child, a failureProbability or k value is malformed or out of range for its numeric type, a transfer gate has no reference or an empty one, the diagram yields no top node, or FaultTree::validate() rejects the result.

Definition at line 158 of file fta_parser.cpp.

References faulttree::xml::parse().

Here is the call graph for this function:

Variable Documentation

◆ kMaxGateInputs

constexpr std::size_t faulttree::kMaxGateInputs = 20
inlineconstexpr

Largest number of inputs a single gate may have.

Gates wider than this would need a conditional table of 2^(n+1) doubles, which is a modelling error rather than something to allocate.

Definition at line 44 of file quantifier.hpp.

Referenced by faulttree::Quantifier::build().