MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/schematic/ValueTrigger.cpp
2024-06-07 11:12:56 +03:00

56 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ValueTrigger.cpp
*
* Created on: 22 апр. 2020 г.
* Author: LeonidTitov
*/
#include "ValueTrigger.hh"
bool schematic::ValueTrigger::setup(
Type type, Id id, Condition condition, Value value,
std::pair<const char *, std::size_t> threshold ) {
TriggerProviders::iterator iter = triggers.find( type );
if( iter != triggers.end() ) {
systemic::IValue<bool> * trig = iter->second->setup( id, condition, value, threshold );
state = false;
implement = trig;
trigger_interface = iter->second;
} else
reset(false);
return implement;
}
void schematic::ValueTrigger::reset(bool new_state) {
state = new_state;
implement = nullptr;
trigger_interface = nullptr;
}
schematic::ValueTrigger::operator bool() const {
return implement ? *implement : state;
}
schematic::ValueTrigger::ValueTrigger( std::pmr::memory_resource * description ) :
implement(nullptr), trigger_interface(nullptr), state(false), triggers(std::less<Type>(),
description)
{
}
void schematic::ValueTrigger::get_threshold(
std::pair<char *, std::size_t> buff ) const {
if( trigger_interface )
trigger_interface->get_threshold( buff );
}