Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
BlinkerFlow.hxx
Go to the documentation of this file.
1
35#ifndef _BRACZ_CUSTOM_BLINKERFLOW_HXX_
36#define _BRACZ_CUSTOM_BLINKERFLOW_HXX_
37
39#include "openlcb/Node.hxx"
41
44{
45public:
51 BlinkerFlow(openlcb::Node *node, uint64_t BLINKER_EVENT_ID)
52 : StateFlowBase(node->iface())
53 , state_(1)
54 , bit_(
55 node, BLINKER_EVENT_ID, BLINKER_EVENT_ID + 1, &state_, (uint8_t)1)
56 , producer_(&bit_)
57 , sleepData_(this)
58 {
60 }
61
62private:
65 {
66 state_ = !state_;
67#ifdef __linux__
68 LOG(INFO, "blink produce %d", state_);
69#endif
72 }
73
79
81 uint8_t state_;
92};
93
94#endif // _BRACZ_CUSTOM_BLINKERFLOW_HXX_
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
Definition StateFlow.hxx:61
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().
Reusable test flow that just blinks a pair of events.
Action blinker()
State that handles sending off the produced event.
Action handle_sleep()
State that sleeps until the next event is due.
BlinkerFlow(openlcb::Node *node, uint64_t BLINKER_EVENT_ID)
Constructor.
openlcb::BitEventProducer producer_
The actual producer object.
uint8_t state_
Which event we produced last.
BarrierNotifiable n_
Helper object for catching callback notifications.
StateFlowTimer sleepData_
Object needed for sleeping in a state flow.
openlcb::WriteHelper helper_
Helper object to write to the bus in an asynchronous way.
openlcb::MemoryBit< uint8_t > bit_
Helper object for the event producer.
Return type for a state flow callback.
Use this timer class to deliver the timeout notification to a stateflow.
Base class for state machines.
void start_flow(Callback c)
Resets the flow to the specified state and starts it.
Action wait_and_call(Callback c)
Wait for resource to become available before proceeding to next state.
Action sleep_and_call(::Timer *timer, long long timeout_nsec, Callback c)
Suspends execution of this control flow for a specified time.
Event handler for a single-bit producer, e.g.
void Update(WriteHelper *writer, Notifiable *done)
Requests the event associated with the current value of the bit to be produced (unconditionally).
Simple implementation of a BitEventInterface when the true state ofthe variable is mapped in memory (...
Base class for NMRAnet nodes conforming to the asynchronous interface.
Definition Node.hxx:52
A statically allocated buffer for sending one message to the OpenLCB bus.
#define LOG(level, message...)
Conditionally write a message to the logging output.
Definition logging.h:99
static const int INFO
Loglevel that is printed by default, reporting some status information.
Definition logging.h:57
#define MSEC_TO_NSEC(_msec)
Convert a millisecond value to a nanosecond value.
Definition os.h:268