Open source Very Long Baseline Interferometry
OpenVLBI
Loading...
Searching...
No Matches
vlbi_server.h
1/* OpenVLBI - Open Source Very Long Baseline Interferometry
2* Copyright © 2017-2023 Ilia Platone
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (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
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License along
15* with this program; if not, write to the Free Software Foundation, Inc.,
16* 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#ifdef _WIN32
26#define restrict __restrict
27extern ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delim, FILE *restrict stream);
28#endif
29
30namespace VLBI
31{
32
61
65class Server
66{
67 public:
71 Server(void);
75 virtual ~Server(void);
76
82 virtual int Init(int argc, char** argv)
83 {
84 (void)argc;
85 (void)argv;
86 return 1;
87 }
88
92 virtual void Parse(void);
93
98 void addContext(const char *name);
99
104 void delContext(const char *name);
105
110 void setContext(const char *name);
111
117
122 inline char* currentContext(void)
123 {
124 return context;
125 }
126
133 void addModel(const char *name, char *format, char *b64);
134
140 dsp_stream_p getModel(const char *name);
141
148 char* getModel(const char *name, char *format);
149
154 void delModel(const char *name);
155
161 int getModels(char** names);
162
168 void addNode(const char *name, char *b64);
169
175 void addNodes(const char *name, char *b64);
176
186 void addNode(const char *name, dsp_location *locations, void *buf, int len, timespec starttime, bool geo);
187
192 void delNode(const char *name);
193
199 void CopyNode(const char *name, const char *node);
200
206 void Plot(const char *name, int flags);
207
214 void Idft(const char *name, const char *magnitude, const char *phase);
215
222 void Dft(const char *name, const char *magnitude, const char *phase);
223
230 void Mask(const char *name, const char *model, const char *mask);
231
238 void Stack(const char *name, const char *model1, const char *model2);
239
245 void Copy(const char *name, const char *model);
246
253 void Diff(const char *name, const char *model1, const char *model2);
254
261 void Convolve(const char *name, const char *model1, const char *model2);
262
269 void LowPass(const char *name, const char *node, double freq);
270
277 void HighPass(const char *name, const char *node, double freq);
278
286 void BandPass(const char *name, const char *node, double lofreq, double hifreq);
287
295 void BandReject(const char *name, const char *node, double lofreq, double hifreq);
296
301 void Shift(const char *name);
302
307 inline virtual void setRa(double value)
308 {
309 Ra = value;
310 }
311
316 inline virtual void setDec(double value)
317 {
318 Dec = value;
319 }
320
325 inline virtual void setFreq(double value)
326 {
327 Freq = value;
328 }
329
334 inline virtual void setSampleRate(double value)
335 {
336 SampleRate = value;
337 }
338
343 inline virtual void setBps(int value)
344 {
345 Bps = value;
346 }
347
352 inline virtual void setWidth(int value)
353 {
354 w = value;
355 }
356
361 inline virtual void setHeight(int value)
362 {
363 h = value;
364 }
365
370 inline double getRa(void)
371 {
372 return Ra;
373 }
374
379 inline double getDec(void)
380 {
381 return Dec;
382 }
383
388 inline double getFreq(void)
389 {
390 return Freq;
391 }
392
397 inline double getSampleRate(void)
398 {
399 return SampleRate;
400 }
401
406 void setCorrelationOrder(int order);
407
412 inline double getBps(void)
413 {
414 return Bps;
415 }
416
421 inline double getWidth(void)
422 {
423 return w;
424 }
425
430 inline double getHeight(void)
431 {
432 return h;
433 }
434
439 void setInput(FILE* in)
440 {
441 input = in;
442 }
443
448 inline FILE* getInput()
449 {
450 return input;
451 }
452
457 void setOutput(FILE* out)
458 {
459 output = out;
460 }
461
466 inline FILE* getOutput()
467 {
468 return output;
469 }
470
475 inline void setDelegate(vlbi_func2_t func)
476 {
477 delegate = func;
478 }
479
484 inline vlbi_func2_t getDelegate() { return delegate; }
485
486 private:
487 vlbi_func2_t delegate;
488 double Ra;
489 double Dec;
490 double Freq;
491 double SampleRate;
492 int Bps;
493 int w;
494 int h;
495 FILE *input, *output;
496 char *context;
497 char *tmpdir { nullptr };
498};
499extern VLBI::Server *server;
501};
502
503#endif //VLBI_SERVER_H
Inherit this class to create an OpenVLBI server application.
Definition vlbi_server.h:66
virtual void setBps(int value)
set the bytes per sample, do this before calling addNode()
Definition vlbi_server.h:343
void addContext(const char *name)
add a new OpenVLBI context by giving it a name. VLBI::Server has an internal context collection
FILE * getInput()
get the input stream
Definition vlbi_server.h:448
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.
virtual void setHeight(int value)
set the plot height, do this before calling Plot()
Definition vlbi_server.h:361
void HighPass(const char *name, const char *node, double freq)
Apply a high pass filter on a node buffer.
double getSampleRate(void)
get the current sample rate
Definition vlbi_server.h:397
int getModels(char **names)
get the names of all the models of the current context.
void setOutput(FILE *out)
set the output stream
Definition vlbi_server.h:457
char * getModel(const char *name, char *format)
Obtain the base64 encoded file buffer of a model by passing its name.
double getDec(void)
get the current declination coordinate
Definition vlbi_server.h:379
vlbi_context getContext(void)
Obtain the current OpenVLBI context object.
virtual void setSampleRate(double value)
set the sampling frequency, do this before calling Plot()
Definition vlbi_server.h:334
dsp_stream_p getModel(const char *name)
Obtain the dsp_stream_p object of a model by passing its 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:370
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.
double getBps(void)
get the bytes per sample
Definition vlbi_server.h:412
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 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...
void delContext(const char *name)
delete an existing OpenVLBI context by name.
void setCorrelationOrder(int order)
set the current correlation order
void Idft(const char *name, const char *magnitude, const char *phase)
Obtain an inverse fourier transform from the magnitude and phase models passed.
virtual void setFreq(double value)
set the frequency observed, do this before calling Plot()
Definition vlbi_server.h:325
void setContext(const char *name)
set the current OpenVLBI context by passing its name.
Server(void)
Constructor, initializes all the internal variables.
vlbi_func2_t getDelegate()
get the current delegate function
Definition vlbi_server.h:484
void setInput(FILE *in)
set the input stream
Definition vlbi_server.h:439
double getFreq(void)
get the current frequency
Definition vlbi_server.h:388
double getHeight(void)
get the plot height
Definition vlbi_server.h:430
void setDelegate(vlbi_func2_t func)
set the delegate function
Definition vlbi_server.h:475
char * currentContext(void)
Obtain the name current OpenVLBI context.
Definition vlbi_server.h:122
void Shift(const char *name)
Shift a model by its dimension in-place.
void Convolve(const char *name, const char *model1, const char *model2)
Convolve a model with a convolution matrix model.
void Diff(const char *name, const char *model1, const char *model2)
Diff a model with another model.
virtual ~Server(void)
Destructor, destroys this object.
void Copy(const char *name, const char *model)
Copy a model into another model.
virtual int Init(int argc, char **argv)
Called immediately after main(), can be overriden to add your custom arguments.
Definition vlbi_server.h:82
virtual void setWidth(int value)
set the plot width, do this before calling Plot()
Definition vlbi_server.h:352
FILE * getOutput()
get the output stream
Definition vlbi_server.h:466
virtual void setDec(double value)
set the target declination coordinate, do this before calling Plot()
Definition vlbi_server.h:316
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 Plot(const char *name, int flags)
Plot the current observation into a new 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...
void delModel(const char *name)
delete from the current context an existing model by name.
void Stack(const char *name, const char *model1, const char *model2)
Stack a model with another model.
void delNode(const char *name)
delete from the current context an existing node by name.
void BandPass(const char *name, const char *node, double lofreq, double hifreq)
Apply a band pass filter on a node buffer.
void CopyNode(const char *name, const char *node)
Copy a node into another node.
virtual void setRa(double value)
set the target right ascension coordinate, do this before calling Plot()
Definition vlbi_server.h:307
double getWidth(void)
get the plot width
Definition vlbi_server.h:421
virtual void Parse(void)
main() creates a loop that calls Parse(), you can use this one, which uses the standard syntax or ove...
vlbi_plot_flags
Flags that characterize a plot.
Definition vlbi_server.h:51
@ plot_flags_uv_coverage
This will fill all baselines projected pixels with ones.
Definition vlbi_server.h:55
@ plot_flags_moving_baseline
This indicates that the nodes have a positional stream companion.
Definition vlbi_server.h:53
@ plot_flags_synced
This indicates that the nodes are synced already and no delay calculation will be done.
Definition vlbi_server.h:57
@ plot_flags_custom_delegate
This will use a custom visibility delegate.
Definition vlbi_server.h:59
double(* vlbi_func2_t)(double, double)
The delegate function type to pass to vlbi_plot_uv_plane.
Definition vlbi.h:342
void * vlbi_context
the OpenVLBI context object type
Definition vlbi.h:345
Contains a set of informations and data relative to a buffer and how to use it.
Definition dsp.h:387
The location type.
Definition dsp.h:352