|
Open Model Railroad Network (OpenMRN)
|
This is a self-owned flow which reads an memory space into a stream. More...
#include <MemoryConfigStream.hxx>
Public Types | |
| using | CallbackFn = std::function< void(uint16_t)> |
| This callback function will be called with an error code, or 0 on success. | |
Public Member Functions | |
| MemorySpaceStreamReadFlow (Node *node, MemorySpace *space, NodeHandle dst, uint8_t dst_stream_id, uint32_t ofs, uint32_t len, CallbackFn started_cb) | |
| Constructor. | |
| uint8_t | get_src_stream_id () |
| uint8_t | get_dst_stream_id () |
Public Member Functions inherited from StateFlowBase | |
| void | run () override |
| Callback from the executor. | |
| void | notify () override |
| Wakeup call arrived. | |
| Service * | service () |
| Return a pointer to the service I am bound to. | |
Public Member Functions inherited from Executable | |
| void | test_deletion () |
Public Member Functions inherited from QMember | |
| void | init () |
| Initiailize a QMember, in place of a public placement construction. | |
Private Member Functions | |
| Action | alloc_stream () |
| Action | got_sender () |
| Action | initiate_stream () |
| Action | wait_for_started () |
| Action | alloc_buffer () |
| Action | have_raw_buffer () |
| Action | try_read () |
| Action | wait_for_close () |
| Action | done_stream () |
| StreamTransport * | stream_transport () |
Private Attributes | |
| LimitedPool | sendBufferPool_ {sizeof(RawBuffer), 2, rawBufferPool} |
| This pool is used to allocate raw buffers to read data into from the memory space. | |
| ByteBufferPtr | sendBuffer_ |
| We keep reading into this buffer from the memory space. | |
| StateFlowTimer | timer_ {this} |
| Helper object for waiting. | |
| NodeHandle | dst_ |
| Address to which we are sending the stream. | |
| CallbackFn | startedCb_ |
| callback to invoke after start is successful. | |
| MemorySpace * | space_ |
| Memory space we are reading. | |
| uint8_t | srcStreamId_ {StreamDefs::INVALID_STREAM_ID} |
| Destination stream ID on the target node. | |
| uint8_t | dstStreamId_ |
| Destination stream ID on the target node. | |
| Node * | node_ |
| Node from which we are sending the stream. | |
| uint32_t | ofs_ |
| Next byte to read. | |
| uint32_t | len_ |
| How many bytes are left to read. | |
| StreamSenderCan * | senderCan_ |
| StreamSender * | sender_ |
Additional Inherited Members | |
Static Public Member Functions inherited from StateFlowBase | |
| template<class T , typename... Args> | |
| static void | invoke_subflow_and_ignore_result (FlowInterface< Buffer< T > > *target_flow, Args &&... args) |
| Calls a helper flow to perform some actions. | |
Protected Types inherited from StateFlowBase | |
| typedef Action(StateFlowBase::* | Callback) () |
| State Flow callback prototype. | |
Protected Member Functions inherited from StateFlowBase | |
| StateFlowBase (Service *service) | |
| Constructor. | |
| ~StateFlowBase () | |
| Destructor. | |
| void | reset_flow (Callback c) |
| Resets the flow to the specified state. | |
| bool | is_state (Callback c) |
| bool | is_terminated () |
| void | start_flow (Callback c) |
| Resets the flow to the specified state and starts it. | |
| Action | again () |
| Call the current state again via call_immediately. | |
| Action | exit () |
| Terminate current StateFlow activity. | |
| Action | delete_this () |
| Terminates the flow and deletes *this. | |
| Action | set_terminated () |
| Sets the flow to terminated state. | |
| Action | call_immediately (Callback c) |
| Imediately call the next state upon return. | |
| Action | wait () |
| Wait for an asynchronous call. | |
| Action | wait_and_call (Callback c) |
| Wait for resource to become available before proceeding to next state. | |
| template<class T > | |
| Action | allocate_and_call (FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr) |
| Allocates a buffer from a pool and proceed to the next state when allocation is successful. | |
| Action | allocate_and_call (Callback c, QAsync *queue) |
| Allocates an entry from an asynchronous queue, and transitions to a state once the allocation is complete. | |
| template<class T > | |
| Buffer< T > * | full_allocation_result (FlowInterface< Buffer< T > > *target_flow) |
| Takes the result of the asynchronous allocation without resetting the object. | |
| template<class T > | |
| T * | full_allocation_result (TypedQAsync< T > *queue) |
| Takes the result of the asynchronous allocation without resetting the object. | |
| template<class T > | |
| void | cast_allocation_result (T **member) |
| Takes the result of the asynchronous allocation without resetting the object. | |
| template<class T > | |
| Buffer< T > * | get_allocation_result (FlowInterface< Buffer< T > > *target_flow) |
| Takes the result of the asynchronous allocation. | |
| Action | yield_and_call (Callback c) |
| Place the current flow to the back of the executor, and transition to a new state after we get the CPU again. | |
| Action | yield () |
| Place the current flow to the back of the executor, and re-try the current state after we get the CPU again. | |
| Action | sleep_and_call (::Timer *timer, long long timeout_nsec, Callback c) |
| Suspends execution of this control flow for a specified time. | |
| template<class T , typename... Args> | |
| Action | invoke_subflow_and_wait (FlowInterface< Buffer< T > > *target_flow, Callback c, Args &&... args) |
| Calls a helper flow to perform some actions. | |
| Action | read_repeated (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO) |
| Blocks until size bytes are read and then invokes the next state. | |
| Action | read_single (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO) |
| Attempts to read at most size_t bytes, and blocks the caller until at least one byte is read. | |
| Action | read_nonblocking (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO) |
| Attempts to read at most size bytes, and then invokes the next state, even if only zero bytes are available right now. | |
| Action | read_repeated_with_timeout (StateFlowTimedSelectHelper *helper, long long timeout_nsec, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO) |
| Blocks until size bytes are read, or a timeout expires. | |
| Action | internal_try_read () |
| Implementation state that gets repeatedly called upon every wakeup and tries to make progress on reading. | |
| Action | write_repeated (StateFlowSelectHelper *helper, int fd, const void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO) |
| Writes some data into a file descriptor, repeating the operation as necessary until all bytes are written. | |
| Action | internal_try_write () |
| Implementation state that gets repeatedly called upon every wakeup and tries to make progress on writing. | |
Protected Member Functions inherited from QMember | |
| QMember () | |
| Constructor. | |
| ~QMember () | |
| Destructor. | |
Protected Attributes inherited from QMember | |
| QMember * | next |
| pointer to the next member in the queue | |
This is a self-owned flow which reads an memory space into a stream.
Definition at line 47 of file MemoryConfigStream.hxx.
| using openlcb::MemorySpaceStreamReadFlow::CallbackFn = std::function<void(uint16_t)> |
This callback function will be called with an error code, or 0 on success.
Definition at line 52 of file MemoryConfigStream.hxx.
|
inline |
Constructor.
Does NOT transfer ownership; this class will delete itself.
| node | virtual nde where to send the stream from. |
| space | memory space pointer |
| dst | target node to send data to |
| dst_stream_id | sream ID on the target node |
| ofs | where to start reading from in the memory space |
| len | how many bytes to send (0xFFFFFFFF to send until EOF) |
| started_cb | will be invoked when the stream initiate reply arrives and data can be sent to the stream. |
Definition at line 65 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 140 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 94 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 222 of file MemoryConfigStream.hxx.
|
inline |
Definition at line 88 of file MemoryConfigStream.hxx.
|
inline |
Definition at line 82 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 100 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 146 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 112 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 230 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 156 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 204 of file MemoryConfigStream.hxx.
|
inlineprivate |
Definition at line 120 of file MemoryConfigStream.hxx.
|
private |
Address to which we are sending the stream.
Definition at line 245 of file MemoryConfigStream.hxx.
|
private |
Destination stream ID on the target node.
Definition at line 253 of file MemoryConfigStream.hxx.
|
private |
How many bytes are left to read.
0xFFFFFFFF if all bytes until EOF need to be read.
Definition at line 260 of file MemoryConfigStream.hxx.
|
private |
Node from which we are sending the stream.
Definition at line 255 of file MemoryConfigStream.hxx.
|
private |
Next byte to read.
Definition at line 257 of file MemoryConfigStream.hxx.
|
private |
We keep reading into this buffer from the memory space.
Definition at line 241 of file MemoryConfigStream.hxx.
|
private |
This pool is used to allocate raw buffers to read data into from the memory space.
By keeping the count limited we can ensure that we only carry 2 kbytes of data in RAM before it gets dumped into the CAN-bus packets.
Definition at line 239 of file MemoryConfigStream.hxx.
|
private |
Definition at line 264 of file MemoryConfigStream.hxx.
|
private |
Definition at line 263 of file MemoryConfigStream.hxx.
|
private |
Memory space we are reading.
Definition at line 249 of file MemoryConfigStream.hxx.
|
private |
Destination stream ID on the target node.
Definition at line 251 of file MemoryConfigStream.hxx.
|
private |
callback to invoke after start is successful.
Definition at line 247 of file MemoryConfigStream.hxx.
|
private |
Helper object for waiting.
Definition at line 243 of file MemoryConfigStream.hxx.