MotionLib  1.0.0
SamBuCa motion library
Public Member Functions | Protected Attributes | List of all members
grbl::MGrblDeviceWrapper Class Reference

Class for implementing Multi-Grbl functionality on top of GrblDeviceBase. More...

#include <MGrblDeviceWrapper.hpp>

Inheritance diagram for grbl::MGrblDeviceWrapper:
Inheritance graph
[legend]
Collaboration diagram for grbl::MGrblDeviceWrapper:
Collaboration graph
[legend]

Public Member Functions

 MGrblDeviceWrapper (size_t instance, const std::shared_ptr< grbl::GrblDeviceBase > &device)
 
void read () override
 fill LineBuffer with incoming bytes
 
void write (const std::string &data) override
 raw write some bytes More...
 
grbl::ErrorCode send (const std::string &cmd, std::function< bool(const std::string &)> msg=[](const std::string &) { return false;}, const std::chrono::milliseconds &timeout=defaultSendTimeout) override
 Send message appending instance id and stripping it off the response provided to handler. More...
 
grbl::ErrorCode sendRealtime (const std::string &cmd, std::function< bool(const std::string &)> msg, const std::chrono::milliseconds &timeout=defaultSendTimeout) override
 Send realtime message appending instance id and stripping it off the response provided to handler. More...
 
bool wait (const std::chrono::milliseconds &timeout) override
 wait for input More...
 
void wake () override
 wake thread waiting for input
 
- Public Member Functions inherited from grbl::GrblDeviceBase
void fetch (const std::chrono::milliseconds &timeout)
 wait for data and process it More...
 
virtual bool takeLine (std::string &line)
 consume line from buffer More...
 

Protected Attributes

size_t m_instance
 
std::shared_ptr< grbl::GrblDeviceBasem_device
 
- Protected Attributes inherited from grbl::GrblDeviceBase
ccut::LineBuffer m_buffer
 

Additional Inherited Members

- Public Attributes inherited from grbl::GrblDeviceBase
ccut::Signal< std::string > dataSignal
 
- Static Public Attributes inherited from grbl::GrblDeviceBase
static const std::chrono::milliseconds defaultSendTimeout
 

Detailed Description

Class for implementing Multi-Grbl functionality on top of GrblDeviceBase.

Allows to create MGrblDeviceWrapper object specifying which Grbl instance it belongs to, and then use send() which will append appropriate instance id to message, and strip it before passing response to provided handler.

Definition at line 48 of file MGrblDeviceWrapper.hpp.

Member Function Documentation

◆ send()

grbl::ErrorCode grbl::MGrblDeviceWrapper::send ( const std::string &  cmd,
std::function< bool(const std::string &)>  msg = [](const std::string &) { return false; },
const std::chrono::milliseconds &  timeout = defaultSendTimeout 
)
overridevirtual

Send message appending instance id and stripping it off the response provided to handler.

Parameters
cmdMessage/command to send
msgCustom handler for the response
timeoutTimeout for response
Returns
grbl::ErrorCode 0 on success, error-code on error

Reimplemented from grbl::GrblDeviceBase.

Definition at line 50 of file MGrblDeviceWrapper.cpp.

◆ sendRealtime()

grbl::ErrorCode grbl::MGrblDeviceWrapper::sendRealtime ( const std::string &  cmd,
std::function< bool(const std::string &)>  msg,
const std::chrono::milliseconds &  timeout = defaultSendTimeout 
)
overridevirtual

Send realtime message appending instance id and stripping it off the response provided to handler.

Parameters
cmdMessage/command to send
msgCustom handler for the response
timeoutTimeout for response
Returns
grbl::ErrorCode 0 on success, error-code on error

Reimplemented from grbl::GrblDeviceBase.

Definition at line 69 of file MGrblDeviceWrapper.cpp.

◆ wait()

bool grbl::MGrblDeviceWrapper::wait ( const std::chrono::milliseconds &  timeout)
overridevirtual

wait for input

Parameters
timeoutwait timeout
Returns
true if data is available
Exceptions
Exception(IO)on IO error

Implements grbl::GrblDeviceBase.

Definition at line 88 of file MGrblDeviceWrapper.cpp.

◆ write()

void grbl::MGrblDeviceWrapper::write ( const std::string &  data)
overridevirtual

raw write some bytes

Parameters
[in]databytes to write

Implements grbl::GrblDeviceBase.

Definition at line 44 of file MGrblDeviceWrapper.cpp.


The documentation for this class was generated from the following files: