Commit b669d05c authored by Locatelli's avatar Locatelli
Browse files

Implement JSON message for sending image to fluentd system

parent 05119a03
- recompute projections x and y min max values when zooming
- move icons to a system directory and not in the project
- status bar with mouse coordinates
\ No newline at end of file
- status bar with mouse coordinates using qt event and not matplotib one
- nomad server restart ploty2 at during its starting
- nomad gui closing shall closed plot windows
- nomad gui starting shall restart previous display plot windows
- recover size and position of plots and also states for grid, log , aspect ratio ....
- Do offscreen for web plots and multiwindow plot
- bring plot to front wait it was already open
- send offscreen log image to log system
\ No newline at end of file
......@@ -61,6 +61,11 @@ MPLCPP = \
view/mpl/widgets/MplCursor.cpp \
view/mpl/widgets/MplLegend.cpp
JSON = \
json/HttpConnection.cpp \
json/LogSender.cpp \
json/RestJsonHttpConnection.cpp
ploty2_SOURCES = \
main.cpp \
manager/RequestDealerManager.cpp \
......@@ -106,7 +111,8 @@ offmplplot_SOURCES = \
$(PROTOBUF) \
$(DATACONT) \
$(MPLCPP) \
$(QT)
$(QT) \
$(JSON)
offmplplot_CPPFLAGS = $(RM_CXXFLAGS) -DOFFSCREEN -DTRACEDEBUG
offmplplot_LDFLAGS = $(RM_LDFLAGS)
......
......@@ -224,11 +224,14 @@ am__objects_10 = view/qt/offmplplot-QtColorMapWidget.$(OBJEXT) \
view/qt/offmplplot-QtUpdateContainer.$(OBJEXT) \
view/qt/offmplplot-QtUpdateThread.$(OBJEXT) \
view/qt/offmplplot-moc_QtUpdateThread.$(OBJEXT)
am__objects_11 = json/offmplplot-HttpConnection.$(OBJEXT) \
json/offmplplot-LogSender.$(OBJEXT) \
json/offmplplot-RestJsonHttpConnection.$(OBJEXT)
am_offmplplot_OBJECTS = offmplplot-mainoffscreenplot.$(OBJEXT) \
manager/offmplplot-ServerRequesterManager.$(OBJEXT) \
manager/offmplplot-ServerSubscriberManager.$(OBJEXT) \
$(am__objects_6) $(am__objects_7) $(am__objects_8) \
$(am__objects_9) $(am__objects_10)
$(am__objects_9) $(am__objects_10) $(am__objects_11)
offmplplot_OBJECTS = $(am_offmplplot_OBJECTS)
offmplplot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
......@@ -236,7 +239,7 @@ offmplplot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
offmplplot_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(offmplplot_LDFLAGS) $(LDFLAGS) -o $@
am__objects_11 = plot/ploty2-Plot.$(OBJEXT) \
am__objects_12 = plot/ploty2-Plot.$(OBJEXT) \
plot/ploty2-EmptyPlot.$(OBJEXT) plot/ploty2-Plot1D.$(OBJEXT) \
plot/ploty2-Plot2D.$(OBJEXT) plot/ploty2-PlotHisto.$(OBJEXT) \
plot/ploty2-PlotToolBar.$(OBJEXT) \
......@@ -249,24 +252,24 @@ am__objects_11 = plot/ploty2-Plot.$(OBJEXT) \
plot/property/ploty2-PropertyPlot.$(OBJEXT) \
plot/property/ploty2-PropertyPlot1D.$(OBJEXT) \
plot/property/ploty2-PropertyPlot2D.$(OBJEXT)
am__objects_12 = \
am__objects_13 = \
protobuf/generated/ploty2-AcquisitionSerializer.pb.$(OBJEXT) \
protobuf/generated/ploty2-CommonResponses.pb.$(OBJEXT) \
protobuf/generated/ploty2-DatabaseRequests.pb.$(OBJEXT) \
protobuf/generated/ploty2-DataPlotMessages.pb.$(OBJEXT) \
protobuf/generated/ploty2-NotificationMessages.pb.$(OBJEXT)
am__objects_13 = datacontainer/ploty2-DataPlotProperties.$(OBJEXT) \
am__objects_14 = datacontainer/ploty2-DataPlotProperties.$(OBJEXT) \
datacontainer/ploty2-PlotDataContainer.$(OBJEXT) \
datacontainer/ploty2-PropertyPlotDataContainer.$(OBJEXT) \
datacontainer/ploty2-UpdateContainer.$(OBJEXT)
am__objects_14 = view/mpl/ploty2-Mpl.$(OBJEXT) \
am__objects_15 = view/mpl/ploty2-Mpl.$(OBJEXT) \
view/mpl/ploty2-MplFigure.$(OBJEXT) \
view/mpl/ploty2-MplPlot1D.$(OBJEXT) \
view/mpl/ploty2-MplPlot2D.$(OBJEXT) \
view/mpl/ploty2-MplEventManager.$(OBJEXT) \
view/mpl/widgets/ploty2-MplCursor.$(OBJEXT) \
view/mpl/widgets/ploty2-MplLegend.$(OBJEXT)
am__objects_15 = view/qt/ploty2-QtColorMapWidget.$(OBJEXT) \
am__objects_16 = view/qt/ploty2-QtColorMapWidget.$(OBJEXT) \
view/qt/ploty2-moc_QtColorMapWidget.$(OBJEXT) \
view/qt/ploty2-QtPlotDataWidget.$(OBJEXT) \
view/qt/ploty2-moc_QtPlotDataWidget.$(OBJEXT) \
......@@ -287,8 +290,8 @@ am_ploty2_OBJECTS = ploty2-main.$(OBJEXT) \
manager/ploty2-ServerRequesterManager.$(OBJEXT) \
manager/ploty2-PlotManager.$(OBJEXT) \
manager/ploty2-OffScreenPlotManager.$(OBJEXT) \
$(am__objects_11) $(am__objects_12) $(am__objects_13) \
$(am__objects_14) $(am__objects_15)
$(am__objects_12) $(am__objects_13) $(am__objects_14) \
$(am__objects_15) $(am__objects_16)
ploty2_OBJECTS = $(am_ploty2_OBJECTS)
ploty2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
......@@ -576,6 +579,11 @@ MPLCPP = \
view/mpl/widgets/MplCursor.cpp \
view/mpl/widgets/MplLegend.cpp
JSON = \
json/HttpConnection.cpp \
json/LogSender.cpp \
json/RestJsonHttpConnection.cpp
ploty2_SOURCES = \
main.cpp \
manager/RequestDealerManager.cpp \
......@@ -621,7 +629,8 @@ offmplplot_SOURCES = \
$(PROTOBUF) \
$(DATACONT) \
$(MPLCPP) \
$(QT)
$(QT) \
$(JSON)
offmplplot_CPPFLAGS = $(RM_CXXFLAGS) -DOFFSCREEN -DTRACEDEBUG
offmplplot_LDFLAGS = $(RM_LDFLAGS)
......@@ -1023,6 +1032,18 @@ view/qt/offmplplot-QtUpdateThread.$(OBJEXT): view/qt/$(am__dirstamp) \
view/qt/$(DEPDIR)/$(am__dirstamp)
view/qt/offmplplot-moc_QtUpdateThread.$(OBJEXT): \
view/qt/$(am__dirstamp) view/qt/$(DEPDIR)/$(am__dirstamp)
json/$(am__dirstamp):
@$(MKDIR_P) json
@: > json/$(am__dirstamp)
json/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) json/$(DEPDIR)
@: > json/$(DEPDIR)/$(am__dirstamp)
json/offmplplot-HttpConnection.$(OBJEXT): json/$(am__dirstamp) \
json/$(DEPDIR)/$(am__dirstamp)
json/offmplplot-LogSender.$(OBJEXT): json/$(am__dirstamp) \
json/$(DEPDIR)/$(am__dirstamp)
json/offmplplot-RestJsonHttpConnection.$(OBJEXT): \
json/$(am__dirstamp) json/$(DEPDIR)/$(am__dirstamp)
offmplplot$(EXEEXT): $(offmplplot_OBJECTS) $(offmplplot_DEPENDENCIES) $(EXTRA_offmplplot_DEPENDENCIES)
@rm -f offmplplot$(EXEEXT)
......@@ -1174,6 +1195,7 @@ test2$(EXEEXT): $(test2_OBJECTS) $(test2_DEPENDENCIES) $(EXTRA_test2_DEPENDENCIE
mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f datacontainer/*.$(OBJEXT)
-rm -f json/*.$(OBJEXT)
-rm -f manager/*.$(OBJEXT)
-rm -f plot/*.$(OBJEXT)
-rm -f plot/offscreen/*.$(OBJEXT)
......@@ -1204,6 +1226,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@datacontainer/$(DEPDIR)/ploty2-PlotDataContainer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@datacontainer/$(DEPDIR)/ploty2-PropertyPlotDataContainer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@datacontainer/$(DEPDIR)/ploty2-UpdateContainer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@json/$(DEPDIR)/offmplplot-HttpConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@json/$(DEPDIR)/offmplplot-LogSender.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@manager/$(DEPDIR)/mplplot-ServerRequesterManager.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@manager/$(DEPDIR)/mplplot-ServerSubscriberManager.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@manager/$(DEPDIR)/offmplplot-ServerRequesterManager.Po@am__quote@
......@@ -2738,6 +2763,48 @@ view/qt/offmplplot-moc_QtUpdateThread.obj: view/qt/moc_QtUpdateThread.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o view/qt/offmplplot-moc_QtUpdateThread.obj `if test -f 'view/qt/moc_QtUpdateThread.cpp'; then $(CYGPATH_W) 'view/qt/moc_QtUpdateThread.cpp'; else $(CYGPATH_W) '$(srcdir)/view/qt/moc_QtUpdateThread.cpp'; fi`
json/offmplplot-HttpConnection.o: json/HttpConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT json/offmplplot-HttpConnection.o -MD -MP -MF json/$(DEPDIR)/offmplplot-HttpConnection.Tpo -c -o json/offmplplot-HttpConnection.o `test -f 'json/HttpConnection.cpp' || echo '$(srcdir)/'`json/HttpConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) json/$(DEPDIR)/offmplplot-HttpConnection.Tpo json/$(DEPDIR)/offmplplot-HttpConnection.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='json/HttpConnection.cpp' object='json/offmplplot-HttpConnection.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o json/offmplplot-HttpConnection.o `test -f 'json/HttpConnection.cpp' || echo '$(srcdir)/'`json/HttpConnection.cpp
json/offmplplot-HttpConnection.obj: json/HttpConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT json/offmplplot-HttpConnection.obj -MD -MP -MF json/$(DEPDIR)/offmplplot-HttpConnection.Tpo -c -o json/offmplplot-HttpConnection.obj `if test -f 'json/HttpConnection.cpp'; then $(CYGPATH_W) 'json/HttpConnection.cpp'; else $(CYGPATH_W) '$(srcdir)/json/HttpConnection.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) json/$(DEPDIR)/offmplplot-HttpConnection.Tpo json/$(DEPDIR)/offmplplot-HttpConnection.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='json/HttpConnection.cpp' object='json/offmplplot-HttpConnection.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o json/offmplplot-HttpConnection.obj `if test -f 'json/HttpConnection.cpp'; then $(CYGPATH_W) 'json/HttpConnection.cpp'; else $(CYGPATH_W) '$(srcdir)/json/HttpConnection.cpp'; fi`
json/offmplplot-LogSender.o: json/LogSender.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT json/offmplplot-LogSender.o -MD -MP -MF json/$(DEPDIR)/offmplplot-LogSender.Tpo -c -o json/offmplplot-LogSender.o `test -f 'json/LogSender.cpp' || echo '$(srcdir)/'`json/LogSender.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) json/$(DEPDIR)/offmplplot-LogSender.Tpo json/$(DEPDIR)/offmplplot-LogSender.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='json/LogSender.cpp' object='json/offmplplot-LogSender.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o json/offmplplot-LogSender.o `test -f 'json/LogSender.cpp' || echo '$(srcdir)/'`json/LogSender.cpp
json/offmplplot-LogSender.obj: json/LogSender.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT json/offmplplot-LogSender.obj -MD -MP -MF json/$(DEPDIR)/offmplplot-LogSender.Tpo -c -o json/offmplplot-LogSender.obj `if test -f 'json/LogSender.cpp'; then $(CYGPATH_W) 'json/LogSender.cpp'; else $(CYGPATH_W) '$(srcdir)/json/LogSender.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) json/$(DEPDIR)/offmplplot-LogSender.Tpo json/$(DEPDIR)/offmplplot-LogSender.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='json/LogSender.cpp' object='json/offmplplot-LogSender.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o json/offmplplot-LogSender.obj `if test -f 'json/LogSender.cpp'; then $(CYGPATH_W) 'json/LogSender.cpp'; else $(CYGPATH_W) '$(srcdir)/json/LogSender.cpp'; fi`
json/offmplplot-RestJsonHttpConnection.o: json/RestJsonHttpConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT json/offmplplot-RestJsonHttpConnection.o -MD -MP -MF json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Tpo -c -o json/offmplplot-RestJsonHttpConnection.o `test -f 'json/RestJsonHttpConnection.cpp' || echo '$(srcdir)/'`json/RestJsonHttpConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Tpo json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='json/RestJsonHttpConnection.cpp' object='json/offmplplot-RestJsonHttpConnection.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o json/offmplplot-RestJsonHttpConnection.o `test -f 'json/RestJsonHttpConnection.cpp' || echo '$(srcdir)/'`json/RestJsonHttpConnection.cpp
json/offmplplot-RestJsonHttpConnection.obj: json/RestJsonHttpConnection.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT json/offmplplot-RestJsonHttpConnection.obj -MD -MP -MF json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Tpo -c -o json/offmplplot-RestJsonHttpConnection.obj `if test -f 'json/RestJsonHttpConnection.cpp'; then $(CYGPATH_W) 'json/RestJsonHttpConnection.cpp'; else $(CYGPATH_W) '$(srcdir)/json/RestJsonHttpConnection.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Tpo json/$(DEPDIR)/offmplplot-RestJsonHttpConnection.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='json/RestJsonHttpConnection.cpp' object='json/offmplplot-RestJsonHttpConnection.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offmplplot_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o json/offmplplot-RestJsonHttpConnection.obj `if test -f 'json/RestJsonHttpConnection.cpp'; then $(CYGPATH_W) 'json/RestJsonHttpConnection.cpp'; else $(CYGPATH_W) '$(srcdir)/json/RestJsonHttpConnection.cpp'; fi`
ploty2-main.o: main.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ploty2_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ploty2-main.o -MD -MP -MF $(DEPDIR)/ploty2-main.Tpo -c -o ploty2-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ploty2-main.Tpo $(DEPDIR)/ploty2-main.Po
......@@ -3669,6 +3736,8 @@ distclean-generic:
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-rm -f datacontainer/$(DEPDIR)/$(am__dirstamp)
-rm -f datacontainer/$(am__dirstamp)
-rm -f json/$(DEPDIR)/$(am__dirstamp)
-rm -f json/$(am__dirstamp)
-rm -f manager/$(DEPDIR)/$(am__dirstamp)
-rm -f manager/$(am__dirstamp)
-rm -f plot/$(DEPDIR)/$(am__dirstamp)
......@@ -3696,7 +3765,7 @@ clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR) datacontainer/$(DEPDIR) manager/$(DEPDIR) plot/$(DEPDIR) plot/offscreen/$(DEPDIR) plot/property/$(DEPDIR) protobuf/generated/$(DEPDIR) tests/$(DEPDIR) view/mpl/$(DEPDIR) view/mpl/widgets/$(DEPDIR) view/qt/$(DEPDIR)
-rm -rf ./$(DEPDIR) datacontainer/$(DEPDIR) json/$(DEPDIR) manager/$(DEPDIR) plot/$(DEPDIR) plot/offscreen/$(DEPDIR) plot/property/$(DEPDIR) protobuf/generated/$(DEPDIR) tests/$(DEPDIR) view/mpl/$(DEPDIR) view/mpl/widgets/$(DEPDIR) view/qt/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
......@@ -3742,7 +3811,7 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR) datacontainer/$(DEPDIR) manager/$(DEPDIR) plot/$(DEPDIR) plot/offscreen/$(DEPDIR) plot/property/$(DEPDIR) protobuf/generated/$(DEPDIR) tests/$(DEPDIR) view/mpl/$(DEPDIR) view/mpl/widgets/$(DEPDIR) view/qt/$(DEPDIR)
-rm -rf ./$(DEPDIR) datacontainer/$(DEPDIR) json/$(DEPDIR) manager/$(DEPDIR) plot/$(DEPDIR) plot/offscreen/$(DEPDIR) plot/property/$(DEPDIR) protobuf/generated/$(DEPDIR) tests/$(DEPDIR) view/mpl/$(DEPDIR) view/mpl/widgets/$(DEPDIR) view/qt/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef COMMON_BASEHTTPCONNECTION_H_
#define COMMON_BASEHTTPCONNECTION_H_
#include <common/base/BaseTypes.h>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <vector>
#include <chrono>
#include <map>
#include "Error.h"
namespace json {
/**
* Class managing http connections.
*/
template<typename SocketType, typename ConnectionSocketType>
class BaseHttpConnection {
public:
/**
* Constructor.
*/
BaseHttpConnection();
/**
* Destructor. Closes the connection.
*/
virtual ~BaseHttpConnection();
/**
* Sets the timeout.
*/
void setTimeout(const boost::posix_time::time_duration& timeout);
/**
* Opens the connection with url and port.
* throws ConnectionException.
*/
virtual void openUrl(const std::string& url, const std::string& port);
/**
* Opens the connection with ip and port.
* throws ConnectionException.
*/
virtual void openIp(const std::string& ip, const std::string& port);
/**
* Sets the method POST or GET.
*/
void setMethod(const std::string& type);
/**
* Sets the path.
* For instance with http://www.example.com:8080/resources/image
* url = www.example.com, port = 8080, path = /resources/image
*/
void setPath(const std::string& path);
/**
* Sets the property.
* For example User-Agent.
*/
void setProperty(const std::string& propertyName, const std::string& value);
/**
* Sets the data.
*/
void setData(const std::string& data);
/**
* Sends the message. Waits until response is returned by the client.
* If verbose is true, request and reponse headers are printed.
* throws RequestException.
*/
std::string send(bool verbose = false);
protected:
void checkDeadline();
bool connectToEndpoint(const boost::asio::ip::tcp::endpoint& endpoint, boost::system::error_code& errorCode);
virtual void createSockets() = 0;
virtual SocketType * readWriteSocket() = 0;
virtual ConnectionSocketType * connectionSocket() = 0;
boost::asio::io_service m_ioService;
boost::asio::deadline_timer m_deadline;
boost::posix_time::time_duration m_timeout;
std::string m_url;
std::string m_port;
std::string m_methodType;
std::string m_path;
std::vector<std::pair<std::string, std::string> > m_properties;
std::string m_data;
};
template<typename SocketType, typename ConnectionSocketType>
BaseHttpConnection<SocketType, ConnectionSocketType>::BaseHttpConnection() :
m_deadline(m_ioService),
m_timeout(boost::posix_time::seconds(10)), m_methodType("GET") {
// no deadline is required until the first socket operation is started
// we set the deadline to positive infinity so that the actor takes no action
// until a specific deadline is set
m_deadline.expires_at(boost::posix_time::pos_infin);
// start the persistent actor that checks for deadline expiry.
checkDeadline();
}
template<typename SocketType, typename ConnectionSocketType>
BaseHttpConnection<SocketType, ConnectionSocketType>::~BaseHttpConnection() {
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::checkDeadline() {
// check whether the deadline has passed
// we compare the deadline against the current time since a new asynchronous operation may have moved the
// deadline before this actor had a chance to run
if (m_deadline.expires_at() <= boost::asio::deadline_timer::traits_type::now()) {
// the deadline has passed
// the socket is closed so that any outstanding asynchronous operations are cancelled
// this allows the blocked connect(), read_line() or write_line() functions to return
if (connectionSocket() != 0) {
connectionSocket()->close();
}
// there is no longer an active deadline
// the expiry is set to positive infinity so that the actor takes no action until a new deadline is set
m_deadline.expires_at(boost::posix_time::pos_infin);
}
// put the actor back to sleep
m_deadline.async_wait(boost::lambda::bind(&BaseHttpConnection<SocketType, ConnectionSocketType>::checkDeadline, this));
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::setTimeout(const boost::posix_time::time_duration& timeout) {
m_timeout = timeout;
}
template<typename SocketType, typename ConnectionSocketType>
bool BaseHttpConnection<SocketType, ConnectionSocketType>::connectToEndpoint(const boost::asio::ip::tcp::endpoint& endpoint, boost::system::error_code& errorCode) {
// we may have an open socket from a previous connection attempt
// this socket cannot be reused, so we must close it before trying to connect again
connectionSocket()->close();
// set up the variable that receives the result of the asynchronous operation
// the error code is set to would_block to signal that the operation is incomplete
// asio guarantees that its asynchronous operations will never fail with would_block, so any other value in ec indicates completion
errorCode = boost::asio::error::would_block;
// start the asynchronous operation itself
// the boost::lambda function object is used as a callback and will update the errorCode variable when the operation completes
// the blocking_udp_client.cpp example shows how you can use boost::bind rather than boost::lambda
connectionSocket()->async_connect(endpoint, boost::lambda::var(errorCode) = boost::lambda::_1);
// block until the asynchronous operation has completed
do {
m_ioService.run_one();
} while (errorCode == boost::asio::error::would_block);
// determine whether a connection was successfully established
// the deadline actor may have had a chance to run and close our socket, even though the connect operation notionally succeeded
// therefore we must check whether the socket is still open before deciding that the we were successful
if (!errorCode && connectionSocket()->is_open()) {
return true;
}
return false;
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::openUrl(const std::string& url, const std::string& port) {
m_url = url;
m_port = port;
try {
// get a list of endpoints corresponding to the server name.
boost::asio::ip::tcp::resolver resolver(m_ioService);
boost::asio::ip::tcp::resolver::query query(url, port);
boost::asio::ip::tcp::resolver::iterator endpointIterator = resolver.resolve(query);
createSockets();
// set a deadline for the asynchronous operation
// the host name may resolve to multiple endpoints, and this function tries to connect to each one in turn
// setting the deadline here means it applies to the entire sequence
m_deadline.expires_from_now(m_timeout);
boost::system::error_code errorCode;
// try each endpoint until we successfully establish a connection
for (; endpointIterator != boost::asio::ip::tcp::resolver::iterator(); ++endpointIterator) {
if (connectToEndpoint(endpointIterator->endpoint(), errorCode)) {
// connected
return;
}
}
// return with exception
throw boost::system::system_error(errorCode ? errorCode : boost::asio::error::host_not_found);
} catch (const std::exception& e) {
throw Error("BaseHttpConnection", "openUrl", e.what());
} catch (...) {
throw Error("BaseHttpConnection", "openUrl", "unknown error");
}
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::openIp(const std::string& ip, const std::string& port) {
m_url = ip;
m_port = port;
try {
createSockets();
// set a deadline for the asynchronous operation
m_deadline.expires_from_now(m_timeout);
boost::system::error_code errorCode;
// use endpoint
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(ip), boost::lexical_cast<unsigned short>(port));
if (connectToEndpoint(endpoint, errorCode)) {
// connected
return;
}
// return with exception
throw boost::system::system_error(errorCode ? errorCode : boost::asio::error::host_not_found);
} catch (const std::exception& e) {
throw Error("BaseHttpConnection", "openIp", e.what());
} catch (...) {
throw Error("BaseHttpConnection", "openUrl", "unknown error");
}
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::setMethod(const std::string& type) {
m_methodType = type;
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::setPath(const std::string& path) {
m_path = path;
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::setProperty(const std::string& propertyName, const std::string& value) {
m_properties.push_back(make_pair(propertyName, value));
}
template<typename SocketType, typename ConnectionSocketType>
void BaseHttpConnection<SocketType, ConnectionSocketType>::setData(const std::string& data) {
m_data = data;
}
template<typename SocketType, typename ConnectionSocketType>
std::string BaseHttpConnection<SocketType, ConnectionSocketType>::send(bool verbose) {
if (readWriteSocket() == 0) {
throw Error("BaseHttpConnection", "send", "socket is not initialised");
}
try {
std::stringstream os;
os << m_methodType << " " << m_path << " HTTP/1.1\r\n";
os << "Host: " << m_url << ":" << m_port << "\n";
for (std::vector<std::pair<std::string, std::string> >::const_iterator p = m_properties.begin(); p != m_properties.end(); ++p) {
os << p->first << ": " << p->second << "\n";
}
os << "\n" << m_data << "\n";
if (verbose) {
std::cout << "request:" << std::endl << os.str() << std::endl;
}
boost::asio::streambuf request;
std::ostream requestStream(&request);
requestStream << os.str();
// set a deadline for the asynchronous operation
m_deadline.expires_from_now(m_timeout);
boost::system::error_code errorCode = boost::asio::error::would_block;
// send the request.
boost::asio::async_write(*readWriteSocket(), request, boost::lambda::var(errorCode) = boost::lambda::_1);
do {
m_ioService.run_one();
} while (errorCode == boost::asio::error::would_block);
if (errorCode) {
// return with exception
throw boost::system::system_error(errorCode);
}
// read the response status line.
// the response streambuf will automatically grow to accommodate the entire line.
// the growth may be limited by passing
// a maximum size to the streambuf constructor.
boost::asio::streambuf response;
// set a deadline for the asynchronous operation
m_deadline.expires_from_now(m_timeout);
errorCode = boost::asio::error::would_block;
boost::asio::async_read_until(*readWriteSocket(), response, "\r\n", boost::lambda::var(errorCode) = boost::lambda::_1);
do {
m_ioService.run_one();
} while (errorCode == boost::asio::error::would_block);
if (errorCode) {
// return with exception
throw Error("BaseHttpConnection", "send", errorCode);
}
// check that response is OK.
std::istream responseStream(&response);
std::string httpVersion;
responseStream >> httpVersion;
unsigned int statusCode;
responseStream >> statusCode;
std::string statusMessage;
getline(responseStream, statusMessage);
if (!responseStream || httpVersion.substr(0, 5) != "HTTP/") {
throw Error("BaseHttpConnection", "send", "invalid response");
}
// set a deadline for the asynchronous operation
m_deadline.expires_from_now(m_timeout);
errorCode = boost::asio::error::would_block;
// read the response headers, which are terminated by a blank line.
boost::asio::async_read_until(*readWriteSocket(), response, "\r\n\r\n", boost::lambda::var(errorCode) = boost::lambda::_1);
do {
m_ioService.run_one();
} while (errorCode == boost::asio::error::would_block);
if (errorCode) {
// return with exception
throw boost::system::system_error(errorCode);
}