#pragma once #include "DFTGate.h" namespace storm { namespace storage { template class DFTVot : public DFTGate { private: unsigned mThreshold; public: DFTVot(size_t id, std::string const& name, unsigned threshold, std::vector>> const& children = {}) : DFTGate(id, name, children), mThreshold(threshold) {} void checkFails(storm::storage::DFTState& state, DFTStateSpaceGenerationQueues& queues) const override { if(state.isOperational(this->mId)) { unsigned nrFailedChildren = 0; for(auto const& child : this->mChildren) { if(state.hasFailed(child->id())) { ++nrFailedChildren; if(nrFailedChildren >= mThreshold) { this->fail(state, queues); return; } } } } } void checkFailsafe(storm::storage::DFTState& state, DFTStateSpaceGenerationQueues& queues) const override { STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child."); if(state.isOperational(this->mId)) { unsigned nrFailsafeChildren = 0; for(auto const& child : this->mChildren) { if(state.isFailsafe(child->id())) { ++nrFailsafeChildren; if(nrFailsafeChildren > this->nrChildren() - mThreshold) { this->failsafe(state, queues); this->childrenDontCare(state, queues); return; } } } } } unsigned threshold() const { return mThreshold; } virtual DFTElementType type() const override { return DFTElementType::VOT; } std::string typestring() const override{ return "VOT (" + std::to_string(mThreshold) + ")"; } virtual bool isTypeEqualTo(DFTElement const& other) const override { if(!DFTElement::isTypeEqualTo(other)) return false; DFTVot const& otherVOT = static_cast const&>(other); return (mThreshold == otherVOT.mThreshold); } }; template inline std::ostream& operator<<(std::ostream& os, DFTVot const& gate) { return os << gate.toString(); } } }