ApparatusFramework::Task Class Reference
[Kernel Services]

#include <KernelServices/Win32/current/include/Task.h>

Inheritance diagram for ApparatusFramework::Task:
ApparatusFramework::ActivityLog ApparatusFramework::CmdInter ApparatusFramework::SupervisedTask ApparatusFramework::TestExecutor ApparatusFramework::TimerMgr ApparatusFramework::WatchdogTaskSupervisor ApparatusFramework::Protocol ApparatusFramework::CANOpenProtocol

List of all members.

Public Types

typedef uint16 StackSize

Public Member Functions

 Task (const TaskId taskId, const TaskPriority priority, const StackSize stackSize=0, const uint16 msgQueueLgth=0, const char taskName[]=0)
virtual ~Task ()
void startTask ()
virtual void handleMsg (Msg *pMsg)
virtual void runBody ()
void sendMsg (Task *pReceiver, Msg *pMsg)
virtual MsgwaitMsg ()
virtual MsgwaitMsgNoLog ()
virtual MsgwaitMsgWithTimeout (const Timeout timeoutInMilliseconds)
MsggetMsgOrBalk ()
virtual void delayFor (const Timeout timeoutInMilliseconds)
TaskPriority taskPriority () const
TaskId taskId () const
const char * taskName () const
unsigned int maxUsedStack ()

Static Public Member Functions

static void sendMsgToTask (Task *pReceiver, Msg *pMsg)
static void sendMsgNoLog (Task *pReceiver, Msg *pMsg)

Public Attributes

HANDLE m_threadRunHandle

Protected Member Functions

 Task (const Task &lvalue)
Taskoperator= (const Task &lvalue)

Friends

class Kernel

Detailed Description

The class task models a runnable object in our system services. A task object is an active object with its own execution thread in the terminology of the unified modeling language (UML). The class provides an abstract method runBody which contains the routine executed in the newly created operating system process. This class is a mixin class.

A higher priority means that the task is more important and will preempt all tasks with a smaller priority. if it is ready. Please read our kernel services documentation for a in-depth discussion of the semantics of task objects.

Definition at line 120 of file Task.h.


Member Typedef Documentation

static methods

Definition at line 128 of file Task.h.


Constructor & Destructor Documentation

ApparatusFramework::Task::Task ( const TaskId  taskId,
const TaskPriority  priority,
const StackSize  stackSize = 0,
const uint16  msgQueueLgth = 0,
const char  taskName[] = 0 
)

constructors, destructors Constructs a new task and the associated process object. The method register the task in the kernel. The kernel will schedule the new task.

Parameters:
taskId unique identifier of the task. Clients can use the identifier to retrieve the task object. The programmer is responsible to define and use unique identifier. No checks are performed to insure that two tasks have always different identifiers.
priority the priority of the task is used by the kernel to schedule the next task accordingly to the current policy. A higher priority means the task will be scheduled before another one with a lower priority.
stackSize size of the stack in bytes necessary for the execution of the stack. Our services do not perform any validity checks concerning the adequacy of the chosen value.
msgQueueLgth defines the maximum number of messages waiting for processing by the task. Our services do not perform any validity checks concerning the adequacy of the chosen value.
taskName A unique string that identifies the task. Certain OSs such as VxWorks need this string.
virtual ApparatusFramework::Task::~Task (  )  [virtual]

Destroys the object and releases all the associated resources. The associated process is automatically killed.

ApparatusFramework::Task::Task ( const Task lvalue  )  [protected]

constructors, destructors The copy constructor is hidden to the clients of the task object. This operation is not defined for available commercial kernels.

Parameters:
lvalue task to be copied.

Member Function Documentation

virtual void ApparatusFramework::Task::delayFor ( const Timeout  timeoutInMilliseconds  )  [virtual]

Delays the task until the given interval of time has elapsed. This method can only be called by the task itself.

Parameters:
timeoutInMilliseconds to wait on the message before the task is again ready for execution. The timeout unit is milliseconds.

Reimplemented in ApparatusFramework::SupervisedTask.

Msg* ApparatusFramework::Task::getMsgOrBalk (  ) 

Gets the next message in the queue. If no message is available the method returns immediately. No task switch is performed by the kernel services.

Returns:
Pointer to the retrieved message. If no message is available, the value null is returned.
Note:
The receiver and sender fields of the message field are checked and updated in this operation if the debug mode of the kernel is used.
virtual void ApparatusFramework::Task::handleMsg ( Msg pMsg  )  [virtual]

HandleMsg is being called by the default implementation of runBody and has to be overridden by the user who works with it. Here one has to decide what to do with the received message.

Parameters:
pMsg received message
unsigned int ApparatusFramework::Task::maxUsedStack (  ) 

Returns the maximum stack size used by this task so far. This method is currently not supported on WIN32 and always returns 0.

Returns:
Always 0.
Task& ApparatusFramework::Task::operator= ( const Task lvalue  )  [protected]

The copy operator is hidden to the clients of the task object. This operation is not defined for available commercial kernels.

Parameters:
lvalue task to be copied.
virtual void ApparatusFramework::Task::runBody (  )  [virtual]

Contains the main loop of the task. This block is executed by the kernel services. This method should always contain an infinite loop. In general the task waits on a message, retrieves and processes it and waits for the next message. Stated in other words the routine implements a finite state machine. The messages are the events triggering the state machine.

Reimplemented in ApparatusFramework::CANOpenProtocol, ApparatusFramework::ActivityLog, ApparatusFramework::CmdInter, ApparatusFramework::TimerMgr, and ApparatusFramework::WatchdogTaskSupervisor.

void ApparatusFramework::Task::sendMsg ( Task pReceiver,
Msg pMsg 
)

Sends the message to the receiver task. The message is inserted in the message queue of the receiving task. The kernel will schedule the receiving task accordingly to the event. This operation can provoke a task switch.

Parameters:
pReceiver the task which should receive the message.
pMsg the message to be sent to the receiving task.
Note:
The receiver and sender fields of the message field are checked and updated in this operation if the debug mode of the kernel is used.
static void ApparatusFramework::Task::sendMsgNoLog ( Task pReceiver,
Msg pMsg 
) [static]

Sends the message without logging overhead. This method should only be used by an object not inheriting from the task class desires to send a message. The sender and receiver fields are set internally by the method. The message is inserted in the message queue of the receiving task. The kernel will schedule the receiving task accordingly to the event. This operation can provoke a task switch. This function will never log the message.

Parameters:
pReceiver the task which should receive the message.
pMsg the message to be sent to the receiving task.
Note:
The receiver and sender fields of the message field are checked and updated in this operation if the debug mode of the kernel is used.
static void ApparatusFramework::Task::sendMsgToTask ( Task pReceiver,
Msg pMsg 
) [static]

Sends the given message to the task passed as parameter. This method should only be used by an object not inheriting from the task class desires to send a message. The sender and receiver fields are set internally by the method. The message is inserted in the message queue of the receiving task. The kernel will schedule the receiving task accordingly to the event.This operation can provoke a task switch.

Parameters:
pReceiver task which should receive the message.
pMsg the message to be sent.
void ApparatusFramework::Task::startTask (  ) 

modifiers Sets the task to the ready state. This method is necessary to avoid calling a pure virtual method during the creation of the task before the child class is constructed.

Reimplemented in ApparatusFramework::SupervisedTask.

TaskId ApparatusFramework::Task::taskId (  )  const

Returns the task ID of the task object.

Returns:
TaskId task ID of the task.
const char* ApparatusFramework::Task::taskName (  )  const

Returns the name string of the task.

Returns:
const char* Pointer to the task name.
TaskPriority ApparatusFramework::Task::taskPriority (  )  const

queries Returns the priority of the task object.

Returns:
TaskPriority priority of the task.
virtual Msg* ApparatusFramework::Task::waitMsg (  )  [virtual]

Waits until the next message is received. This operation can provoke a task switch.

Returns:
Msg* pointer to the retrieved message.
Note:
The receiver and sender fields of the message field are checked and updated in this operation if the debug mode of the kernel is used.

Reimplemented in ApparatusFramework::SupervisedTask.

virtual Msg* ApparatusFramework::Task::waitMsgNoLog (  )  [virtual]

Waits until the next message is received. This operation can provoke a task switch. This function will never log the message.

Returns:
Msg* pointer to the retrieved message.
Note:
The receiver and sender fields of the message field are checked and updated in this operation if the debug mode of the kernel is used.
virtual Msg* ApparatusFramework::Task::waitMsgWithTimeout ( const Timeout  timeoutInMilliseconds  )  [virtual]

Waits until the next message is received or until the timeout delay is elapsed. This operation can provoke a task switch.

Parameters:
timeoutInMilliseconds delay to wait on the message before the task is again ready for execution.
Returns:
Pointer to the retrieved message.
Note:
The receiver and sender fields of the message field are checked and updated in this operation if the debug mode of the kernel is used.
Attention:
This method is not supported for Windows operating system.

Friends And Related Function Documentation

friend class Kernel [friend]

Makes friend with our Kernel class.

Definition at line 125 of file Task.h.


Member Data Documentation

An event handle to signal that the thread is running

Definition at line 343 of file Task.h.

© 2004-2010 bbv Software Services AG / Apparatus Services