-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMySpecTclApp.cpp
executable file
·362 lines (294 loc) · 8.55 KB
/
MySpecTclApp.cpp
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
This software is Copyright by the Board of Trustees of Michigan
State University (c) Copyright 2014.
You may use this software under the terms of the GNU public license
(GPL). The terms of this license are described at:
http://www.gnu.org/licenses/gpl.txt
Authors:
Ron Fox
Jeromy Tompkins
NSCL
Michigan State University
East Lansing, MI 48824-1321
*/
static const char* Copyright = "(C) Copyright Michigan State University 2008, All rights reserved";
// Class: CMySpecTclApp
////////////////////////// FILE_NAME.cpp /////////////////////////////////////////////////////
#include <config.h>
#include "MySpecTclApp.h"
#include "EventProcessor.h"
#include "TCLAnalyzer.h"
#include <Event.h>
#include <TreeParameter.h>
#include "CFERSUnpacker.h"
#ifdef HAVE_STD_NAMESPACE
using namespace std;
#endif
// Local Class definitions:
// Instantiate the unpackers we'll use.
static CFERSUnpacker gFERSUnpacker;
// Function:
// void CreateAnalysisPipeline(CAnalyzer& rAnalyzer)
// Operation Type:
// Override
/*
Purpose:
Sets up an analysis pipeline. This function is required and must
be filled in by the SpecTcl user. Pipeline elements are objects
which are members of classes derived from the CEventProcessor
class. They should be added to the Analyzer's event processing pipeline
by calling RegisterEventProcessor (non virtual base class member).
The sample implementation in this
file produces a two step pipeline. The first step decodes a fixed length
event into the CEvent array. The first parameter is put into index 1 and so on.
The second step produces a compiled pseudo parameter by adding event array
elements 1 and 2 and putting the result into element 0.
*/
void
CMySpecTclApp::CreateAnalysisPipeline(CAnalyzer& rAnalyzer)
{
RegisterEventProcessor(gFERSUnpacker, "FERS");
}
// Constructors, destructors and other replacements for compiler cannonicals:
CMySpecTclApp::CMySpecTclApp()
{
}
// Destructor:
CMySpecTclApp::~CMySpecTclApp ( )
{
}
// Functions for class CMySpecTclApp
// Function:
// void BindTCLVariables(CTCLInterpreter& rInterp)
// Operation Type:
// override
/*
Purpose:
Add code to this function to bind any TCL variable to
the SpecTcl interpreter. Note that at this time,
variables have not yet been necessarily created so you
can do Set but not necessarily Get operations.
*/
void
CMySpecTclApp::BindTCLVariables(CTCLInterpreter& rInterp)
{
CTclGrammerApp::BindTCLVariables(rInterp);
}
// Function:
// void SourceLimitScripts(CTCLInterpreter& rInterpreter)
// Operation Type:
// Override
/*
Purpose:
Add code here to source additional variable setting
scripts. At this time the entire SpecTcl/Tk infrastructure
is not yet set up. Scripts run at this stage can only run
basic Tcl/Tk commands, and not SpecTcl extensions.
Typically, this might be used to set a bunch of initial values
for variables which were bound in BindTCLVariables.
*/
void
CMySpecTclApp::SourceLimitScripts(CTCLInterpreter& rInterpreter)
{
CTclGrammerApp::SourceLimitScripts(rInterpreter);
}
// Function:
// void SetLimits()
// Operation Type:
// overide
/*
Purpose:
Called after BindVariables and SourceLimitScripts.
This function can be used to fetch values of bound Tcl
variables which were modified/set by the limit scripts to
update program default values.
*/
void
CMySpecTclApp::SetLimits()
{
CTclGrammerApp::SetLimits();
}
// Function:
// void CreateHistogrammer()
// Operation Type:
// Override
/*
Purpose:
Creates the histogramming data sink. If you want to override
this in general you probably won't make use of the actual
base class function. You might, however extend this by
defining a base set of parameters and histograms from within
the program.
*/
void
CMySpecTclApp::CreateHistogrammer()
{
CTclGrammerApp::CreateHistogrammer();
}
/*! \brief Create custom displays
*
* If a user creates their own custom display that they want to use,
* they can create it here by adding it to the DisplayInterface. You could
* also use this to override certain parameters in the provided displays.
*/
void
CMySpecTclApp::CreateDisplays()
{
CTclGrammerApp::CreateDisplays();
}
// Function:
// void SelectDisplayer()
// Operation Type:
// Override.
/*
Purpose:
Select a displayer object. The implementation in the base class
chooses the display and starts it. There is not a whole lot of
reason you would want to change this behavior.
*/
void
CMySpecTclApp::SelectDisplayer()
{
CTclGrammerApp::SelectDisplayer();
}
/*! \brief Set up a displays
*
* This is typically used to add observer objects to the displays
* that connect SpecTcl actions with the current display.
*/
void
CMySpecTclApp::SetUpDisplay()
{
CTclGrammerApp::SetUpDisplay();
}
// Function:
// void SetupTestDataSource()
// Operation Type:
// Override
/*
Purpose:
Allows you to set up a test data source. At
present, SpecTcl must have a data source of some sort
connected to it... The default test data source produces a
fixed length event where all parameters are selected from
a gaussian distribution. If you can figure out how to do it,
you can setup your own data source... as long as you don't
start analysis, the default one is harmless.
*/
void
CMySpecTclApp::SetupTestDataSource()
{
CTclGrammerApp::SetupTestDataSource();
}
// Function:
// void CreateAnalyzer(CEventSink* pSink)
// Operation Type:
// Override
/*
Purpose:
Creates an analyzer. The Analyzer is connected to the data
source which supplies buffers. Connected to the analyzer is a
buffer decoder and an event unpacker. The event unpacker is
the main experiment dependent chunk of code, not the analyzer.
The analyzer constructed by the base class is a CTclAnalyzer instance.
This is an analyzer which maintains statistics about itself in Tcl Variables.
*/
void
CMySpecTclApp::CreateAnalyzer(CEventSink* pSink)
{
CTclGrammerApp::CreateAnalyzer(pSink);
}
// Function:
// void SelectDecoder(CAnalyzer& rAnalyzer)
// Operation Type:
// Override
/*
Purpose:
Selects a decoder and attaches it to the analyzer.
A decoder is responsible for knowing the overall structure of
a buffer produced by a data analysis system. The default code
constructs a CNSCLBufferDecoder object which knows the format
of NSCL buffers.
*/
void
CMySpecTclApp::SelectDecoder(CAnalyzer& rAnalyzer)
{
CTclGrammerApp::SelectDecoder(rAnalyzer);
}
// Function:
// void AddCommands(CTCLInterpreter& rInterp)
// Operation Type:
// Override
/*
Purpose:
This function adds commands to extend Tcl/Tk/SpecTcl.
The base class function registers the standard SpecTcl command
packages. Your commands can be registered at this point.
Do not remove the sample code or the SpecTcl commands will
not get registered.
*/
void
CMySpecTclApp::AddCommands(CTCLInterpreter& rInterp)
{
CTclGrammerApp::AddCommands(rInterp);
}
// Function:
// void SetupRunControl()
// Operation Type:
// Override.
/*
Purpose:
Sets up the Run control object. The run control object
is responsible for interacting with the underlying operating system
and programming framework to route data from the data source to
the SpecTcl analyzer. The base class object instantiates a
CTKRunControl object. This object uses fd waiting within the
Tcl/TK event processing loop framework to dispatch buffers for
processing as they become available.
*/
void
CMySpecTclApp::SetupRunControl()
{
CTclGrammerApp::SetupRunControl();
}
// Function:
// void SourceFunctionalScripts(CTCLInterpreter& rInterp)
// Operation Type:
// Override
/*
Purpose:
This function allows the user to source scripts
which have access to the full Tcl/Tk/SpecTcl
command set along with whatever extensions have been
added by the user in AddCommands.
*/
void
CMySpecTclApp::SourceFunctionalScripts(CTCLInterpreter& rInterp)
{
CTclGrammerApp::SourceFunctionalScripts(rInterp);
}
// Function:
// int operator()()
// Operation Type:
// Override.
/*
Purpose:
Entered at Tcl/Tk initialization time (think of this
as the entry point of the SpecTcl program). The base
class default implementation calls the member functions
of this class in an appropriate order. It's possible for the user
to extend this functionality by adding code to this function.
*/
int
CMySpecTclApp::operator()()
{
return CTclGrammerApp::operator()();
}
CMySpecTclApp myApp;
#ifdef SPECTCL_5_INIT
CTclGrammerApp* CTclGrammerApp::m_pInstance = &myApp;
CTCLApplication* gpTCLApplication;
#else
CTclGrammerApp& app(myApp); // Create an instance of me.
CTCLApplication* gpTCLApplication=&app; // Findable by the Tcl/tk framework.
#endif