mjsonrpc schema
This page lists every JSON-RPC method provided by the midas web server (mhttpd), with its parameters and results.
These methods are normally called from JavaScript on custom pages, using mjsonrpc_call(). For the most common methods, midas.js has wrapper functions that are easier to use, such as mjsonrpc_db_get_value() instead of mjsonrpc_call("db_get_values", ...). Use mjsonrpc_call() for the methods that don't have a wrapper.
For an introduction to custom pages and JavaScript, see the JavaScript API overview and Custom pages: overview.
Calling a method from JavaScript
mjsonrpc_call("al_reset_alarm", {"alarms": ["Alarm A", "Alarm B"]}).then(function(rpc) {
let result = rpc.result; // The method's results
}).catch(function(error) {
mjsonrpc_error_alert(error);
});
Array indices in ODB paths
db_get_values and db_paste accept array indices at the end of an ODB path, to read or write some of the elements of an array. So do the midas.js functions that call them, such as mjsonrpc_db_get_values(), mjsonrpc_db_paste() and mjsonrpc_db_set_value(). Indices start at 0, and can be listed and combined with ranges:
| Path | Elements |
|---|---|
/Example/Thresholds[2] |
2 |
/Example/Thresholds[1,2,3] |
1, 2 and 3 |
/Example/Thresholds[1-3] |
1, 2 and 3 |
/Example/Thresholds[3-1] |
3, 2 and 1, in that order |
/Example/Thresholds[0,2-4,7] |
0, 2, 3, 4 and 7 |
When reading, a path with one index gives a single value. A path with several indices gives a list of their values, in the order of the indices, and its status is a list with one status for each element.
When writing with db_paste:
- One index (
[2]): give a single value. A list, even of one value, is an error. - Several indices: give a list with one value for each index, in the same order, or a single value to write to all of them. A list of a different length is an error (
DB_TYPE_MISMATCH, 315), and nothing is written. The status is a list with one status for each element. - An index past the end of the array: the array is made longer. Any new elements before it are set to 0.
- No index: the list replaces the whole array, which is resized to the length of the list. To change only some elements, give their indices.
For example, this sets /Example/Count to 9, and elements 3, 2 and 1 of /Example/Thresholds to 30, 20 and 10:
mjsonrpc_db_paste(["/Example/Count", "/Example/Thresholds[3-1]"], [9, [30, 20, 10]]).then(function(rpc) {
let status = rpc.result.status; // [1, [1, 1, 1]]
}).catch(function(error) {
mjsonrpc_error_alert(error);
});
How values are encoded
Most ODB values are sent as the matching JSON numbers, strings and booleans. The exceptions are:
| ODB values | Sent as | Example |
|---|---|---|
UINT16 (WORD), UINT32 (DWORD) and UINT64 |
A string with the value in hexadecimal | "0x55b96181" |
INT64 |
A string with the value in decimal, because JavaScript numbers can't hold every 64-bit integer | "20015998343868" |
Not-a-number and infinity, in FLOAT and DOUBLE |
The strings "NaN", "Infinity" and "-Infinity", because JSON has no way to write these values |
"NaN" |
In JavaScript, Number("0x55b96181") converts the hexadecimal string of a UINT16 or UINT32 value. For INT64 and UINT64 values, use BigInt instead (see below). When writing, you can give these values as numbers or as strings in the same format (e.g. "0x10" or "NaN").
64-bit integers in JavaScript
JavaScript numbers can only hold integers exactly up to 2^53 − 1
If your ODB/webpage uses 64-bit numbers, your JavaScript code must treat them with great care.
Midas returns INT64 and UINT64 values as strings. If you convert them with Number() or parseInt(), they will get rounded! This is particularly problematic if you have a 64-bit number that you're using as a bitmask. You should instead use BigInt() to parse the strings:
| Value sent by midas | True value | Number(value) |
BigInt(value) |
|---|---|---|---|
"9007199254740991" (2^53 − 1, INT64) |
9007199254740991 |
9007199254740991 |
9007199254740991n |
"9007199254740993" (INT64) |
9007199254740993 |
9007199254740992 (rounded) |
9007199254740993n |
"0x0020000000000001" (UINT64) |
9007199254740993 |
9007199254740992 (rounded) |
9007199254740993n |
"0xffffffffffffffff" (UINT64 bitmask with all bits set) |
18446744073709551615 |
18446744073709552000 (rounded, so the lowest bits are lost) |
18446744073709551615n |
Usage of BigInt():
BigInt()converts both decimal strings (used forINT64values) and hexadecimal strings (used forUINT64values).- In calculations, use
BigIntvalues for every number, e.g.1nrather than1. Otherwise you will get errors of the formTypeError: Cannot mix BigInt and other types, use explicit conversions. - To write a value back, either convert it to a string with
toString(), or let JSON encodeBigIntvalues directly (see below). Midas accepts both decimal strings and JSON numbers forINT64/UINT64keys.
These examples read a 64-bit counter, add one to it and write it back. They show different approaches for how to send the 64-bit number to midas:
| Approach | Pros | Cons |
|---|---|---|
toString() |
Works in every browser. Doesn't affect the rest of the page | You have to convert every 64-bit value before writing it, including in arrays and in the parameters of other methods. If you forget one, JSON.stringify() throws an error |
BigInt.prototype.toJSON() |
Set once, then pass BigInt values anywhere, as they are |
Changes BigInt for the whole page. Needs a recent browser (JSON.rawJSON() was added in 2023-2025). JSON written elsewhere on the page also gets 64-bit numbers, which JSON.parse() rounds when it reads them back |
Example using toString()
mjsonrpc_db_get_value("/Example/Event count").then(function(rpc) {
let count = BigInt(rpc.result.data[0]); // e.g. "9007199254740993" (INT64) or "0x0020000000000001" (UINT64)
count += 1n;
return mjsonrpc_db_set_value("/Example/Event count", count.toString()); // "9007199254740994"
}).catch(function(error) {
mjsonrpc_error_alert(error);
});
Example writing BigInts directly
// Once, at the start of the page: write BigInt values in JSON as exact numbers
BigInt.prototype.toJSON = function () {
return JSON.rawJSON(this.toString());
};
mjsonrpc_db_get_value("/Example/Event count").then(function(rpc) {
let count = BigInt(rpc.result.data[0]);
count += 1n;
return mjsonrpc_db_set_value("/Example/Event count", count); // no need for toString()
}).catch(function(error) {
mjsonrpc_error_alert(error);
});
Key names in db_get_values results
When you read an ODB directory with db_get_values (or mjsonrpc_db_get_values()), the key names in the result are in lower case. ODB key names aren't case sensitive, but JavaScript property names are, so this means you don't need to know how a name is capitalised in the ODB:
mjsonrpc_db_get_values(["/Runinfo"]).then(function(rpc) {
let runinfo = rpc.result.data[0];
let run_number = runinfo["run number"]; // "Run number" in the ODB
let state = runinfo.state;
}).catch(function(error) {
mjsonrpc_error_alert(error);
});
Each key also has two extra entries: <name>/name, with the name as it is in the ODB, and <name>/last_written, with the time it was last written. Symlinks are followed, so you get the values they point to. To leave out the extra entries and send less data, call db_get_values with mjsonrpc_call() and set omit_names and omit_last_written. To keep the original capitalisation, set preserve_case, but then you have to use the names exactly as they are in the ODB.
Reading only values that have changed
To update a page without reading everything again, call db_get_values with omit_old_timestamp set to a time (in seconds since 1970). Only the keys written since that time are returned. The time a key was last written is in its /last_written entry. The filtering has some limits:
- An array is returned whole if any of its elements was written.
- Subdirectories are always included, and appear empty (
{}) if nothing in them has changed. - Keys that have never been written (whose last-written time is 0) are always included.
Sending several requests at once
Each call to an mjsonrpc_xxx function sends a separate HTTP request to mhttpd. To send several JSON-RPC requests in one HTTP request, which is much faster, build the requests with mjsonrpc_make_request() and send them together as a list with mjsonrpc_send_request(). The result is a list with one entry for each request, in the same order. Each entry has result if the request worked, or error if it didn't, so check each one:
let requests = [
mjsonrpc_make_request("db_get_values", {"paths": ["/Runinfo"]}),
mjsonrpc_make_request("cm_msg_retrieve", {"min_messages": 10})
];
mjsonrpc_send_request(requests).then(function(batch) {
for (let rpc of batch) {
if (rpc.error)
console.log("Request " + rpc.request.method + " failed: " + rpc.error.message);
}
let runinfo = batch[0].result.data[0];
let messages = batch[1].result.messages;
}).catch(function(error) {
mjsonrpc_error_alert(error);
});
From other languages (see below), send a JSON array of requests in the body of one POST, and the reply is a JSON array of replies.
Calling these methods from other languages
If you want, you can also call these methods from scripts and programs written in other languages: any language that can send an HTTP request will work. Send a JSON-RPC 2.0 request as an HTTP POST to mhttpd's ?mjsonrpc URL, with the Content-Type: application/json header. Put the method's parameters in params, and read its results from result.
For C++ and Python, the midas libraries are usually a better choice, as they talk to the experiment directly rather than through mhttpd. See Hello world! Writing programs in midas.
These examples read /Runinfo/Run number from mhttpd on the same machine, which by default listens on port 8080 without a password. To connect from another machine, see Web security.
curl -s -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "db_get_values", "params": {"paths": ["/Runinfo/Run number"]}, "id": 1}' \
"http://localhost:8080/?mjsonrpc"
The reply looks like:
{"result":{"data":[123],"status":[1],"tid":[7],"last_written":[1792014728]},"jsonrpc":"2.0","id":1}
This example needs Java 15 or later, and only uses the standard library.
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class RunNumber {
public static void main(String[] args) throws Exception {
String request = """
{"jsonrpc": "2.0", "method": "db_get_values",
"params": {"paths": ["/Runinfo/Run number"]}, "id": 1}
""";
HttpRequest httpRequest = HttpRequest.newBuilder(URI.create("http://localhost:8080/?mjsonrpc"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(request))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Parse the reply with a JSON library, such as Jackson or Gson
System.out.println(response.body());
}
}
This example needs .NET 6 or later, and only uses the standard library.
using System.Net.Http.Json;
using System.Text.Json;
var request = new
{
jsonrpc = "2.0",
method = "db_get_values",
@params = new { paths = new[] { "/Runinfo/Run number" } },
id = 1
};
using var client = new HttpClient();
var response = await client.PostAsJsonAsync("http://localhost:8080/?mjsonrpc", request);
response.EnsureSuccessStatusCode();
using var reply = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
if (reply.RootElement.TryGetProperty("error", out var error))
throw new Exception($"RPC error: {error.GetProperty("message")}");
var result = reply.RootElement.GetProperty("result");
var status = result.GetProperty("status")[0].GetInt32();
if (status != 1)
throw new Exception($"db_get_values status {status}");
Console.WriteLine($"Run number: {result.GetProperty("data")[0]}");
All methods
al_reset_alarm
reset alarms
Parameters:This method accepts an object with keys:
-
alarms(array of string)REQUIRED- array of alarm names
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of al_reset_alarm() for each alarm
al_trigger_alarm
trigger an alarm
Parameters:This method accepts an object with keys:
-
name(string)REQUIRED- alarm name -
message(string)REQUIRED- alarm message -
class(string)REQUIRED- alarm class -
condition(string)REQUIRED- alarm condition -
type(integer)REQUIRED- alarm type (AT_xxx)
The rpc.result member contains
an object with keys:
-
status(integer) - return status of al_trigger_alarm()
al_trigger_class
trigger an alarm
Parameters:This method accepts an object with keys:
-
class(string)REQUIRED- alarm class -
message(string)REQUIRED- alarm message -
first(bool) - see al_trigger_class() in midas.c
The rpc.result member contains
an object with keys:
-
status(integer) - return status of al_trigger_class()
bm_receive_event
read event buffers
Parameters:This method accepts an object with keys:
-
buffer_name(string)REQUIRED- name of event buffer -
event_id(integer) - requested event id, -1 means any event id -
trigger_mask(integer) - requested trigger mask, -1 means any trigger mask -
get_recent(bool) - get last available event that matches this event request -
last_event_header(array of integer) - do not resend an event we already received: event header of last received event [event_id,trigger_mask,serial_number,time_stamp] -
timeout_millisec(number) - how long to wait for an event
The rpc.result member contains
an object with keys:
-
binary data(arraybuffer) - binary event data -
status(integer) - return status of bm_open_buffer(), bm_request_event(), bm_set_cache_size(), bm_receive_alloc()
brpc
make RPC call into frontend program via RPC_BRPC
Parameters:This method accepts an object with keys:
-
client_name(string)REQUIRED- Connect to this MIDAS client, see cm_connect_client() -
cmd(string)REQUIRED- Command passed to client -
args(string)REQUIRED- Parameters passed to client as a string, could be JSON encoded -
max_reply_length(integer) - Optional maximum length of client reply. MIDAS RPC does not support returning data of arbitrary length, maximum length has to be known ahead of time.
The rpc.result member contains
an object with keys:
-
reply(string) - Reply from client as a string, could be JSON encoded -
status(integer) - return status of cm_connect_client() and rpc_client_call()
brpc_cxx
make RPC call into frontend program via RPC_BRPC_CXX
Parameters:This method accepts an object with keys:
-
client_name(string)REQUIRED- Connect to this MIDAS client, see cm_connect_client() -
cmd(string)REQUIRED- Command passed to client -
args(string)REQUIRED- Parameters passed to client as a string, could be JSON encoded
The rpc.result member contains
an object with keys:
-
reply(string) - Reply from client as a string, could be JSON encoded -
status(integer) - return status of cm_connect_client() and rpc_client_call()
brpc_old
make RPC call into frontend program via RPC_BRPC
Parameters:This method accepts an object with keys:
-
client_name(string)REQUIRED- Connect to this MIDAS client, see cm_connect_client() -
cmd(string)REQUIRED- Command passed to client -
args(string)REQUIRED- Parameters passed to client as a string, could be JSON encoded -
max_reply_length(integer) - Optional maximum length of client reply. MIDAS RPC does not support returning data of arbitrary length, maximum length has to be known ahead of time.
The rpc.result member contains
an object with keys:
-
reply(string) - Reply from client as a string, could be JSON encoded -
status(integer) - return status of cm_connect_client() and rpc_client_call()
cm_exist
calls MIDAS cm_exist() to check if given MIDAS program is running
Parameters:This method accepts an object with keys:
-
name(string)REQUIRED- name of the program, corresponding to ODB /Programs/name -
unique(bool) - bUnique argument to cm_exist()
The rpc.result member contains
an object with keys:
-
status(integer) - return status of cm_exist()
cm_msg1
Generate a midas message using cm_msg1()
Parameters:This method accepts an object with keys:
-
facility(string) - message facility, default is "midas" -
user(string) - message user, default is "javascript_commands" -
type(integer) - message type, MT_xxx from midas.h, default is MT_INFO -
message(string)REQUIRED- message text
The rpc.result member contains
an object with keys:
-
status(integer) - return status of cm_msg1()
cm_msg_facilities
get message facilities using cm_msg_facilities()
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
an object with keys:
-
status(integer) - return status of cm_msg_facilities() -
facilities(array of string) - array of facility names
cm_msg_retrieve
Retrieve midas messages using cm_msg_retrieve2()
Parameters:This method accepts an object with keys:
-
facility(string) - message facility, default is "midas" -
min_messages(integer) - get at least this many messages, default is 1 -
time(number) - start from given timestamp, value 0 means give me newest messages, default is 0
The rpc.result member contains
an object with keys:
-
num_messages(integer) - number of messages returned -
messages(string) - messages separated by \n -
status(integer) - return status of cm_msg_retrieve2()
cm_shutdown
calls MIDAS cm_shutdown() to stop given MIDAS program
Parameters:This method accepts an object with keys:
-
name(string)REQUIRED- name of the program, corresponding to ODB /Programs/name
The rpc.result member contains
an object with keys:
-
status(integer) - return status of cm_shutdown()
cm_transition
start and stop runs
Parameters:This method accepts an object with keys:
-
transition(string)REQUIRED- requested transition: TR_START, TR_STOP, TR_PAUSE, TR_RESUME -
run_number(integer) - New run number, value 0 means /runinfo/run_number + 1, default is 0 -
async_flag(integer) - Transition type. Default is multithreaded transition TR_MTHREAD -
debug_flag(integer) - See cm_transition(), value 1: trace to stdout, value 2: trace to midas.log
The rpc.result member contains
an object with keys:
-
status(integer) - return status of cm_transition() -
error_string(string) - return error string from cm_transition()
db_copy
get complete ODB data in the "save" json encoding, suitable for reloading with odbedit command "load"
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB subtree paths
The rpc.result member contains
an object with keys:
-
data(array of object) - keys and values of ODB data for each path -
status(array of integer) - return status of db_copy_json_save() for each path
db_create
Create new ODB entries
Parameters:This method accepts a single parameter (not an object):
-
(
object) - {desc}
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_create_key(), db_set_num_values() and db_set_data() (for TID_STRING) for each path
db_delete
delete ODB keys
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB paths to delete
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_delete() for each path
db_get_values
get values of ODB data from given subtrees
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB subtree paths, see note on array indices -
omit_names(bool) - omit the /name entries -
omit_last_written(bool) - omit the /last_written entries and the last_written[] result -
omit_tid(bool) - omit the tid[] result -
omit_old_timestamp(number) - omit data older than given ODB timestamp -
preserve_case(bool) - preserve the capitalization of ODB key names (WARNING: ODB is not case sensitive); note that this will also have side effect of setting the omit_names option
The rpc.result member contains
an object with keys:
-
data(array of anything) - values of ODB data for each path, all key names are in lower case, all symlinks are followed -
status(array of integer) - return status of db_copy_json_values() or db_copy_json_index() for each path -
tid(array of integer) - odb type id for each path, absent if omit_tid is true -
last_written(array of number) - last_written value of the ODB subtree for each path, absent if omit_last_written is true
db_key
get ODB keys
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB paths
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_key() for each path -
keys(array of integer) - timestamp when data was last updated
db_link
Create ODB symlinks
Parameters:This method accepts an object with keys:
-
new_links(array of string)REQUIRED- array of new symlinks to be created -
target_paths(array of string)REQUIRED- array of existing ODB paths for each link
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_create_link() for each path
db_ls
get contents of given ODB subdirectory in the "ls" json encoding - similar to odbedit command "ls -l"
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB subtree paths
The rpc.result member contains
an object with keys:
-
data(array of object) - keys and values of ODB data for each path -
status(array of integer) - return status of db_copy_json_ls() for each path
db_paste
write data into ODB
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB subtree paths, see note on array indices -
values(array of anything)REQUIRED- array of data values written to ODB via db_paste_json() for each path
The rpc.result member contains
an object with keys:
-
status(array of integer) - array of return status of db_paste_json() for each path
db_rename
Change size of ODB arrays
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB paths to rename -
new_names(array of string)REQUIRED- array of new names for each ODB path
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_rename_key() for each path
db_reorder
Change order of ODB keys in a subdirectory
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of new symlinks to be created -
indices(array of integer)REQUIRED- array of existing ODB paths for each link
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_reorder_key() for each path
db_resize
Change size of ODB arrays
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB paths to resize -
new_lengths(array of integer)REQUIRED- array of new lengths for each ODB path
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_set_num_values() for each path
db_resize_string
Change size of ODB string arrays
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB paths to resize -
new_lengths(array of integer)REQUIRED- array of new lengths for each ODB path -
new_string_lengths(array of integer)REQUIRED- array of new string lengths for each ODB path
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_resize_string() for each path
db_scl
Show ODB clients
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
an object with keys:
-
scl(json) - return value of db_scl()
db_set_mode
set access modes for ODB keys
Parameters:This method accepts an object with keys:
-
paths(array of string)REQUIRED- array of ODB paths -
modes(array of integer)REQUIRED- array of access mode bitmaps -
recursive(bool) - also set modes of directory contents recursively (default false)
The rpc.result member contains
an object with keys:
-
status(array of integer) - return status of db_set_mode() for each path
db_sor
Show ODB open records starting from given ODB path
Parameters:This method accepts an object with keys:
-
path(string) - ODB path
The rpc.result member contains
an object with keys:
-
sor(json) - return value of db_sor()
el_delete
Delete elog message
Parameters:This method accepts an object with keys:
-
tag(string)REQUIRED- tag of message to delete
The rpc.result member contains
an object with keys:
-
status(integer) - return status of el_delete
el_query
Query elog messages
Parameters:This method accepts an object with keys:
-
last_n_hours(integer) - return messages from the last N hours
The rpc.result member contains
an object with keys:
-
status(integer) - return status of el_retrieve -
msg(array of string) - message tag
el_retrieve
Get an elog message
Parameters:This method accepts an object with keys:
-
tag(string)REQUIRED- elog message tag
The rpc.result member contains
an object with keys:
-
status(integer) - return status of el_retrieve -
msg.tag(string) - message tag
exec_script
execute custom script defined in ODB /Script (scripts show in the menu) or /CustomScript (scripts from custom pages)
Parameters:This method accepts an object with keys:
-
script(string) - Execute ODB /Script/xxx -
customscript(string) - Execute ODB /CustomScript/xxx
The rpc.result member contains
an object with keys:
-
status(integer) - return status of cm_exec_script()
ext_delete_file
Delete a file or empty directory within userfiles
Parameters:This method accepts an object with keys:
-
filename(string)REQUIRED- Path relative to userfiles; symlinks and root are not allowed
The rpc.result member contains
an object with keys:
-
status(integer) - SUCCESS on success -
error(string) - Failure description
ext_list_files
js_ext_list_files
Parameters:This method accepts an object with keys:
-
subdir(string)REQUIRED- List files in experiment_directory/userfiles/subdir -
fileext(string)REQUIRED- Filename extension
The rpc.result member contains
an object with keys:
-
status(integer) - return status of midas library calls -
path(string) - Search path -
subdirs(array of string) - list of subdirectories -
files(array of string) - script description
ext_read_file
js_ext_read_script
Parameters:This method accepts an object with keys:
-
filename(string)REQUIRED- File name, read from experiment_directory/userfiles/filename
The rpc.result member contains
an object with keys:
-
content(string) - ASCII file content -
status(integer) - return status of midas library calls -
error(string) - error text
ext_rename_file
Rename a file or directory within userfiles without overwriting an existing entry
Parameters:This method accepts an object with keys:
-
filename(string)REQUIRED- Existing path relative to userfiles -
new_name(string)REQUIRED- New base name in the same directory
The rpc.result member contains
an object with keys:
-
status(integer) - SUCCESS on success -
error(string) - Failure description
ext_save_file
js_ext_save_file
Parameters:This method accepts an object with keys:
-
filename(string)REQUIRED- File name, save in experiment_directory/userfiles/filename -
script(string)REQUIRED- ASCII content
The rpc.result member contains
an object with keys:
-
status(integer) - return status of midas library calls -
error(string) - error text
get_alarms
get alarm data
Parameters:This method accepts an object with keys:
-
get_all(bool) - get all alarms, even in alarm system not active and alarms not triggered
The rpc.result member contains
an object with keys:
-
status(integer) - return status of midas library calls -
alarm_system_active(bool) - value of ODB "/Alarms/alarm system active" -
alarms(array of string) - final alarm text shown to user by mhttpd
get_debug
get current value of mjsonrpc_debug
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
integer) - current value of mjsonrpc_debug
get_schema
Get the MIDAS JSON-RPC schema JSON object
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
object) - returns the MIDAS JSON-RPC schema JSON object
get_sleep
get current value of mjsonrpc_sleep
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
integer) - current value of mjsonrpc_sleep
get_time
get current value of mjsonrpc_time
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
integer) - current value of mjsonrpc_time
get_timezone
get current server timezone offset in seconds
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
integer) - offset in seconds
hs_get_active_events
get list of active history events using hs_read_event_list()
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
an object with keys:
-
status(integer) - return status of hs_read_event_list() -
events(array of string) - array of history event names
hs_get_channels
get list of history channels in /Logger/History
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
an object with keys:
-
status(integer) - return success or failure status -
default_channel(string) - name of the default logger history channel -
channels(array of string) - all logger history channel names -
active_channels(array of string) - active logger history channel names
hs_get_events
get list of history events that existed at give time using hs_get_events()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
time(number) - timestamp, value 0 means current time, default is 0
The rpc.result member contains
an object with keys:
-
status(integer) - return status of hs_get_events() -
channel(string) - logger history channel name -
events(array of string) - array of history event names
hs_get_last_written
get list of history tags for given history events that existed at give time using hs_get_last_written()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
time(number) - timestamp, value 0 means current time, default is 0 -
events(array of string)REQUIRED- array of history event names -
tags(array of string)REQUIRED- array of history event tag names -
index(array of string)REQUIRED- array of history event tag array indices
The rpc.result member contains
an object with keys:
-
status(integer) - return status -
channel(string) - logger history channel name -
last_written(array of number) - array of last-written times for each history event
hs_get_tags
get list of history tags for given history events that existed at give time using hs_get_tags()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
time(number) - timestamp, value 0 means current time, default is 0 -
events(array of string) - array of history event names, default is get all events using hs_get_events()
The rpc.result member contains
an object with keys:
-
status(integer) - return status -
channel(string) - logger history channel name -
events(array of integer) - history tag number of array elements, omitted if 1
hs_image_retrieve
Get a list of history image files
Parameters:This method accepts an object with keys:
-
image(string) - image name as defined under /History/Images/<image> -
start_time(number)REQUIRED- start time of the data -
end_time(number)REQUIRED- end time of the data
The rpc.result member contains
an object with keys:
-
time(array of arraybuffer) - array of time stamps in seconds -
filename(array of arraybuffer) - array of file names
hs_read
get history data for given history events that existed at give time using hs_read_buffer()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
start_time(number)REQUIRED- start time of the data -
end_time(number)REQUIRED- end time of the data -
events(array of string)REQUIRED- array of history event names -
tags(array of string)REQUIRED- array of history event tag names -
index(array of string)REQUIRED- array of history event tag array indices
The rpc.result member contains
an object with keys:
-
status(integer) - return status -
channel(string) - logger history channel name -
data(array of number) - value data
hs_read_arraybuffer
get history data for given history events that existed at give time using hs_read_buffer()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
start_time(number)REQUIRED- start time of the data -
end_time(number)REQUIRED- end time of the data -
events(array of string)REQUIRED- array of history event names -
tags(array of string)REQUIRED- array of history event tag names -
index(array of string)REQUIRED- array of history event tag array indices
The rpc.result member contains
an object with keys:
-
binary data(arraybuffer) - binary data, see documentation
hs_read_binned
get history data for given history events that existed at give time using hs_read_buffer()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
start_time(number)REQUIRED- start time of the data -
end_time(number)REQUIRED- end time of the data -
num_bins(integer)REQUIRED- number of time bins -
events(array of string)REQUIRED- array of history event names -
tags(array of string)REQUIRED- array of history event tag names -
index(array of string)REQUIRED- array of history event tag array indices
The rpc.result member contains
an object with keys:
-
status(integer) - return status -
channel(string) - logger history channel name -
data(array of number) - value of last data entry
hs_read_binned_arraybuffer
get history data for given history events that existed at give time using hs_read_buffer()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel -
start_time(number)REQUIRED- start time of the data -
end_time(number)REQUIRED- end time of the data -
num_bins(integer)REQUIRED- number of time bins -
events(array of string)REQUIRED- array of history event names -
tags(array of string)REQUIRED- array of history event tag names -
index(array of string)REQUIRED- array of history event tag array indices
The rpc.result member contains
an object with keys:
-
binary data(arraybuffer) - binary data, see documentation
hs_reopen
reopen the history channel to make sure we see the latest list of events using hs_clear_cache()
Parameters:This method accepts an object with keys:
-
channel(string) - midas history channel, default is the default reader channel
The rpc.result member contains
an object with keys:
-
status(integer) - return status of hs_get_events() -
channel(string) - logger history channel name
jrpc
make RPC call into frontend program via RPC_JRPC
Parameters:This method accepts an object with keys:
-
client_name(string)REQUIRED- Connect to this MIDAS client, see cm_connect_client() -
cmd(string)REQUIRED- Command passed to client -
args(string)REQUIRED- Parameters passed to client as a string, could be JSON encoded -
max_reply_length(integer) - Optional maximum length of client reply. MIDAS RPC does not support returning strings of arbitrary length, maximum length has to be known ahead of time.
The rpc.result member contains
an object with keys:
-
reply(string) - Reply from client as a string, could be JSON encoded -
status(integer) - return status of cm_connect_client() and rpc_client_call()
jrpc_cxx
make RPC call into frontend program via RPC_JRPC_CXX
Parameters:This method accepts an object with keys:
-
client_name(string)REQUIRED- Connect to this MIDAS client, see cm_connect_client() -
cmd(string)REQUIRED- Command passed to client -
args(string)REQUIRED- Parameters passed to client as a string, could be JSON encoded
The rpc.result member contains
an object with keys:
-
reply(string) - Reply from client as a string, could be JSON encoded -
status(integer) - return status of cm_connect_client() and rpc_client_call()
jrpc_old
make RPC call into frontend program via RPC_JRPC
Parameters:This method accepts an object with keys:
-
client_name(string)REQUIRED- Connect to this MIDAS client, see cm_connect_client() -
cmd(string)REQUIRED- Command passed to client -
args(string)REQUIRED- Parameters passed to client as a string, could be JSON encoded -
max_reply_length(integer) - Optional maximum length of client reply. MIDAS RPC does not support returning strings of arbitrary length, maximum length has to be known ahead of time.
The rpc.result member contains
an object with keys:
-
reply(string) - Reply from client as a string, could be JSON encoded -
status(integer) - return status of cm_connect_client() and rpc_client_call()
make_subdir
js_make_subdir
Parameters:This method accepts an object with keys:
-
subdir(string)REQUIRED- Create folder experiment_directory/userfiles/subdir
The rpc.result member contains
an object with keys:
-
status(integer) - return status of midas library calls -
path(string) - Search path
null
RPC method always returns null
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
null) - always returns null
read_binary_file
js_read_binary_file
Parameters:This method accepts an object with keys:
-
filename(string)REQUIRED- File name, read from experiment_directory/userfiles/filename
The rpc.result member contains
an object with keys:
-
binary data(arraybuffer) - Binary file content -
status(integer) - Return status of midas library calls -
error(string) - Error text
seq_validate
js_seq_validate
Parameters:This method accepts an object with keys:
-
script(string)REQUIRED- MSL source text -
filename(string) - current file below userfiles/sequencer, used to resolve INCLUDE paths
The rpc.result member contains
an object with keys:
-
status(integer) - MIDAS status code -
errors(array of string) - validation diagnostic -
warnings(array of string) - non-blocking missing ODB path diagnostic
set_debug
set new value of mjsonrpc_debug
Parameters:This method accepts a single parameter (not an object):
-
(
object) - {desc}
The rpc.result member contains
a single value:
-
(
integer) - new value of mjsonrpc_debug
set_sleep
set new value of mjsonrpc_sleep
Parameters:This method accepts a single parameter (not an object):
-
(
object) - {desc}
The rpc.result member contains
a single value:
-
(
integer) - new value of mjsonrpc_sleep
set_time
set new value of mjsonrpc_time
Parameters:This method accepts a single parameter (not an object):
-
(
object) - {desc}
The rpc.result member contains
a single value:
-
(
integer) - new value of mjsonrpc_time
ss_millitime
get current MIDAS time using ss_millitime()
Parameters:There are no parameters for this method.
Returns:The rpc.result member contains
a single value:
-
(
integer) - current value of ss_millitime()
start_program
start MIDAS program defined in ODB /Programs/name
Parameters:This method accepts an object with keys:
-
name(string)REQUIRED- name of the program, corresponding to ODB /Programs/name
The rpc.result member contains
an object with keys:
-
status(integer) - return status of ss_system()
user_example1
example of user defined RPC method that returns up to 3 results
Parameters:This method accepts an object with keys:
-
arg(string)REQUIRED- example string argment -
optional_arg(integer) - optional example integer argument
The rpc.result member contains
an object with keys:
-
string(string) - returns the value of "arg" parameter -
integer(integer) - returns the value of "optional_arg" parameter
user_example2
example of user defined RPC method that returns more than 3 results
Parameters:This method accepts an object with keys:
-
arg(string)REQUIRED- example string argment -
optional_arg(integer) - optional example integer argument
The rpc.result member contains
an object with keys:
-
string1(string) - returns the value of "arg" parameter -
string2(string) - returns "hello" -
string3(string) - returns "world!" -
value1(integer) - returns the value of "optional_arg" parameter -
value2(number) - returns 3.14
user_example3
example of user defined RPC method that returns an error
Parameters:This method accepts an object with keys:
-
arg(integer)REQUIRED- integer value, if zero, throws a JSON-RPC error
The rpc.result member contains
an object with keys:
-
status(integer) - returns the value of "arg" parameter