Home > src > Bridge > task_management > create_task.m

create_task

PURPOSE ^

CREATE_TASK - return new task structure

SYNOPSIS ^

function newtask = create_task(varargin)

DESCRIPTION ^

 CREATE_TASK - return new task structure
 CREATE_TASK( OBJID, TASKPRIO )
 param: objid - a name (string) of the object the task refers to
 param: taskprio - the priority (as real or integer value) of the
        task
 param: time - the time step the task was created 

 AUTHOR  Ronnie Johansson
 CREATED 2004-04-21
 ALTERED 2004-05-12 - added field 'id' to task structure and
                      changed name for this function from 'initializetask()'
 ALTERED 2004-05-14 - added extra argument time
 ALTERED 2005-01-20 - changed prio field from numeric to struct
 ALTERED 2005-01-25 - minor correction

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function newtask = create_task(varargin)
0002 % CREATE_TASK - return new task structure
0003 % CREATE_TASK( OBJID, TASKPRIO )
0004 % param: objid - a name (string) of the object the task refers to
0005 % param: taskprio - the priority (as real or integer value) of the
0006 %        task
0007 % param: time - the time step the task was created
0008 %
0009 % AUTHOR  Ronnie Johansson
0010 % CREATED 2004-04-21
0011 % ALTERED 2004-05-12 - added field 'id' to task structure and
0012 %                      changed name for this function from 'initializetask()'
0013 % ALTERED 2004-05-14 - added extra argument time
0014 % ALTERED 2005-01-20 - changed prio field from numeric to struct
0015 % ALTERED 2005-01-25 - minor correction
0016 %
0017 
0018 switch nargin 
0019  case 0 % no arguments
0020   newtask.id = '';
0021   newtask.objid = '';
0022   newtask.prio = NaN;
0023   newtask.ptime = 0;
0024  case 1 % one argument, check that it is a string
0025   if (isa(varargin{1},'char'))
0026     newtask.id = ['Task.' varargin{1}];
0027     newtask.objid = varargin{1};
0028     newtask.prio = NaN;
0029     newtask.ptime = 0;
0030   else
0031     error('Wrong argument type; first argument should be a string!')
0032   end 
0033  case 2 % two arguments
0034   if (isa(varargin{1},'char'))
0035     newtask.id = ['Task.' varargin{1}];
0036     newtask.objid = varargin{1};
0037     newtask.prio = NaN;
0038     newtask.ptime = 0;
0039   else
0040     error('Wrong argument type; first argument should be a string!')
0041   end 
0042 %  if (isa(varargin{2},'numeric'))
0043 %    newtask.id = ['Task.' varargin{1}];
0044 %    newtask.objid = varargin{1};
0045 %    newtask.prio = varargin{2};
0046 %    newtask.ptime = 0;
0047 %  else
0048   if (isa(varargin{2},'struct'))
0049     newtask.id = ['Task.' varargin{1}];
0050     newtask.objid = varargin{1};
0051     newtask.prio = varargin{2};
0052     newtask.ptime = 0;
0053   else
0054     error('Wrong argument type; second argument should be a number!')
0055   end 
0056  case 3 % three arguments
0057     if isa(varargin{1},'char') && isa(varargin{2}, 'struct') && isa(varargin{3}, 'numeric')
0058      newtask.id = ['Task.' varargin{1}];
0059      newtask.objid = varargin{1};
0060      newtask.prio = varargin{2};
0061      newtask.ptime = varargin{3};
0062    else
0063      error('Wrong input type.');
0064    end
0065  otherwise
0066   error('Wrong input to function: initializetask!');
0067 end
0068 
0069 
0070 
0071 
0072 
0073 
0074

Generated on Wed 16-Mar-2005 09:17:47 by m2html © 2003