Skip to content

Midas C++ API - constants and generic macros

This page contains the constants, basic types and macros defined in midas.h. Functions throughout the C++ API take these constants as arguments (e.g. TID_xxx data types and TR_xxx transitions).

For the status codes that the functions return, see Status and error codes.

Public Defines

Macros

System states

STATE_PAUSED
#define STATE_PAUSED 2

MIDAS run paused

Defined in include/midas.h:306

STATE_RUNNING
#define STATE_RUNNING 3

MIDAS run running

Defined in include/midas.h:307

STATE_STOPPED
#define STATE_STOPPED 1

MIDAS run stopped

Defined in include/midas.h:305

Data format

FORMAT_FIXED
#define FORMAT_FIXED 4

Fixed length binary records

Defined in include/midas.h:314

FORMAT_MIDAS
#define FORMAT_MIDAS 1

MIDAS banks

Defined in include/midas.h:311

FORMAT_ROOT
#define FORMAT_ROOT 7

CERN ROOT format

Defined in include/midas.h:317

Event Sampling type

GET_ALL
#define GET_ALL (1<<0)

get all events (consume)

Defined in include/midas.h:321

GET_NONBLOCKING
#define GET_NONBLOCKING (1<<1)

get as much as possible without blocking producer

Defined in include/midas.h:322

GET_RECENT
#define GET_RECENT (1<<2)

get recent event (not older than 1 s)

Defined in include/midas.h:323

MIDAS Data Type Definitions

TID_ARRAY
#define TID_ARRAY 13

array with unknown contents

Defined in include/midas.h:347

TID_BITFIELD
#define TID_BITFIELD 11

32 Bits Bitfield 0 111... (32)

Defined in include/midas.h:345

TID_BOOL
#define TID_BOOL 8

four bytes bool 0 1

Defined in include/midas.h:340

TID_BYTE
#define TID_BYTE 1

DEPRECATED, use TID_UINT8 instead

Defined in include/midas.h:327

TID_CHAR
#define TID_CHAR 3

single character 0 255

Defined in include/midas.h:331

TID_DOUBLE
#define TID_DOUBLE 10

8 Byte float format

Defined in include/midas.h:343

TID_DWORD
#define TID_DWORD 6

DEPRECATED, use TID_UINT32 instead

Defined in include/midas.h:336

TID_FLOAT
#define TID_FLOAT 9

4 Byte float format

Defined in include/midas.h:341

TID_FLOAT32
#define TID_FLOAT32 9

4 Byte float format

Defined in include/midas.h:342

TID_FLOAT64
#define TID_FLOAT64 10

8 Byte float format

Defined in include/midas.h:344

TID_INT
#define TID_INT 7

DEPRECATED, use TID_INT32 instead

Defined in include/midas.h:338

TID_INT16
#define TID_INT16 5

signed word -32768 32767

Defined in include/midas.h:335

TID_INT32
#define TID_INT32 7

signed dword -2^31 2^31-1

Defined in include/midas.h:339

TID_INT64
#define TID_INT64 17

8 bytes int -2^63 2^63-1

Defined in include/midas.h:351

TID_INT8
#define TID_INT8 2

signed byte -128 127

Defined in include/midas.h:330

TID_KEY
#define TID_KEY 15

key in online database

Defined in include/midas.h:349

TID_LAST
#define TID_LAST 19

end of TID list indicator

Defined in include/midas.h:354

#define TID_LINK 16

link in online database

Defined in include/midas.h:350

TID_QWORD
#define TID_QWORD 18

8 bytes unsigned int 0 2^64-1

Defined in include/midas.h:353

TID_SBYTE
#define TID_SBYTE 2

DEPRECATED, use TID_INT8 instead

Defined in include/midas.h:329

TID_SHORT
#define TID_SHORT 5

DEPRECATED, use TID_INT16 instead

Defined in include/midas.h:334

TID_STRING
#define TID_STRING 12

zero terminated string

Defined in include/midas.h:346

TID_STRUCT
#define TID_STRUCT 14

structure with fixed length

Defined in include/midas.h:348

TID_UINT16
#define TID_UINT16 4

two bytes 0 65535

Defined in include/midas.h:333

TID_UINT32
#define TID_UINT32 6

four bytes 0 2^32-1

Defined in include/midas.h:337

TID_UINT64
#define TID_UINT64 18

8 bytes unsigned int 0 2^64-1

Defined in include/midas.h:352

TID_UINT8
#define TID_UINT8 1

unsigned byte 0 255

Defined in include/midas.h:328

TID_WORD
#define TID_WORD 4

DEPRECATED, use TID_UINT16 instead

Defined in include/midas.h:332

Transition flags

TR_ASYNC
#define TR_ASYNC 2

Defined in include/midas.h:359

TR_DETACH
#define TR_DETACH 4

Defined in include/midas.h:360

TR_MTHREAD
#define TR_MTHREAD 8

Defined in include/midas.h:361

TR_SYNC
#define TR_SYNC 1

Defined in include/midas.h:358

Synchronous / Asynchronous flags

BM_NO_WAIT
#define BM_NO_WAIT 1

Defined in include/midas.h:366

BM_WAIT
#define BM_WAIT 0

Defined in include/midas.h:365

Access modes

MODE_ALLOC
#define MODE_ALLOC (1<<6)

Defined in include/midas.h:374

MODE_DELETE
#define MODE_DELETE (1<<2)

Defined in include/midas.h:372

MODE_EXCLUSIVE
#define MODE_EXCLUSIVE (1<<3)

Defined in include/midas.h:373

MODE_READ
#define MODE_READ (1<<0)

Defined in include/midas.h:370

MODE_WATCH
#define MODE_WATCH (1<<7)

Defined in include/midas.h:375

MODE_WRITE
#define MODE_WRITE (1<<1)

Defined in include/midas.h:371

RPC options

RPC_HNDLE_CONNECT
#define RPC_HNDLE_CONNECT -2

Defined in include/midas.h:394

RPC_HNDLE_MSERVER
#define RPC_HNDLE_MSERVER -1

Defined in include/midas.h:393

RPC_NO_REPLY
#define RPC_NO_REPLY 0x80000000l

Defined in include/midas.h:396

Watchdog flags

WF_CALL_WD
#define WF_CALL_WD (1<<1)

Defined in include/midas.h:401

WF_WATCH_ME
#define WF_WATCH_ME (1<<0)

Defined in include/midas.h:400

Transitions values

TR_DEFERRED
#define TR_DEFERRED (1<<12)

Defined in include/midas.h:410

TR_PAUSE
#define TR_PAUSE (1<<2)

Pause transition

Defined in include/midas.h:407

TR_RESUME
#define TR_RESUME (1<<3)

Resume transition

Defined in include/midas.h:408

TR_START
#define TR_START (1<<0)

Start transition

Defined in include/midas.h:405

TR_STARTABORT
#define TR_STARTABORT (1<<4)

Start aborted transition

Defined in include/midas.h:409

TR_STOP
#define TR_STOP (1<<1)

Stop transition

Defined in include/midas.h:406

Equipment types

EQ_EB
#define EQ_EB (1<<7)

Event run through the event builder

Defined in include/midas.h:421

EQ_FRAGMENTED
#define EQ_FRAGMENTED (1<<6)

Fragmented Event

Defined in include/midas.h:420

EQ_INTERRUPT
#define EQ_INTERRUPT (1<<2)

Interrupt Event

Defined in include/midas.h:416

EQ_MANUAL_TRIG
#define EQ_MANUAL_TRIG (1<<5)

Manual triggered Event

Defined in include/midas.h:419

EQ_MULTITHREAD
#define EQ_MULTITHREAD (1<<3)

Multithread Event readout

Defined in include/midas.h:417

EQ_PERIODIC
#define EQ_PERIODIC (1<<0)

Periodic Event

Defined in include/midas.h:414

EQ_POLLED
#define EQ_POLLED (1<<1)

Polling Event

Defined in include/midas.h:415

EQ_SLOW
#define EQ_SLOW (1<<4)

Slow Control Event

Defined in include/midas.h:418

EQ_USER
#define EQ_USER (1<<8)

Polling handled in user part

Defined in include/midas.h:422

Read - On flags

RO_ALWAYS
#define RO_ALWAYS (0xFF)

Always and during transitions

Defined in include/midas.h:436

RO_BOR
#define RO_BOR (1<<3)

At the Begin of run

Defined in include/midas.h:429

RO_EOR
#define RO_EOR (1<<4)

At the End of run

Defined in include/midas.h:430

RO_NONTRANS
#define RO_NONTRANS (RO_RUNNING|RO_STOPPED|RO_PAUSED)

Always except on tranistion

Defined in include/midas.h:435

RO_ODB
#define RO_ODB (1<<8)

Copy event data to ODB

Defined in include/midas.h:438

RO_PAUSE
#define RO_PAUSE (1<<5)

Before pausing the run

Defined in include/midas.h:431

RO_PAUSED
#define RO_PAUSED (1<<2)

???

Defined in include/midas.h:428

RO_RESUME
#define RO_RESUME (1<<6)

Before resuming the run

Defined in include/midas.h:432

RO_RUNNING
#define RO_RUNNING (1<<0)

While running

Defined in include/midas.h:426

RO_STOPPED
#define RO_STOPPED (1<<1)

Before stopping the run

Defined in include/midas.h:427

RO_TRANSITIONS
#define RO_TRANSITIONS (RO_BOR|RO_EOR|RO_PAUSE|RO_RESUME)

At all transitions

Defined in include/midas.h:434

EVENTID_ALL

#define EVENTID_ALL -1

Defined in include/midas.h:537

TRIGGER_ALL

#define TRIGGER_ALL -1

Defined in include/midas.h:538

System message types

MCALL
#define MCALL MT_CALL, __FILE__, __LINE__

info message for telephone call

Defined in include/midas.h:565

MDEBUG
#define MDEBUG MT_DEBUG, __FILE__, __LINE__

Defined in include/midas.h:561

MERROR
#define MERROR MT_ERROR, __FILE__, __LINE__

Defined in include/midas.h:559

MINFO
#define MINFO MT_INFO, __FILE__, __LINE__

Defined in include/midas.h:560

MLOG
#define MLOG MT_LOG, __FILE__, __LINE__

info message which is only logged

Defined in include/midas.h:563

MT_ALL
#define MT_ALL 0xFF

Defined in include/midas.h:549

MT_CALL
#define MT_CALL (1<<6)

Defined in include/midas.h:548

MT_CALL_STR
#define MT_CALL_STR "CALL"

Defined in include/midas.h:557

MT_DEBUG
#define MT_DEBUG (1<<2)

Defined in include/midas.h:544

MT_DEBUG_STR
#define MT_DEBUG_STR "DEBUG"

Defined in include/midas.h:553

MT_ERROR
#define MT_ERROR (1<<0)

Defined in include/midas.h:542

MT_ERROR_STR
#define MT_ERROR_STR "ERROR"

Defined in include/midas.h:551

MT_INFO
#define MT_INFO (1<<1)

Defined in include/midas.h:543

MT_INFO_STR
#define MT_INFO_STR "INFO"

Defined in include/midas.h:552

MT_LOG
#define MT_LOG (1<<4)

Defined in include/midas.h:546

MT_LOG_STR
#define MT_LOG_STR "LOG"

Defined in include/midas.h:555

MT_TALK
#define MT_TALK (1<<5)

Defined in include/midas.h:547

MT_TALK_STR
#define MT_TALK_STR "TALK"

Defined in include/midas.h:556

MT_USER
#define MT_USER (1<<3)

Defined in include/midas.h:545

MT_USER_STR
#define MT_USER_STR "USER"

Defined in include/midas.h:554

MTALK
#define MTALK MT_TALK, __FILE__, __LINE__

info message for speech system

Defined in include/midas.h:564

MUSER
#define MUSER MT_USER, __FILE__, __LINE__

produced by interactive user

Defined in include/midas.h:562

Public Macros

Macros

ALIGN8

#define ALIGN8(x) (((x)+7) & ~7)

Align macro for data alignment on 8-byte boundary

Defined in include/midas.h:522

MAX

#define MAX(a, b) (((a)>(b))?(a):(b))

MAX

Defined in include/midas.h:509

MIN

#define MIN(a, b) (((a)<(b))?(a):(b))

MIN

Defined in include/midas.h:515

VALIGN

#define VALIGN(adr, align) (((POINTER_T) (adr)+(align)-1) & ~((align)-1))

Align macro for variable data alignment

Defined in include/midas.h:526

Basic types

The midas API uses these types, defined in midas.h. For the TID_xxx type that matches each one, see Data types.

Type Definition Use
BYTE unsigned char 8-bit unsigned value
WORD unsigned short 16-bit unsigned value
DWORD unsigned int 32-bit unsigned value
BOOL DWORD Boolean (TRUE or FALSE). It's 4 bytes long, like a TID_BOOL value in the ODB, so don't use a C++ bool instead
INT int 32-bit signed value. Used for status codes and most integer arguments
HNDLE INT Handle of an ODB key, event buffer, connection etc.
UINT8, UINT16, UINT32, UINT64 unsigned char … unsigned long long Unsigned values of the given width
INT8, INT16, INT32, INT64 char … long long Signed values of the given width. INT8 is a plain char, which is unsigned on some platforms (e.g. Linux on ARM)
POINTER_T, PTYPE long int or int An integer the same size as a pointer. PTYPE is the old name
midas_thread_t pthread_t Handle of a thread, returned by ss_thread_create()
STRING_LIST std::vector<std::string> List of strings

Built-in limits and defaults

The sizes of names and the numbers of clients etc. are fixed when midas is compiled. For all the limits, see Limits. To raise one, see Large experiments.

Name Value Meaning
NAME_LENGTH 32 Maximum length of an ODB key name, client name or experiment name, including the terminating null
HOST_NAME_LENGTH 256 Maximum length of a host name
MAX_ODB_PATH 256 Maximum length of an ODB path
MAX_CLIENTS 64 Maximum number of clients connected to the ODB or to one event buffer
MAX_EVENT_REQUESTS 10 Maximum number of event requests per client
MAX_OPEN_RECORDS 256 Maximum number of open hotlinks
BANKLIST_MAX 4096 Maximum number of banks in an event
STRING_BANKLIST_MAX 16384 Size of the string that bk_list() fills in
TRANSITION_ERROR_STRING_LENGTH 256 Maximum length of the error message of a run transition
DEFAULT_ODB_SIZE 1 MiB Default size of a new ODB. Set the size with odbinit -s
DEFAULT_MAX_EVENT_SIZE 4 MiB Default maximum event size. Set the size in /Experiment/MAX_EVENT_SIZE
DEFAULT_BUFFER_SIZE 32 MiB Default size of an event buffer. Set the size in /Experiment/Buffer sizes
EVENT_BUFFER_NAME "SYSTEM" Name of the main event buffer
MIN_WRITE_CACHE_SIZE 10000000 Default and minimum size in bytes of an event buffer's write cache
MAX_WRITE_CACHE_SIZE_DIV 3 The write cache can be at most this fraction (1/3) of the buffer size
MAX_WRITE_CACHE_EVENT_SIZE_DIV 10 Events bigger than this fraction (1/10) of the write cache aren't cached
MIDAS_TCP_PORT 1175 Default port that mserver listens on
DEFAULT_RPC_TIMEOUT 10000 Default timeout of an RPC call, in milliseconds
DEFAULT_WATCHDOG_TIMEOUT 10000 Default watchdog timeout, in milliseconds. A client that doesn't contact midas for this long is removed
WATCHDOG_INTERVAL 1000 Interval of midas's internal watchdog checks, in milliseconds

Special event IDs

These event IDs are used for the special events that midas writes, and for fragmented events.

Name Value Meaning
EVENTID_BOR 0x8000 Begin-of-run event, with a copy of the ODB
EVENTID_EOR 0x8001 End-of-run event, with a copy of the ODB
EVENTID_MESSAGE 0x8002 Message event, with the text of a message
EVENTID_FRAG1 0xC000 Added to the event ID of the first fragment of a fragmented event
EVENTID_FRAG 0xD000 Added to the event ID of the other fragments of a fragmented event
MIDAS_MAGIC 0x494d The trigger mask of begin-of-run and end-of-run events (the characters MI)

Event header macros

These macros read or change the fields of an event's EVENT_HEADER. Their argument is a pointer to the event data, just after the header, not to the header itself. This is the pevent that's passed to the readout functions of a frontend, and to the bk_xxx functions.

In a frontend, mfe fills in the header before calling the readout function, so the readout function can use these macros to read the header or to override it. mfe then sets the data size from the readout function's return value, so don't set DATA_SIZE there.

INT read_trigger_event(char* pevent, INT off)
{
  // Mark every 100th event as a calibration event
  if (SERIAL_NUMBER(pevent) % 100 == 0) {
    TRIGGER_MASK(pevent) = 2;
  }

  bk_init(pevent);
  ...
}

TMEvent (in midasio) has the same fields as members, e.g. event.serial_number.

TRIGGER_MASK

#define TRIGGER_MASK(e) ((((EVENT_HEADER *) e)-1)->trigger_mask)

TRIGGER_MASK Extract or set the trigger mask field pointed by the argument.

Parameters:

  • e –
    pointer to the midas event (pevent)

Defined in include/midas.h:867

EVENT_ID

#define EVENT_ID(e) ((((EVENT_HEADER *) e)-1)->event_id)

EVENT_ID Extract or set the event ID field pointed by the argument..

Parameters:

  • e –
    pointer to the midas event (pevent)

Defined in include/midas.h:874

SERIAL_NUMBER

#define SERIAL_NUMBER(e) ((((EVENT_HEADER *) e)-1)->serial_number)

SERIAL_NUMBER Extract or set/reset the serial number field pointed by the argument.

Parameters:

  • e –
    pointer to the midas event (pevent)

Defined in include/midas.h:881

TIME_STAMP

#define TIME_STAMP(e) ((((EVENT_HEADER *) e)-1)->time_stamp)

TIME_STAMP Extract or set/reset the time stamp field pointed by the argument.

Parameters:

  • e –
    pointer to the midas event (pevent)

Defined in include/midas.h:888

DATA_SIZE

#define DATA_SIZE(e) ((((EVENT_HEADER *) e)-1)->data_size)

DATA_SIZE Extract or set/reset the data size field pointed by the argument.

Parameters:

  • e –
    pointer to the midas event (pevent)

Defined in include/midas.h:895

Bank format flags

These are the bits of the flags field of an event's BANK_HEADER (see Global bank header). bk_init(), bk_init32() and bk_init32a() set them.

Name Value Meaning
BANK_FORMAT_VERSION 1 Version of the bank format, in the lowest 4 bits. Also used to detect the byte order
BANK_FORMAT_32BIT 0x10 The bank sizes are 32 bits long (BANK32 banks)
BANK_FORMAT_64BIT_ALIGNED 0x20 The bank data is aligned to 64 bits (BANK32A banks)

Device driver flags

These flags go in the flags field of a DEVICE_DRIVER in a class driver frontend's device driver list, which describes most of them in more detail.

Name Value Meaning
DF_INPUT 1<<0 The channels are inputs
DF_OUTPUT 1<<1 The channels are outputs
DF_PRIO_DEVICE 1<<2 Read the demand values from the device, instead of setting them from the ODB
DF_READ_ONLY 1<<3 Never write demand values to the device
DF_MULTITHREAD 1<<4 Talk to the device in its own thread
DF_HW_RAMP 1<<5 The high voltage device ramps the voltage itself
DF_LABELS_FROM_DEVICE 1<<6 Take the channel names from the device
DF_REPORT_TEMP 1<<7 High voltage devices: also read the temperature of the cards
DF_REPORT_STATUS 1<<8 High voltage devices: also read the status of each channel
DF_REPORT_CHSTATE 1<<9 High voltage devices: also read the state of each channel
DF_REPORT_CRATEMAP 1<<10 High voltage devices: also read the crate map (the size and occupancy of the crate)
DF_QUICKSTART 1<<11 Don't read all the channels when the frontend starts, so that it starts faster
DF_POLL_DEMAND 1<<12 Keep reading the demand values from the device
DF_PRIORITY_READ 1<<13 With DF_MULTITHREAD: for 10 seconds after a channel's demand value is set, read that channel more often

Slow control and interrupt commands

These are the commands that a slow control class driver passes to its device drivers, and a device driver to its bus driver (see Writing a device driver), and the commands that mfe passes to a frontend's interrupt_configure(). The BD_xxx macros call a device driver's bus driver.

Macros

Slow control device driver commands

CMD_CLOSE
#define CMD_CLOSE 12

Defined in include/midas.h:774

CMD_DISABLE_COMMAND
#define CMD_DISABLE_COMMAND (1<<15)

Defined in include/midas.h:808

CMD_ENABLE_COMMAND
#define CMD_ENABLE_COMMAND (1<<14)

Defined in include/midas.h:807

CMD_EXIT
#define CMD_EXIT 2

Defined in include/midas.h:764

CMD_GET
#define CMD_GET CMD_GET_FIRST

Defined in include/midas.h:788

CMD_GET_CHSTATE
#define CMD_GET_CHSTATE CMD_GET_DIRECT+6

Defined in include/midas.h:802

CMD_GET_CRATEMAP
#define CMD_GET_CRATEMAP CMD_GET_DIRECT+7

Defined in include/midas.h:803

CMD_GET_CURRENT
#define CMD_GET_CURRENT CMD_GET_FIRST+1

Defined in include/midas.h:789

CMD_GET_CURRENT_LIMIT
#define CMD_GET_CURRENT_LIMIT CMD_GET_DIRECT+2

Defined in include/midas.h:798

CMD_GET_DEMAND
#define CMD_GET_DEMAND CMD_GET_FIRST+5

Defined in include/midas.h:793

CMD_GET_DEMAND_DIRECT
#define CMD_GET_DEMAND_DIRECT CMD_GET_DIRECT+8

Defined in include/midas.h:804

CMD_GET_DIRECT
#define CMD_GET_DIRECT CMD_GET_LAST+1

Defined in include/midas.h:796

CMD_GET_DIRECT_LAST
#define CMD_GET_DIRECT_LAST CMD_GET_DIRECT+8

Defined in include/midas.h:805

CMD_GET_FIRST
#define CMD_GET_FIRST CMD_SET_LAST+1

Defined in include/midas.h:787

CMD_GET_LABEL
#define CMD_GET_LABEL 10

Defined in include/midas.h:772

CMD_GET_LAST
#define CMD_GET_LAST CMD_GET_FIRST+5

Defined in include/midas.h:794

CMD_GET_RAMPDOWN
#define CMD_GET_RAMPDOWN CMD_GET_DIRECT+4

Defined in include/midas.h:800

CMD_GET_RAMPUP
#define CMD_GET_RAMPUP CMD_GET_DIRECT+3

Defined in include/midas.h:799

CMD_GET_STATUS
#define CMD_GET_STATUS CMD_GET_FIRST+3

Defined in include/midas.h:791

CMD_GET_TEMPERATURE
#define CMD_GET_TEMPERATURE CMD_GET_FIRST+4

Defined in include/midas.h:792

CMD_GET_THRESHOLD
#define CMD_GET_THRESHOLD 6

Defined in include/midas.h:768

CMD_GET_THRESHOLD_CURRENT
#define CMD_GET_THRESHOLD_CURRENT 7

Defined in include/midas.h:769

CMD_GET_THRESHOLD_ZERO
#define CMD_GET_THRESHOLD_ZERO 8

Defined in include/midas.h:770

CMD_GET_TRIP
#define CMD_GET_TRIP CMD_GET_FIRST+2

Defined in include/midas.h:790

CMD_GET_TRIP_TIME
#define CMD_GET_TRIP_TIME CMD_GET_DIRECT+5

Defined in include/midas.h:801

CMD_GET_VOLTAGE_LIMIT
#define CMD_GET_VOLTAGE_LIMIT CMD_GET_DIRECT

Defined in include/midas.h:797

CMD_IDLE
#define CMD_IDLE 5

Defined in include/midas.h:767

CMD_INIT
#define CMD_INIT 1

Defined in include/midas.h:763

CMD_MISC_LAST
#define CMD_MISC_LAST 12

Defined in include/midas.h:775

CMD_OPEN
#define CMD_OPEN 11

Defined in include/midas.h:773

CMD_SET
#define CMD_SET CMD_SET_FIRST

Defined in include/midas.h:778

CMD_SET_CHSTATE
#define CMD_SET_CHSTATE CMD_SET_FIRST+6

Defined in include/midas.h:784

CMD_SET_CURRENT_LIMIT
#define CMD_SET_CURRENT_LIMIT CMD_SET_FIRST+2

Defined in include/midas.h:780

CMD_SET_FIRST
#define CMD_SET_FIRST CMD_MISC_LAST+1

Defined in include/midas.h:777

CMD_SET_LABEL
#define CMD_SET_LABEL 9

Defined in include/midas.h:771

CMD_SET_LAST
#define CMD_SET_LAST CMD_SET_FIRST+6

Defined in include/midas.h:785

CMD_SET_RAMPDOWN
#define CMD_SET_RAMPDOWN CMD_SET_FIRST+4

Defined in include/midas.h:782

CMD_SET_RAMPUP
#define CMD_SET_RAMPUP CMD_SET_FIRST+3

Defined in include/midas.h:781

CMD_SET_TRIP_TIME
#define CMD_SET_TRIP_TIME CMD_SET_FIRST+5

Defined in include/midas.h:783

CMD_SET_VOLTAGE_LIMIT
#define CMD_SET_VOLTAGE_LIMIT CMD_SET_FIRST+1

Defined in include/midas.h:779

CMD_START
#define CMD_START 3

Defined in include/midas.h:765

CMD_STOP
#define CMD_STOP 4

Defined in include/midas.h:766

Slow control bus driver commands

CMD_DEBUG
#define CMD_DEBUG 104

Defined in include/midas.h:816

CMD_GETS
#define CMD_GETS 103

Defined in include/midas.h:815

CMD_NAME
#define CMD_NAME 105

Defined in include/midas.h:817

CMD_PUTS
#define CMD_PUTS 102

Defined in include/midas.h:814

CMD_READ
#define CMD_READ 101

Defined in include/midas.h:813

CMD_WRITE
#define CMD_WRITE 100

Defined in include/midas.h:812

Commands for interrupt events

CMD_INTERRUPT_ATTACH
#define CMD_INTERRUPT_ATTACH 102

Defined in include/midas.h:823

CMD_INTERRUPT_DETACH
#define CMD_INTERRUPT_DETACH 103

Defined in include/midas.h:824

CMD_INTERRUPT_DISABLE
#define CMD_INTERRUPT_DISABLE 101

Defined in include/midas.h:822

CMD_INTERRUPT_ENABLE
#define CMD_INTERRUPT_ENABLE 100

Defined in include/midas.h:821

macros for bus driver access

BD_GETS
#define BD_GETS(s, z, p, t) info->bd(CMD_GETS, info->bd_info, s, z, p, t)

Defined in include/midas.h:828

BD_PUTS
#define BD_PUTS(s) info->bd(CMD_PUTS, info->bd_info, s)

Defined in include/midas.h:830

BD_READS
#define BD_READS(s, z, t) info->bd(CMD_READ, info->bd_info, s, z, t)

Defined in include/midas.h:829

BD_WRITES
#define BD_WRITES(s) info->bd(CMD_WRITE, info->bd_info, s)

Defined in include/midas.h:831

RPC definitions

These define the remote procedure calls that a program can register with rpc_register_functions(). Each call is described by an RPC_LIST entry, with an RPC_PARAM for each parameter.

Name Value Meaning
RPC_IN 1<<0 Parameter flag: the value is sent to the server
RPC_OUT 1<<1 Parameter flag: the value is returned by the server
RPC_POINTER 1<<2 Parameter flag: the parameter is passed as a pointer
RPC_FIXARRAY 1<<3 Parameter flag: the parameter is an array of fixed size (the n field of the RPC_PARAM)
RPC_VARARRAY 1<<4 Parameter flag: the parameter is an array whose size is given by the next parameter
RPC_CXX 1<<6 Parameter flag: a TID_STRING parameter is a C++ std::string
RPC_OUTGOING 1<<5 Used internally when converting the byte order of values that are sent
MAX_RPC_PARAMS 20 Maximum number of parameters of an RPC call
RPC_MIN_ID, RPC_MAX_ID 1, 9999 Range of IDs for your own RPC calls. midas's own calls use IDs outside this range

CAMAC

These are for frontends that read out CAMAC crates. See also the CAMAC functions.

LAM sources

An equipment's event source (the source field of its EQUIPMENT_INFO) says which CAMAC crate and stations can trigger it with a LAM. The crate number is in the top 8 bits, and a bitmask of stations in the low 24 bits:

LAM_SOURCE(0, LAM_STATION(5))   // station 5 in crate 0
LAM_SOURCE(0, 0xFFFFFF)         // any station in crate 0

LAM_SOURCE

#define LAM_SOURCE(c, s) (c<<24 | ((s) & 0xFFFFFF))

Code the LAM crate and LAM station into a bitwise register.

Parameters:

  • c –
    Crate number
  • s –
    Slot number

Defined in include/midas.h:469

LAM_STATION

#define LAM_STATION(s) (1<<(s-1))

Code the Station number bitwise for the LAM source.

Parameters:

  • s –
    Slot number

Defined in include/midas.h:475

LAM_SOURCE_CRATE

#define LAM_SOURCE_CRATE(c) (c>>24)

Convert the coded LAM crate to Crate number.

Parameters:

  • c –
    coded crate

Defined in include/midas.h:481

LAM_SOURCE_STATION

#define LAM_SOURCE_STATION(s) ((s) & 0xFFFFFF)

Convert the coded LAM station to Station number.

Parameters:

  • s –
    Slot number

Defined in include/midas.h:487

CNAF commands

These are the commands of the RPC_CNAF16 and RPC_CNAF24 remote procedure calls, which let other programs (e.g. mhttpd's CNAF page) access a frontend's CAMAC crates. A frontend handles these calls if it calls register_cnaf_callback().

Command Value What it does
CNAF 0x1 A normal read or write: functions 0–15 read, 16–23 write, and 24–31 are control functions
CNAF_nQ 0x2 Repeat a read until Q is no longer set, with cam16i_rq() or cam24i_rq()
CNAF_INHIBIT_SET 0x100 Set the crate inhibit, with cam_inhibit_set()
CNAF_INHIBIT_CLEAR 0x101 Clear the crate inhibit, with cam_inhibit_clear()
CNAF_CRATE_CLEAR 0x102 Clear the crate (C cycle), with cam_crate_clear()
CNAF_CRATE_ZINIT 0x103 Initialise the crate (Z cycle), with cam_crate_zinit()
CNAF_TEST 0x110 Does nothing. Used to check that the frontend answers