Belle II Software development
RCCallback.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
9#ifndef _Belle2_RCCallback_hh
10#define _Belle2_RCCallback_hh
11
12#include "daq/slc/runcontrol/RCState.h"
13#include "daq/slc/runcontrol/RCConfig.h"
14
15#include <daq/slc/nsm/NSMCallback.h>
16
17namespace Belle2 {
23 class DBInterface;
24
25 class RCCallback : public NSMCallback {
26
27 friend class RCMonitor;
28 friend class RCConfigHandler;
29
30 public:
31 RCCallback(int timeout = 4);
32 virtual ~RCCallback() {}
33
34 public:
35 void init(NSMCommunicator& com) override;
36 virtual void boot(const std::string& /* opt */, const DBObject&) {}
37 virtual void load(const DBObject&, const std::string& /*runtype*/) {}
38 virtual void start(int /*expno*/, int /*runno*/) {}
39 virtual void stop() {}
40 virtual void recover(const DBObject&, const std::string& /*runtype*/) {}
41 virtual bool resume(int /*subno*/) { return true; }
42 virtual bool pause() { return true; }
43 virtual void abort() {}
44 virtual void monitor() {}
45 virtual std::string dbdump();
46
47 public:
48 bool perform(NSMCommunicator& com) override;
49 void timeout(NSMCommunicator& com) override;
50
51 public:
52 virtual void initialize(const DBObject&) {}
53 virtual void configure(const DBObject&) {}
54 void dump(bool isstart);
55
56 public:
57 const NSMNode& getRuncontrol() const { return m_runcontrol; }
58 void setState(const RCState& state);
59 void setRCConfig(const std::string& rcconfig) { m_rcconfig_org = rcconfig; }
60 void setDBTable(const std::string& table) { m_table = table; }
61 void setDBFile(const std::string& file) { m_file = file; }
62 const std::string& getDBTable() const { return m_table; }
63 void setAutoReply(bool auto_reply) { m_auto = auto_reply; }
64 void setDB(DBInterface* db, const std::string& table);
65 DBInterface* getDB() { return m_db; }
66 void setProvider(const std::string& host, int port)
67 {
68 m_provider_host = host;
69 m_provider_port = port;
70 }
71 DBObject& getDBObject() { return m_obj; }
72 void setRunNumbers(int expno, int runno)
73 {
74 m_expno = expno;
75 m_runno = runno;
76 }
77 int getExpNumber() const { return m_expno; }
78 int getRunNumber() const { return m_runno; }
79 void setRunTypeRecord(const std::string& runtype) { m_runtype_record = runtype; }
80 const std::string& getRunTypeRecord() const { return m_runtype_record; }
81
82 private:
83 void dbload(int length, const char* data);
84
85 public:
86 DBObject dbload(const std::string& path);
87 void configure_raw(int length, const char* data);
88
89 private:
90 RCState m_state_demand;
91 DBObject m_obj;
92 DBInterface* m_db;
93 std::string m_table;
94 std::string m_file;
95 bool m_auto;
96 std::string m_rcconfig;
97 std::string m_rcconfig_org;
98 std::string m_provider_host;
99 int m_provider_port;
100 int m_expno;
101 int m_runno;
102 NSMNode m_runcontrol;
103 std::string m_runtype_record;
104
105 protected:
106 bool m_showall;
107
108 };
109
110 inline void RCCallback::setDB(DBInterface* db, const std::string& table)
111 {
112 m_db = db;
113 m_table = table;
114 }
115
117};
118
119#endif
Abstract base class for different kinds of events.