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
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);
JSON data:
db_get_values() status:
Runinfo/State:
Run number:
/Example/int:
/Example/int_array:
data age:
JSON data:
JSON data:
RPC Status:
ls of /Equipment:
ls of /Example:
ls of non-existing directory:
JSON data:
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.
list of messages facilities goes here
number of messages goes here
list of messages goes here
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 last-written goes here
history data
binned history data
history data
binned history data
Observe updated values in the ODBGet() section above. (Hint: press the "update now" button above)
Observe the effect of these functions on the MIDAS Programs page.
Observe the effect of these functions on the MIDAS Status page and Messages page.
Observe the effect of these functions on the MIDAS Alarms page and Status page.
Alarms:
(note: frontend "fetest" should be running!) Also see the result of this function in the output of fetest and
in MIDAS Messages.
JRPC reply:
(note: frontend "fetest" should be running!) Also see the result of this function in the output of fetest and
in MIDAS Messages.
BRPC reply:
Enable tracing of http requests:
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
JSON-RPC schema:
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")
Last updated: never
Last status
Last value