Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CReadoutMain Class Reference

#include <CReadoutMain.h>

Inheritance diagram for CReadoutMain:

CMyExperiment CMyExperiment List of all members.

Public Methods

 CReadoutMain ()
 Default constructor.

 ~CReadoutMain ()
 Destructor.

bool getWindowed () const
bool getServer () const
unsigned short getPort () const
bool getVmeTrigger () const
string getTitle () const
unsigned int getScalerPeriod () const
CInterpreterShellgetInterpreter ()
CRunStategetRunState ()
CExperimentgetExperiment ()
CTimergetClock ()
virtual void SetupRunVariables (CExperiment &rExperiment, CInterpreterStartup &rStartup, CInterpreterCore &rCore)
virtual void SetupStateVariables (CExperiment &rExperiment, CInterpreterStartup &rStartup, CInterpreterCore &rCore)
virtual void AddUserCommands (CExperiment &rExperiment, CInterpreterStartup &rStartup, CInterpreterCore &rCore)
void Exit ()

Static Public Methods

CReadoutMain * getInstance ()

Protected Methods

virtual int operator() (int argc, char **argv)
void ParseSwitches (int argc, char **argv)
void CreateInterpreter ()
void CreateExperiment ()
virtual void SetupReadout (CExperiment &rExperiment)
virtual void SetupScalers (CExperiment &rExperiment)

Private Methods

 CReadoutMain (const CReadoutMain &rhs)
 Copy constructor.

CReadoutMain & operator= (const CReadoutMain &rhs)
 Assignment.

int operator== (const CReadoutMain &rhs) const
 Comparison for equality.

int operator!= (const CReadoutMain &rhs) const

Private Attributes

bool m_fWindowed
 True if Tk interpreter is started.

bool m_fServer
 True if system runs a Tcl Server.

bool m_fExit
 True if should exit.

unsigned short m_nPort
 Number of Tcl server port if enabled.

bool m_fVmeTrigger
 True if trigger is VME based.

CInterpreterShellm_pInterpreter
 Command interpreter wrapper.

CTimer m_TimerQueue
 Managed queue of timed events.

CRunState m_RunState
 Run State Transition manager..

CExperiment m_Experiment
 Experiment specific code container.


Detailed Description

CReadoutMain is a singleton class which represents the application object. It creates subcomponent's and their related threads, starts them and waits for the interpreter thread to exit. When that happens the application can be shutdown. The interpreter thread shuts down in response to the replaced exit command. (Exit here is not the normal Tcl exit command). The entry point is able to parse the following switches:

-w - Requests a windowed interface. -pnum - Requests that the server run a TclServer on port num. -c - Requests that trigger management be via the NSCL standard CAMAC setup. Default is to use the NSCL standard VME trigger setup.

Definition at line 325 of file CReadoutMain.h.


Constructor & Destructor Documentation

CReadoutMain::CReadoutMain  
 

Default constructor.

Default constructor. This member is called for the single instance of the object.. which is statically declared.

Definition at line 341 of file CReadoutMain.cpp.

CReadoutMain::~CReadoutMain  
 

Destructor.

Destructor. Race conditions make it safer to not destroy anything.

Definition at line 356 of file CReadoutMain.cpp.

CReadoutMain::CReadoutMain const CReadoutMain &    rhs [private]
 

Copy constructor.


Member Function Documentation

void CReadoutMain::AddUserCommands CExperiment   rExperiment,
CInterpreterStartup &    rStartup,
CInterpreterCore   rCore
[virtual]
 

Must be overridden if you want to add additional readout specific commands:

Parameters:
rExperiment  - Refers to the experiment.
rStartup  - Refers to the interpreter startup thread.
rCore  - Refers to the core readout tcl extensions.
The default implementation is a no-op and can be overridden.

Note:
This member is called int he context of the interpreter thread therefore noe synchronization is required with the interpreter.

Reimplemented in CMyExperiment, and CMyExperiment.

Definition at line 571 of file CReadoutMain.cpp.

Referenced by CMyExperiment::AddUserCommands(), and CInterpreterCore::RegisterExtensions().

void CReadoutMain::CreateExperiment   [protected]
 

Based on the member data m_fVmeTrigger creates an experiment object and configures it with the appropriate trigger/clear modules. The experiment object configures the rest of itself based on the experiment's Initialize callout which performs experiment specific initialization including and not limited to configuring the EventReader component.

Definition at line 474 of file CReadoutMain.cpp.

References CExperiment::EstablishBusy(), CExperiment::EstablishTrigger(), m_Experiment, SetupReadout(), and SetupScalers().

Referenced by operator()().

void CReadoutMain::CreateInterpreter   [protected]
 

Based on the member data:

m_fWindowed - true selects a Tk based interpreter,

and schedules it to start up. The startup will register standard Readout Tcl extensions and variables, and then callback our members to register custom extensions.

Definition at line 449 of file CReadoutMain.cpp.

References m_pInterpreter.

Referenced by operator()().

void CReadoutMain::Exit   [inline]
 

Definition at line 415 of file CReadoutMain.h.

References m_fExit.

Referenced by CExitCommand::operator()().

CTimer& CReadoutMain::getClock   [inline]
 

Definition at line 388 of file CReadoutMain.h.

Referenced by CExperiment::GetElapsedTime(), CExperiment::SetupTimedEvent(), CExperiment::Start(), and CExperiment::Stop().

CExperiment* CReadoutMain::getExperiment   [inline]
 

Definition at line 385 of file CReadoutMain.h.

Referenced by CResumeCommand::operator()(), CPauseCommand::operator()(), CEndCommand::operator()(), CBeginCommand::operator()(), and CInterpreterCore::RegisterExtensions().

CReadoutMain * CReadoutMain::getInstance   [static]
 

Get a pointer to the single instance of a ReadoutMain object which can exist in the system.

Definition at line 663 of file CReadoutMain.cpp.

Referenced by CStateVariable::CStateVariable(), CTCLListener::CTCLListener(), CExperiment::GetRunNumber(), initevt(), CResumeCommand::operator()(), CPauseCommand::operator()(), CExitCommand::operator()(), CEndCommand::operator()(), CBeginCommand::operator()(), CExperiment::ReadEvent(), CInterpreterCore::RegisterExtensions(), and CExperiment::Start().

CInterpreterShell* CReadoutMain::getInterpreter   [inline]
 

Definition at line 379 of file CReadoutMain.h.

Referenced by CTCLListener::CTCLListener(), CExperiment::GetRunNumber(), initevt(), CExperiment::ReadEvent(), CExperiment::Start(), CExperiment::TriggerRunVariableBuffer(), and CExperiment::TriggerStateVariableBuffer().

unsigned short CReadoutMain::getPort   const [inline]
 

Definition at line 364 of file CReadoutMain.h.

References m_nPort.

Referenced by CInterpreterCore::RegisterExtensions().

CRunState* CReadoutMain::getRunState   [inline]
 

Definition at line 382 of file CReadoutMain.h.

Referenced by CStateVariable::CStateVariable(), CResumeCommand::operator()(), CPauseCommand::operator()(), CEndCommand::operator()(), and CBeginCommand::operator()().

unsigned int CReadoutMain::getScalerPeriod   const
 

Returns the scaler readout period in seconds.

Note:
Scaler timers require a period in ms so be sure to scale this appropriately.

Definition at line 622 of file CReadoutMain.cpp.

References CStateVariableCommand::end(), CStateVariableCommand::find(), CInterpreterShell::getInterpreterCore(), CInterpreterCore::getStateVariables(), m_pInterpreter, and StateVariableIterator.

Referenced by CExperiment::Start().

bool CReadoutMain::getServer   const [inline]
 

Definition at line 360 of file CReadoutMain.h.

References m_fServer.

Referenced by CInterpreterCore::RegisterExtensions().

string CReadoutMain::getTitle   const
 

Returns the current run title. This is the value of the title run state variable. If that run state variable is not yet set we return -not set-.

Definition at line 584 of file CReadoutMain.cpp.

References CStateVariableCommand::end(), CStateVariableCommand::find(), CInterpreterShell::getInterpreterCore(), CInterpreterCore::getStateVariables(), m_pInterpreter, and StateVariableIterator.

Referenced by CExperiment::EmitEnd(), CExperiment::EmitPause(), CExperiment::EmitResume(), and CExperiment::EmitStart().

bool CReadoutMain::getVmeTrigger   const [inline]
 

Definition at line 368 of file CReadoutMain.h.

References m_fVmeTrigger.

bool CReadoutMain::getWindowed   const [inline]
 

Definition at line 356 of file CReadoutMain.h.

References m_fWindowed.

Referenced by CInterpreterCore::RegisterExtensions().

int CReadoutMain::operator!= const CReadoutMain &    rhs const [private]
 

int CReadoutMain::operator() int    argc,
char **    argv
[protected, virtual]
 

Entry point to the program. The flow is relatively simple: We parse the switches, Create the interpreter, Create the experiment and Create the timer manager, and then block to let the child threads run.

Parameters:
argc  - Count of command line arguments.
argv  - Array o fpointers to command line arguments. Note that argv[0] is the path name to this program.
Bug:
May need to replace sleep loop with wait on a condition which would be signalled by Tcl interpreter's exit.

Definition at line 382 of file CReadoutMain.cpp.

References CreateExperiment(), CreateInterpreter(), CReaper::getInstance(), m_fExit, and ParseSwitches().

CReadoutMain& CReadoutMain::operator= const CReadoutMain &    rhs [private]
 

Assignment.

int CReadoutMain::operator== const CReadoutMain &    rhs const [private]
 

Comparison for equality.

void CReadoutMain::ParseSwitches int    argc,
char **    argv
[protected]
 

Parses the command line switches into the member variables. Switches supported are described in the CReadoutMain class description.

Parameters:
argc  - Number of command line parameters.
argv  - Vector of command line pointers. argv[0] is the program name.
We'll allow illegal switches since they may be directed at tcl/tk. we won't allow illegal formats of switches however.

We make use of the gnu getgetopts cmdline parser. Our parse 'grammer' is in options.ggo

Definition at line 423 of file CReadoutMain.cpp.

References gengetopt_args_info::camac_trigger_flag, cmdline_parser(), m_fServer, m_fVmeTrigger, m_fWindowed, m_nPort, gengetopt_args_info::port_arg, gengetopt_args_info::port_given, and gengetopt_args_info::window_flag.

Referenced by operator()().

void CReadoutMain::SetupReadout CExperiment   rExperiment [protected, virtual]
 

This must be overridden to create the user's readout procedures

Parameters:
rExperiment  - reference to the experiment object.

Reimplemented in CMyExperiment, and CMyExperiment.

Definition at line 499 of file CReadoutMain.cpp.

Referenced by CreateExperiment(), and CMyExperiment::SetupReadout().

void CReadoutMain::SetupRunVariables CExperiment   rExperiment,
CInterpreterStartup &    rStartup,
CInterpreterCore   rCore
[virtual]
 

This must be overridden if the experimenter wants to provide any initial run variables.

Parameters:
rExperiment  - reference to the experiment object.
rStartup  - Reference to the Tcl interpreter startup thread.
rCore  - Reference to the core readout Tcl extensions.
The default implementation is a no-op and can be overridden.

Note:
This member is called back from the interpreter core in the context of the interpreter startup thread. Therefore, no syncrhonization is required with the interpreter.

Reimplemented in CMyExperiment, and CMyExperiment.

Definition at line 527 of file CReadoutMain.cpp.

Referenced by CInterpreterCore::RegisterExtensions(), and CMyExperiment::SetupRunVariables().

void CReadoutMain::SetupScalers CExperiment   rExperiment [protected, virtual]
 

This must be overridden to create the user's scaler readout procedure.

Parameters:
rExperiment  - reference to the experiment object.

Reimplemented in CMyExperiment, and CMyExperiment.

Definition at line 509 of file CReadoutMain.cpp.

Referenced by CreateExperiment(), and CMyExperiment::SetupScalers().

void CReadoutMain::SetupStateVariables CExperiment   rExperiment,
CInterpreterStartup &    rStartup,
CInterpreterCore   rCore
[virtual]
 

This must be overridden if the experimenter wants to provide any run state variables. If you override this be sure to call the base class member e.g.: CReadoutMain::SetupStateVariables(rExperiment, Interp) as the first executable line.

Parameters:
rExperiment  - Reference to the experiment object.
rStartup  - Reference to the interpreter startup thread.
rCore  - Reference to the set of core readout extensions.
The default implementation can be overridden and is an no-op.
Note:
This function is called in the context of the tcl interpreter thread and therefore does not need to synchronize with it in any way.

Reimplemented in CMyExperiment, and CMyExperiment.

Definition at line 550 of file CReadoutMain.cpp.

Referenced by CInterpreterCore::RegisterExtensions(), and CMyExperiment::SetupStateVariables().


Member Data Documentation

CExperiment CReadoutMain::m_Experiment [private]
 

Experiment specific code container.

Definition at line 337 of file CReadoutMain.h.

Referenced by CreateExperiment().

bool CReadoutMain::m_fExit [private]
 

True if should exit.

Definition at line 330 of file CReadoutMain.h.

Referenced by Exit(), and operator()().

bool CReadoutMain::m_fServer [private]
 

True if system runs a Tcl Server.

Definition at line 329 of file CReadoutMain.h.

Referenced by getServer(), and ParseSwitches().

bool CReadoutMain::m_fVmeTrigger [private]
 

True if trigger is VME based.

Definition at line 332 of file CReadoutMain.h.

Referenced by getVmeTrigger(), and ParseSwitches().

bool CReadoutMain::m_fWindowed [private]
 

True if Tk interpreter is started.

Definition at line 328 of file CReadoutMain.h.

Referenced by getWindowed(), and ParseSwitches().

unsigned short CReadoutMain::m_nPort [private]
 

Number of Tcl server port if enabled.

Definition at line 331 of file CReadoutMain.h.

Referenced by getPort(), and ParseSwitches().

CInterpreterShell* CReadoutMain::m_pInterpreter [private]
 

Command interpreter wrapper.

Definition at line 334 of file CReadoutMain.h.

Referenced by CreateInterpreter(), getScalerPeriod(), and getTitle().

CRunState CReadoutMain::m_RunState [private]
 

Run State Transition manager..

Definition at line 336 of file CReadoutMain.h.

CTimer CReadoutMain::m_TimerQueue [private]
 

Managed queue of timed events.

Definition at line 335 of file CReadoutMain.h.


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 13:37:21 2002 for Event Readout system. by doxygen1.2.16