Skip to content

Commit

Permalink
correlation delegate parsed from javascript code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Platone committed Apr 20, 2022
1 parent 8362f11 commit 5e930fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
8 changes: 7 additions & 1 deletion scripts/idft.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions vlbi_server_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <base64.h>
#include "strings.h"
#include "mjs.h"
char *js_code_str;
static char *js_code_str;

static double js_callback(double a, double b) {
struct mjs *mjs = mjs_create();
Expand Down Expand Up @@ -79,7 +79,7 @@ void JSONServer::Parse()
{
double lat = 0, lon = 0, el = 0;
int i = 0;
for(int y = 0; y < 3; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "latitude"))
{
Expand Down Expand Up @@ -111,7 +111,7 @@ void JSONServer::Parse()
{
char *name = nullptr;
char *base64 = nullptr;
for(int y = 0; y < 2; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "name"))
{
Expand All @@ -131,7 +131,7 @@ void JSONServer::Parse()
{
char *name = nullptr;
char *base64 = nullptr;
for(int y = 0; y < 2; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "name"))
{
Expand All @@ -155,7 +155,7 @@ void JSONServer::Parse()
char *locations = nullptr;
int buflen = 0;
int locationslen = 0;
for(int y = 0; y < 5; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "name"))
{
Expand Down Expand Up @@ -197,11 +197,11 @@ void JSONServer::Parse()
}
if(!strcmp(n, "plot"))
{
if(v->u.object.length == 8)
if(v->u.object.length >= 8)
{
int flags = 0;
char *name = nullptr;
for(int y = 0; y < 8; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "name"))
{
Expand Down Expand Up @@ -260,12 +260,12 @@ void JSONServer::Parse()
{
if(!strcmp(values[y].value->u.string.ptr, "coverage"))
flags |= plot_flags_uv_coverage;
if(!strcmp(values[y].value->u.string.ptr, "raw"))
else if(!strcmp(values[y].value->u.string.ptr, "default"))
flags &= ~plot_flags_uv_coverage;
if(!strcmp(values[y].value->u.string.ptr, "custom")) {
for(int z = 0; z < 8; z ++)
else {
for(int z = 0; z < (int)values[y].value->u.object.length; z ++)
{
if(!strcmp(values[z].name, "code"))
if(!strcmp(values[z].name, values[y].value->u.string.ptr))
{
js_code_str = v->u.string.ptr;
setDelegate(js_callback);
Expand All @@ -285,7 +285,7 @@ void JSONServer::Parse()
i++;
}
}
if(i == 8)
if(i >= 8)
{
Plot(name, flags);
}
Expand All @@ -297,7 +297,7 @@ void JSONServer::Parse()
{
char* name = nullptr;
char* format = nullptr;
for(int y = 0; y < 2; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "name"))
{
Expand Down Expand Up @@ -327,7 +327,7 @@ void JSONServer::Parse()
char* name = nullptr;
char* format = nullptr;
char* base64 = nullptr;
for(int y = 0; y < 3; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "name"))
{
Expand Down Expand Up @@ -359,7 +359,7 @@ void JSONServer::Parse()
char* idft = nullptr;
char* magnitude = nullptr;
char* phase = nullptr;
for(int y = 0; y < 4; y ++)
for(int y = 0; y < (int)v->u.object.length; y ++)
{
if(!strcmp(values[y].name, "inverse"))
{
Expand Down

0 comments on commit 5e930fe

Please sign in to comment.