|
enum | State {
NOTREADY = 0
,
READY = 1
,
RUNNING = 2
,
PAUSING = 3
,
PAUSED = 4
,
RESUMING = 5
} |
|
enum | EFlag {
NOERRO
,
PROCESS_DOWN = 0x01
,
SOCKET_BIND = 0x02
,
SOCKET_IN = 0x04
,
SOCKET_OUT = 0x08
,
EVENTFORMAT = 0x10
,
CPRFIFO_EMPTY = 0x20
,
CPRFIFO_FULL = 0x40
,
CPRFIFO_LEF_FULL = 0x80
} |
|
Definition at line 22 of file RunInfoBuffer.h.
◆ EFlag
Definition at line 35 of file RunInfoBuffer.h.
35 {
36 NOERRO,
37 PROCESS_DOWN = 0x01,
38 SOCKET_BIND = 0x02,
39 SOCKET_IN = 0x04,
40 SOCKET_OUT = 0x08,
41 EVENTFORMAT = 0x10,
42 CPRFIFO_EMPTY = 0x20,
43 CPRFIFO_FULL = 0x40,
44 CPRFIFO_LEF_FULL = 0x80
45 };
◆ State
Definition at line 25 of file RunInfoBuffer.h.
25 {
26 NOTREADY = 0,
27 READY = 1,
28 RUNNING = 2,
29 PAUSING = 3,
30 PAUSED = 4,
31 RESUMING = 5
32 };
◆ RunInfoBuffer()
◆ ~RunInfoBuffer()
◆ addInputCount()
void addInputCount |
( |
unsigned int |
count | ) |
|
|
inline |
◆ addInputNBytes()
void addInputNBytes |
( |
unsigned long long |
nbyte | ) |
|
|
inline |
◆ addOutputCount()
void addOutputCount |
( |
unsigned int |
count | ) |
|
|
inline |
◆ addOutputNBytes()
void addOutputNBytes |
( |
unsigned long long |
nbyte | ) |
|
|
inline |
◆ clear()
Definition at line 59 of file RunInfoBuffer.cc.
60{
61 if (m_info == NULL) return;
64}
Lock Guard for a Mutex instance.
◆ close()
Definition at line 66 of file RunInfoBuffer.cc.
67{
68 m_memory.close();
69 return true;
70}
◆ copyEventHeader()
void copyEventHeader |
( |
int * |
buf | ) |
|
◆ get()
◆ getErrorFlag()
unsigned int getErrorFlag |
( |
| ) |
const |
|
inline |
◆ getEventHeader()
◆ getExpNumber()
unsigned int getExpNumber |
( |
| ) |
const |
|
inline |
◆ getInputAddress()
int getInputAddress |
( |
| ) |
const |
|
inline |
◆ getInputCount()
unsigned int getInputCount |
( |
| ) |
const |
|
inline |
◆ getInputNBytes()
unsigned long long getInputNBytes |
( |
| ) |
const |
|
inline |
◆ getInputPort()
int getInputPort |
( |
| ) |
const |
|
inline |
◆ getName()
const std::string getName |
( |
| ) |
const |
|
inline |
◆ getNodeId()
unsigned int getNodeId |
( |
| ) |
const |
|
inline |
◆ getOutputAddress()
int getOutputAddress |
( |
| ) |
const |
|
inline |
◆ getOutputCount()
unsigned int getOutputCount |
( |
| ) |
const |
|
inline |
◆ getOutputNBytes()
unsigned long long getOutputNBytes |
( |
| ) |
const |
|
inline |
◆ getOutputPort()
int getOutputPort |
( |
| ) |
const |
|
inline |
◆ getPath()
const std::string getPath |
( |
| ) |
const |
|
inline |
◆ getRunNumber()
unsigned int getRunNumber |
( |
| ) |
const |
|
inline |
◆ getState()
unsigned int getState |
( |
| ) |
const |
|
inline |
◆ getSubNumber()
unsigned int getSubNumber |
( |
| ) |
const |
|
inline |
◆ init()
Definition at line 49 of file RunInfoBuffer.cc.
50{
51 if (m_info == NULL) return false;
52 m_mutex.init();
53 m_cond.init();
55 LogFile::debug("Initialized %s", m_path.c_str());
56 return true;
57}
◆ isAvailable()
bool isAvailable |
( |
| ) |
const |
|
inline |
◆ isNotReady()
Definition at line 107 of file RunInfoBuffer.h.
107{ return (m_info) && m_info->state == NOTREADY; }
◆ isPaused()
Definition at line 111 of file RunInfoBuffer.h.
111{ return (m_info) && m_info->state == PAUSED; }
◆ isPausing()
Definition at line 110 of file RunInfoBuffer.h.
110{ return (m_info) && m_info->state == PAUSING; }
◆ isReady()
Definition at line 108 of file RunInfoBuffer.h.
108{ return (m_info) && m_info->state == READY; }
◆ isResuming()
Definition at line 112 of file RunInfoBuffer.h.
112{ return (m_info) && m_info->state == RESUMING; }
◆ isRunning()
Definition at line 109 of file RunInfoBuffer.h.
109{ return (m_info) && m_info->state == RUNNING; }
◆ lock()
Definition at line 79 of file RunInfoBuffer.cc.
80{
81 if (m_info == NULL) return false;
82 return m_mutex.lock();
83}
◆ notify()
Definition at line 103 of file RunInfoBuffer.cc.
104{
105 if (m_info == NULL) return false;
106 return m_cond.broadcast();
107}
◆ open()
bool open |
( |
const std::string & |
nodename, |
|
|
int |
nodeid = 0 , |
|
|
bool |
recreate = false |
|
) |
| |
Definition at line 24 of file RunInfoBuffer.cc.
26{
27 m_nodename = nodename;
28 std::string username = getenv("USER");
29 m_path = "/run_info_" + username + "_" + nodename;
30 if (!m_memory.open(m_path, size())) {
31 perror("shm_open");
32 LogFile::fatal("Failed to open %s", m_path.c_str());
33 return false;
34 }
35 char* buf = (char*)m_memory.map(0, size());
36 if (buf == NULL) {
37 return false;
38 }
40 buf += m_mutex.size();
42 buf += m_cond.size();
44 if (recreate) init();
45 if (nodeid > 0) setNodeId(nodeid);
46 return true;
47}
◆ reportError()
bool reportError |
( |
EFlag |
eflag | ) |
|
Definition at line 146 of file RunInfoBuffer.cc.
147{
148 if (m_info == NULL) return false;
150 setErrorFlag(eflag);
151 notify();
152 return true;
153}
◆ reportNotReady()
Definition at line 164 of file RunInfoBuffer.cc.
165{
166 if (m_info == NULL) return false;
168 setState(RunInfoBuffer::NOTREADY);
169 notify();
170 return true;
171}
◆ reportReady()
Definition at line 155 of file RunInfoBuffer.cc.
156{
157 if (m_info == NULL) return false;
159 setState(RunInfoBuffer::READY);
160 notify();
161 return true;
162}
◆ reportRunning()
Definition at line 137 of file RunInfoBuffer.cc.
138{
139 if (m_info == NULL) return false;
141 setState(RunInfoBuffer::RUNNING);
142 notify();
143 return true;
144}
◆ setErrorFlag()
void setErrorFlag |
( |
EFlag |
eflag | ) |
|
|
inline |
Definition at line 89 of file RunInfoBuffer.h.
89{ m_info->eflag = (unsigned int)eflag; }
◆ setExpNumber()
void setExpNumber |
( |
unsigned int |
expno | ) |
|
|
inline |
◆ setInputAddress()
void setInputAddress |
( |
int |
addr | ) |
|
|
inline |
◆ setInputCount()
void setInputCount |
( |
unsigned int |
count | ) |
|
|
inline |
◆ setInputNBytes()
void setInputNBytes |
( |
unsigned long long |
nbyte | ) |
|
|
inline |
◆ setInputPort()
void setInputPort |
( |
int |
port | ) |
|
|
inline |
◆ setNodeId()
void setNodeId |
( |
unsigned int |
id | ) |
|
|
inline |
◆ setOutputAddress()
void setOutputAddress |
( |
int |
addr | ) |
|
|
inline |
◆ setOutputCount()
void setOutputCount |
( |
unsigned int |
count | ) |
|
|
inline |
◆ setOutputNBytes()
void setOutputNBytes |
( |
unsigned long long |
nbyte | ) |
|
|
inline |
◆ setOutputPort()
void setOutputPort |
( |
int |
port | ) |
|
|
inline |
◆ setRunNumber()
void setRunNumber |
( |
unsigned int |
runno | ) |
|
|
inline |
◆ setState()
void setState |
( |
State |
state | ) |
|
|
inline |
Definition at line 88 of file RunInfoBuffer.h.
88{ m_info->state = (unsigned int)state; }
◆ setSubNumber()
void setSubNumber |
( |
unsigned int |
subno | ) |
|
|
inline |
◆ size()
Definition at line 18 of file RunInfoBuffer.cc.
19{
20 return m_mutex.size() + m_cond.size() +
22}
◆ unlink()
Definition at line 72 of file RunInfoBuffer.cc.
73{
74 m_memory.unlink();
75 m_memory.close();
76 return true;
77}
◆ unlock()
Definition at line 85 of file RunInfoBuffer.cc.
86{
87 if (m_info == NULL) return false;
88 return m_mutex.unlock();
89}
◆ wait() [1/2]
Definition at line 91 of file RunInfoBuffer.cc.
92{
93 if (m_info == NULL) return false;
94 return m_cond.wait(m_mutex);
95}
◆ wait() [2/2]
Definition at line 97 of file RunInfoBuffer.cc.
98{
99 if (m_info == NULL) return false;
100 return m_cond.wait(m_mutex, time, 0);
101}
◆ waitReady()
bool waitReady |
( |
int |
timeout | ) |
|
Definition at line 121 of file RunInfoBuffer.cc.
122{
123 if (m_info == NULL) return false;
125 if (getState() != RunInfoBuffer::READY &&
126 getState() != RunInfoBuffer::RUNNING) {
127 if (!wait(timeout)) {
128 if (getState() != RunInfoBuffer::READY &&
129 getState() != RunInfoBuffer::RUNNING) {
130 return false;
131 }
132 }
133 }
134 return true;
135}
◆ waitRunning()
bool waitRunning |
( |
int |
timeout | ) |
|
Definition at line 109 of file RunInfoBuffer.cc.
110{
111 if (m_info == NULL) return false;
113 if (getState() != RunInfoBuffer::RUNNING) {
114 if (!wait(timeout)) {
115 return false;
116 }
117 }
118 return true;
119}
◆ m_cond
◆ m_info
◆ m_memory
◆ m_mutex
◆ m_nodename
◆ m_path
The documentation for this class was generated from the following files: