Home Examples Task Event Codes
Beginner

Task Event Codes

10.1    Task Event Codes

Task Event Codes provide a method of time-stamping when something occurred and what that something was, which can be useful for subsequent data analysis. Examples of typical Task Event Codes that are time-stamped in this manner include target on/off events and user-defined errors (e.g. the subject moved too slowly), however, they can be anything that the end-user wishes. Task Event Codes are end-user specific; they have no meaning to Dexterit-E. Task Event Codes are displayed in the Dexterit-E GUI as they occur during run-time and are automatically saved to the exam file.

To save a Task Event Code, a Task Event Code must be passed into the DataLogging block in the Simulink code (see example below). Task Event Codes are logged only when the event_codes input to the DataLogging block changes. Within a Simulink model, Task Event Codes are treated and evaluated as numbers. However, names and descriptions can be defined for Task Event Codes in the Parameter Table Defn block (see example below), such that if a name is defined for a Task Event Code, then when that Task Event Code occurs and gets logged, then the name of the Task Event Code gets saved to the exam file. If there is no name defined for a logged Task Event Code, then a name is auto-generated based on the Task Event Code’s number (see below).

Some rules for Task Event Codes are:

  1. In the Dexterit-E user interface, and in the data files generated by Dexterit-E after running a task, Task Event Codes are saved as, and referred to as, (Note: Task Event Codes should not be confused with Stateflow Events, which do not appear in the Dexterit-E user interface, and which are not saved to data files).
  2. When a Task Event Code is saved in a data file it is saved (as an “event”) with the name from the Parameter Table Defn block, if one If a Task Event Code is sent that is not defined by name in the Parameter Table Defn block then it will be saved with the name “Unnamed Event: code [value]”.
  3. In addition to the name, the number of the Task Event Code is also saved to the data
  4. The Parameter Table Defn block will allow you to define a maximum of 511 named Task Event Codes codes with values between 1-65535.
  5. If a Task Event Code is set to zero then no event is In the Parameter Table Defn block E_NO_EVENT is a constant created by default and set to zero.
  6. Task Event Code values can be in the range 1-16.7 Negative values are converted and saved as the absolute value of the Task Event Code.
  7. Task Event Codes are only recorded by Dexterit-E when the event_codes input on the Data Logging block changes. In order to record the same Task Event Code twice in a row you can send the negative of the Task Event Code. For example, if you sent Task Event Code 5, then later Task Event Code -5, they will both be registered as Task Event Code 5, but at different times. It is also possible to set the event_codes value to E_NO_EVENT in between setting event_codes to a required Task Event Code value.
  8. Task Event Codes are recorded at 1 If the value being passed into the Data Logging block for a Task Event Code changes more than once during a 1 ms time interval then only the last value of the Task Event Code is recorded. If you need to be able to register multiple Task Event Codes during 1 ms then a vector of Task Event Codes can be passed to the Data Logging block. Each element of the vector will treated independently (i.e. if element 1 changes at a given time frame, but not element 2, then only the Task Event Code for element 1 will be logged).

10.1.1   Simulink Code for Task Event Codes Example

This Task Program is the same as 6.7 Centre-out Reaching Task, but with a new output added to the Stateflow chart called event_code. This new output is connected to the event_codes input of the DataLogging block, which has been made available by checking Log event codes in the DataLogging block’s dialog. It allows Task Event Codes to be recorded during a task.

Figure 10.1: Simulink Code for Task Event Codes Example

 

10.1.2   Parameter Table Defn Block for Task Event Codes Example

To save the name and description of Task Event Codes, the end-user must define the Task Event Codes in the Parameter Table Defn block.

Figure 10.2: Task Event Codes in the Parameter Table Defn Block.

  • Evt # – is value of the Task Event Code used in Simulink (i.e. when the Task Program logs an event_code of this value, then the name and description associated with that code as defined here is what gets saved in the data file as an “event”)
  • Constant Name – A name that can be used within any Stateflow code, or in Simulink blocks as described in 6.12 Using the Parameter Table Defn Block.
  • Event Code Label – The name that will be saved for the Task Event Code in the data Reserved labels that are not allowed are listed in 14.13 System Generated Task Events Codes.
  • Options – The available options are:
    • None – No extra handling is
    • Error – If this Task Event Code is detected then the trial is marked as an Error Trial (12 Error Trials: Repeating and/or Reporting).
    • Hidden – The Task Event Code is not displayed to the operator during a task in Dexterit-E user interface (unless Show hidden events is selected from the menu).
    • Red, Green, Blue, Orange, Purple – The given colour is used when displaying the Task Event Code in the Dexterit-E user interface.
  • Parameter Description – A textual description of the meaning of this Task Event

10.1.3   Stateflow Chart for Task Event Codes Example

In the Stateflow Chart shown next, the output event_code is assigned various values when different states are entered. The values that event_code is set to in this example (e.g.

STAY_CENTER) are constants, defined in the Parameter Table Defn block.

 

Figure 10.3: Stateflow Chart for Task Event Codes Example

Task Event Codes are only registered and saved when the event_codes input to the DataLogging block changes. It is therefore imperative that the event_code be forced to change at least once per trial. In this Stateflow Chart example, there is only one branch to the flow chart, and so the event_code will cycle through different values and will always be set appropriately. However, for a Stateflow Chart with multiple branches, setting event_code=E_NO_EVENT as part of the Between_Trials state is required. See 6.13 Including Pause Button Functionality for an example of this type.

Related Tasks

AdvancedPosition Control
Position Control – by Velocity or Duration
This version of the position controller demo allows you to specify the peak velocity of the trajectory or the duration.
AdvancedLoadsPosition Control
Reaching Task with Force Channel with Position Control
Adds position control to the force channel sample task.