37#ifndef _OPENLCB_DCCACCYPRODUCER_HXX_
38#define _OPENLCB_DCCACCYPRODUCER_HXX_
43#include "openlcb/NonAuthoritativeEventProducer.hxx"
81 const uint16_t address)
129 std::function<
void(
unsigned,
bool)> dcc_state_callback =
nullptr)
152 for (
unsigned i = 0; i <
instances_->size(); ++i)
184 switch (
input()->cmd_)
186 case Command::CMD_QUERY:
188 case Command::CMD_SET:
237 for (
unsigned i = 0; i <
instances_->size(); ++i)
241 instances_->at(i)->dccStateCallback_(bit + 1, value);
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
BarrierNotifiable * reset(Notifiable *done)
Resets the barrier. Returns &*this. Asserts that is_done().
Action wait_and_return_ok()
Waits to be notified before moving onto the next state for termination.
Action return_with_error(int error)
Terminates the flow and returns the request buffer to the caller with an specific error code.
This class provides support for one time initialization.
int once(void)
call one time intialization routine
Return type for a state flow callback.
Action call_immediately(Callback c)
Imediately call the next state upon return.
DCC accessory address event producer for the Well-Known DCC Accessory range.
Action entry() override
Entry point to sub-flow that dispatches the next state based on the incoming command.
Route
DCC accessory activation values.
DccAccyProducer(Node *node, std::function< void(unsigned, bool)> dcc_state_callback=nullptr)
Constructor.
~DccAccyProducer()
Destructor. Remove "this" instance from instances_ vector.
static OSThreadOnce once_
one time execution helper
static uninitialized< BitRangeNonAuthoritativeEventP > eventProducer_
Singleton instance of a BitRangeNonAuthoritativeEventP for the DCC accessory address Well-Known Event...
static uninitialized< std::vector< DccAccyProducer * > > instances_
Vector of all the subscribers to the DCC accessory address Well-Known Event ID Range.
static void once_routine()
Called once.
static void state_callback(unsigned bit, bool value)
Callback called when there is a notification of event (DCC accessory address) state.
std::function< void(unsigned, bool)> dccStateCallback_
Callback method that will be invoked when a consumer identified message is received with a known stat...
BarrierNotifiable bn_
notfiable for unblocking the next state
Action query()
Query the last known state of the accessory address.
WriteHelper writer_
statically allocated buffer
Action set()
Set the state of the accessory address.
DccAccyProducerInput * input()
Helper method for accessing the subflow input data.
static Atomic instancesLock_
This lock protects the instances_ vector;.
static constexpr uint16_t MAX_ADDRESS
highest possible DCC address supported
Base class for NMRAnet nodes conforming to the asynchronous interface.
A statically allocated buffer for sending one message to the OpenLCB bus.
Template class that allows allocating storage for an object but not calling its constructor.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
All callable flow request objects have to derive from this struct.
C++ Namespace for collecting all commands that can be sent to the DccAccyProducer flow.
static constexpr uint64_t ACTIVATE_BASIC_DCC_ACCESSORY_EVENT_BASE
Base address of DCC accessory decoder well-known event range (active)