EnglishJapanese Reload Front page List of pages Search Recent changes RSS of recent changes

Manual for developers

This page shows information to develop new your software.

  • Manual for babies
    If you want to know how to use the standard babies or how to develop your full customized babies, please see pdf files in here.
  • libbabies for custom babies
    There is useful library to develop your custom babies.

libbabies for custom babies

libbabies is library to develop your custom babies. To obtain libbabies, please download babirl140725 or later. In 'skelton' directory, there are an example and library.

libbabies.c : source of library
libbabies.h : header file
csample.c   : a skelton of custom babies
segidlist.h : segment ID list used in RIBF
Makefile    : make file for csample

Customize parameters in libbabies.h

There are some customize parameters in libbabies.h. Usually, you don't need to modify this.

//#define DEBUG 1   // If enable this, debug messages are shown

// Selection of buffer size, w/o HUGEBUFF, LARGEBUFF => 256kB buffer
#define HUGEBUFF    1    // 8MB Buffer
//#define LARGEBUFF    1    // 2MB Buffer

#define BABIESRC  "./babies.rc"  // path of initialization file for babies

Procedure

  1. register user functions
  2. initialize libbabies
  3. main loop

Register user functions

In libbabies, user functions can be called when some commands are issued by babicon.

babies_quit(void *(func)(void))
When "esquit" by babicon comes or SIGINT is received, function will be called.
babies_start(void *(func)(void))
When "start" by babicon, function will be called. If babies_nssta() is not registered, this function is called for "nssta" too.
babies_nssta(void *(func)(void))
When "nssta" by babicon, this function is called.
babies_stop(void *(func)(void))
When "stop" is called, this function will be called after data taking is terminated by babies_last_block().
babies_reload(void *(func)(void))
When "reloadesdrv" by babicon, this function is called.
babies_evtloop(void *(func)(void))
Registered function will be lunched as a thread. In this loop, data are taken and copied to buffer in libbabies. Please see EventLoop.

Initialization

babies_init(int efn)
Initialize libbabies. This function must be called before babies_main().
babies_name(char *name)
The name of your program can be registered. It is read by "whoareyou" command of babicon.
babies_check(void)
This function shows parameters you registered.

Main loop

babies_main(void)
It is a main loop to receive commands from babild/babicon. The process is blocked this babies_main().

Event Loop

EventLoop is for readout data from your device, and transfer data to babild (event builder). Your event loop is registered by babies_evtloop(void *(func)(void)). The template of EventLoop is like this:

void evtloop(void){
  int status;
  
  while((status = babies_status()) != -1){
    switch(status){
    case STAT_RUN_IDLE:
      /* noop */
       break;

    /* "start" or "nssta" command by babicon, status will be here */
    case STAT_RUN_START:
    case STAT_RUN_NSSTA:     

      /* Wait your event here, don't block forever, should have the timeout */
      // recv(...), or select(...), or your function

      babies_init_event();                                    // Initialize event
      babies_init_segment(MKSEGID(0, 0, 0, C16));             // Make segment header
      //babies_segdata((char *)yourdata, sizeof(yourdata));   // Copy your data to the buffer
      babies_end_segment();                                   // End segment
      babies_end_event();                                     // End event
      if(babies_chk_block(8000)){                             // Check the buffer size in the libbabies
        babies_flush();                                       // Data send to babild
      }
      break;

    /* "stop" command by babicon, status will be STAT_RUN_WAITSTOP; */
    case STAT_RUN_WAITSTOP:
      babies_flush();                                         // Data send to babild
      babies_last_block();                                    // Declare the stop sequence is finished
      break;
    default:
      break;
    }
  }
}

Sequence

In case of csample.c, the routines are called as follow. Please note that csample is multi-thread program, evtloop and other functions run in parallel.

csampleseq.png

Installation babirlDAQ and test with libbabies

About the full installation, please refer DAQ/Manual/Installation or DAQ/Manual/TestBench. If you only use libbabies based babies, NBBQ is not required.

Install babirlDAQ

Uncompress tar file or get files via svn (from RIKEN inside)

(by tar file)
cd ~/
tar zxvf babirl-****.tar.gz
ln -s babirl-**** babirl

Configure include/userdefine.h

Edit userdefine.h like this, (here assuming user = daq)

cd babirl
emacs -nw include/userdefine.h
/* include/userdefine.h */ 
#define BABIRLDIR "/home/daq/babirl"
#define PIDDIR    "/home/daq/babirl/run"

Compilation

cd babirl
make

Processes

To run babirlDAQ on 1PC with user mode:

Launch babinfo and babild

cd babirl
bin/babinfo
bin/babild -l 1

Launch your babies or csample for the test

csample generates dummy data when DAQ is started

cd babirl/skelton
./csample 20

Check the connectivity

cd babirl
bin/babicon

You could connect babild(=Event Builder).

Functionality check

register event fragment

Launch babicon (localhost)

bin/babicon

by babicon

localhost> seteflist 20 add localhost Test
localhost> nssta
// nssta is DAQ start without data storage
localhost> stop
// you may see the number of events

online client

Launch babian

bin/babian

And register, client

bin/babicon
localhost> setclinfo 0 add localhost 
localhost> nssta

Launch chkridf with online mode

bin/chkridf -s 0

You can see the latest raw data. If you need to use more than 64kB block, please use babianpull instead of babian. This is 'pull' type TCP/IP online client. Nomal babian is 'push' type UDP/IP online client.

babian/babianpull HOSTNAME

client information in babicon is not necessary. Please delete.

bin/babicon
localhost> setclinfo 0 del
Last-modified: Sun, 26 Mar 2017 17:51:14 HADT (2753d)