Generic hardware access library
|
A series of commands which can be excecuted at once. More...
#include <CommandSequence.hh>
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 |
CommandSequenceReader & | reader |
const AddressTableInterface & | addressTable |
int | commandIndex |
std::vector< SequencerCommand * > | commandList |
std::vector< SequencerCommand * > ::iterator | commandIterator |
std::map< std::string, uint32_t > | variableMap |
std::map< std::string, int > | labelMap |
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.
Definition at line 41 of file CommandSequence.hh.
HAL::CommandSequence::CommandSequence | ( | std::string | name, |
HAL::CommandSequenceReader & | reader, | ||
const AddressTableInterface & | addressTable | ||
) | throw ( SequencerSyntaxError, NoSuchItemException ) |
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.)
name | is an arbitray name for the sequence. |
reader | is a "Reader" for the CommandSequence. It is possible to read CommandSequences from different sources (e.g. ASCII files, XML-representations, databases). |
addressTable | refers to the addressTable which is used by this CommandSequence. |
Definition at line 4 of file CommandSequence.cc.
HAL::CommandSequence::~CommandSequence | ( | ) | [virtual] |
The Destructor deletes all commands of this CommandSequence.
Definition at line 32 of file CommandSequence.cc.
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.
SequencerSyntaxError | is 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.
SequencerSyntaxError | is 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.
SequencerSyntaxError | is 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.
SequencerSyntaxError | is 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.
SequencerSyntaxError | is thrown if the label does not exist in this sequence. |
Definition at line 86 of file CommandSequence.cc.
void HAL::CommandSequence::rescan | ( | ) | throw ( NoSuchItemException, SequencerSyntaxError ) |
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::run | ( | const HardwareDeviceInterface & | device | ) | throw ( SequencerSyntaxError, IllegalOperationException, BusAdapterException, MaskBoundaryException, TimeoutException) |
Run the CommandSequence on a specific device.
Definition at line 40 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.
SequencerSyntaxError | is thrown if the variable does not exist in this sequence. |
Definition at line 79 of file CommandSequence.cc.
const AddressTableInterface& HAL::CommandSequence::addressTable [private] |
Definition at line 170 of file CommandSequence.hh.
int HAL::CommandSequence::commandIndex [private] |
Definition at line 171 of file CommandSequence.hh.
std::vector< SequencerCommand* >::iterator HAL::CommandSequence::commandIterator [private] |
Definition at line 173 of file CommandSequence.hh.
std::vector< SequencerCommand* > HAL::CommandSequence::commandList [private] |
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.
Definition at line 169 of file CommandSequence.hh.
std::map< std::string, uint32_t > HAL::CommandSequence::variableMap [private] |
Definition at line 174 of file CommandSequence.hh.