Generic hardware access library
HAL::CommandSequence Class Reference

A series of commands which can be excecuted at once. More...

#include <CommandSequence.hh>

List of all members.

Public Member Functions

 CommandSequence (std::string name, CommandSequenceReader &reader, const AddressTableInterface &addressTable) throw ( SequencerSyntaxError, NoSuchItemException )
 Build a command sequence.
virtual ~CommandSequence ()
 The Destructor deletes all commands of this CommandSequence.
void run (const HardwareDeviceInterface &device) throw ( SequencerSyntaxError, IllegalOperationException, BusAdapterException, MaskBoundaryException, TimeoutException)
 Run the CommandSequence on a specific device.
std::string getName () const
uint32_t * addVariable (std::string name, uint32_t initValue=0)
 This is used by the constructor of the DefineCommand.
void addLabel (std::string name)
 This is used by the constructor of the LabelCommand.
uint32_t getVariable (std::string name) const throw ( SequencerSyntaxError )
 Retrieves the value of a variable registered with this sequence.
uint32_t * getVariablePointer (std::string name) throw ( SequencerSyntaxError )
 Retrieves the pointer to a specific variale.
void setVariable (std::string name, uint32_t value) throw ( SequencerSyntaxError )
 Sets a variable to specific value.
void existVariable (std::string name) const throw ( SequencerSyntaxError )
 Checks if a variable is existing in this sequence.
void gotoLabel (std::string labelName) throw (SequencerSyntaxError )
 Excecution of a sequence is continued at a specific label.
void rescan () throw ( NoSuchItemException, SequencerSyntaxError )
 This function re-reads the whole sequence from the reader given in the constructor.
void existLabel (std::string labelName) const throw ( SequencerSyntaxError )
 Checks the existance of a specific label in the sequence.

Private Attributes

std::string name
CommandSequenceReaderreader
const AddressTableInterfaceaddressTable
int commandIndex
std::vector< SequencerCommand * > commandList
std::vector< SequencerCommand * >
::iterator 
commandIterator
std::map< std::string, uint32_t > variableMap
std::map< std::string, int > labelMap

Detailed Description

A series of commands which can be excecuted at once.

The Command sequence is similar to a poor mans script. It is able to store and later excecute sequences of hardware access commands. Which commands are available is described in the CommandCreator. (The system is designed to easily be extendable for new commands.)

Please note that commands in sequences are CASE SENSITIVE.

See also:
CommandCreator
Author:
Christoph Schwick
Revision:
1.1
Date:
2007/03/05 18:02:09

Definition at line 41 of file CommandSequence.hh.


Constructor & Destructor Documentation

Build a command sequence.

The sequence is built by reading all commands from the reader and storing them for later excecution in an internal data structure. The reader only delivers command names and their parameters. The constructor uses the CommandCreator in order to create for each command an object (SequencerCommand) and store it internally in a list. The CommandSequence aquires ownership of the commands. This means it is responsible for their destruction. On the other hand it is important to note that the CommandSequence only keeps references to the AddressTable and to the CommandSequenceReader. Therefore these two must exist at least as long as the CommandSequencer. It is the responsibility of the user to ensure this. (The technical reason why these two items are not passed by value so that a local copy is made, is that both items must be polymorphic types: for example the addressTable could be a VME or a PCIAddressTable.)

Parameters:
nameis an arbitray name for the sequence.
readeris a "Reader" for the CommandSequence. It is possible to read CommandSequences from different sources (e.g. ASCII files, XML-representations, databases).
addressTablerefers to the addressTable which is used by this CommandSequence.

Definition at line 4 of file CommandSequence.cc.

The Destructor deletes all commands of this CommandSequence.

Definition at line 32 of file CommandSequence.cc.


Member Function Documentation

void HAL::CommandSequence::addLabel ( std::string  name)

This is used by the constructor of the LabelCommand.

A new label is registered with the sequence in this way.

Definition at line 59 of file CommandSequence.cc.

uint32_t * HAL::CommandSequence::addVariable ( std::string  name,
uint32_t  initValue = 0 
)

This is used by the constructor of the DefineCommand.

A new variable is registered with the sequence in this way.

Definition at line 53 of file CommandSequence.cc.

void HAL::CommandSequence::existLabel ( std::string  labelName) const throw ( SequencerSyntaxError )

Checks the existance of a specific label in the sequence.

Exceptions:
SequencerSyntaxErroris thrown if the label does not exist in this sequence.

Definition at line 107 of file CommandSequence.cc.

void HAL::CommandSequence::existVariable ( std::string  name) const throw ( SequencerSyntaxError )

Checks if a variable is existing in this sequence.

Exceptions:
SequencerSyntaxErroris thrown if the variable does not exist in this sequence.

Definition at line 92 of file CommandSequence.cc.

std::string HAL::CommandSequence::getName ( ) const [inline]

Definition at line 87 of file CommandSequence.hh.

uint32_t HAL::CommandSequence::getVariable ( std::string  name) const throw ( SequencerSyntaxError )

Retrieves the value of a variable registered with this sequence.

Exceptions:
SequencerSyntaxErroris thrown if the variable does not exist in this sequence.

Definition at line 67 of file CommandSequence.cc.

uint32_t * HAL::CommandSequence::getVariablePointer ( std::string  name) throw ( SequencerSyntaxError )

Retrieves the pointer to a specific variale.

This is used by the ReadCommand and UmaskedReadCommand.

Exceptions:
SequencerSyntaxErroris thrown if the variable does not exist in this sequence.

Definition at line 73 of file CommandSequence.cc.

void HAL::CommandSequence::gotoLabel ( std::string  labelName) throw (SequencerSyntaxError )

Excecution of a sequence is continued at a specific label.

This is used by the GotoCommand.

Exceptions:
SequencerSyntaxErroris thrown if the label does not exist in this sequence.

Definition at line 86 of file CommandSequence.cc.

This function re-reads the whole sequence from the reader given in the constructor.

It allows you to change sequences while the program is running. For example if you have a menu driven program and one menu point is to excecute a specific sequence, you can change the sequence while your program is running. If you rescan the sequence always before excecution you can try out your new version of the sequence without restarting the program.

Definition at line 14 of file CommandSequence.cc.

void HAL::CommandSequence::setVariable ( std::string  name,
uint32_t  value 
) throw ( SequencerSyntaxError )

Sets a variable to specific value.

This command can be used from within the application to set specific parameters in a sequence before excecuting them.

Exceptions:
SequencerSyntaxErroris thrown if the variable does not exist in this sequence.

Definition at line 79 of file CommandSequence.cc.


Member Data Documentation

Definition at line 171 of file CommandSequence.hh.

std::vector< SequencerCommand* >::iterator HAL::CommandSequence::commandIterator [private]

Definition at line 173 of file CommandSequence.hh.

Definition at line 172 of file CommandSequence.hh.

std::map< std::string, int > HAL::CommandSequence::labelMap [private]

Definition at line 175 of file CommandSequence.hh.

std::string HAL::CommandSequence::name [private]

Definition at line 168 of file CommandSequence.hh.

std::map< std::string, uint32_t > HAL::CommandSequence::variableMap [private]

Definition at line 174 of file CommandSequence.hh.


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