Midas C++ API
This section contains the full API reference for the midas C++ library.
For a first example program, and how to build it with make or CMake, see Hello world! Writing programs in midas.
Each feature also has a "programming" page with examples, such as ODB: programming.
Midas itself is written in C++, and its C++ library gives you access to every feature. Most of the library is a set of C-style functions declared in midas.h, which work the same way as they did when midas was written in C. Newer, higher-level C++ interfaces are available for some features, such as accessing the ODB and writing frontends.
Conventions
Most of the C-style functions follow the same conventions:
- Prefixes: functions are grouped by a prefix that says which part of midas they belong to, such as
cm_xxxfor common functions anddb_xxxfor the ODB. Each group has its own page, listed below - Status codes: most functions return an
INTstatus code. All the success codes (SUCCESS,CM_SUCCESS,DB_SUCCESSetc.) have the value 1, and other values say what went wrong. The codes are listed in Status and error codes - Outputs: results are returned through pointer parameters. Where a function fills a buffer, you also pass the size of the buffer, and some functions update the size to say how much they wrote
- Handles: objects inside midas (the ODB, an ODB key, an event buffer etc.) are referred to by an integer
HNDLE. ODB: programming explains the ODB handles - Types: midas defines its own fixed-size types, such as
INT,DWORDandBOOL, and theTID_xxxcodes for the ODB data types. See Data types
Contents
Core library
Most of these functions are declared in midas.h. The exceptions are the history functions, which are in history.h, and the ring buffer functions and many of the system services, which are in msystem.h.
| Page | Contents |
|---|---|
cm_xxx |
Common functions: connecting to an experiment, run transitions, watchdogs, cm_yield() and other client housekeeping |
cm_msg_xxx |
Writing and reading messages |
bm_xxx |
Sending and receiving events through event buffers |
db_xxx |
Low-level access to the ODB |
bk_xxx |
Creating and reading data banks in events |
rpc_xxx |
Remote procedure calls between midas programs, including JSON-RPC |
ss_xxx |
System services: operating-system functions such as threads, mutexes, timers and shared memory |
rb_xxx |
Ring buffers for passing data between threads |
al_xxx |
Triggering and resetting alarms |
el_xxx |
Submitting and reading elog entries |
hs_xxx |
Reading and writing history data |
Higher-level interfaces
| Page | Header | Contents |
|---|---|---|
midas::odb |
odbxx.h |
Modern C++ access to the ODB, which behaves like a dictionary that's kept in sync with the ODB |
| MVOdb | mvodb.h |
Object-oriented ODB access, which also works with saved ODB dumps |
| TMFE | tmfe.h |
Object-oriented C++ framework for writing frontends |
| mfe | mfe.h |
The original C-style framework for writing frontends |
| mdev | drivers/mdev/mdev.h |
Framework and drivers for slow control frontends |
ODB: programming compares the three ways of accessing the ODB from C++, and Frontends: programming compares the frontend frameworks.
Other libraries
| Page | Header | Contents |
|---|---|---|
| MSCB | mscb/include/mscbxx.h, mscb.h |
Access to MSCB devices, from C++ (midas::mscb) or C |
| Hardware access | mvmestd.h, mcstd.h, ... |
Standard interfaces for VME, CAMAC and Fastbus crates and USB devices |
| midasio | midasio/midasio.h |
Reading and writing midas data files |
| manalyzer | manalyzer/manalyzer.h |
Framework for analysing midas data, online or from files |
| mjson | mjson/mjson.h |
Parsing, building and writing JSON documents (MJsonNode) |
| mxml | mxml/mxml.h |
Parsing, building and writing XML documents |
| Utility functions | mstrlcpy.h, crc32c.h |
Safe string copying (mstrlcpy(), mstrlcat()) and CRC-32C checksums |
Definitions
| Page | Contents |
|---|---|
| Constants and generic macros | TID_xxx types, basic types, built-in limits, CAMAC LAM sources and CNAF commands, and other constants and macros |
| Status and error codes | The status codes that functions return, such as DB_SUCCESS and DB_NO_KEY |
| Data structures | Structures such as KEY, EVENT_HEADER and EQUIPMENT |
| System internals | Constants, macros and structures from msystem.h, which are mostly used inside midas itself |