Changeset 178 in flair-src for trunk


Ignore:
Timestamp:
May 19, 2017, 4:15:52 PM (8 years ago)
Author:
Bayard Gildas
Message:

Change Udp socket object name (from "Socket" to "UdpSocket")

Location:
trunk
Files:
11 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/demos/SimpleFleet/uav/src/SimpleFleet.cpp

    r167 r178  
    3737#include <Tab.h>
    3838#include <Pid.h>
    39 #include <Socket.h>
     39#include <UdpSocket.h>
    4040#include <string.h>
    4141
     
    7676    u_y->UseDefaultPlot(graphLawTab->LastRowLastCol());
    7777
    78     message=new Socket(uav,"Message",broadcast,true);
     78    message=new UdpSocket(uav,"Message",broadcast,true);
    7979
    8080    customReferenceOrientation= new AhrsData(this,"reference");
  • trunk/demos/SimpleFleet/uav/src/SimpleFleet.h

    r167 r178  
    2020    namespace core {
    2121        class FrameworkManager;
    22         class Socket;
     22        class UdpSocket;
    2323        class AhrsData;
    2424    }
     
    7272        flair::core::Vector2Df posHold;
    7373        float yawHold;
    74         flair::core::Socket *message;
     74        flair::core::UdpSocket *message;
    7575        flair::core::Time posWait;
    7676
  • trunk/lib/FlairCore/src/UdpSocket.cpp

    r177 r178  
    44// %flair:license}
    55//  created:    2013/11/17
    6 //  filename:   Socket.cpp
     6//  filename:   UdpSocket.cpp
    77//
    88//  author:     Guillaume Sanahuja
     
    1515//
    1616/*********************************************************************/
    17 #include "Socket.h"
    18 #include "Socket_impl.h"
     17#include "UdpSocket.h"
     18#include "UdpSocket_impl.h"
    1919#include <FrameworkManager.h>
    2020#include <string.h>
     
    2626namespace core {
    2727
    28 Socket::Socket(const Object *parent, string name, uint16_t port)
     28UdpSocket::UdpSocket(const Object *parent, string name, uint16_t port)
    2929    : Object(parent, name) {
    30   pimpl_ = new Socket_impl(this, name, port);
     30  pimpl_ = new UdpSocket_impl(this, name, port);
    3131}
    3232
    33 Socket::Socket(const Object *parent, string name, string address,
     33UdpSocket::UdpSocket(const Object *parent, string name, string address,
    3434               bool broadcast)
    3535    : Object(parent, name) {
    36   pimpl_ = new Socket_impl(this, name, address, broadcast);
     36  pimpl_ = new UdpSocket_impl(this, name, address, broadcast);
    3737}
    3838
    39 Socket::~Socket() { delete pimpl_; }
     39UdpSocket::~UdpSocket() { delete pimpl_; }
    4040
    41 void Socket::SendMessage(const char *message, size_t message_len) {
     41void UdpSocket::SendMessage(const char *message, size_t message_len) {
    4242  pimpl_->SendMessage(message, message_len);
    4343}
    4444
    45 void Socket::SendMessage(string message) { pimpl_->SendMessage(message); }
     45void UdpSocket::SendMessage(string message) { pimpl_->SendMessage(message); }
    4646
    47 ssize_t Socket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,
     47ssize_t UdpSocket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,
    4848                            size_t *src_len) {
    4949  return pimpl_->RecvMessage(buf, buf_len, timeout, src, src_len);
    5050}
    5151
    52 void Socket::NetworkToHost(char *data, size_t dataSize) {
     52void UdpSocket::NetworkToHost(char *data, size_t dataSize) {
    5353  if (core::IsBigEndian())
    5454    return;
     
    6969}
    7070
    71 void Socket::HostToNetwork(char *data, size_t dataSize) {
     71void UdpSocket::HostToNetwork(char *data, size_t dataSize) {
    7272  if (IsBigEndian())
    7373    return;
  • trunk/lib/FlairCore/src/UdpSocket.h

    r177 r178  
    1111 */
    1212
    13 #ifndef SOCKET_H
    14 #define SOCKET_H
     13#ifndef UDPSOCKET_H
     14#define UDPSOCKET_H
    1515
    1616#include <unistd.h>
     
    1818#include <Object.h>
    1919
    20 class Socket_impl;
     20class UdpSocket_impl;
    2121
    2222namespace flair {
    2323namespace core {
    2424
    25 /*! \class Socket
     25/*! \class UdpSocket
    2626*
    2727* \brief Class encapsulating a UDP socket. It assumes packets are coming from
     
    2929*
    3030*/
    31 class Socket : public Object {
     31class UdpSocket : public Object {
    3232public:
    3333  /*!
     
    4141  * \param broadcast true if address is a broadcast address
    4242  */
    43   Socket(const Object *parent, std::string name, std::string address,
     43  UdpSocket(const Object *parent, std::string name, std::string address,
    4444         bool broadcast = false);
    4545
     
    5353  * \param port listening port
    5454  */
    55   Socket(const Object *parent, std::string name, uint16_t port);
     55  UdpSocket(const Object *parent, std::string name, uint16_t port);
    5656
    5757  /*!
     
    5959  *
    6060  */
    61   ~Socket();
     61  ~UdpSocket();
    6262
    6363  /*!
     
    103103
    104104private:
    105   class Socket_impl *pimpl_;
     105  class UdpSocket_impl *pimpl_;
    106106};
    107107
     
    109109} // end namespace flair
    110110
    111 #endif // SOCKET_H
     111#endif // UDPSOCKET_H
  • trunk/lib/FlairCore/src/UdpSocket_impl.cpp

    r177 r178  
    1515//
    1616/*********************************************************************/
    17 #include "Socket_impl.h"
    18 #include "Socket.h"
     17#include "UdpSocket_impl.h"
     18#include "UdpSocket.h"
    1919#include "FrameworkManager.h"
    2020#include <fcntl.h>
     
    2929using namespace flair::core;
    3030
    31 Socket_impl::Socket_impl(const Socket *self, string name, uint16_t port) {
     31UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, uint16_t port) {
    3232  this->self = self;
    3333  this->port = port;
     
    3737}
    3838
    39 Socket_impl::Socket_impl(const Socket *self, string name, string address,
     39UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, string address,
    4040                         bool broadcast) {
    4141  this->self = self;
     
    5151}
    5252
    53 void Socket_impl::Init(void) {
     53void UdpSocket_impl::Init(void) {
    5454  int yes = 1;
    5555
     
    143143}
    144144
    145 Socket_impl::~Socket_impl() {
     145UdpSocket_impl::~UdpSocket_impl() {
    146146#ifdef __XENO__
    147147  is_running = false;
     
    157157}
    158158
    159 void Socket_impl::SendMessage(const char *src, size_t src_len) {
     159void UdpSocket_impl::SendMessage(const char *src, size_t src_len) {
    160160  ssize_t written;
    161161  string to_send;
     
    189189}
    190190
    191 void Socket_impl::SendMessage(string message) {
     191void UdpSocket_impl::SendMessage(string message) {
    192192  ssize_t written;
    193193
     
    214214}
    215215
    216 ssize_t Socket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,
     216ssize_t UdpSocket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,
    217217                                 char *src, size_t *src_len) {
    218218  ssize_t nb_read;
     
    291291
    292292#ifdef __XENO__
    293 void *Socket_impl::user(void *arg) {
    294   Socket_impl *caller = (Socket_impl *)arg;
     293void *UdpSocket_impl::user(void *arg) {
     294  UdpSocket_impl *caller = (UdpSocket_impl *)arg;
    295295  int pipe_fd = -1;
    296296  string devname;
  • trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h

    r177 r178  
    44// %flair:license}
    55/*!
    6  * \file Socket_impl.h
     6 * \file UdpSocket_impl.h
    77 * \brief Classe creant une socket
    88 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
     
    1111 */
    1212
    13 #ifndef SOCKET_IMPL_H
    14 #define SOCKET_IMPL_H
     13#ifndef UDPSOCKET_IMPL_H
     14#define UDPSOCKET_IMPL_H
    1515
    1616#include <sys/socket.h>
     
    2121#endif
    2222
    23 namespace flair {
    24 namespace core {
    25 class Socket;
    26 }
    27 }
     23namespace flair { namespace core {
     24  class UdpSocket;
     25} }
    2826
    29 class Socket_impl {
     27class UdpSocket_impl {
    3028public:
    31   Socket_impl(const flair::core::Socket *self, std::string name,
     29  UdpSocket_impl(const flair::core::UdpSocket *self, std::string name,
    3230              std::string address, bool broadcast = false);
    33   Socket_impl(const flair::core::Socket *self, std::string name, uint16_t port);
    34   ~Socket_impl();
     31  UdpSocket_impl(const flair::core::UdpSocket *self, std::string name, uint16_t port);
     32  ~UdpSocket_impl();
    3533
    3634  void SendMessage(std::string message);
     
    4543  bool broadcast;
    4644  void Init(void);
    47   const flair::core::Socket *self;
     45  const flair::core::UdpSocket *self;
    4846  struct sockaddr_in sock_in;
    4947#ifdef __XENO__
     
    5553};
    5654
    57 #endif // SOCKET_IMPL_H
     55#endif // UDPSOCKET_IMPL_H
  • trunk/lib/FlairSensorActuator/src/EmulatedController.cpp

    r157 r178  
    1414#include <Controller.h>
    1515#include <TcpSocket.h>
    16 #include <Socket.h>
     16#include <UdpSocket.h>
    1717#include <cstring>
    1818#include <string>
  • trunk/lib/FlairSensorActuator/src/HostEthController.cpp

    r137 r178  
    2626#include <TargetController.h>
    2727#include <TcpSocket.h>
    28 #include <Socket.h>
     28#include <UdpSocket.h>
    2929#include <cstring>
    3030#include <string>
     
    5454  controlSocket = new TcpSocket((Thread *)this, "eth controller control socket",
    5555                                blocking, !blocking);
    56   dataSocket = new Socket((Thread *)this, "eth controller data socket",
     56  dataSocket = new UdpSocket((Thread *)this, "eth controller data socket",
    5757                          _address + ":" + std::to_string(_port + 1));
    5858  dataSender =
  • trunk/lib/FlairSensorActuator/src/HostEthController.h

    r137 r178  
    2828class cvmatrix;
    2929class TcpSocket;
    30 class Socket;
     30class UdpSocket;
    3131class Mutex;
    3232}
     
    6464  std::string controllerName;
    6565  core::TcpSocket *controlSocket; // connection to the target
    66   core::Socket *dataSocket;
     66  core::UdpSocket *dataSocket;
    6767  std::string targetAddress;
    6868  int targetPort;
  • trunk/lib/FlairSensorActuator/src/TargetEthController.cpp

    r137 r178  
    2121#include <FrameworkManager.h>
    2222#include <TcpSocket.h>
    23 #include <Socket.h>
     23#include <UdpSocket.h>
    2424#include <cstring>
    2525#include <string>
     
    4444      new TcpSocket(getFrameworkManager(), "TEC_listening_socket", blocking, blocking);
    4545  dataSocket =
    46       new Socket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side
     46      new UdpSocket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side
    4747}
    4848
  • trunk/lib/FlairSensorActuator/src/TargetEthController.h

    r137 r178  
    2929class cvmatrix;
    3030class TcpSocket;
    31 class Socket;
     31class UdpSocket;
    3232}
    3333namespace gui {
     
    7878  int listeningPort;
    7979  core::TcpSocket *controlSocket = NULL;
    80   core::Socket *dataSocket;
     80  core::UdpSocket *dataSocket;
    8181  std::string *axisName = NULL;
    8282  std::string *buttonName = NULL;
  • trunk/tools/Controller/Mavlink/src/Forwarder.cpp

    r137 r178  
    1818#include "Forwarder.h"
    1919
    20 #include <Socket.h>
     20#include <UdpSocket.h>
    2121#include <Thread.h>
    2222#include <FrameworkManager.h>
     
    4141  // cout << "output socket : " << outputAddress + ":" + to_string(outputPort) << endl;
    4242
    43   inputSocket = new Socket((Thread *)this, "input socket", inputPort);
    44   outputSocket = new Socket((Thread *)this, "output socket", outputAddress + ":" + to_string(outputPort));
     43  inputSocket = new UdpSocket((Thread *)this, "input socket", inputPort);
     44  outputSocket = new UdpSocket((Thread *)this, "output socket", outputAddress + ":" + to_string(outputPort));
    4545}
    4646
  • trunk/tools/Controller/Mavlink/src/Forwarder.h

    r137 r178  
    2323#include <Thread.h>
    2424
    25 namespace flair {
    26 namespace core {
    27   class Socket;
    28 }
    29 }
     25namespace flair { namespace core {
     26  class UdpSocket;
     27} }
    3028
    3129class Forwarder : public flair::core::Thread {
     
    4139  void Run();
    4240
    43   flair::core::Socket *inputSocket;
     41  flair::core::UdpSocket *inputSocket;
    4442  std::string inputAddress;
    4543  int inputPort;
     
    4745  const int inputBufferSize = 200;
    4846
    49   flair::core::Socket *outputSocket;
     47  flair::core::UdpSocket *outputSocket;
    5048  std::string outputAddress;
    5149  int outputPort;
  • trunk/tools/Controller/Mavlink/src/GuiFlair.cpp

    r137 r178  
    2020#include "GuiInterface.h"
    2121
    22 #include <Socket.h>
     22#include <UdpSocket.h>
    2323
    2424//todo remove for tests
     
    3434        cout << "MavPlanner GuiFlair constructor" << endl;
    3535
    36         outputSocket = new Socket((Thread *)this, "output socket", "127.0.0.1:5036");
     36        outputSocket = new UdpSocket((Thread *)this, "output socket", "127.0.0.1:5036");
    3737
    3838        // outputSocket = new Socket(parent, "output socket", "127.255.255.255:9001", true);
    39         inputSocket = new Socket((Thread *)this, "input socket", 9001);
     39        inputSocket = new UdpSocket((Thread *)this, "input socket", 9001);
    4040}
    4141
  • trunk/tools/Controller/Mavlink/src/GuiFlair.h

    r137 r178  
    2424#include "GuiInterface.h"
    2525
    26 namespace flair {
    27 namespace core {
    28   class Socket;
    29 }
    30 }
     26namespace flair { namespace core {
     27  class UdpSocket;
     28} }
    3129
    3230class GuiFlair : public GuiInterface {
     
    4442
    4543private:
    46   flair::core::Socket *inputSocket;
    47   flair::core::Socket *outputSocket;
     44  flair::core::UdpSocket *inputSocket;
     45  flair::core::UdpSocket *outputSocket;
    4846  std::string outputAddress;
    4947  int outputPort;       
Note: See TracChangeset for help on using the changeset viewer.