Open source Very Long Baseline Interferometry
OpenVLBI
vlbi_server.h
1 /* OpenVLBI - Open Source Very Long Baseline Interferometry
2 * Copyright © 2017-2022 Ilia Platone
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef VLBI_SERVER_H
20 #define VLBI_SERVER_H
21 
22 #include <vlbi.h>
23 #include <dsp.h>
24 
25 namespace VLBI
26 {
27 
45 typedef enum
46 {
56 
60 class Server
61 {
62  public:
66  Server(void);
70  virtual ~Server(void);
71 
77  virtual int Init(int argc, char** argv)
78  {
79  (void)argc;
80  (void)argv;
81  return 1;
82  }
83 
87  virtual void Parse(void);
88 
93  void AddContext(const char *name);
94 
99  void DelContext(const char *name);
100 
105  void SetContext(const char *name);
106 
112 
117  inline char* CurrentContext(void)
118  {
119  return context;
120  }
121 
128  void AddModel(const char *name, char *format, char *b64);
129 
135  dsp_stream_p GetModel(const char *name);
136 
143  char* GetModel(const char *name, char *format);
144 
149  void DelModel(const char *name);
150 
156  int GetModels(char** names);
157 
163  void AddNode(const char *name, char *b64);
164 
170  void AddNodes(const char *name, char *b64);
171 
181  void AddNode(const char *name, dsp_location *locations, void *buf, int len, timespec starttime, bool geo);
182 
187  void DelNode(const char *name);
188 
194  void Plot(const char *name, int flags);
195 
202  void Idft(const char *name, const char *magnitude, const char *phase);
203 
210  void Dft(const char *name, const char *magnitude, const char *phase);
211 
218  void Mask(const char *name, const char *model, const char *mask);
219 
226  void Stack(const char *name, const char *model1, const char *model2);
227 
234  void Diff(const char *name, const char *model1, const char *model2);
235 
240  void Shift(const char *name);
241 
246  inline virtual void SetRa(double value)
247  {
248  Ra = value;
249  }
250 
255  inline virtual void SetDec(double value)
256  {
257  Dec = value;
258  }
259 
264  inline virtual void SetFreq(double value)
265  {
266  Freq = value;
267  }
268 
273  inline virtual void SetSampleRate(double value)
274  {
275  SampleRate = value;
276  }
277 
282  inline virtual void SetBps(int value)
283  {
284  Bps = value;
285  }
286 
291  inline virtual void SetWidth(int value)
292  {
293  w = value;
294  }
295 
300  inline virtual void SetHeight(int value)
301  {
302  h = value;
303  }
304 
309  inline double GetRa(void)
310  {
311  return Ra;
312  }
313 
318  inline double GetDec(void)
319  {
320  return Dec;
321  }
322 
327  inline double GetFreq(void)
328  {
329  return Freq;
330  }
331 
336  inline double GetSampleRate(void)
337  {
338  return SampleRate;
339  }
340 
345  inline double GetBps(void)
346  {
347  return Bps;
348  }
349 
354  inline double GetWidth(void)
355  {
356  return w;
357  }
358 
363  inline double GetHeight(void)
364  {
365  return h;
366  }
367 
372  void SetInput(FILE* in)
373  {
374  input = in;
375  }
376 
381  inline FILE* GetInput()
382  {
383  return input;
384  }
385 
390  void SetOutput(FILE* out)
391  {
392  output = out;
393  }
394 
399  inline FILE* GetOutput()
400  {
401  return output;
402  }
403 
408  inline void setDelegate(vlbi_func2_t func)
409  {
410  delegate = func;
411  }
412 
417  inline vlbi_func2_t getDelegate() { return delegate; }
418 
419  private:
420  vlbi_func2_t delegate;
421  double Ra;
422  double Dec;
423  double Freq;
424  double SampleRate;
425  int Bps;
426  int w;
427  int h;
428  FILE *input, *output;
429  char *context;
430 };
431 extern VLBI::Server *server;
433 };
434 
435 #endif //VLBI_SERVER_H
Inherit this class to create an OpenVLBI server application.
Definition: vlbi_server.h:61
double GetBps(void)
Get the bytes per sample.
Definition: vlbi_server.h:345
void AddNode(const char *name, dsp_location *locations, void *buf, int len, timespec starttime, bool geo)
Create a new node from a its raw data, give it a name and add it to the current context.
double GetFreq(void)
Get the current frequency.
Definition: vlbi_server.h:327
void AddContext(const char *name)
Add a new OpenVLBI context by giving it a name. VLBI::Server has an internal context collection.
void DelNode(const char *name)
Delete from the current context an existing node by name.
void Mask(const char *name, const char *model, const char *mask)
Mask a model with another model by multiplication.
double GetRa(void)
Get the current right ascension coordinate.
Definition: vlbi_server.h:309
void DelContext(const char *name)
Delete an existing OpenVLBI context by name.
void Dft(const char *name, const char *magnitude, const char *phase)
Save the magnitude and phase to new models obtained by the fourier transform of the model passed.
void Idft(const char *name, const char *magnitude, const char *phase)
Obtain an inverse fourier transform from the magnitude and phase models passed.
vlbi_context GetContext(void)
Obtain the current OpenVLBI context object.
Server(void)
Constructor, initializes all the internal variables.
vlbi_func2_t getDelegate()
Get the current delegate function.
Definition: vlbi_server.h:417
virtual void SetSampleRate(double value)
Set the sampling frequency, do this before calling Plot()
Definition: vlbi_server.h:273
void setDelegate(vlbi_func2_t func)
Set the delegate function.
Definition: vlbi_server.h:408
void AddModel(const char *name, char *format, char *b64)
Create a new model from a picture, give it a name and add it to the current context.
void Shift(const char *name)
Shift a model by its dimension in-place.
char * CurrentContext(void)
Obtain the name current OpenVLBI context.
Definition: vlbi_server.h:117
void Diff(const char *name, const char *model1, const char *model2)
Diff a model with another model.
virtual ~Server(void)
Destructor, destroys this object.
virtual void SetHeight(int value)
Set the plot height, do this before calling Plot()
Definition: vlbi_server.h:300
void SetContext(const char *name)
Set the current OpenVLBI context by passing its name.
virtual int Init(int argc, char **argv)
Called immediately after main(), can be overriden to add your custom arguments.
Definition: vlbi_server.h:77
double GetDec(void)
Get the current declination coordinate.
Definition: vlbi_server.h:318
void DelModel(const char *name)
Delete from the current context an existing model by name.
double GetHeight(void)
Get the plot height.
Definition: vlbi_server.h:363
double GetWidth(void)
Get the plot width.
Definition: vlbi_server.h:354
char * GetModel(const char *name, char *format)
Obtain the base64 encoded file buffer of a model by passing its name.
virtual void SetRa(double value)
Set the target right ascension coordinate, do this before calling Plot()
Definition: vlbi_server.h:246
FILE * GetOutput()
Get the output stream.
Definition: vlbi_server.h:399
void Plot(const char *name, int flags)
Plot the current observation into a new model.
void AddNode(const char *name, char *b64)
Create a new node from a monodimensional image FITS file, give it a name and add it to the current co...
virtual void SetBps(int value)
Set the bytes per sample, do this before calling AddNode()
Definition: vlbi_server.h:282
void Stack(const char *name, const char *model1, const char *model2)
Stack a model with another model.
void AddNodes(const char *name, char *b64)
Create as many nodes as the rows number of an SDFITS file, give it a name and add it to the current c...
virtual void SetWidth(int value)
Set the plot width, do this before calling Plot()
Definition: vlbi_server.h:291
void SetInput(FILE *in)
Set the input stream.
Definition: vlbi_server.h:372
double GetSampleRate(void)
Get the current sample rate.
Definition: vlbi_server.h:336
void SetOutput(FILE *out)
Set the output stream.
Definition: vlbi_server.h:390
virtual void SetDec(double value)
Set the target declination coordinate, do this before calling Plot()
Definition: vlbi_server.h:255
dsp_stream_p GetModel(const char *name)
Obtain the dsp_stream_p object of a model by passing its name.
FILE * GetInput()
Get the input stream.
Definition: vlbi_server.h:381
virtual void SetFreq(double value)
Set the frequency observed, do this before calling Plot()
Definition: vlbi_server.h:264
virtual void Parse(void)
main() creates a loop that calls Parse(), you can use this one, which uses the standard syntax or ove...
int GetModels(char **names)
Get the names of all the models of the current context.
vlbi_plot_flags
Flags that characterize a plot.
Definition: vlbi_server.h:46
@ plot_flags_uv_coverage
This will fill all baselines projected pixels with ones.
Definition: vlbi_server.h:50
@ plot_flags_moving_baseline
This indicates that the nodes have a positional stream companion.
Definition: vlbi_server.h:48
@ plot_flags_synced
This indicates that the nodes are synced already and no delay calculation will be done.
Definition: vlbi_server.h:52
@ plot_flags_custom_delegate
This will use a custom visibility delegate.
Definition: vlbi_server.h:54
double(* vlbi_func2_t)(double, double)
The delegate function type to pass to vlbi_plot_uv_plane.
Definition: vlbi.h:337
void * vlbi_context
the OpenVLBI context object type
Definition: vlbi.h:340
Contains a set of informations and data relative to a buffer and how to use it.
Definition: dsp.h:362
The location type.
Definition: dsp.h:327