MIDAS Javascript functions

This web page shows examples of how to use most MIDAS javascript and JSON-RPC functions. For more information, please read the MIDAS documentation: https://midas.triumf.ca/MidasWiki/index.php/Mhttpd.js

Index

mjsonrpc_set_url(url);
mjsonrpc_db_get_values(paths);
mjsonrpc_db_copy(paths);
mjsonrpc_db_paste(paths, values);
mjsonrpc_db_ls(paths); 
mjsonrpc_db_create(specs);
mjsonrpc_db_resize(paths, new_lengths);
test db_resize_string(paths, new_lengths, new_string_lengths);
mjsonrpc_db_key(paths);
test db_rename
test db_link
test db_reorder
mjsonrpc_db_delete(paths); 
mjsonrpc_cm_msg(message);
test cm_msg_facilities();
test cm_msg_retrieve(facility, time, min_messages);
test cm_exist()
test cm_shutdown()
test start_program()
test al_trigger_alarm()  
test al_reset_alarm()  
test get_alarms()
test jrpc()
test brpc()
ODBEdit(path);
        

ODB functions:

mjsonrpc_db_create()

mjsonrpc_db_get_values()


JSON data:
db_get_values() status:
Runinfo/State:
Run number:
/Example/int:
/Example/int_array:
data age:

db_get_value() omit all optional information to reduce data size


JSON data:

mjsonrpc_db_copy()


JSON data:

mjsonrpc_db_paste()

mjsonrpc_db_ls()


RPC Status:
ls of /Equipment:
ls of /Example:
ls of non-existing directory:

mjsonrpc_db_resize()

db_resize_string()

mjsonrpc_db_key()


JSON data:

mjsonrpc_db_rename()

mjsonrpc_db_link()

mjsonrpc_db_reorder()

mjsonrpc_db_delete()


Message functions

mjsonrpc_cm_msg()

Type in a message and press Enter. See the new message on the MIDAS "messages" page or press "Get MIDAS messages" button in the ODBGetMsg() section above.

cm_msg_facilities


list of messages facilities goes here

cm_msg_retrieve


number of messages goes here
list of messages goes here


History functions

hs_get_active_events (hs_read_event_list)


list of active history events goes here


list of logger history channels


result of hs_reopen


list of history events goes here


list of history events goes here, channel MIDAS


list of history tags goes here


list of history last-written goes here


history data


binned history data


history data


binned history data


Inline editor functions

ODBEdit()

Observe updated values in the ODBGet() section above. (Hint: press the "update now" button above)


Programs control functions

Observe the effect of these functions on the MIDAS Programs page.


Run control

Observe the effect of these functions on the MIDAS Status page and Messages page.

test cm_transition()

test cm_transition_status()


Alarm functions

Observe the effect of these functions on the MIDAS Alarms page and Status page.

mjsonrpc_al_trigger_alarm()

mjsonrpc_al_reset_alarm()

mjsonrpc_get_alarms()


Alarms:


mjsonrpc_jrpc() direct RPC from web page to frontend program

(note: frontend "fetest" should be running!) Also see the result of this function in the output of fetest and in MIDAS Messages.

JRPC reply:


mjsonrpc_brpc() direct RPC from web page to frontend program

(note: frontend "fetest" should be running!) Also see the result of this function in the output of fetest and in MIDAS Messages.

BRPC reply:


mhttpd special functions

Enable tracing of http requests:

MIDAS JSON RPC special functions and test cases

Test built-in functions:

Test json encoder and decoder:

Test error responses:

Test batch requests:

Test examples from mjsonrpc_user.cxx

test mjsonrpc_db_get_values() crash

test mjsonrpc_db_paste() array korner cases

test mjsonrpc_db_paste() values korner cases TID_BOOL /example/bool

test mjsonrpc_db_paste() values korner cases TID_INT /example/int

test mjsonrpc_db_paste() values korner cases TID_DWORD /example/dword

test mjsonrpc_db_paste() values korner cases TID_QWORD /example/qword

test mjsonrpc_db_paste() values korner cases TID_DOUBLE /example/double

test mjsonrpc_db_paste() values korner cases TID_FLOAT /example/float

Test nan and inf encoding

Test arraybuffer requests

Test modbset()

Test set and get e.innerHTML or enter: Span: test_innerHTML

mjsonrpc_get_schema()


JSON-RPC schema:


Obsolete functions

ODBSet(path, value, pwdname); ---- use mjsonrpc_db_paste() instead
ODBGet(path, format, defval, len, type); ---- use ODBMCopy() instead ---- use mjsonrpc_db_get_values() instead
ODBMGet(paths, callback, formats); ---- use ODBMCopy() instead ---- use mjsonrpc_db_get_values() instead
ODBGetRecord(path); ---- use ODBMCopy() instead ---- use mjsonrpc_db_get_values() instead
ODBExtractRecord(record, key); ---- use ODBMCopy() instead ---- use mjsonrpc_db_get_values() instead
new ODBKey(path); ---- use ODBMKey() instead
ODBCopy(path, format); ---- use ODBMCopy() instead ---- use mjsonrpc_db_get_values() instead
ODBMCopy(paths, callback, format); ---- use mjsonrpc_db_get_values() instead
ODBMLs(paths, callback); ---- use mjsonrpc_db_ls() instead
ODBMCreate(paths, types); ---- use mjsonrpc_db_create() instead
ODBMCreate(paths, types, arraylengths, stringlengths, callback); ---- use mjsonrpc_db_create() instead
ODBMResize(paths, arraylengths, stringlengths, callback); ---- use mjsonrpc_db_resize() instead
ODBMRename(paths, names, callback);  ---- use RPC "db_rename"
ODBMLink(paths, links, callback);  ---- use RPC "db_link"
ODBMReorder(paths, indices, callback); ---- use RPC "db_reorder"
ODBMKey(paths, callback); ---- use mjsonrpc_db_key() instead
ODBMDelete(paths, callback); ---- use mjsonrpc_db_delete() instead
ODBRpc(name, command, args[, callback[, max_reply_length]]); ---- use RPC "jrpc"
ODBGenerateMsg(m); ---- use mjsonrpc_cm_msg() instead
ODBGetMsg(n); --- use RPC "cm_msg_retrieve"
ODBGetAlarms(); ---- use mjsonrpc_call("get_alarms")
        

Example of periodic update

Last updated: never

Last status

Last value