MIDAS
JSON-RPC Functions

Classes

class  MJSO
 

Typedefs

typedef MJsonNode *() mjsonrpc_handler_t(const MJsonNode *params)
 

Functions

void mjsonrpc_init ()
 
void mjsonrpc_user_init ()
 
void mjsonrpc_add_handler (const char *method, mjsonrpc_handler_t *handler, bool needs_locking=false)
 
void mjsonrpc_exit ()
 
void mjsonrpc_set_std_mutex (void *mutex)
 
MJsonNode * mjsonrpc_get_schema ()
 
std::string mjsonrpc_schema_to_text (const MJsonNode *schema)
 
MJsonNode * mjsonrpc_make_error (int code, const char *message, const char *data)
 
MJsonNode * mjsonrpc_make_result (MJsonNode *node)
 
MJsonNode * mjsonrpc_make_result (const char *name, MJsonNode *value, const char *name2=NULL, MJsonNode *value2=NULL, const char *name3=NULL, MJsonNode *value3=NULL)
 
const MJsonNode * mjsonrpc_get_param (const MJsonNode *params, const char *name, MJsonNode **error)
 
MJsonNode * mjsonrpc_decode_post_data (const char *post_data)
 
static MJSOMJSO::MakeObjectSchema (const char *description)
 
static MJSOMJSO::MakeArraySchema (const char *description)
 
void MJSO::AddToSchema (MJsonNode *s, const char *name)
 
static MJSOMJSO::I ()
 
void MJSO::D (const char *description)
 
MJSOMJSO::Params ()
 
MJSOMJSO::Result ()
 
MJSOMJSO::PA (const char *description)
 
MJSOMJSO::RA (const char *description)
 
void MJSO::P (const char *name, int mjson_type, const char *description)
 
void MJSO::R (const char *name, int mjson_type, const char *description)
 
void MJSO::Add (const char *name, int mjson_type, const char *description)
 
MJSOMJSO::AddObject (const char *name, const char *description)
 
MJSOMJSO::AddArray (const char *name, const char *description)
 
 MJSO::MJSO ()
 

Variables

int mjsonrpc_debug
 
MJsonNode * MJSO::properties
 
MJsonNode * MJSO::required
 
MJsonNode * MJSO::items
 
MJSOMJSO::params
 
MJSOMJSO::result
 

Detailed Description


Typedef Documentation

◆ mjsonrpc_handler_t

typedef MJsonNode*() mjsonrpc_handler_t(const MJsonNode *params)

Definition at line 18 of file mjsonrpc.h.

Function Documentation

◆ MJSO()

MJSO::MJSO ( )
protected

Definition at line 402 of file mjsonrpc.cxx.

403  : MJsonNode(MJSON_OBJECT)
404 {
405  properties = NULL;
406  required = NULL;
407  items = NULL;
408  params = NULL;
409  result = NULL;
410 }
MJsonNode * properties
Definition: mjsonrpc.h:61
MJsonNode * required
Definition: mjsonrpc.h:62
MJSO * result
Definition: mjsonrpc.h:66
MJsonNode * items
Definition: mjsonrpc.h:63
MJSO * params
Definition: mjsonrpc.h:65
Here is the caller graph for this function:

◆ Add()

void MJSO::Add ( const char *  name,
int  mjson_type,
const char *  description 
)

Definition at line 355 of file mjsonrpc.cxx.

356 {
357  MJsonNode* p = MJsonNode::MakeObject();
358  p->AddToObject("description", MJsonNode::MakeString(description));
359  if (mjson_type == MJSON_ARRAY)
360  p->AddToObject("type", MJsonNode::MakeString("array"));
361  else if (mjson_type == MJSON_OBJECT)
362  p->AddToObject("type", MJsonNode::MakeString("object"));
363  else if (mjson_type == MJSON_STRING)
364  p->AddToObject("type", MJsonNode::MakeString("string"));
365  else if (mjson_type == MJSON_INT)
366  p->AddToObject("type", MJsonNode::MakeString("integer"));
367  else if (mjson_type == MJSON_NUMBER)
368  p->AddToObject("type", MJsonNode::MakeString("number"));
369  else if (mjson_type == MJSON_BOOL)
370  p->AddToObject("type", MJsonNode::MakeString("bool"));
371  else if (mjson_type == MJSON_NULL)
372  p->AddToObject("type", MJsonNode::MakeString("null"));
373  else if (mjson_type == MJSON_ARRAYBUFFER)
374  p->AddToObject("type", MJsonNode::MakeString("arraybuffer"));
375  else if (mjson_type == MJSON_JSON)
376  p->AddToObject("type", MJsonNode::MakeString("json"));
377  else if (mjson_type == 0)
378  ;
379  else
380  assert(!"invalid value of mjson_type");
381  this->AddToSchema(p, name);
382 }
void AddToSchema(MJsonNode *s, const char *name)
Definition: mjsonrpc.cxx:261
char description[1000]
Definition: mana.cxx:267
#define name(x)
Definition: midas_macro.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddArray()

MJSO * MJSO::AddArray ( const char *  name,
const char *  description 
)

Definition at line 393 of file mjsonrpc.cxx.

394 {
396  s->AddToObject("description", MJsonNode::MakeString(description));
397  s->AddToObject("type", MJsonNode::MakeString("array"));
398  this->AddToSchema(s, name);
399  return s;
400 }
Definition: mjsonrpc.h:59
static MJSO * MakeArraySchema(const char *description)
Definition: mjsonrpc.cxx:242
Here is the call graph for this function:

◆ AddObject()

MJSO * MJSO::AddObject ( const char *  name,
const char *  description 
)

Definition at line 384 of file mjsonrpc.cxx.

385 {
387  s->AddToObject("description", MJsonNode::MakeString(description));
388  s->AddToObject("type", MJsonNode::MakeString("object"));
389  this->AddToSchema(s, name);
390  return s;
391 }
static MJSO * MakeObjectSchema(const char *description)
Definition: mjsonrpc.cxx:229
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddToSchema()

void MJSO::AddToSchema ( MJsonNode *  s,
const char *  name 
)
protected

Definition at line 261 of file mjsonrpc.cxx.

262 {
263  if (!xname)
264  xname = "";
265 
266  bool optional = strchr(xname, '?');
267  bool array = strchr(xname, '[');
268 
269  // remove the "?" and "[]" marker characters
270  std::string name = xname;
271  name = remove(name, '?');
272  name = remove(name, '[');
273  name = remove(name, ']');
274 
275  if (optional)
276  s->AddToObject("optional", MJsonNode::MakeBool(true));
277 
278  if (array) { // insert an array schema
279  MJSO* ss = MakeArraySchema(s->FindObjectNode("description")->GetString().c_str());
280  s->DeleteObjectNode("description");
281  ss->AddToSchema(s, "");
282  s = ss;
283  }
284 
285  if (items)
286  items->AddToArray(s);
287  else {
288  assert(properties);
289  assert(required);
290  properties->AddToObject(name.c_str(), s);
291  if (!optional) {
292  required->AddToArray(MJsonNode::MakeString(name.c_str()));
293  }
294  }
295 }
static std::string remove(const std::string s, char c)
Definition: mjsonrpc.cxx:252
Here is the call graph for this function:
Here is the caller graph for this function:

◆ D()

void MJSO::D ( const char *  description)

Definition at line 302 of file mjsonrpc.cxx.

303 {
304  this->AddToObject("description", MJsonNode::MakeString(description));
305 }

◆ I()

MJSO * MJSO::I ( )
static

Definition at line 297 of file mjsonrpc.cxx.

298 {
299  return MakeObjectSchema(NULL);
300 }
Here is the call graph for this function:

◆ MakeArraySchema()

MJSO * MJSO::MakeArraySchema ( const char *  description)
staticprotected

Definition at line 242 of file mjsonrpc.cxx.

243 {
244  MJSO* p = new MJSO();
245  p->AddToObject("description", MJsonNode::MakeString(description));
246  p->AddToObject("type", MJsonNode::MakeString("array"));
247  p->items = MJsonNode::MakeArray();
248  p->AddToObject("items", p->items);
249  return p;
250 }
MJSO()
Definition: mjsonrpc.cxx:402
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeObjectSchema()

MJSO * MJSO::MakeObjectSchema ( const char *  description)
staticprotected

Definition at line 229 of file mjsonrpc.cxx.

230 {
231  MJSO* p = new MJSO();
232  if (description)
233  p->AddToObject("description", MJsonNode::MakeString(description));
234  p->AddToObject("type", MJsonNode::MakeString("object"));
235  p->properties = MJsonNode::MakeObject();
236  p->required = MJsonNode::MakeArray();
237  p->AddToObject("properties", p->properties);
238  p->AddToObject("required", p->required);
239  return p;
240 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_add_handler()

void mjsonrpc_add_handler ( const char *  method,
mjsonrpc_handler_t handler,
bool  needs_locking = false 
)

Definition at line 4637 of file mjsonrpc.cxx.

4638 {
4640  e.fHandler = handler;
4641  e.fNeedsLocking = needs_locking;
4642  gMethodsTable[method] = e;
4643 }
static MethodsTable gMethodsTable
Definition: mjsonrpc.cxx:4634
Definition: mjsonrpc.cxx:4626
static double e(void)
Definition: tinyexpr.c:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_decode_post_data()

MJsonNode* mjsonrpc_decode_post_data ( const char *  post_data)

Definition at line 5257 of file mjsonrpc.cxx.

5258 {
5259  //printf("mjsonrpc call, data [%s]\n", post_data);
5260  MJsonNode *request = MJsonNode::Parse(post_data);
5261 
5262  assert(request != NULL); // Parse never returns NULL - either parsed data or an MJSON_ERROR node
5263 
5264  if (mjsonrpc_debug) {
5265  printf("mjsonrpc: request:\n");
5266  request->Dump();
5267  printf("\n");
5268  }
5269 
5270  if (mjsonrpc_sleep) {
5271  if (mjsonrpc_debug) {
5272  printf("mjsonrpc: sleep %d\n", mjsonrpc_sleep);
5273  }
5274  for (int i=0; i<mjsonrpc_sleep; i++) {
5275  sleep(1);
5276  }
5277  }
5278 
5279  if (request->GetType() == MJSON_ERROR) {
5280  MJsonNode* reply = mjsonrpc_make_error(-32700, "Parse error", request->GetError().c_str());
5281  reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5282  reply->AddToObject("id", MJsonNode::MakeNull());
5283 
5284  if (mjsonrpc_debug) {
5285  printf("mjsonrpc: invalid json: reply:\n");
5286  printf("%s\n", reply->Stringify().c_str());
5287  printf("\n");
5288  }
5289 
5290  delete request;
5291  return reply;
5292  } else if (request->GetType() == MJSON_OBJECT) {
5293  MJsonNode* reply = mjsonrpc_handle_request(request);
5294  delete request;
5295  return reply;
5296  } else if (request->GetType() == MJSON_ARRAY) {
5297  const MJsonNodeVector* a = request->GetArray();
5298 
5299  if (a->size() < 1) {
5300  MJsonNode* reply = mjsonrpc_make_error(-32600, "Invalid request", "batch request array has less than 1 element");
5301  reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5302  reply->AddToObject("id", MJsonNode::MakeNull());
5303 
5304  if (mjsonrpc_debug) {
5305  printf("mjsonrpc: invalid json: reply:\n");
5306  printf("%s\n", reply->Stringify().c_str());
5307  printf("\n");
5308  }
5309 
5310  delete request;
5311  return reply;
5312  }
5313 
5314  MJsonNode* reply = MJsonNode::MakeArray();
5315 
5316  for (unsigned i=0; i<a->size(); i++) {
5317  MJsonNode* r = mjsonrpc_handle_request(a->at(i));
5318  reply->AddToArray(r);
5319  if (r->GetType() == MJSON_ARRAYBUFFER) {
5320  delete request;
5321  delete reply;
5322  reply = mjsonrpc_make_error(-32600, "Invalid request", "MJSON_ARRAYBUFFER return is not permitted for batch requests");
5323  reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5324  reply->AddToObject("id", MJsonNode::MakeNull());
5325  return reply;
5326  }
5327  }
5328 
5329  delete request;
5330  return reply;
5331  } else {
5332  MJsonNode* reply = mjsonrpc_make_error(-32600, "Invalid request", "request is not a JSON object or JSON array");
5333  reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5334  reply->AddToObject("id", MJsonNode::MakeNull());
5335 
5336  if (mjsonrpc_debug) {
5337  printf("mjsonrpc: invalid json: reply:\n");
5338  printf("%s\n", reply->Stringify().c_str());
5339  printf("\n");
5340  }
5341 
5342  delete request;
5343  return reply;
5344  }
5345 }
MJsonNode * mjsonrpc_make_error(int code, const char *message, const char *data)
Definition: mjsonrpc.cxx:122
int mjsonrpc_debug
Definition: mjsonrpc.cxx:111
INT i
Definition: mdump.cxx:35
char request[600000]
Definition: melog.cxx:90
#define sleep(ms)
Definition: midas_macro.h:269
static MJsonNode * mjsonrpc_handle_request(const MJsonNode *request)
Definition: mjsonrpc.cxx:5103
static int mjsonrpc_sleep
Definition: mjsonrpc.cxx:112
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_exit()

void mjsonrpc_exit ( )

Definition at line 4734 of file mjsonrpc.cxx.

4735 {
4736  if (mjsonrpc_debug) {
4737  printf("mjsonrpc_exit!\n");
4738  }
4739 
4740  js_hs_exit();
4741  DeleteEventStash();
4742 }
static void DeleteEventStash()
Definition: mjsonrpc.cxx:3629
static void js_hs_exit()
Definition: mjsonrpc.cxx:1746
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_get_param()

const MJsonNode* mjsonrpc_get_param ( const MJsonNode *  params,
const char *  name,
MJsonNode **  error 
)

Definition at line 177 of file mjsonrpc.cxx.

178 {
179  assert(gNullNode != NULL);
180 
181  // NULL params is a request for documentation, return an empty object
182  if (!params) {
183  if (error)
184  *error = MJsonNode::MakeObject();
185  return gNullNode;
186  }
187 
188  const MJsonNode* obj = params->FindObjectNode(name);
189  if (!obj) {
190  if (error)
191  *error = mjsonrpc_make_error(-32602, "Invalid params", (std::string("missing parameter: ") + name).c_str());
192  return gNullNode;
193  }
194 
195  if (error)
196  *error = NULL;
197  return obj;
198 }
static MJsonNode * gNullNode
Definition: mjsonrpc.cxx:175
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_get_schema()

MJsonNode* mjsonrpc_get_schema ( )

Definition at line 4772 of file mjsonrpc.cxx.

4773 {
4775 }
static MJsonNode * mjsonrpc_make_schema(MethodsTable *h)
Definition: mjsonrpc.cxx:4744
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_init()

void mjsonrpc_init ( )

Definition at line 4650 of file mjsonrpc.cxx.

4651 {
4652  if (mjsonrpc_debug) {
4653  printf("mjsonrpc_init!\n");
4654  }
4655 
4656  if (!gNullNode)
4657  gNullNode = MJsonNode::MakeNull();
4658 
4659  // test, debug and control methods for the rpc system
4660  mjsonrpc_add_handler("null", xnull);
4661  mjsonrpc_add_handler("get_debug", get_debug);
4662  mjsonrpc_add_handler("set_debug", set_debug);
4663  mjsonrpc_add_handler("get_sleep", get_sleep);
4664  mjsonrpc_add_handler("set_sleep", set_sleep);
4665  mjsonrpc_add_handler("get_time", get_time);
4666  mjsonrpc_add_handler("set_time", set_time);
4667  mjsonrpc_add_handler("get_schema", get_schema);
4668  // interface to alarm functions
4669  mjsonrpc_add_handler("al_reset_alarm", js_al_reset_alarm, true);
4670  mjsonrpc_add_handler("al_trigger_alarm", js_al_trigger_alarm, true);
4671  mjsonrpc_add_handler("al_trigger_class", js_al_trigger_class, true);
4672  // interface to midas.c functions
4673  mjsonrpc_add_handler("cm_exist", js_cm_exist, true);
4674  mjsonrpc_add_handler("cm_msg_facilities", js_cm_msg_facilities);
4675  mjsonrpc_add_handler("cm_msg_retrieve", js_cm_msg_retrieve);
4676  mjsonrpc_add_handler("cm_msg1", js_cm_msg1);
4677  mjsonrpc_add_handler("cm_shutdown", js_cm_shutdown, true);
4678  mjsonrpc_add_handler("cm_transition", js_cm_transition, true);
4679  mjsonrpc_add_handler("bm_receive_event", js_bm_receive_event, true);
4680  // interface to odb functions
4681  mjsonrpc_add_handler("db_copy", js_db_copy);
4682  mjsonrpc_add_handler("db_paste", js_db_paste);
4683  mjsonrpc_add_handler("db_get_values", js_db_get_values);
4684  mjsonrpc_add_handler("db_ls", js_db_ls);
4685  mjsonrpc_add_handler("db_create", js_db_create);
4686  mjsonrpc_add_handler("db_delete", js_db_delete);
4687  mjsonrpc_add_handler("db_resize", js_db_resize);
4688  mjsonrpc_add_handler("db_resize_string", js_db_resize_string);
4689  mjsonrpc_add_handler("db_rename", js_db_rename);
4690  mjsonrpc_add_handler("db_scl", js_db_scl);
4691  mjsonrpc_add_handler("db_sor", js_db_sor);
4692  mjsonrpc_add_handler("db_link", js_db_link);
4693  mjsonrpc_add_handler("db_reorder", js_db_reorder);
4694  mjsonrpc_add_handler("db_key", js_db_key);
4695  // interface to elog functions
4696  mjsonrpc_add_handler("el_retrieve", js_el_retrieve, true);
4697  mjsonrpc_add_handler("el_query", js_el_query, true);
4698  mjsonrpc_add_handler("el_delete", js_el_delete, true);
4699  // interface to midas history
4700  mjsonrpc_add_handler("hs_get_active_events", js_hs_get_active_events, true);
4701  mjsonrpc_add_handler("hs_get_channels", js_hs_get_channels, true);
4702  mjsonrpc_add_handler("hs_get_events", js_hs_get_events, true);
4703  mjsonrpc_add_handler("hs_get_tags", js_hs_get_tags, true);
4704  mjsonrpc_add_handler("hs_get_last_written", js_hs_get_last_written, true);
4705  mjsonrpc_add_handler("hs_reopen", js_hs_reopen, true);
4706  mjsonrpc_add_handler("hs_read", js_hs_read, true);
4707  mjsonrpc_add_handler("hs_read_binned", js_hs_read_binned, true);
4708  mjsonrpc_add_handler("hs_read_arraybuffer", js_hs_read_arraybuffer, true);
4709  mjsonrpc_add_handler("hs_read_binned_arraybuffer", js_hs_read_binned_arraybuffer, true);
4710  // interface to image history
4711  mjsonrpc_add_handler("hs_image_retrieve", js_hs_image_retrieve, true);
4712  // sequencer and file_picker
4713  mjsonrpc_add_handler("make_subdir", js_make_subdir, true);
4714  mjsonrpc_add_handler("ext_list_files", js_ext_list_files, true);
4715  mjsonrpc_add_handler("ext_save_file", js_ext_save_file, true);
4716  mjsonrpc_add_handler("ext_read_file", js_ext_read_file, true);
4717  // Read binary files of Uint8Arry
4718  mjsonrpc_add_handler("read_binary_file", js_read_binary_file, true);
4719  // interface to ss_system functions
4720  mjsonrpc_add_handler("ss_millitime", js_ss_millitime);
4721  // methods that perform computations or invoke actions
4722  mjsonrpc_add_handler("get_alarms", get_alarms);
4723  //mjsonrpc_add_handler("get_messages", get_messages);
4724  mjsonrpc_add_handler("jrpc", jrpc);
4725  mjsonrpc_add_handler("brpc", brpc);
4726  mjsonrpc_add_handler("start_program", start_program);
4727  mjsonrpc_add_handler("exec_script", exec_script);
4728  // timezone function
4729  mjsonrpc_add_handler("get_timezone", js_get_timezone);
4730 
4732 }
void mjsonrpc_user_init()
void mjsonrpc_add_handler(const char *method, mjsonrpc_handler_t *handler, bool needs_locking)
Definition: mjsonrpc.cxx:4637
static MJsonNode * js_db_delete(const MJsonNode *params)
Definition: mjsonrpc.cxx:1093
static MJsonNode * js_ext_save_file(const MJsonNode *params)
Definition: mjsonrpc.cxx:4264
static MJsonNode * xnull(const MJsonNode *params)
Definition: mjsonrpc.cxx:412
static MJsonNode * js_hs_get_last_written(const MJsonNode *params)
Definition: mjsonrpc.cxx:1976
static MJsonNode * js_read_binary_file(const MJsonNode *params)
Definition: mjsonrpc.cxx:4422
static MJsonNode * js_make_subdir(const MJsonNode *params)
Definition: mjsonrpc.cxx:4070
static MJsonNode * js_hs_read_arraybuffer(const MJsonNode *params)
Definition: mjsonrpc.cxx:2448
static MJsonNode * js_el_delete(const MJsonNode *params)
Definition: mjsonrpc.cxx:3332
static MJsonNode * js_db_resize_string(const MJsonNode *params)
Definition: mjsonrpc.cxx:1179
static MJsonNode * js_db_sor(const MJsonNode *params)
Definition: mjsonrpc.cxx:1437
static MJsonNode * js_cm_transition(const MJsonNode *params)
Definition: mjsonrpc.cxx:3481
static MJsonNode * jrpc(const MJsonNode *params)
Definition: mjsonrpc.cxx:3355
static MJsonNode * js_db_copy(const MJsonNode *params)
Definition: mjsonrpc.cxx:859
static MJsonNode * js_hs_read_binned_arraybuffer(const MJsonNode *params)
Definition: mjsonrpc.cxx:2633
static MJsonNode * js_cm_msg_facilities(const MJsonNode *params)
Definition: mjsonrpc.cxx:1482
static MJsonNode * js_cm_msg_retrieve(const MJsonNode *params)
Definition: mjsonrpc.cxx:1539
static MJsonNode * get_debug(const MJsonNode *params)
Definition: mjsonrpc.cxx:4502
static MJsonNode * js_get_timezone(const MJsonNode *params)
Definition: mjsonrpc.cxx:4596
static MJsonNode * js_db_create(const MJsonNode *params)
Definition: mjsonrpc.cxx:1029
static MJsonNode * js_db_get_values(const MJsonNode *params)
Definition: mjsonrpc.cxx:639
static MJsonNode * js_db_reorder(const MJsonNode *params)
Definition: mjsonrpc.cxx:1392
static MJsonNode * js_db_ls(const MJsonNode *params)
Definition: mjsonrpc.cxx:804
static MJsonNode * js_bm_receive_event(const MJsonNode *params)
Definition: mjsonrpc.cxx:3662
static MJsonNode * set_sleep(const MJsonNode *params)
Definition: mjsonrpc.cxx:4542
static MJsonNode * exec_script(const MJsonNode *params)
Definition: mjsonrpc.cxx:518
static MJsonNode * js_hs_image_retrieve(const MJsonNode *params)
Definition: mjsonrpc.cxx:2946
static MJsonNode * js_el_retrieve(const MJsonNode *params)
Definition: mjsonrpc.cxx:2991
static MJsonNode * js_al_trigger_class(const MJsonNode *params)
Definition: mjsonrpc.cxx:1637
static MJsonNode * js_al_trigger_alarm(const MJsonNode *params)
Definition: mjsonrpc.cxx:1610
static MJsonNode * get_alarms(const MJsonNode *params)
Definition: mjsonrpc.cxx:3848
static MJsonNode * get_time(const MJsonNode *params)
Definition: mjsonrpc.cxx:4556
static MJsonNode * js_db_resize(const MJsonNode *params)
Definition: mjsonrpc.cxx:1130
static MJsonNode * js_db_rename(const MJsonNode *params)
Definition: mjsonrpc.cxx:1300
static MJsonNode * js_ss_millitime(const MJsonNode *params)
Definition: mjsonrpc.cxx:3829
static MJsonNode * set_debug(const MJsonNode *params)
Definition: mjsonrpc.cxx:4515
static MJsonNode * js_ext_list_files(const MJsonNode *params)
Definition: mjsonrpc.cxx:4136
static MJsonNode * js_hs_get_active_events(const MJsonNode *params)
Definition: mjsonrpc.cxx:1668
static MJsonNode * js_cm_exist(const MJsonNode *params)
Definition: mjsonrpc.cxx:431
static MJsonNode * brpc(const MJsonNode *params)
Definition: mjsonrpc.cxx:3420
static MJsonNode * js_hs_reopen(const MJsonNode *params)
Definition: mjsonrpc.cxx:1873
static MJsonNode * js_cm_shutdown(const MJsonNode *params)
Definition: mjsonrpc.cxx:458
static MJsonNode * get_schema(const MJsonNode *params)
Definition: mjsonrpc.cxx:4583
static MJsonNode * js_al_reset_alarm(const MJsonNode *params)
Definition: mjsonrpc.cxx:1586
static MJsonNode * js_hs_get_tags(const MJsonNode *params)
Definition: mjsonrpc.cxx:1898
static MJsonNode * js_hs_read_binned(const MJsonNode *params)
Definition: mjsonrpc.cxx:2214
static MJsonNode * js_db_scl(const MJsonNode *params)
Definition: mjsonrpc.cxx:1459
static MJsonNode * js_hs_read(const MJsonNode *params)
Definition: mjsonrpc.cxx:2105
static MJsonNode * js_db_paste(const MJsonNode *params)
Definition: mjsonrpc.cxx:914
static MJsonNode * js_hs_get_events(const MJsonNode *params)
Definition: mjsonrpc.cxx:1832
static MJsonNode * get_sleep(const MJsonNode *params)
Definition: mjsonrpc.cxx:4529
static MJsonNode * js_ext_read_file(const MJsonNode *params)
Definition: mjsonrpc.cxx:4340
static MJsonNode * set_time(const MJsonNode *params)
Definition: mjsonrpc.cxx:4569
static MJsonNode * js_cm_msg1(const MJsonNode *params)
Definition: mjsonrpc.cxx:1507
static MJsonNode * js_db_key(const MJsonNode *params)
Definition: mjsonrpc.cxx:1232
static MJsonNode * js_el_query(const MJsonNode *params)
Definition: mjsonrpc.cxx:3057
static MJsonNode * js_hs_get_channels(const MJsonNode *params)
Definition: mjsonrpc.cxx:1755
static MJsonNode * start_program(const MJsonNode *params)
Definition: mjsonrpc.cxx:485
static MJsonNode * js_db_link(const MJsonNode *params)
Definition: mjsonrpc.cxx:1350
Here is the caller graph for this function:

◆ mjsonrpc_make_error()

MJsonNode* mjsonrpc_make_error ( int  code,
const char *  message,
const char *  data 
)

Definition at line 122 of file mjsonrpc.cxx.

123 {
124  MJsonNode* errnode = MJsonNode::MakeObject();
125  errnode->AddToObject("code", MJsonNode::MakeInt(code));
126  errnode->AddToObject("message", MJsonNode::MakeString(message));
127  errnode->AddToObject("data", MJsonNode::MakeString(data));
128 
129  MJsonNode* result = MJsonNode::MakeObject();
130  result->AddToObject("error", errnode);
131  return result;
132 }
void * data
Definition: mana.cxx:268
#define message(type, str)
Definition: midas_macro.h:262
Here is the caller graph for this function:

◆ mjsonrpc_make_result() [1/2]

MJsonNode* mjsonrpc_make_result ( const char *  name,
MJsonNode *  value,
const char *  name2 = NULL,
MJsonNode *  value2 = NULL,
const char *  name3 = NULL,
MJsonNode *  value3 = NULL 
)

Definition at line 141 of file mjsonrpc.cxx.

142 {
143  MJsonNode* node = MJsonNode::MakeObject();
144 
145  if (name)
146  node->AddToObject(name, value);
147  if (name2)
148  node->AddToObject(name2, value2);
149  if (name3)
150  node->AddToObject(name3, value3);
151 
152  MJsonNode* result = MJsonNode::MakeObject();
153  result->AddToObject("result", node);
154  return result;
155 }
double value[100]
Definition: odbhist.cxx:42

◆ mjsonrpc_make_result() [2/2]

MJsonNode* mjsonrpc_make_result ( MJsonNode *  node)

Definition at line 134 of file mjsonrpc.cxx.

135 {
136  MJsonNode* result = MJsonNode::MakeObject();
137  result->AddToObject("result", node);
138  return result;
139 }

◆ mjsonrpc_schema_to_text()

std::string mjsonrpc_schema_to_text ( const MJsonNode *  schema)

Definition at line 5082 of file mjsonrpc.cxx.

5083 {
5084  std::string s;
5085  NestedOutput out;
5086  out.Clear();
5087  mjsonrpc_schema_to_html_anything(schema, 0, &out);
5088  //s += "<pre>\n";
5089  //s += nested_dump();
5090  //s += "</pre>\n";
5091  s += out.Print();
5092  return s;
5093 }
void Clear()
Definition: mjsonrpc.cxx:4810
std::string Print()
Definition: mjsonrpc.cxx:4827
static std::string mjsonrpc_schema_to_html_anything(const MJsonNode *schema, int nest_level, NestedOutput *o)
Definition: mjsonrpc.cxx:5043
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_set_std_mutex()

void mjsonrpc_set_std_mutex ( void *  mutex)

Definition at line 4645 of file mjsonrpc.cxx.

4646 {
4647  gMutex = (std::mutex*)mutex;
4648 }
static std::mutex * gMutex
Definition: mjsonrpc.cxx:4635
Here is the caller graph for this function:

◆ mjsonrpc_user_init()

void mjsonrpc_user_init ( )

Definition at line 116 of file mjsonrpc_user.cxx.

117 {
118  if (mjsonrpc_debug) {
119  printf("mjsonrpc_user_init!\n");
120  }
121 
122  // add user functions to the rpc list
123 
124  mjsonrpc_add_handler("user_example1", user_example1);
125  mjsonrpc_add_handler("user_example2", user_example2);
126  mjsonrpc_add_handler("user_example3", user_example3);
127 }
static MJsonNode * user_example3(const MJsonNode *params)
static MJsonNode * user_example1(const MJsonNode *params)
static MJsonNode * user_example2(const MJsonNode *params)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ P()

void MJSO::P ( const char *  name,
int  mjson_type,
const char *  description 
)

Definition at line 339 of file mjsonrpc.cxx.

340 {
341  if (name == NULL)
342  this->Add("params", mjson_type, description);
343  else
344  Params()->Add(name, mjson_type, description);
345 }
MJSO * Params()
Definition: mjsonrpc.cxx:307
void Add(const char *name, int mjson_type, const char *description)
Definition: mjsonrpc.cxx:355
Here is the call graph for this function:

◆ PA()

MJSO * MJSO::PA ( const char *  description)

Definition at line 325 of file mjsonrpc.cxx.

326 {
328  this->AddToSchema(s, "params");
329  return s;
330 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Params()

MJSO * MJSO::Params ( )

Definition at line 307 of file mjsonrpc.cxx.

308 {
309  if (!params) {
310  params = MakeObjectSchema(NULL);
311  this->AddToSchema(params, "params");
312  }
313  return params;
314 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ R()

void MJSO::R ( const char *  name,
int  mjson_type,
const char *  description 
)

Definition at line 347 of file mjsonrpc.cxx.

348 {
349  if (name == NULL)
350  this->Add("result", mjson_type, description);
351  else
352  Result()->Add(name, mjson_type, description);
353 }
MJSO * Result()
Definition: mjsonrpc.cxx:316
Here is the call graph for this function:

◆ RA()

MJSO * MJSO::RA ( const char *  description)

Definition at line 332 of file mjsonrpc.cxx.

333 {
335  this->AddToSchema(s, "result");
336  return s;
337 }
Here is the call graph for this function:

◆ Result()

MJSO * MJSO::Result ( )

Definition at line 316 of file mjsonrpc.cxx.

317 {
318  if (!result) {
319  result = MakeObjectSchema(NULL);
320  this->AddToSchema(result, "result");
321  }
322  return result;
323 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ items

MJsonNode* MJSO::items
protected

Definition at line 63 of file mjsonrpc.h.

◆ mjsonrpc_debug

int mjsonrpc_debug
extern

Definition at line 111 of file mjsonrpc.cxx.

◆ params

MJSO* MJSO::params
protected

Definition at line 65 of file mjsonrpc.h.

◆ properties

MJsonNode* MJSO::properties
protected

Definition at line 61 of file mjsonrpc.h.

◆ required

MJsonNode* MJSO::required
protected

Definition at line 62 of file mjsonrpc.h.

◆ result

MJSO* MJSO::result
protected

Definition at line 66 of file mjsonrpc.h.