1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 18:10:47 +02:00

Clang-format run

This commit is contained in:
Simon Rasmussen
2017-07-09 02:54:49 +02:00
parent 577fcdbf98
commit 3a5fa23f6b
31 changed files with 343 additions and 343 deletions

View File

@@ -1,10 +1,10 @@
#include "ur_modern_driver/ur/commander.h"
#include "ur_modern_driver/log.h"
bool URCommander::write(std::string& s)
bool URCommander::write(std::string &s)
{
size_t len = s.size();
const uint8_t* data = reinterpret_cast<const uint8_t*>(s.c_str());
const uint8_t *data = reinterpret_cast<const uint8_t *>(s.c_str());
size_t written;
return stream_.write(data, len, written);
}
@@ -12,10 +12,10 @@ bool URCommander::write(std::string& s)
void URCommander::formatArray(std::ostringstream &out, std::array<double, 6> &values)
{
std::string mod("[");
for(auto const& val : values)
for (auto const &val : values)
{
out << mod << val;
mod = ",";
out << mod << val;
mod = ",";
}
out << "]";
}
@@ -27,7 +27,7 @@ bool URCommander::uploadProg(std::string &s)
bool URCommander::setToolVoltage(uint8_t voltage)
{
if(voltage != 0 || voltage != 12 || voltage != 24)
if (voltage != 0 || voltage != 12 || voltage != 24)
return false;
std::ostringstream out;
@@ -59,7 +59,6 @@ bool URCommander::stopj(double a)
return write(s);
}
bool URCommander_V1_X::speedj(std::array<double, 6> &speeds, double acceleration)
{
std::ostringstream out;
@@ -86,7 +85,6 @@ bool URCommander_V1_X::setDigitalOut(uint8_t pin, bool value)
return write(s);
}
bool URCommander_V3_X::speedj(std::array<double, 6> &speeds, double acceleration)
{
std::ostringstream out;
@@ -110,16 +108,16 @@ bool URCommander_V3_X::setDigitalOut(uint8_t pin, bool value)
std::ostringstream out;
std::string func;
if(pin < 8)
if (pin < 8)
{
func = "set_standard_digital_out";
}
else if(pin < 16)
else if (pin < 16)
{
func = "set_configurable_digital_out";
pin -= 8;
}
else if(pin < 18)
else if (pin < 18)
{
func = "set_tool_digital_out";
pin -= 16;
@@ -127,7 +125,6 @@ bool URCommander_V3_X::setDigitalOut(uint8_t pin, bool value)
else
return false;
out << func << "(" << (int)pin << "," << (value ? "True" : "False") << ")\n";
std::string s(out.str());
return write(s);

View File

@@ -59,7 +59,7 @@ bool MasterBoardData_V3_0__1::parseWith(BinParser& bp)
bp.parse(euromap67_interface_installed);
if (euromap67_interface_installed)
{
{
if (!bp.checkSize(MasterBoardData_V3_0__1::EURO_SIZE))
return false;

View File

@@ -1,12 +1,11 @@
#include <cstring>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "ur_modern_driver/log.h"
#include "ur_modern_driver/ur/server.h"
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <unistd.h>
#include <cstring>
#include "ur_modern_driver/log.h"
URServer::URServer(int port)
: port_(port)
URServer::URServer(int port) : port_(port)
{
}
@@ -29,7 +28,7 @@ std::string URServer::getIP()
socklen_t len = sizeof(name);
int res = ::getsockname(getSocketFD(), (sockaddr*)&name, &len);
if(res < 0)
if (res < 0)
{
LOG_ERROR("Could not get local IP");
return std::string();
@@ -44,11 +43,11 @@ bool URServer::bind()
{
std::string empty;
bool res = TCPSocket::setup(empty, port_);
if(!res)
if (!res)
return false;
if(::listen(getSocketFD(), 1) < 0)
if (::listen(getSocketFD(), 1) < 0)
return false;
return true;
@@ -56,14 +55,14 @@ bool URServer::bind()
bool URServer::accept()
{
if(TCPSocket::getState() != SocketState::Connected || client_.getSocketFD() > 0)
if (TCPSocket::getState() != SocketState::Connected || client_.getSocketFD() > 0)
return false;
struct sockaddr addr;
struct sockaddr addr;
socklen_t addr_len;
int client_fd = ::accept(getSocketFD(), &addr, &addr_len);
if(client_fd <= 0)
if (client_fd <= 0)
return false;
setOptions(client_fd);
@@ -73,13 +72,13 @@ bool URServer::accept()
void URServer::disconnectClient()
{
if(client_.getState() != SocketState::Connected)
if (client_.getState() != SocketState::Connected)
return;
client_.close();
}
bool URServer::write(const uint8_t* buf, size_t buf_len, size_t &written)
bool URServer::write(const uint8_t* buf, size_t buf_len, size_t& written)
{
return client_.write(buf, buf_len, written);
}

View File

@@ -6,22 +6,22 @@
#include "ur_modern_driver/log.h"
#include "ur_modern_driver/ur/stream.h"
bool URStream::write(const uint8_t* buf, size_t buf_len, size_t &written)
bool URStream::write(const uint8_t* buf, size_t buf_len, size_t& written)
{
std::lock_guard<std::mutex> lock(write_mutex_);
return TCPSocket::write(buf, buf_len, written);
}
bool URStream::read(uint8_t* buf, size_t buf_len, size_t &total)
bool URStream::read(uint8_t* buf, size_t buf_len, size_t& total)
{
std::lock_guard<std::mutex> lock(read_mutex_);
std::lock_guard<std::mutex> lock(read_mutex_);
bool initial = true;
uint8_t* buf_pos = buf;
size_t remainder = sizeof(int32_t);
size_t read = 0;
while(remainder > 0 && TCPSocket::read(buf_pos, remainder, read))
while (remainder > 0 && TCPSocket::read(buf_pos, remainder, read))
{
TCPSocket::setOptions(getSocketFD());
if (initial)
@@ -39,6 +39,6 @@ bool URStream::read(uint8_t* buf, size_t buf_len, size_t &total)
buf_pos += read;
remainder -= read;
}
return remainder == 0;
}