-
Notifications
You must be signed in to change notification settings - Fork 9
/
RtConductor.h
211 lines (160 loc) · 4.99 KB
/
RtConductor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*=========================================================================
* RtConductor.h is the header for a class that oversees and coordinates all
* operations during a real-time fMRI session.
*
* Copyright 2007-2013, the MURFI dev team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef RTCONDUCTOR_H
#define RTCONDUCTOR_H
#include"ace/Task.h"
#include<vector>
#include<sstream>
#include"RtConfigFmriRun.h"
#include"RtInput.h"
#include"RtInputScannerImages.h"
#include"RtOutput.h"
#include"RtOutputFile.h"
#include"RtStream.h"
#include"RtCode.h"
#include "RtInfoClient.h"
using namespace std;
// class declaration
class RtConductor : public ACE_Task_Base {
public:
//*** constructors/destructors ***//
// default constructor
// haha, you can't call this
RtConductor() : ACE_Task_Base(), configured(false), running(false) {};
// constructor with config
explicit RtConductor(const RtConfigFmriRun &conf);
// destructor
virtual ~RtConductor();
//*** initialization routines ***//
// retreive configuration
RtConfig &getConfig() { return config; }
// initialize config and prepare to run
// NOTE: this function must me called before each call to run(), but its
// called from the constructor taking a config class, too.
// in:
// configuration for this run
// out:
// true (for success) or false
bool configure(const RtConfigFmriRun &_config);
// after a run, clean up and close streams
void deconfigure();
// adds input mode
// in:
// in: input object
// out:
// true (for success) or false
bool addInput(RtInput *in);
// adds input mode that has already been configured
// in:
// out: input object
// out:
// true (for success) or false
bool addExistingInput(RtInput *in);
// adds a vector of inputs
// in:
// in: vector of input object
// out:
// true (for success) or false
bool addVectorOfInputs(vector<RtInput*> &ins);
// adds output mode
// in:
// out: output object
// out:
// true (for success) or false
bool addOutput(RtOutput *out);
// adds output mode that has already been configured
// in:
// out: output object
// out:
// true (for success) or false
bool addExistingOutput(RtOutput *out);
// adds outputs from a vector
// in:
// out: vector of output objects
// out:
// true (for success) or false
bool addVectorOfOutputs(vector<RtOutput*> &outs);
//*** operation routines ***//
// begins execution of a realtime fMRI session
// out:
// 0 (for success) or error code
int svc();
// get whether execution is happening
bool isRunning() { return running; }
//*** callback entries for threads ***//
// receive a code signaling completetion of data input or processing
void receiveCode(unsigned int code, RtData *data);
// write to the log file
void log(const string &s);
// write to the log file
void log(stringstream &s);
//** gets **//
// get an input by its name
// in
// name: name of input to get
// out
// pointer to the input object
RtInput *getInputByName(const string &name);
// get an output by its name
// in
// name: name of output to get
// out
// pointer to the output object
RtOutput *getOutputByName(const string &name);
// get all the outputs with a name
// in
// name: name of output to get
// out
// vector of pointers to the output objects
vector<RtOutput*> getAllOutputsWithName(const string &name);
// get the number of expected timepoints in this run
int getNumExpectedTimePoints() {
return config.get("scanner:measurements");
}
protected:
//*** methods ***//
// builds the processing stream
// out:
// true (for success) or false
bool buildStream();
//*** members ***//
// configuration object
RtConfigFmriRun config;
// the data processing stream
RtStream stream;
// output object to log
RtOutputFile outputLog;
// these vectors store the objects that handle io
// note that their indexing is related to the code number they throw when
// processing is complete. the index is related by the START_CODE_?????
// static class members
// vector of input objects
vector<RtInput*> inputs;
// vector of output objects
vector<RtOutput*> outputs;
// TEMP debugging
RtInfoClient* infoClient;
// whether we are ready to run
bool configured;
// whether we are running
bool running;
private:
};
#endif