ARCS SDK API
0.24.0
|
#include <socket.h>
Public 成员函数 | |
Socket () | |
virtual | ~Socket () |
int | socketOpen (const std::string &address, int port, const std::string &socket_name="socket_0") |
Open TCP/IP ethernet communication socket. 更多... | |
int | socketClose (const std::string &socket_name="socket_0") |
Closes TCP/IP socket communication Closes down the socket connection to the server. 更多... | |
int | socketReadAsciiFloat (int number, const std::string &variable, const std::string &socket_name="socket_0") |
Reads a number of ascii formatted floats from the socket. 更多... | |
int | socketReadBinaryInteger (int number, const std::string &variable, const std::string &socket_name="socket_0") |
Reads a number of 32 bit integers from the socket. 更多... | |
int | socketReadByteList (int number, const std::string &variable, const std::string &socket_name="socket_0") |
Reads a number of bytes from the socket. 更多... | |
int | socketReadString (const std::string &variable, const std::string &socket_name="socket_0", const std::string &prefix="", const std::string &suffix="", bool interpret_escape=false) |
Reads all data from the socket and returns the data as a string. 更多... | |
int | socketReadAllString (const std::string &variable, const std::string &socket_name="socket_0") |
Instruction std::vector<char> 更多... | |
int | socketSendByte (char value, const std::string &socket_name="socket_0") |
Sends a byte to the server Sends the byte through the socket. 更多... | |
int | socketSendInt (int value, const std::string &socket_name="socket_0") |
Sends an int (int32_t) to the server Sends the int through the socket. 更多... | |
int | socketSendLine (const std::string &str, const std::string &socket_name="socket_0") |
Sends a string with a newline character to the server - useful for communicatin with the UR dashboard server Sends the string <str> through the socket in ASCII coding. 更多... | |
int | socketSendString (const std::string &str, const std::string &socket_name="socket_0") |
Sends a string to the server Sends the string <str> through the socket in ASCII coding. 更多... | |
int | socketSendAllString (bool is_check, const std::vector< char > &str, const std::string &socket_name="socket_0") |
Protected 属性 | |
void * | d_ |
arcs::common_interface::Socket::Socket | ( | ) |
|
virtual |
int arcs::common_interface::Socket::socketClose | ( | const std::string & | socket_name = "socket_0" | ) |
Closes TCP/IP socket communication Closes down the socket connection to the server.
Instruction
socket_name |
int arcs::common_interface::Socket::socketOpen | ( | const std::string & | address, |
int | port, | ||
const std::string & | socket_name = "socket_0" |
||
) |
Open TCP/IP ethernet communication socket.
Instruction
address | |
port | |
socket_name |
int arcs::common_interface::Socket::socketReadAllString | ( | const std::string & | variable, |
const std::string & | socket_name = "socket_0" |
||
) |
Instruction std::vector<char>
variable | |
socket_name |
int arcs::common_interface::Socket::socketReadAsciiFloat | ( | int | number, |
const std::string & | variable, | ||
const std::string & | socket_name = "socket_0" |
||
) |
Reads a number of ascii formatted floats from the socket.
A maximum of 30 values can be read in one command. A list of numbers read (list of floats, length=number+1)
Instruction
Result will be store in a register named reg_key. Use getFloatVec to retrive data
number | |
variable | |
socket_name |
int arcs::common_interface::Socket::socketReadBinaryInteger | ( | int | number, |
const std::string & | variable, | ||
const std::string & | socket_name = "socket_0" |
||
) |
Reads a number of 32 bit integers from the socket.
Bytes are in network byte order. A maximum of 30 values can be read in one command. A list of numbers read (list of ints, length=number+1)
Instruction
std::vector<int>
number | |
variable | |
socket_name |
int arcs::common_interface::Socket::socketReadByteList | ( | int | number, |
const std::string & | variable, | ||
const std::string & | socket_name = "socket_0" |
||
) |
Reads a number of bytes from the socket.
Bytes are in network byte order. A maximum of 30 values can be read in one command. A list of numbers read (list of ints, length=number+1)
Instruction
std::vector<char>
number | |
variable | |
socket_name |
int arcs::common_interface::Socket::socketReadString | ( | const std::string & | variable, |
const std::string & | socket_name = "socket_0" , |
||
const std::string & | prefix = "" , |
||
const std::string & | suffix = "" , |
||
bool | interpret_escape = false |
||
) |
Reads all data from the socket and returns the data as a string.
Bytes are in network byte order.
The optional parameters "prefix" and "suffix", can be used to express what is extracted from the socket. The "prefix" specifies the start of the substring (message) extracted from the socket. The data up to the end of the "prefix" will be ignored and removed from the socket. The "suffix" specifies the end of the substring (message) extracted from the socket. Any remaining data on the socket, after the "suffix", will be preserved. E.g. if the socket server sends a string "noise>hello<", the controller can receive the "hello" by calling this script function with the prefix=">" and suffix="<". By using the "prefix" and "suffix" it is also possible send multiple string to the controller at once, because the suffix defines where the message ends. E.g. sending ">hello<>world<"
Instruction
std::string
variable | |
socket_name | |
prefix | |
suffix | |
interpret_escape |
int arcs::common_interface::Socket::socketSendAllString | ( | bool | is_check, |
const std::vector< char > & | str, | ||
const std::string & | socket_name = "socket_0" |
||
) |
is_check | |
str | |
socket_name |
int arcs::common_interface::Socket::socketSendByte | ( | char | value, |
const std::string & | socket_name = "socket_0" |
||
) |
Sends a byte to the server Sends the byte through the socket.
Expects no response. Can be used to send special ASCII characters; 10 is newline, 2 is start of text, 3 is end of text.
Instruction
value | |
socket_name |
int arcs::common_interface::Socket::socketSendInt | ( | int | value, |
const std::string & | socket_name = "socket_0" |
||
) |
Sends an int (int32_t) to the server Sends the int through the socket.
Send in network byte order. Expects no response
Instruction
value | |
socket_name |
int arcs::common_interface::Socket::socketSendLine | ( | const std::string & | str, |
const std::string & | socket_name = "socket_0" |
||
) |
Sends a string with a newline character to the server - useful for communicatin with the UR dashboard server Sends the string <str> through the socket in ASCII coding.
Expects no response.
Instruction
str | |
socket_name |
int arcs::common_interface::Socket::socketSendString | ( | const std::string & | str, |
const std::string & | socket_name = "socket_0" |
||
) |
Sends a string to the server Sends the string <str> through the socket in ASCII coding.
Expects no response.
Instruction
str | |
socket_name |