Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vlbi #20

Closed
wants to merge 4 commits into from
Closed

Vlbi #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8...3.8)

PROJECT(OpenVLBI C CXX)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
Expand All @@ -14,14 +14,15 @@ find_package(Threads REQUIRED)
option(CMAKE_BUILD_RPATH_USE_ORIGIN "rpath issue fix" ON)
option(WITH_VLBI_SERVER "Add OpenVLBI servers" ON)
option(WITH_INDI_SERVER "Add INDI server for OpenVLBI" ON)
option(WITH_SHARED_SERVER "Add shared server library for OpenVLBI" ON)
option(WITH_DUMMY_SERVER "Add dummy server for OpenVLBI" ON)
option(WITH_JSON_SERVER "Add JSON server for OpenVLBI" ON)

set (CMAKE_CXX_STANDARD 11)
set (CMAKE_C_STANDARD 11)
set (VLBI_VERSION_MAJOR 3)
set (VLBI_VERSION_MINOR 0)
set (VLBI_VERSION_RELEASE 2)
set (VLBI_VERSION_RELEASE 3)
set (VLBI_VERSION_STRING "${VLBI_VERSION_MAJOR}.${VLBI_VERSION_MINOR}.${VLBI_VERSION_RELEASE}")
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}")
Expand Down Expand Up @@ -125,4 +126,12 @@ add_executable(vlbi_server_dummy ${CMAKE_CURRENT_SOURCE_DIR}/vlbi_server_dummy.c
target_link_libraries(vlbi_server_dummy openvlbi_server openvlbi ${M_LIB} ${ZLIB_LIBRARY})
install(TARGETS vlbi_server_dummy RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif(WITH_DUMMY_SERVER)

if(WITH_SHARED_SERVER)
add_library(vlbi_server SHARED ${CMAKE_CURRENT_SOURCE_DIR}/vlbi_server.cpp ${CMAKE_CURRENT_SOURCE_DIR}/vlbi/instancecollection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/vlbi/collection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/vlbi/base64.c ${CMAKE_CURRENT_SOURCE_DIR}/vlbi_server_shared.cpp ${CMAKE_CURRENT_SOURCE_DIR}/vlbi_server_dummy.cpp)
target_link_libraries(vlbi_server openvlbi_server openvlbi ${CFITSIO_LIBRARIES} ${M_LIB} ${ZLIB_LIBRARY})
set_target_properties(vlbi_server PROPERTIES VERSION ${VLBI_VERSION_STRING} SOVERSION ${VLBI_VERSION_MAJOR})
install(TARGETS vlbi_server LIBRARY DESTINATION ${LIB_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/vlbi_server_c.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/OpenVLBI)
endif(WITH_SHARED_SERVER)
endif(WITH_VLBI_SERVER)
6 changes: 3 additions & 3 deletions dsp/dsp.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ typedef double complex_t[2];
#define dsp_t_min -dsp_t_max
///Size of strings
#define DSP_NAME_SIZE 128
///Hypercomplex type
typedef struct hypercomplex_t{
///Multicomplex type
typedef struct multicomplex_t {
int dims;
double real;
double *imaginary;
} hypercomplex;
} multicomplex;
/**
* \brief get/set the maximum number of threads allowed
* \param value if greater than 1, set a maximum number of threads allowed
Expand Down
76 changes: 61 additions & 15 deletions vlbi/baselinecollection.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/* OpenVLBI - Open Source Very Long Baseline Interferometry
* Copyright © 2017-2023 Ilia Platone
* Copyright © 2017-2022 Ilia Platone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <cstdio>
Expand Down Expand Up @@ -50,16 +50,14 @@ void BaselineCollection::update()
for(int i = 0; i < getNodes()->count() * (getNodes()->count() - 1) / 2; i++)
{
VLBINode** nodes = (VLBINode**)malloc(sizeof(VLBINode*) * getCorrelationOrder());
char name[DSP_NAME_SIZE * getCorrelationOrder() + getCorrelationOrder()];
char name[150] = "";
for(int o = 0; o < getCorrelationOrder(); o++) {
int idx = (i + o * (i / getNodes()->count() + 1)) % getNodes()->count();
nodes[o] = getNodes()->at(idx);
if(o == 0)
sprintf(name, "%s", nodes[o]->getName());
else {
strcat(name, "*");
strcat(name, nodes[o]->getName());
}
else
sprintf(name, "%s_%s", name, nodes[o]->getName());
}
VLBIBaseline *b = new VLBIBaseline(nodes, getCorrelationOrder());
if(!this->contains(name))
Expand Down Expand Up @@ -108,6 +106,54 @@ bool BaselineCollection::contains(const char* element)
return VLBICollection::contains(element);
}

bool BaselineCollection::contains(const char** elements)
{
return get(elements) != nullptr;
}

bool BaselineCollection::contains(VLBINode** elements)
{
return get(elements) != nullptr;
}

VLBIBaseline *BaselineCollection::get(const char** elements)
{
VLBIBaseline *b = nullptr;
int x = 0;
for(x = 0; x < count(); x++) {
b = at(x);
int match = 0;
for(int y = 0; y < getCorrelationOrder(); y++) {
for(int z = 0; z < getCorrelationOrder(); z++) {
if(!strcmp(b->getNode(y)->getName(), elements[z])) match ++;
}
}
if(match < getCorrelationOrder()) continue;
break;
}
if(x == count() || b == nullptr) return nullptr;
return b;
}

VLBIBaseline *BaselineCollection::get(VLBINode **nodes)
{
VLBIBaseline *b = nullptr;
int x = 0;
for(x = 0; x < count(); x++) {
b = at(x);
int match = 0;
for(int y = 0; y < getCorrelationOrder(); y++) {
for(int z = 0; z < getCorrelationOrder(); z++) {
if(!strcmp(b->getNode(y)->getName(), nodes[z]->getName())) match ++;
}
}
if(match < getCorrelationOrder()) continue;
break;
}
if(x == count() || b == nullptr) return nullptr;
return b;
}

void BaselineCollection::setTarget(double *target)
{
memcpy(Stream->target, target, sizeof(double) * 3);
Expand Down
4 changes: 4 additions & 0 deletions vlbi/baselinecollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ class BaselineCollection : public VLBICollection
void add(VLBIBaseline *element);
void removeAt(int index);
VLBIBaseline *get(const char* name);
VLBIBaseline *get(const char** names);
VLBIBaseline *get(VLBINode **nodes);
void remove(const char* element);
void clear();
VLBIBaseline * at(int index);
bool contains(const char *element);
bool contains(const char** elements);
bool contains(VLBINode** elements);
int indexOf(VLBIBaseline *element);
void setTarget(double *target);
void setRa(double ra);
Expand Down
28 changes: 13 additions & 15 deletions vlbi/nodecollection.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/* OpenVLBI - Open Source Very Long Baseline Interferometry
* Copyright © 2017-2023 Ilia Platone
* Copyright © 2017-2022 Ilia Platone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <cstdio>
Expand Down Expand Up @@ -74,12 +74,10 @@ bool NodeCollection::contains(const char* element)
void NodeCollection::setRelative(bool value)
{
relative = value;
if(value)
baselines->setRelative(value);
for(int x = 0; x < count(); x++)
{
for(int x = 0; x < count(); x++)
{
memcpy(at(x)->stationLocation().coordinates, station.coordinates, sizeof(dsp_location));
}
memcpy(at(x)->stationLocation().coordinates, station.coordinates, sizeof(dsp_location));
}
}

Expand Down
10 changes: 5 additions & 5 deletions vlbi_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ static int is_running = 1;
static InstanceCollection *contexts;
VLBI::Server::Server()
{
input = stdin;
output = stdout;
setInput(fdopen(0, "rb"));
setOutput(fdopen(1, "w+"));
Ra = 0;
Dec = 0;
Freq = 1420000000;
Expand All @@ -52,7 +52,7 @@ VLBI::Server::Server()
if(nullptr == tmpdir)
tmpdir = (char*)"/tmp";
context = (char*)malloc(9);
strcpy(context, "OpenVLBI\0");
memcpy(context, "OpenVLBI\0", 9);
contexts = new InstanceCollection();
}

Expand Down Expand Up @@ -725,8 +725,8 @@ int main(int argc, char *argv[])
#endif
int opt;
dsp_set_app_name(argv[0]);
dsp_set_stdout(stderr);
dsp_set_stderr(stderr);
dsp_set_stdout(fdopen(2, "w+"));
dsp_set_stderr(fdopen(2, "w+"));
while ((opt = getopt(argc, argv, "t:f:o:vh")) != -1)
{
switch (opt)
Expand Down
53 changes: 53 additions & 0 deletions vlbi_server_shared.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "vlbi_server_dummy.h"
#include "vlbi_server_shared.h"

void VLBI_Server_Parse() { VLBI::server->Parse(); }
void VLBI_Server_addContext(const char *name) { VLBI::server->addContext(name); }
void VLBI_Server_delContext(const char *name) { VLBI::server->delContext(name); }
void VLBI_Server_setContext(const char *name) { VLBI::server->setContext(name); }
vlbi_context VLBI_Server_getContext() { return VLBI::server->getContext(); }
char* VLBI_Server_currentContext() { return VLBI::server->currentContext(); }
void VLBI_Server_addModel(const char *name, char *format, char *b64) { VLBI::server->addModel(name, format, b64); }
dsp_stream_p VLBI_Server_getModel(const char *name) { return VLBI::server->getModel(name); }
char* VLBI_Server_getModel(const char *name, char *format) { return VLBI::server->getModel(name, format); }
void VLBI_Server_delModel(const char *name) { VLBI::server->delModel(name); }
int VLBI_Server_getModels(char** names) { return VLBI::server->getModels(names); }
void VLBI_Server_addNodeFromFits(const char *name, char *b64) { VLBI::server->addNode(name, b64); }
void VLBI_Server_addNodes(const char *name, char *b64) { VLBI::server->addNodes(name, b64); }
void VLBI_Server_addNode(const char *name, dsp_location *locations, void *buf, int len, timespec starttime, bool geo) { VLBI::server->addNode(name, locations, buf, len, starttime, geo); }
void VLBI_Server_delNode(const char *name) { VLBI::server->delNode(name); }
void VLBI_Server_CopyNode(const char *name, const char *node) { VLBI::server->CopyNode(name, node); }
void VLBI_Server_Plot(const char *name, int flags) { VLBI::server->Plot(name, flags); }
void VLBI_Server_Idft(const char *name, const char *magnitude, const char *phase) { VLBI::server->Idft(name, magnitude, phase); }
void VLBI_Server_Dft(const char *name, const char *magnitude, const char *phase) { VLBI::server->Dft(name, magnitude, phase); }
void VLBI_Server_Mask(const char *name, const char *model, const char *mask) { VLBI::server->Mask(name, model, mask); }
void VLBI_Server_Stack(const char *name, const char *model1, const char *model2) { VLBI::server->Stack(name, model1, model2); }
void VLBI_Server_Copy(const char *name, const char *model) { VLBI::server->Copy(name, model); }
void VLBI_Server_Diff(const char *name, const char *model1, const char *model2) { VLBI::server->Diff(name, model1, model2); }
void VLBI_Server_Convolve(const char *name, const char *model1, const char *model2) { VLBI::server->Convolve(name, model1, model2); }
void VLBI_Server_LowPass(const char *name, const char *node, double freq) { VLBI::server->LowPass(name, node, freq); }
void VLBI_Server_HighPass(const char *name, const char *node, double freq) { VLBI::server->HighPass(name, node, freq); }
void VLBI_Server_BandPass(const char *name, const char *node, double lofreq, double hifreq) { VLBI::server->BandPass(name, node, lofreq, hifreq); }
void VLBI_Server_BandReject(const char *name, const char *node, double lofreq, double hifreq) { VLBI::server->BandReject(name, node, lofreq, hifreq); }
void VLBI_Server_Shift(const char *name) { VLBI::server->Shift(name); }
void VLBI_Server_setRa(double value) { VLBI::server->setRa(value); }
void VLBI_Server_setDec(double value) { VLBI::server->setDec(value); }
void VLBI_Server_setFreq(double value) { VLBI::server->setFreq(value); }
void VLBI_Server_setSampleRate(double value) { VLBI::server->setSampleRate(value); }
void VLBI_Server_setBps(int value) { VLBI::server->setBps(value); }
void VLBI_Server_setWidth(int value) { VLBI::server->setWidth(value); }
void VLBI_Server_setHeight(int value) { VLBI::server->setHeight(value); }
double VLBI_Server_getRa() { return VLBI::server->getRa(); }
double VLBI_Server_getDec() { return VLBI::server->getDec(); }
double VLBI_Server_getFreq() { return VLBI::server->getFreq(); }
double VLBI_Server_getSampleRate() { return VLBI::server->getSampleRate(); }
void VLBI_Server_setCorrelationOrder(int order) { VLBI::server->setCorrelationOrder(order); }
double VLBI_Server_getBps() { return VLBI::server->getBps(); }
double VLBI_Server_getWidth() { return VLBI::server->getWidth(); }
double VLBI_Server_getHeight() { return VLBI::server->getHeight(); }
void VLBI_Server_setInput(FILE* in) { VLBI::server->setInput(in); }
FILE* VLBI_Server_getInput() { return VLBI::server->getInput(); }
void VLBI_Server_setOutput(FILE* out) { VLBI::server->setOutput(out); }
FILE* VLBI_Server_getOutput() { return VLBI::server->getOutput(); }
void VLBI_Server_setDelegate(vlbi_func2_t func) { VLBI::server->setDelegate(func); }
vlbi_func2_t VLBI_Server_getDelegate() { return VLBI::server->getDelegate(); }
Loading
Loading