[Positioning] OutputSocket -> OutputUDPSocket
This commit is contained in:
parent
a2c0556ee8
commit
22cad4c214
|
@ -76,7 +76,7 @@ OBJ_LIST = \
|
||||||
output.o \
|
output.o \
|
||||||
outputterminal.o \
|
outputterminal.o \
|
||||||
outputcsv.o \
|
outputcsv.o \
|
||||||
outputsocket.o \
|
outputudpsocket.o \
|
||||||
positioning.o \
|
positioning.o \
|
||||||
input.o \
|
input.o \
|
||||||
inputcsv.o \
|
inputcsv.o \
|
||||||
|
@ -214,11 +214,16 @@ $(OBJ_DIR)/outputcsv.o: \
|
||||||
$(SRC_DIR)/outputmedium.hh \
|
$(SRC_DIR)/outputmedium.hh \
|
||||||
$(OBJ_DIR)/textfilewriter.o \
|
$(OBJ_DIR)/textfilewriter.o \
|
||||||
$(OBJ_DIR)/result.o
|
$(OBJ_DIR)/result.o
|
||||||
|
$(OBJ_DIR)/outputudpsocket.o: \
|
||||||
|
$(SRC_DIR)/outputmedium.hh \
|
||||||
|
$(OBJ_DIR)/result.o
|
||||||
$(OBJ_DIR)/outputcsv.o: \
|
$(OBJ_DIR)/outputcsv.o: \
|
||||||
$(SRC_DIR)/outputmedium.hh \
|
$(SRC_DIR)/outputmedium.hh \
|
||||||
$(OBJ_DIR)/result.o
|
$(OBJ_DIR)/result.o
|
||||||
$(OBJ_DIR)/output.o: \
|
$(OBJ_DIR)/output.o: \
|
||||||
$(OBJ_DIR)/outputterminal.o \
|
$(OBJ_DIR)/outputterminal.o \
|
||||||
|
$(OBJ_DIR)/outputcsv.o \
|
||||||
|
$(OBJ_DIR)/outputudpsocket.o \
|
||||||
$(OBJ_DIR)/configuration.o \
|
$(OBJ_DIR)/configuration.o \
|
||||||
$(OBJ_DIR)/posexcept.o
|
$(OBJ_DIR)/posexcept.o
|
||||||
$(OBJ_DIR)/multilaterationalgorithm.o: \
|
$(OBJ_DIR)/multilaterationalgorithm.o: \
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "outputterminal.hh"
|
#include "outputterminal.hh"
|
||||||
#include "outputcsv.hh"
|
#include "outputcsv.hh"
|
||||||
#include "outputsocket.hh"
|
#include "outputudpsocket.hh"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ void Output::initialise_output_media()
|
||||||
else if (*i == "CSV")
|
else if (*i == "CSV")
|
||||||
initialise_output_csv() ;
|
initialise_output_csv() ;
|
||||||
|
|
||||||
else if (*i == "Socket")
|
else if (*i == "UDP")
|
||||||
initialise_output_socket() ;
|
initialise_output_udp_socket() ;
|
||||||
|
|
||||||
else
|
else
|
||||||
throw bad_configuration(
|
throw bad_configuration(
|
||||||
|
@ -69,17 +69,19 @@ void Output::initialise_output_terminal()
|
||||||
output_media.push_back(new OutputTerminal) ;
|
output_media.push_back(new OutputTerminal) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Output::initialise_output_socket()
|
|
||||||
|
void Output::initialise_output_udp_socket()
|
||||||
{
|
{
|
||||||
if (! Configuration::is_configured("output.remote-ip"))
|
if (! Configuration::is_configured("output.remote-ip"))
|
||||||
throw missing_configuration(
|
throw missing_configuration(
|
||||||
"No remote ip specified in the configuration!") ;
|
"No remote ip specified in the configuration!") ;
|
||||||
|
|
||||||
output_media.push_back(
|
output_media.push_back(
|
||||||
new OutputSocket(
|
new OutputUDPSocket(
|
||||||
Configuration::string_value("output.remote-ip"))) ;
|
Configuration::string_value("output.remote-ip"))) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Output::initialise_output_csv()
|
void Output::initialise_output_csv()
|
||||||
{
|
{
|
||||||
if (! Configuration::is_configured("output.csv-file"))
|
if (! Configuration::is_configured("output.csv-file"))
|
||||||
|
|
|
@ -18,7 +18,7 @@ protected:
|
||||||
void initialise_output_media(void) ;
|
void initialise_output_media(void) ;
|
||||||
void initialise_output_terminal(void) ;
|
void initialise_output_terminal(void) ;
|
||||||
void initialise_output_csv(void) ;
|
void initialise_output_csv(void) ;
|
||||||
void initialise_output_socket(void) ;
|
void initialise_output_udp_socket(void) ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "outputsocket.hh"
|
#include "outputudpsocket.hh"
|
||||||
#include "request.hh"
|
#include "request.hh"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -16,14 +16,14 @@ struct sockaddr_in serverAddress ;
|
||||||
/* *** Constructors *** */
|
/* *** Constructors *** */
|
||||||
|
|
||||||
|
|
||||||
OutputSocket::OutputSocket(const string &_remote_ip):
|
OutputUDPSocket::OutputUDPSocket(const string &_remote_ip):
|
||||||
remote_ip(_remote_ip)
|
remote_ip(_remote_ip)
|
||||||
{
|
{
|
||||||
init_socket() ;
|
init_socket() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OutputSocket::~OutputSocket()
|
OutputUDPSocket::~OutputUDPSocket()
|
||||||
{
|
{
|
||||||
kill_socket() ;
|
kill_socket() ;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ OutputSocket::~OutputSocket()
|
||||||
/* *** Operations *** */
|
/* *** Operations *** */
|
||||||
|
|
||||||
|
|
||||||
void OutputSocket::write(const Result &result)
|
void OutputUDPSocket::write(const Result &result)
|
||||||
{
|
{
|
||||||
string timestampXYZ;
|
string timestampXYZ;
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
|
@ -53,7 +53,7 @@ void OutputSocket::write(const Result &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OutputSocket::init_socket()
|
void OutputUDPSocket::init_socket()
|
||||||
{
|
{
|
||||||
cout << "Initialisation socket..." << endl;
|
cout << "Initialisation socket..." << endl;
|
||||||
hostInfo = gethostbyname(remote_ip.c_str());
|
hostInfo = gethostbyname(remote_ip.c_str());
|
||||||
|
@ -66,7 +66,7 @@ void OutputSocket::init_socket()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OutputSocket::send_data(string data)
|
void OutputUDPSocket::send_data(string data)
|
||||||
{
|
{
|
||||||
if (sendto(socketDescriptor, data.c_str(), data.size(), 0,
|
if (sendto(socketDescriptor, data.c_str(), data.size(), 0,
|
||||||
(struct sockaddr *) &serverAddress,
|
(struct sockaddr *) &serverAddress,
|
||||||
|
@ -78,7 +78,7 @@ void OutputSocket::send_data(string data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OutputSocket::kill_socket()
|
void OutputUDPSocket::kill_socket()
|
||||||
{
|
{
|
||||||
cout << "Fermeture de la socket..." << endl;
|
cout << "Fermeture de la socket..." << endl;
|
||||||
close(socketDescriptor);
|
close(socketDescriptor);
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef _OWLPS_POSITIONING_OUTPUTSOCKET_HH_
|
#ifndef _OWLPS_POSITIONING_OUTPUTUDPSOCKET_HH_
|
||||||
#define _OWLPS_POSITIONING_OUTPUTSOCKET_HH_
|
#define _OWLPS_POSITIONING_OUTPUTUDPSOCKET_HH_
|
||||||
|
|
||||||
#include "outputmedium.hh"
|
#include "outputmedium.hh"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/// Sends results to an UDP socket
|
/// Sends results to an UDP socket
|
||||||
class OutputSocket: public OutputMedium
|
class OutputUDPSocket: public OutputMedium
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int socketDescriptor ;
|
int socketDescriptor ;
|
||||||
|
@ -22,8 +22,8 @@ private:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OutputSocket(const std::string &_remote_ip) ;
|
OutputUDPSocket(const std::string &_remote_ip) ;
|
||||||
~OutputSocket(void) ;
|
~OutputUDPSocket(void) ;
|
||||||
|
|
||||||
/** @name Operations */
|
/** @name Operations */
|
||||||
//@{
|
//@{
|
||||||
|
@ -34,4 +34,4 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _OWLPS_POSITIONING_OUTPUTSOCKET_HH_
|
#endif // _OWLPS_POSITIONING_OUTPUTUDPSOCKET_HH_
|
Loading…
Reference in New Issue