57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
|
|
/*!\file
|
|||
|
|
* \brief \todo <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
*/
|
|||
|
|
/*
|
|||
|
|
* DiscreteOutputSetup.cpp
|
|||
|
|
*
|
|||
|
|
* Created on: 2 <EFBFBD><EFBFBD><EFBFBD>. 2019 <EFBFBD>.
|
|||
|
|
* Author: titov
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#include "DiscreteOutputGpio.hh"
|
|||
|
|
|
|||
|
|
#include "../../driver/DiscreteOutput_OnePin.hh"
|
|||
|
|
#include "../../driver/DiscreteOutput_DoublePin.hh"
|
|||
|
|
|
|||
|
|
bool application::board::DiscreteOutputGpio::input( Environment & env ) {
|
|||
|
|
|
|||
|
|
return grab( pin, env.rholder.getShared<IGpio>( links.pin ) );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void application::board::DiscreteOutputGpio::build( Environment & env ) {
|
|||
|
|
|
|||
|
|
driver::detail::DiscreteOutput_OnePin * do_one =
|
|||
|
|
memories::instance_object<driver::detail::DiscreteOutput_OnePin>(
|
|||
|
|
env.static_object_ma,
|
|||
|
|
*pin, cfg.activation_level );
|
|||
|
|
|
|||
|
|
env.rholder.share<driver::IDiscreteOutput>( *do_one, links.discrete_output );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
application::board::DiscreteOutputGpio::DiscreteOutputGpio(
|
|||
|
|
const Links & links, const Setting & cfg ) : pin(nullptr), links(links), cfg(cfg) {}
|
|||
|
|
|
|||
|
|
bool application::board::DiscreteOutputDoubleGpio::input(
|
|||
|
|
Environment & env ) {
|
|||
|
|
|
|||
|
|
return grab( pin_a, env.rholder.getShared<IGpio>( links.pin_a ) )
|
|||
|
|
and grab( pin_b, env.rholder.getShared<IGpio>( links.pin_b ) );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void application::board::DiscreteOutputDoubleGpio::build(
|
|||
|
|
Environment & env ) {
|
|||
|
|
|
|||
|
|
driver::detail::DiscreteOutput_DoublePin * do_double =
|
|||
|
|
memories::instance_object<driver::detail::DiscreteOutput_DoublePin>(
|
|||
|
|
env.static_object_ma,
|
|||
|
|
*pin_a, cfg.activation_level_a, *pin_b, cfg.activation_level_b );
|
|||
|
|
|
|||
|
|
env.rholder.share<driver::IDiscreteOutput>( *do_double, links.discrete_output );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
application::board::DiscreteOutputDoubleGpio::DiscreteOutputDoubleGpio(
|
|||
|
|
const Links & links, const Setting & cfg ) : pin_a(nullptr), pin_b(nullptr), links(links), cfg(cfg) {}
|