TwiceAsNice
2019-02-18
|
#include <ChatLineMock.h>
Classes | |
struct | Reply |
Public Member Functions | |
ChatLineMockCore () | |
virtual | ~ChatLineMockCore () |
virtual int | open (const char *_device) |
open device with name tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More... | |
virtual int | close () |
closedevice More... | |
virtual int | tryReadlines (const int _max=-1) |
check if you can savly read a line. More... | |
virtual int | nprintf (int _max, const char *_rsp_fmtstr, const char *_cmd_fmtstr,...) |
send line _cmd with params (like printf) and recv lines until a line _rsp is received or _max lines received. More... | |
virtual int | chat (const char *_rsp, int _max, const char *_cmd=NULL) |
send line _cmd and recv lines until a line _rsp is received or _max lines received. More... | |
virtual int | chat (const char *_rsp, const char *_cmd=NULL) |
send line _cmd and recv lines until a line _rsp is received. More... | |
virtual void | setResponse (unsigned int _cmdID, std::string _response, std::string _event="", Nice::Time _time=Nice::Time(), bool _repeat=false) |
This method allows to set the command response. More... | |
virtual std::vector< std::string > | getBuffer () |
All command responses are stored in the serial buffer (m_srbuffer). More... | |
std::string | operator[] (int _num) |
This operation allows to have access to the elements within the serial buffer (m_srbuffer) More... | |
virtual unsigned int | size () |
ChatLineMockCore () | |
virtual | ~ChatLineMockCore () |
virtual int | open (const char *_device) |
open device with name tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More... | |
virtual int | close () |
closedevice More... | |
virtual int | tryReadlines (const int _max=-1) |
check if you can savly read a line. More... | |
virtual int | nprintf (int _max, const char *_rsp_fmtstr, const char *_cmd_fmtstr,...) |
send line _cmd with params (like printf) and recv lines until a line _rsp is received or _max lines received. More... | |
virtual int | chat (const char *_rsp, int _max, const char *_cmd=NULL) |
send line _cmd and recv lines until a line _rsp is received or _max lines received. More... | |
virtual int | chat (const char *_rsp, const char *_cmd=NULL) |
send line _cmd and recv lines until a line _rsp is received. More... | |
virtual void | setResponse (unsigned int _cmdID, std::string _response, std::string _event="", Nice::Time _time=Nice::Time(), bool _repeat=false) |
This method allows to set the command response. More... | |
virtual std::vector< std::string > | getBuffer () |
All command responses are stored in the serial buffer (m_srbuffer). More... | |
std::string | operator[] (int _num) |
This operation allows to have access to the elements within the serial buffer (m_srbuffer) More... | |
virtual unsigned int | size () |
![]() | |
ChatLine () | |
constructor More... | |
ChatLine (const char *_device) | |
constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More... | |
ChatLine (int _fd) | |
constructor with file descriptor More... | |
virtual | ~ChatLine () |
destructor More... | |
virtual int | sendline (const std::string &_line) |
send line _line More... | |
virtual int | recvline (std::string &_line) |
recv line _line More... | |
int | dumpdata () |
dump data in buffers More... | |
int | chat (int _num, const char *_cmd=NULL) |
send line _cmd and wait for _num lines. More... | |
int | mprintf (int _num, const char *_cmd=NULL,...) |
send line _cmd with params (like printf) and wait for _num lines. More... | |
int | printf (const char *_rsp_fmtstr, const char *_cmd_fmtstr=NULL,...) |
send line _cmd with params (like printf) and recv lines until a line _rsp is received. More... | |
std::string | operator[] (int _num) |
return recvd line number _num More... | |
std::size_t | size () |
return number of recvd lines More... | |
Nice::SeqString | srbuffer () |
void | setLineEnd (const char *_end) |
set the end of a rcvd- and sentline. More... | |
void | setLineEndSend (const char *_end) |
the string _end is sent after every raw line. More... | |
void | setLineEndRecv (const char *_end) |
characters from the string _end are used to detect the end of the line. More... | |
void | setMinLine (int _min_line) |
ChatLine () | |
constructor More... | |
ChatLine (const char *_device) | |
constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More... | |
ChatLine (int _fd) | |
constructor with file descriptor More... | |
virtual | ~ChatLine () |
destructor More... | |
virtual int | sendline (const std::string &_line) |
send line _line More... | |
virtual int | recvline (std::string &_line) |
recv line _line More... | |
int | dumpdata () |
dump data in buffers More... | |
int | chat (int _num, const char *_cmd=NULL) |
send line _cmd and wait for _num lines. More... | |
int | mprintf (int _num, const char *_cmd=NULL,...) |
send line _cmd with params (like printf) and wait for _num lines. More... | |
int | printf (const char *_rsp_fmtstr, const char *_cmd_fmtstr=NULL,...) |
send line _cmd with params (like printf) and recv lines until a line _rsp is received. More... | |
std::string | operator[] (int _num) |
return recvd line number _num More... | |
std::size_t | size () |
return number of recvd lines More... | |
Nice::SeqString | srbuffer () |
void | setLineEnd (const char *_end) |
set the end of a rcvd- and sentline. More... | |
void | setLineEndSend (const char *_end) |
the string _end is sent after every raw line. More... | |
void | setLineEndRecv (const char *_end) |
characters from the string _end are used to detect the end of the line. More... | |
void | setMinLine (int _min_line) |
![]() | |
ChatCore () | |
constructor More... | |
ChatCore (const char *_device) | |
constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More... | |
ChatCore (int _fd) | |
constructor with file descriptor More... | |
virtual | ~ChatCore () |
destructor More... | |
virtual int | open () |
virtual int | open (int _fd) |
open device with file descriptor More... | |
virtual bool | isConnected () const |
check if its connected More... | |
virtual int | wait (Nice::Time _time) |
wait _time sec for data, returns earlier as soon as data has arrived. More... | |
virtual int | openListenSocket (int _port) |
open a listen socket. More... | |
virtual int | tryAccept (ChatCore &_newConnection) |
try accepting for X secs. X is set by member setTimeout More... | |
void | setTimeout (Nice::Time _t) |
set read timeout in seconds, -1 = wait forever. More... | |
Nice::Time | timeout () |
void | setVerbose (int _v) |
set verbosity parameters More... | |
void | setName (std::string _name) |
std::string | name () |
ChatCore () | |
constructor More... | |
ChatCore (const char *_device) | |
constructor with devicename tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD. More... | |
ChatCore (int _fd) | |
constructor with file descriptor More... | |
virtual | ~ChatCore () |
destructor More... | |
virtual int | open () |
virtual int | open (int _fd) |
open device with file descriptor More... | |
virtual bool | isConnected () const |
check if its connected More... | |
virtual int | wait (Nice::Time _time) |
wait _time sec for data, returns earlier as soon as data has arrived. More... | |
virtual int | openListenSocket (int _port) |
open a listen socket. More... | |
virtual int | tryAccept (ChatCore &_newConnection) |
try accepting for X secs. X is set by member setTimeout More... | |
void | setTimeout (Nice::Time _t) |
set read timeout in seconds, -1 = wait forever. More... | |
Nice::Time | timeout () |
void | setVerbose (int _v) |
set verbosity parameters More... | |
void | setName (std::string _name) |
std::string | name () |
Protected Member Functions | |
virtual int | getResponse (const unsigned int _cmdID, const int _max=-1, const char *_cmd="") |
This command is used by the chat method to response for the correct command request. More... | |
virtual void | sendAllEvents () |
virtual void | sendCommandRequest (const unsigned int _cmdID, const char *_cmd) |
virtual Nice::Time | checkNextEvent () |
virtual int | getResponse (const unsigned int _cmdID, const int _max=-1, const char *_cmd="") |
This command is used by the chat method to response for the correct command request. More... | |
virtual void | sendAllEvents () |
virtual void | sendCommandRequest (const unsigned int _cmdID, const char *_cmd) |
virtual Nice::Time | checkNextEvent () |
![]() | |
virtual void | setStdSettings () |
virtual void | timeoutAktion (const std::string &) |
virtual int | getc (char *_ch) |
virtual void | setStdSettings () |
virtual void | timeoutAktion (const std::string &) |
virtual int | getc (char *_ch) |
![]() | |
int | openTCP (std::string &_host, uint16_t _port) |
int | openTTY (std::string &_device, int _baud, int _numbits, std::string _parity) |
int | openTCP (std::string &_host, uint16_t _port) |
int | openTTY (std::string &_device, int _baud, int _numbits, std::string _parity) |
Protected Attributes | |
std::string | m_endl |
std::multimap< Nice::Date, std::vector< std::string > > | m_eventStack |
std::multimap< unsigned int, Reply > | m_responseStack |
std::queue< std::string > | m_streamBuffer |
bool | m_sendVersionString |
Nice::Mutex | m_mutex |
![]() | |
Nice::SeqString | m_srbuffer |
char | m_lineEndSend [7] |
char | m_lineEndRecv [7] |
unsigned int | m_minLine |
char | m_readBlockBuffer [1025] |
std::string | m_readBuffer |
std::string | m_lineBuffer |
![]() | |
std::string | m_device_name |
int | m_fd |
Nice::Time | m_timeout |
int | verbose_ |
bool | m_persistent |
std::string | m_name |
Additional Inherited Members | |
![]() | |
enum | { CONNECTION_TIMEOUT = -7777 } |
enum | { CONNECTION_TIMEOUT = -7777 } |
![]() | |
enum | ChatVERBOSE { ChatVERBOSE = 0x1, ChatCOLOR = 0x2, ChatTIME = 0x4, ChatECHO = 0x8, ChatVERBOSE = 0x1, ChatCOLOR = 0x2, ChatTIME = 0x4, ChatECHO = 0x8 } |
enum | ChatVERBOSE { ChatVERBOSE = 0x1, ChatCOLOR = 0x2, ChatTIME = 0x4, ChatECHO = 0x8, ChatVERBOSE = 0x1, ChatCOLOR = 0x2, ChatTIME = 0x4, ChatECHO = 0x8 } |
Basda::ChatLineMockCore::ChatLineMockCore | ( | ) |
|
virtual |
Basda::ChatLineMockCore::ChatLineMockCore | ( | ) |
|
virtual |
send line _cmd and recv lines until a line _rsp is received or _max lines received.
For the recv end pattern:
? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match. \x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. Example: "*Q" # wait for a line with Q at the end. "{good,bad}" # wait for a line that is good or bad.
Reimplemented from Nice::ChatLine.
|
virtual |
send line _cmd and recv lines until a line _rsp is received or _max lines received.
For the recv end pattern:
? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match. \x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. Example: "*Q" # wait for a line with Q at the end. "{good,bad}" # wait for a line that is good or bad.
Reimplemented from Nice::ChatLine.
send line _cmd and recv lines until a line _rsp is received.
For the recv end pattern:
? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match. \x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. Example: "*Q" # wait for a line with Q at the end. "{good,bad}" # wait for a line that is good or bad.
Reimplemented from Nice::ChatLine.
send line _cmd and recv lines until a line _rsp is received.
For the recv end pattern:
? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match. \x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. Example: "*Q" # wait for a line with Q at the end. "{good,bad}" # wait for a line that is good or bad.
Reimplemented from Nice::ChatLine.
|
protectedvirtual |
|
protectedvirtual |
|
inlinevirtual |
closedevice
Reimplemented from Nice::ChatCore.
|
inlinevirtual |
closedevice
Reimplemented from Nice::ChatCore.
|
virtual |
All command responses are stored in the serial buffer (m_srbuffer).
The client is able to read out the buffer via that method.
|
virtual |
All command responses are stored in the serial buffer (m_srbuffer).
The client is able to read out the buffer via that method.
|
protectedvirtual |
This command is used by the chat method to response for the correct command request.
It checks for event messages first and than for the command requests.
_cmdID | The command ID of the command request. |
_max | This number indicates how many lines the service want to be receive at once. If the number is -1, all lines will be send back. |
_cmd | The command string is used for auto generation of the command response. |
Reimplemented in Basda::ChatLineMockMocon, Basda::ChatLineMockMocon, Basda::ChatLineMockCocon, Basda::ChatLineMockUnimod, Basda::ChatLineMockCocon, and Basda::ChatLineMockUnimod.
|
protectedvirtual |
This command is used by the chat method to response for the correct command request.
It checks for event messages first and than for the command requests.
_cmdID | The command ID of the command request. |
_max | This number indicates how many lines the service want to be receive at once. If the number is -1, all lines will be send back. |
_cmd | The command string is used for auto generation of the command response. |
Reimplemented in Basda::ChatLineMockMocon, Basda::ChatLineMockMocon, Basda::ChatLineMockCocon, Basda::ChatLineMockUnimod, Basda::ChatLineMockCocon, and Basda::ChatLineMockUnimod.
|
virtual |
send line _cmd with params (like printf) and recv lines until a line _rsp is received or _max lines received.
For the recv end pattern:
? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match. \x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. Example: "*Q" # wait for a line with Q at the end. "{good,bad}" # wait for a line that is good or bad.
Reimplemented from Nice::ChatLine.
|
virtual |
send line _cmd with params (like printf) and recv lines until a line _rsp is received or _max lines received.
For the recv end pattern:
? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match. \x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. Example: "*Q" # wait for a line with Q at the end. "{good,bad}" # wait for a line that is good or bad.
Reimplemented from Nice::ChatLine.
|
virtual |
open device with name tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD.
Reimplemented from Nice::ChatCore.
|
virtual |
open device with name tcp://HOSTNAME:PORT or tty:/dev/ttyX:BAUD.
Reimplemented from Nice::ChatCore.
std::string Basda::ChatLineMockCore::operator[] | ( | int | _num | ) |
This operation allows to have access to the elements within the serial buffer (m_srbuffer)
_num | the index to access the command response |
std::string Basda::ChatLineMockCore::operator[] | ( | int | _num | ) |
This operation allows to have access to the elements within the serial buffer (m_srbuffer)
_num | the index to access the command response |
|
protectedvirtual |
Reimplemented in Basda::ChatLineMockMocon, and Basda::ChatLineMockMocon.
|
protectedvirtual |
Reimplemented in Basda::ChatLineMockMocon, and Basda::ChatLineMockMocon.
|
virtual |
This method allows to set the command response.
Depending on which command is called the response string is send back and the device and service has to deal with it.
_cmdID | This is the command ID. All command responses of this command will be send back when this command is called. |
_reponse | The command response which will be send back. |
_event | In case this command throws an event, the command event can be set here. This command event will be thrown after _time. |
_time | The relative time when the command event should be thrown. Note: This is not the absolute time. The countdown of the time will be start when the command is called. |
_repeat | Every command response will be send only once to the service. If the command is called twice, the second gets no response unless the parameter _repeat is true. If this command is true, the command response will not be deleted from the command response stack. |
|
virtual |
This method allows to set the command response.
Depending on which command is called the response string is send back and the device and service has to deal with it.
_cmdID | This is the command ID. All command responses of this command will be send back when this command is called. |
_reponse | The command response which will be send back. |
_event | In case this command throws an event, the command event can be set here. This command event will be thrown after _time. |
_time | The relative time when the command event should be thrown. Note: This is not the absolute time. The countdown of the time will be start when the command is called. |
_repeat | Every command response will be send only once to the service. If the command is called twice, the second gets no response unless the parameter _repeat is true. If this command is true, the command response will not be deleted from the command response stack. |
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
check if you can savly read a line.
Reimplemented from Nice::ChatLine.
|
virtual |
check if you can savly read a line.
Reimplemented from Nice::ChatLine.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |