Robotcode
1.0
|
Abstract block class with behavior for a collection of trials. More...
#include <Experiment.h>
Public Member Functions | |
Block () | |
Constructor. | |
~Block () | |
Destructor. | |
virtual bool | init (int blocknum, string filename) |
initialize the Trials | |
virtual void | control () |
control loop for block | |
virtual void | announce () |
Calls the announcing routine for a block. | |
virtual void | start () |
starts the block | |
virtual void | giveFeedback () |
function for Block feedback | |
virtual void | end () |
Called after feedback: Clean feedback + End the block. | |
virtual Trial * | getTrial ()=0 |
create a new Trial | |
virtual void | save () |
save mov and dat file | |
Public Attributes | |
int | blockNumber |
Block number. | |
int | trialNum |
Number of the current Trial. | |
int | numTrials |
Total number of trials. | |
vector< Trial * > | trialVec |
Vector of trials. | |
BlockState | state |
state of the block | |
string | datFilename |
Data file name. | |
string | movFilename |
Mov file name. | |
string | targetFilename |
Name of current Target file. | |
ofstream | datFile |
Data file. | |
ofstream | movFile |
Mov file. | |
ifstream | targetFile |
Target file for input. | |
bool | isSaved |
is Block saved? |
Abstract block class with behavior for a collection of trials.
A block is created by typing run at the Text Display. It then reads in a target file and creates as many trial objects as lines in the target file. It then runs these trials and saves the data to disk.
Block::Block | ( | ) |
Constructor.
The Constructor only sets the number of Trials to zero
Block::~Block | ( | ) |
Destructor.
Destructor frees the memory allocated by the block, including the recorded data
bool Block::init | ( | int | blockn, |
string | filename | ||
) | [virtual] |
initialize the Trials
Initializes the Block by reading from a target file init makes the .mov and .dat file for later data saving. Calls Trial::read to specify how a trial is read
blockn | Block number |
filename | Name of the target file to be read in |
void Block::control | ( | ) | [virtual] |
control loop for block
Control loop for the Block. When started it calls start(). Then it sets the state of the first trial to START_TRIAL and waits until it is in the state END_TRIAL. Then it automatically advances to the next trial. After the block it calls give_feedback and save.
check if user interrupted current block
void Block::save | ( | ) | [virtual] |
save mov and dat file
Saves the data collected in a Block. Gives error message if files could not be opened for writing. The routine calls trial->writeDat() to write a line in the dat file, and trial->writeMov() to write a trial into the mov file