Ipc

From CLONWiki
Revision as of 11:29, 6 September 2017 by Boiarino (talk | contribs)
Jump to navigation Jump to search

Interprocess communication in Hall B is based on package located in $CLON/src/ipc. Currently it is based on ActiveMQ, which can be replaced with another messager if necessary, for example jlab-developed xMsg. Switching between messagers is done by changing $CLON/src/Makefile.include and recompiling entire $CLON area. ActiveMQ or any other messager must be installed in /usr/local/src area.

Top level classes can be found in $CLON/src/ipc/ipc.s/ipc_lib.h, test program is $CLON/src/ipc/main/ipc_client.cc.

User code includes following:


#include "ipc_lib.h"
#include "MessageActionControl.h"
#include "MessageActionXXXX.h" // XXXX is particular listener, like MessageActionEPICS.h
IpcServer &server = IpcServer::Instance(); // get ipc server instance, it is implemented as singleton
main()
{
  // 
  // 1st and 2nd params - usually EXPID and SESSION
  // 3rd and 4th params - for sender only, for example 'epics' and 'dbrouter'
  // 5th and 6th params (optional) - for receiver only, for example 'epics' and '*' (listen for messages)
  server.init(getenv("EXPID"), getenv("SESSION"), (char *)"epics", (char *)"myname", (char *)"epics", (char *)"*");
  MessageActionControl  *control = new MessageActionControl((char *)"myname");
  MessageActionXXXX        *xxxx = new MessageActionXXXX();
  server.addActionListener(control);
  server.addActionListener(xxxx);
  server << clrm << ...stuff... << endm;
  server.close();
}