casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
grpcPlotMSAdaptor.qo.h
Go to the documentation of this file.
1 //# grpcPlotMSAdaptor.h.h: provides viewer services via grpc
2 //# Copyright (C) 2019
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef GRPCPLOTMSADAPTOR_H_
29 #define GRPCPLOTMSADAPTOR_H_
30 #include <grpc++/grpc++.h>
32 #include <casagrpc/protos/plotms.grpc.pb.h>
33 #include <casagrpc/protos/shutdown.grpc.pb.h>
36 #include <QObject>
37 #include <map>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41  class grpcPMSShutdown : public QObject, public ::casatools::rpc::Shutdown::Service {
42 
43  Q_OBJECT //# Allows slot/signal definition. Must only occur in
44  //# implement/.../*.h files
45  public:
47  ::grpc::Status now(::grpc::ServerContext*, const ::google::protobuf::Empty*, ::google::protobuf::Empty*);
48 
49  signals:
50  void exit_now( );
51 
52  private:
54  };
55 
56  class grpcPlotMS : public QObject, public ::rpc::plotms::app::Service {
57 
58  Q_OBJECT //# Allows slot/signal definition. Must only occur in
59  //# implement/.../*.h files
60  public:
61  constexpr static char APP_SERVER_SWITCH[] = "--server";
62  grpcPlotMS( PlotEngine *pe );
63  void set_plotter( PlotMSPlotter *plt );
64 
65  ::grpc::Status getPlotMSPid( ::grpc::ServerContext *context,
66  const ::google::protobuf::Empty*,
67  ::rpc::plotms::Pid *reply );
68  ::grpc::Status setShowGui( ::grpc::ServerContext *context,
69  const ::rpc::plotms::Toggle *req,
70  ::google::protobuf::Empty* );
71  ::grpc::Status setGridSize( ::grpc::ServerContext *context,
72  const ::rpc::plotms::GridSize *req,
73  ::google::protobuf::Empty* );
74  ::grpc::Status isDrawing( ::grpc::ServerContext *context,
75  const ::google::protobuf::Empty*,
76  ::rpc::plotms::Toggle *reply );
77  ::grpc::Status clearPlots( ::grpc::ServerContext *context,
78  const ::google::protobuf::Empty*,
79  ::google::protobuf::Empty* );
80  ::grpc::Status setPlotMSFilename( ::grpc::ServerContext *context,
81  const ::rpc::plotms::SetVis *req,
82  ::google::protobuf::Empty* );
83  ::grpc::Status setPlotAxes( ::grpc::ServerContext *context,
84  const ::rpc::plotms::SetAxes *req,
85  ::google::protobuf::Empty* );
86  ::grpc::Status setShowAtm( ::grpc::ServerContext *context,
87  const ::rpc::plotms::SetToggle *req,
88  ::google::protobuf::Empty* );
89  ::grpc::Status setShowTsky( ::grpc::ServerContext *context,
90  const ::rpc::plotms::SetToggle *req,
91  ::google::protobuf::Empty* );
92  ::grpc::Status setPlotMSSelection( ::grpc::ServerContext *context,
93  const ::rpc::plotms::SetSelection *req,
94  ::google::protobuf::Empty* );
95  ::grpc::Status setPlotMSAveraging( ::grpc::ServerContext *context,
96  const ::rpc::plotms::SetAveraging *req,
97  ::google::protobuf::Empty* );
98  ::grpc::Status setPlotMSTransformations( ::grpc::ServerContext *context,
99  const ::rpc::plotms::SetTransform *req,
100  ::google::protobuf::Empty* );
101  ::grpc::Status setPlotMSCalibration( ::grpc::ServerContext *context,
102  const ::rpc::plotms::SetCalibration *req,
103  ::google::protobuf::Empty* );
104  ::grpc::Status setFlagExtension( ::grpc::ServerContext *context,
105  const ::rpc::plotms::SetFlagExtension *req,
106  ::google::protobuf::Empty* );
107  ::grpc::Status setExportRange( ::grpc::ServerContext *context,
108  const ::rpc::plotms::ExportRange *req,
109  ::google::protobuf::Empty* );
110  ::grpc::Status setPlotMSIterate( ::grpc::ServerContext *context,
111  const ::rpc::plotms::SetIterate *req,
112  ::google::protobuf::Empty* );
113  ::grpc::Status setColorAxis( ::grpc::ServerContext *context,
114  const ::rpc::plotms::SetString *req,
115  ::google::protobuf::Empty* );
116  ::grpc::Status setSymbol( ::grpc::ServerContext *context,
117  const ::rpc::plotms::SetSymbol *req,
118  ::google::protobuf::Empty* );
119  ::grpc::Status setFlaggedSymbol( ::grpc::ServerContext *context,
120  const ::rpc::plotms::SetSymbol *req,
121  ::google::protobuf::Empty* );
122  ::grpc::Status setConnect( ::grpc::ServerContext *context,
123  const ::rpc::plotms::SetConnect *req,
124  ::google::protobuf::Empty* );
125  ::grpc::Status setLegend( ::grpc::ServerContext *context,
126  const ::rpc::plotms::SetLegend *req,
127  ::google::protobuf::Empty* );
128  ::grpc::Status setTitle( ::grpc::ServerContext *context,
129  const ::rpc::plotms::SetString *req,
130  ::google::protobuf::Empty* );
131  ::grpc::Status setTitleFont( ::grpc::ServerContext *context,
132  const ::rpc::plotms::SetInt *req,
133  ::google::protobuf::Empty* );
134  ::grpc::Status setXAxisFont( ::grpc::ServerContext *context,
135  const ::rpc::plotms::SetInt *req,
136  ::google::protobuf::Empty* );
137  ::grpc::Status setYAxisFont( ::grpc::ServerContext *context,
138  const ::rpc::plotms::SetInt *req,
139  ::google::protobuf::Empty* );
140  ::grpc::Status setXAxisLabel( ::grpc::ServerContext *context,
141  const ::rpc::plotms::SetString *req,
142  ::google::protobuf::Empty* );
143  ::grpc::Status setYAxisLabel( ::grpc::ServerContext *context,
144  const ::rpc::plotms::SetString *req,
145  ::google::protobuf::Empty* );
146  ::grpc::Status setGridParams( ::grpc::ServerContext *context,
147  const ::rpc::plotms::SetGrid *req,
148  ::google::protobuf::Empty* );
149  ::grpc::Status setXRange( ::grpc::ServerContext *context,
150  const ::rpc::plotms::SetRange *req,
151  ::google::protobuf::Empty* );
152  ::grpc::Status setYRange( ::grpc::ServerContext *context,
153  const ::rpc::plotms::SetRange *req,
154  ::google::protobuf::Empty* );
155  ::grpc::Status setPlotMSPageHeaderItems( ::grpc::ServerContext *context,
156  const ::rpc::plotms::SetString *req,
157  ::google::protobuf::Empty* );
158  ::grpc::Status save( ::grpc::ServerContext *context,
159  const ::rpc::plotms::Save *req,
160  ::google::protobuf::Empty* );
161  ::grpc::Status update( ::grpc::ServerContext *context,
162  const ::google::protobuf::Empty *req,
163  ::google::protobuf::Empty* );
164 
165  protected:
166  // update parameters
167  void clear_parameters( );
168  void update_parameters( );
169  void update_parameters(int index);
170  void populate_selection( const ::rpc::plotms::SetSelection &req, PlotMSSelection &sel );
172  std::map<std::pair<int,int>,PlotMSPlotParameters::Group*> param_groups;
180  PMS_PP_MSData *ppdata(int index);
181  PMS_PP_Cache *ppcache(int index);
182  PMS_PP_Axes *ppaxes(int index);
183  PMS_PP_Iteration *ppiter(int index);
184  PMS_PP_Display *ppdisp(int index);
185  PMS_PP_Canvas *ppcan(int index);
186  PMS_PP_PageHeader *pphead(int index);
187  void qtGO( std::function<void()> );
188 
189  signals:
190  void new_op( );
191 
192  private:
196  bool invalid_index( int );
199  };
200 
202  public:
204  plotms_service(new grpcPlotMS(v)),
206 
207  std::string uri;
208 
209  std::unique_ptr<grpc::Server> server;
210 
211  std::unique_ptr<grpcPlotMS> plotms_service;
212  std::unique_ptr<grpcPMSShutdown> shutdown_service;
213 
215  if (getenv("GRPC_DEBUG")) {
216  fprintf(stdout, "stopping grpc server...\n");
217  fflush(stdout);
218  }
219  if ( server ) server->Shutdown( );
220  }
221  };
222 }
223 #endif
::grpc::Status setFlaggedSymbol(::grpc::ServerContext *context, const ::rpc::plotms::SetSymbol *req,::google::protobuf::Empty *)
void update_parameters()
std::unique_ptr< grpc::Server > server
PMS_PP_Canvas * sys_ppcan(PlotMSPlotParameters *sp)
::grpc::Status setFlagExtension(::grpc::ServerContext *context, const ::rpc::plotms::SetFlagExtension *req,::google::protobuf::Empty *)
::grpc::Status setPlotAxes(::grpc::ServerContext *context, const ::rpc::plotms::SetAxes *req,::google::protobuf::Empty *)
PMS_PP_PageHeader * sys_pphead(PlotMSPlotParameters *sp)
::grpc::Status setColorAxis(::grpc::ServerContext *context, const ::rpc::plotms::SetString *req,::google::protobuf::Empty *)
::grpc::Status setTitle(::grpc::ServerContext *context, const ::rpc::plotms::SetString *req,::google::protobuf::Empty *)
::grpc::Status setGridParams(::grpc::ServerContext *context, const ::rpc::plotms::SetGrid *req,::google::protobuf::Empty *)
::grpc::Status clearPlots(::grpc::ServerContext *context, const ::google::protobuf::Empty *,::google::protobuf::Empty *)
grpcPMSShutdown(PlotEngine *qtv)
::grpc::Status setSymbol(::grpc::ServerContext *context, const ::rpc::plotms::SetSymbol *req,::google::protobuf::Empty *)
PMS_PP_Display * ppdisp(int index)
::grpc::Status setLegend(::grpc::ServerContext *context, const ::rpc::plotms::SetLegend *req,::google::protobuf::Empty *)
::grpc::Status setPlotMSIterate(::grpc::ServerContext *context, const ::rpc::plotms::SetIterate *req,::google::protobuf::Empty *)
Subclass of PlotMSPlotParameters::Group to handle display parameters.
::grpc::Status setPlotMSSelection(::grpc::ServerContext *context, const ::rpc::plotms::SetSelection *req,::google::protobuf::Empty *)
PMS_PP_PageHeader * pphead(int index)
::grpc::Status isDrawing(::grpc::ServerContext *context, const ::google::protobuf::Empty *,::rpc::plotms::Toggle *reply)
Specifies an casacore::MS selection.
::grpc::Status getPlotMSPid(::grpc::ServerContext *context, const ::google::protobuf::Empty *,::rpc::plotms::Pid *reply)
void release_notification(PlotMSPlotParameters *sp)
Parameters for a PlotMSPlot.
::grpc::Status update(::grpc::ServerContext *context, const ::google::protobuf::Empty *req,::google::protobuf::Empty *)
::grpc::Status setPlotMSPageHeaderItems(::grpc::ServerContext *context, const ::rpc::plotms::SetString *req,::google::protobuf::Empty *)
Subclass of PlotMSPlotParameters::Group to handle canvas parameters.
void hold_notification(PlotMSPlotParameters *sp)
PlotMSPlotter * plotter_
::grpc::Status now(::grpc::ServerContext *, const ::google::protobuf::Empty *,::google::protobuf::Empty *)
::grpc::Status setGridSize(::grpc::ServerContext *context, const ::rpc::plotms::GridSize *req,::google::protobuf::Empty *)
::grpc::Status setShowAtm(::grpc::ServerContext *context, const ::rpc::plotms::SetToggle *req,::google::protobuf::Empty *)
::grpc::Status setXAxisFont(::grpc::ServerContext *context, const ::rpc::plotms::SetInt *req,::google::protobuf::Empty *)
PMS_PP_Axes * sys_ppaxes(PlotMSPlotParameters *sp)
PMS_PP_MSData * sys_ppdata(PlotMSPlotParameters *sp)
Subclass of PlotMSPlotParameters::Group to handle page header parameters.
PMS_PP_Iteration * sys_ppiter(PlotMSPlotParameters *sp)
::grpc::Status setXAxisLabel(::grpc::ServerContext *context, const ::rpc::plotms::SetString *req,::google::protobuf::Empty *)
void set_plotter(PlotMSPlotter *plt)
PMS_PP_Cache * ppcache(int index)
::grpc::Status setConnect(::grpc::ServerContext *context, const ::rpc::plotms::SetConnect *req,::google::protobuf::Empty *)
Subclass of PlotMSPlotParameters::Group to handle subparameters for casacore::MS data.
::grpc::Status setPlotMSTransformations(::grpc::ServerContext *context, const ::rpc::plotms::SetTransform *req,::google::protobuf::Empty *)
::grpc::Status setShowGui(::grpc::ServerContext *context, const ::rpc::plotms::Toggle *req,::google::protobuf::Empty *)
::grpc::Status setYRange(::grpc::ServerContext *context, const ::rpc::plotms::SetRange *req,::google::protobuf::Empty *)
Subclass of PlotMSPlotParameters::Group to handle axes parameters.
::grpc::Status setExportRange(::grpc::ServerContext *context, const ::rpc::plotms::ExportRange *req,::google::protobuf::Empty *)
void qtGO(std::function< void()>)
::grpc::Status setTitleFont(::grpc::ServerContext *context, const ::rpc::plotms::SetInt *req,::google::protobuf::Empty *)
std::unique_ptr< grpcPlotMS > plotms_service
::grpc::Status setShowTsky(::grpc::ServerContext *context, const ::rpc::plotms::SetToggle *req,::google::protobuf::Empty *)
static constexpr char APP_SERVER_SWITCH[]
bool invalid_index(int)
void clear_parameters()
update parameters
grpcPlotMS(PlotEngine *pe)
PMS_PP_Iteration * ppiter(int index)
::grpc::Status setPlotMSAveraging(::grpc::ServerContext *context, const ::rpc::plotms::SetAveraging *req,::google::protobuf::Empty *)
std::unique_ptr< grpcPMSShutdown > shutdown_service
::grpc::Status setYAxisLabel(::grpc::ServerContext *context, const ::rpc::plotms::SetString *req,::google::protobuf::Empty *)
Subclass of PlotMSPlotParameters::Group to handle cache parameters.
::grpc::Status setPlotMSFilename(::grpc::ServerContext *context, const ::rpc::plotms::SetVis *req,::google::protobuf::Empty *)
Subclass of PlotMSPlotParameters::Group to handle iteration parameters.
PlotMSPlotParameters * get_sysparams(int index)
std::map< std::pair< int, int >, PlotMSPlotParameters::Group * > param_groups
PMS_PP_Display * sys_ppdisp(PlotMSPlotParameters *sp)
High(ish)-level plotter class that manages the GUI (semi-) transparently to the rest of PlotMS...
PMS_PP_MSData * ppdata(int index)
::grpc::Status save(::grpc::ServerContext *context, const ::rpc::plotms::Save *req,::google::protobuf::Empty *)
Abstracts the interface DBUS uses to talk to the main PlotMS application.
Definition: PlotEngine.h:45
PMS_PP_Cache * sys_ppcache(PlotMSPlotParameters *sp)
void populate_selection(const ::rpc::plotms::SetSelection &req, PlotMSSelection &sel)
PMS_PP_Canvas * ppcan(int index)
::grpc::Status setYAxisFont(::grpc::ServerContext *context, const ::rpc::plotms::SetInt *req,::google::protobuf::Empty *)
::grpc::Status setXRange(::grpc::ServerContext *context, const ::rpc::plotms::SetRange *req,::google::protobuf::Empty *)
PMS_PP_Axes * ppaxes(int index)
::grpc::Status setPlotMSCalibration(::grpc::ServerContext *context, const ::rpc::plotms::SetCalibration *req,::google::protobuf::Empty *)
T getenv(const char *name, const T defaultVal)