Belle II Software  release-08-01-10
RFNSM.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #ifndef RFNSM_H
9 #define RFNSM_H
10 //
11 // State definitions
12 //
13 // State transition of RFARM
14 // "configure" "start" "pause"
15 // OFFLINE<->CONFIGURED<->RUNNING<->PAUSE
16 // ^ "unconfigure" "resume"
17 // +---------"restart"
18 //
19 #define RFSTATE_UNCONFIGURED 0
20 #define RFSTATE_CONFIGURED 1
21 #define RFSTATE_TRANSITION 2
22 #define RFSTATE_RUNNING 3
23 #define RFSTATE_IDLE 4
24 
25 #include <string>
26 
27 #include "nsm2/nsm2.h"
28 
29 #include "daq/rfarm/manager/RFServerBase.h"
30 #include "daq/rfarm/manager/RfNodeInfo.h"
31 
32 static std::string RFSTATE[] = { "Unconfigured", "Configured", "Transition", "Running", "Idle" };
33 
34 namespace Belle2 {
40  // Class to handle global reference to status
41  class RFNSM_Status {
42  public:
43  RFNSM_Status();
44  ~RFNSM_Status();
45 
46  static RFNSM_Status& Instance();
47 
48  void set_flag(int);
49  int get_flag();
50 
51  void set_state(int);
52  int get_state();
53 
54  private:
55  int m_flag;
56  int m_state;
57  static RFNSM_Status* s_instance;
58  };
59 
60  // Class to interface to NSM
61  class RFNSM {
62  public:
63  RFNSM(char* nodename, RFServerBase*);
64  ~RFNSM();
65 
66  void AllocMem(char* format);
67  RfNodeInfo* GetNodeInfo();
68 
69  static NSMcontext* GetContext() { return g_context; }
70 
71  private:
72  std::string m_nodename;
73  std::string m_formatfile;
74  RfNodeInfo* m_info;
75  static NSMcontext* g_context;
76  // RFServerBase* m_server;
77 
78  // Wrappers to be called from NSM
79  static void m_Configure(NSMmsg*, NSMcontext*);
80  static void m_UnConfigure(NSMmsg*, NSMcontext*);
81  static void m_Start(NSMmsg*, NSMcontext*);
82  static void m_Stop(NSMmsg*, NSMcontext*);
83  static void m_Pause(NSMmsg*, NSMcontext*);
84  static void m_Resume(NSMmsg*, NSMcontext*);
85  static void m_Restart(NSMmsg*, NSMcontext*);
86  static void m_Status(NSMmsg*, NSMcontext*);
87 
88  // Functions to receive response from function call
89  static void m_OK(NSMmsg*, NSMcontext*);
90  static void m_ERROR(NSMmsg*, NSMcontext*);
91 
92  };
94 };
95 #endif
96 
97 
98 
99 
Abstract base class for different kinds of events.
Definition: nsm2.h:224