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 
242  void Convolute(const char *name, const char *model1, const char *model2);
243 
250  void LowPass(const char *name, const char *node, double freq);
251 
258  void HighPass(const char *name, const char *node, double freq);
259 
267  void BandPass(const char *name, const char *node, double lofreq, double hifreq);
268 
276  void BandReject(const char *name, const char *node, double lofreq, double hifreq);
277 
282  void Shift(const char *name);
283 
288  inline virtual void SetRa(double value)
289  {
290  Ra = value;
291  }
292 
297  inline virtual void SetDec(double value)
298  {
299  Dec = value;
300  }
301 
306  inline virtual void SetFreq(double value)
307  {
308  Freq = value;
309  }
310 
315  inline virtual void SetSampleRate(double value)
316  {
317  SampleRate = value;
318  }
319 
324  inline virtual void SetBps(int value)
325  {
326  Bps = value;
327  }
328 
333  inline virtual void SetWidth(int value)
334  {
335  w = value;
336  }
337 
342  inline virtual void SetHeight(int value)
343  {
344  h = value;
345  }
346 
351  inline double GetRa(void)
352  {
353  return Ra;
354  }
355 
360  inline double GetDec(void)
361  {
362  return Dec;
363  }
364 
369  inline double GetFreq(void)
370  {
371  return Freq;
372  }
373 
378  inline double GetSampleRate(void)
379  {
380  return SampleRate;
381  }
382 
387  inline double GetBps(void)
388  {
389  return Bps;
390  }
391 
396  inline double GetWidth(void)
397  {
398  return w;
399  }
400 
405  inline double GetHeight(void)
406  {
407  return h;
408  }
409 
414  void SetInput(FILE* in)
415  {
416  input = in;
417  }
418 
423  inline FILE* GetInput()
424  {
425  return input;
426  }
427 
432  void SetOutput(FILE* out)
433  {
434  output = out;
435  }
436 
441  inline FILE* GetOutput()
442  {
443  return output;
444  }
445 
450  inline void setDelegate(vlbi_func2_t func)
451  {
452  delegate = func;
453  }
454 
459  inline vlbi_func2_t getDelegate() { return delegate; }
460 
461  private:
462  vlbi_func2_t delegate;
463  double Ra;
464  double Dec;
465  double Freq;
466  double SampleRate;
467  int Bps;
468  int w;
469  int h;
470  FILE *input, *output;
471  char *context;
472 };
473 extern VLBI::Server *server;
475 };
476 
477 #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:387
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.
void HighPass(const char *name, const char *node, double freq)
Apply a high pass filter on a node buffer.
double GetFreq(void)
Get the current frequency.
Definition: vlbi_server.h:369
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:351
void BandReject(const char *name, const char *node, double lofreq, double hifreq)
Apply a band reject filter on a node buffer.
void LowPass(const char *name, const char *node, double freq)
Apply a low pass filter on a node buffer.
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.
void Convolute(const char *name, const char *model1, const char *model2)
Convolute a model with a convolution matrix model.
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:459
virtual void SetSampleRate(double value)
Set the sampling frequency, do this before calling Plot()
Definition: vlbi_server.h:315
void setDelegate(vlbi_func2_t func)
Set the delegate function.
Definition: vlbi_server.h:450
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:342
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:360
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:405
double GetWidth(void)
Get the plot width.
Definition: vlbi_server.h:396
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:288
FILE * GetOutput()
Get the output stream.
Definition: vlbi_server.h:441
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:324
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:333
void SetInput(FILE *in)
Set the input stream.
Definition: vlbi_server.h:414
void BandPass(const char *name, const char *node, double lofreq, double hifreq)
Apply a band pass filter on a node buffer.
double GetSampleRate(void)
Get the current sample rate.
Definition: vlbi_server.h:378
void SetOutput(FILE *out)
Set the output stream.
Definition: vlbi_server.h:432
virtual void SetDec(double value)
Set the target declination coordinate, do this before calling Plot()
Definition: vlbi_server.h:297
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:423
virtual void SetFreq(double value)
Set the frequency observed, do this before calling Plot()
Definition: vlbi_server.h:306
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:363
The location type.
Definition: dsp.h:328