SourceForge.net Logo

DAQpp::RunState Class Reference
[DAQ++ objects]

class RunState. More...

#include <RunState.h>

Inheritance diagram for DAQpp::RunState:

Inheritance graph
[legend]
Collaboration diagram for DAQpp::RunState:

Collaboration graph
[legend]

List of all members.

Public Types

enum  StatusType {
  NotDefined, NotReady, GettingReady, Ready,
  Starting, Paused, Running, Stopping,
  Stopped, TimeOut, last_state
}
 Posible state values. More...

Public Member Functions

 RunState ()
 Constructor.
 RunState (const RunState &s)
 Copy constructor.
RunStateoperator= (const RunState &s)
 Asignment operator.
virtual ~RunState ()
 Destructor.
const std::string & get_name () const
 returns the name of the RunState
void set_name (const std::string &s)
 sets the name of the RunState
void reset ()
 Resets the internal counters.
void start ()
 Starts the timer.
void stop ()
 Stops the timer.
int Ntrig () const
 returns the number of triggers
void new_trigger ()
 Increases the number of triggers.
void new_writen ()
 Increases the number of saved events.
int Nwriten () const
 Returns the number of saved events.
double eff () const
 Returns the efficiency.
double rate (bool average=false) const
 Returns the acquisition rate.
double time () const
 Returns the time elapsed since the start.
double get_throughput () const
 returns the throughput
void reset_throughput ()
 resets the throughput counter
void set_throughput (int x)
 sets the throughput counter to a given value
StatusType get_status () const
 Returns the current status.
bool isRunning () const
 Returns true if the object is running.
bool isReady () const
 Returns true if the object's state is Ready.
bool isPaused () const
 Returns true if the object's state is Paused.
bool isNotReady () const
 Returns true if the object's state is NotReady.
bool isTimeout () const
 Returns true if the object's state is TimeOut.
StatusType set_status (StatusType st)
 Sets the current status.
void update (Observable *o, Argument *arg)
 Receives a request to change status.
void addAction (RunStateAction *)
 Adds an action.
void deleteAction (RunStateAction *)
 Deletes an action from the list.
void clearActionList ()
 Clears all the action list.
void executeActionList ()
 Execute all the actions in the action list.

Static Public Member Functions

static std::string const & status_str (StatusType st)
 Returs the state as a string.

Static Public Attributes

static std::string str_state [last_state]
 array with the names of the possible states

Private Types

typedef std::set
< RunStateAction * > 
ActionList
 generic type for the list of actions

Private Member Functions

void cpy (const RunState &s)

Private Attributes

std::string name
 name of the RunState
int ntrig
 Number of triggers.
int nwriten
 Number of events writen.
int throughput
 Throughput.
StatusType status
 State.
GTimer timer
 A timer used internally to compute rate, run duration, etc.
int ntrg0
 Internal buffer.
double tim0
 Internal buffer.
ActionList action_list
 List of actions to be made at update time.

Classes

struct  executeAction
 This is a unary function that will be executed on every RunAction after update. More...


Detailed Description

class RunState.

This class mantains the information about the status of a DAQ object. The status can be any of:

This class derives both from an Observer and Observable. As an Observable, it will notify any change of state to any of the subscribed Observers. As an Observer, the situation is a bit confusing and should probably need reconsideration. In the update method it expects as argument a pointer to an

 Arg<StatusType> 
On receipt of the notification it will change the state to the one given in the argument.

It provides methods to access some other information about the DAQ object, like the number of triggers, the number of events saved, the run duration time, the efficiency, the rate, etc.

It also mantains a list of RunStateAction. Those objects represent an action that could be executed at request. The list of Actions is mantained by addAction(),deleteAction(),clearActionList(), executeActionList().

The idea of this list of actions is to be able to make some operations, like monitoring, in an authomatic way. One could think on actions like:

class UpdateWidget : public RunStateAction {
   private:
      RunState *_state;
      GtkWidget *_wdgt;

   public:
      UpdateWidget(GtkWidget *w, RunState *s=0)
  : _wdgt(w),_state(s) {}
      GtkWidget *wdgt() { return _wdgt; }
      RunState *state() { return _state; }
};

class UpdateLabel : public UpdateWidget {
   private:
      string str
   public:
      UpdateLabel(GtkWidget *w, RunState *s=0)
  : UpdateWidget(w,s),str("label") {}
      void execute() {
  gtk_label_set_text(GTK_LABEL(wdgt),str.c_str());
      }
};

and similarly with classes like UpdateButton, UpdateSlider, etc.

Author:
Carlos Lacasta

Member Enumeration Documentation

Posible state values.

Enumerator:
NotDefined  state undefined
NotReady  not ready for run, needs a GetReady command
GettingReady  the object is initializing
Ready  the object has been initialized and is ready to run
Starting  the acquisition has just started and the object is preparing to acquire
Paused  the object is acquiring but the acquisition has been paused
Running  the object is acquiring
Stopping  the object is closing the acquisition
Stopped  the object has closed the acquisition
TimeOut  the object does not respond


Member Function Documentation

void DAQpp::RunState::reset (  ) 

Resets the internal counters.

It will reset the run duration time, the number of triggers, saved events, etc.

References ntrig, nwriten, DAQpp::GTimer::reset(), throughput, and timer.

Referenced by RunState(), DAQpp::RunManager::Start(), and DAQpp::Module::update().

double DAQpp::RunState::eff (  )  const

Returns the efficiency.

The Efficiency is defined as the ration between saved events and number of triggers.

References ntrig, and nwriten.

double DAQpp::RunState::rate ( bool  average = false  )  const

Returns the acquisition rate.

It provides the acquisition time. It can be the average rate over the whole acquisition period, if average is true, or the instantaneous rate if average is false.

References isRunning(), ntrg0, ntrig, tim0, and timer.

void DAQpp::RunState::update ( Observable *  o,
Argument arg 
) [virtual]

Receives a request to change status.

This is the method call by any observable for which the RunState has subscribed for notifications. It expects as agument a pointer to an

Implements Observer.

References set_status().


Member Data Documentation

std::string DAQpp::RunState::str_state [static]

Initial value:

 {
            "NotDefined",
            "NotReady",
            "GettingReady",
            "Ready",
            "Starting",
            "Paused",
            "Running",
            "Stopping",
            "Stopped",
            "TimeOut"
        }
array with the names of the possible states

Referenced by status_str().


The documentation for this class was generated from the following files:

Generated on Mon Apr 21 10:00:05 2008 for DAQ++ by  doxygen 1.5.5