//This file was generated by the LASAL2 CodeGenerator  -- 
//Please, do not edit this file (it might be overwritten by the next generator run)
//{{LSL_DECLARATION

(*!
<Class
	Name               = "_TaskObjectControl"
	Revision           = "1.1"
	GUID               = "{BC147441-61AA-11D6-8832-0048545E88BC}"
	RealtimeTask       = "false"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "true"
	HighPriority       = "false"
	Automatic          = "false"
	UpdateMode         = "Prescan"
	SharedCommandTable = "true"
	Objectsize         = "(284,120)"
	Comment            = "provides an interface to investigate/manipulate objects and their tasks">
	<Channels>
		<Server Name="Server0" GUID="{BC147442-61AA-11D6-8832-0048545E88BC}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false"/>
	</Channels>
	<Dependencies>
		<Files>
			<File Path=".\Source\code\OsiBaseNew.st"/>
			<File Path=".\Source\code\OsiBaseNew.h" Include="false"/>
			<File Path=".\SystemTypes.h" Include="false"/>
		</Files>
	</Dependencies>
</Class>
*)
_TaskObjectControl : CLASS
	TYPE
	  OS_TASK : STRUCT  //! <Type Comment="interface list" Name="OS_TASK"/>
	    AddCyclicFunction : pVoid;
	    AddCyclicObject : pVoid;
	    RemoveCyclicTask : pVoid;
	    SignalCyclicTask : pVoid;
	    AddRTFunction : pVoid;
	    AddRTObject : pVoid;
	    RemoveRTTask : pVoid;
	    SignalRTTask : pVoid;
	    StartMeasCyc : pVoid;
	    StopMeasCyc : pVoid;
	    StartMeasRT : pVoid;
	    StopMeasRT : pVoid;
	    AddFRGFunction : pVoid;
	    AddFRGObject : pVoid;
	    SuspendFRGTask : pVoid;
	    ResumeFRGTask : pVoid;
	    InitTaskModul : pVoid;
	    GetTaskList : pVoid;
	    AddHPUserObject : pVoid;
	    Dummy2 : pVoid;
	    Dummy3 : pVoid;
	    Dummy4 : pVoid;
	    GetKernelCyclic : pVoid;
	    SuspendKernelCyclic : pVoid;
	    SetObjectState : pVoid;
	    ResetTaskState : pVoid;
	    GetObjectInfo : pVoid;
	    BackupObject : pVoid;
	    RestoreObject : pVoid;
	  END_STRUCT;
	END_TYPE
  //Servers:
	Server0 	: SvrChCmd_DINT;
  //Clients:
  //Variables:
  //Functions:
	
	FUNCTION _TaskObjectControl
		VAR_OUTPUT
			ret_code 	: ConfStates;
		END_VAR;
				//! <Function Comment="This function reads statistic information about a Lasal Object, situated in RT-, CT-, or BG-Work." Name="GetObjectInfo"/>
	FUNCTION __CDECL VIRTUAL GLOBAL GetObjectInfo
		VAR_INPUT
			thispointer 	: pVoid;			//! <Variable Comment="Parameter Thispointer is the thispointer of the object, from which to gather information." Name="GetObjectInfo.thispointer"/>
			tasktype 	: USINT;			//! <Variable Comment="Parameter TaskType specifies in which task list the object should be searched. A combination of task types is not possible, for objects that run i.e. both RT- &amp; CT-Work, the function has to be called for each task type." Name="GetObjectInfo.tasktype"/>
			objinfo 	: ^LSLOBJ_INFO;			//! <Variable Comment="Parameter ObjInfo points to a LSLOBJ_INFO structure." Name="GetObjectInfo.objinfo"/>
		END_VAR
		VAR_OUTPUT
			retval (EAX) 	: DINT;			//! <Variable Comment="If the function succeeds, the object is found, ZERO is returned and Parameter ObjInfo is filled. &#10;If the function fails, a negative error-code is returned: &#10;  -1   no application &#10;  -5   object not found &#10;  -3   wrong task type" Name="GetObjectInfo.retval"/>
		END_VAR;
	
	FUNCTION __CDECL VIRTUAL GLOBAL ChangeObjectState
		VAR_INPUT
			thispointer 	: pVoid;			//! <Variable Comment="Parameter Thispointer is the thispointer of the object that&apos;s to be changed." Name="ChangeObjectState.thispointer"/>
			actioncmd 	: USINT;			//! <Variable Comment="Parameter ActionCmd specifies the action that is done for this object. &#10;&#10;Possible actions are: &#10;* ACTION_IDLE(0):   performs no action, but return value still indicates whether object exists or not &#10;* ACTION_NEWTIME(1):   set new period time for object &#10;* ACTION_SUSPEND(2):   erase the objects ALWAYS or TIMED flags &#10;* ACTION_CONTNUE(3):   reset the objects TIMED flag &#10;* ACTION_SIGNAL(4):   call object ONCE &#10;* ACTION_ADD(5):   add object to update list, task type indicates the list type (RT, CT..) &#10;* ACTION_ALWAYS(6):   set object to run with ALWAYS flag" Name="ChangeObjectState.actioncmd"/>
			tasktype 	: USINT;			//! <Variable Comment="Parameter TaskType specifies in which list the object can be found. &#10;&#10;Defines for TaskTypes of Objects: &#10; #define OBJ_CT 1  // cyclic &#10; #define OBJ_RT 2  // realtime &#10; #define OBJ_TT 3  // foreground &#10; #define OBJ_BG 4  // background &#10; #define OBJ_HP 5  // high-priority user" Name="ChangeObjectState.tasktype"/>
			debugobj 	: USINT;			//! <Variable Comment="Parameter DebugObj switches the debug-mode ON or OFF. If DebugObj is set to a NONZERO value, the mode is ENABLED, otherwise it is DISABLED." Name="ChangeObjectState.debugobj"/>
			newtime 	: UDINT;			//! <Variable Comment="Parameter NewTime is only recognized with ACTION_NEWTIME, and then it specifies the objects new period." Name="ChangeObjectState.newtime"/>
		END_VAR
		VAR_OUTPUT
			retval (EAX) 	: DINT;			//! <Variable Comment="If the function succeeds, it returns ZERO and the action was successful. &#10;&#10;If the function fails, a negative error-code is returned. &#10;Return Values: &#10;  -1  wrong task type / internal error &#10;  -2  no application &#10;  -4  could not add object to list &#10;  -5  object not found" Name="ChangeObjectState.retval"/>
		END_VAR;
				//! <Function Comment="This function deletes an object from the update list and puts it into a suspend respectively backup list. When an object is in an update list, it is executed and when an object is in a suspend/backup list, its execution is suspended." Name="BackUpObject"/>
	FUNCTION __CDECL VIRTUAL GLOBAL BackUpObject
		VAR_INPUT
			thispointer 	: pVoid;			//! <Variable Comment="Parameter Thispointer is the thispointer of the object that&apos;s to be backed up." Name="BackUpObject.thispointer"/>
			tasktype 	: USINT;			//! <Variable Comment="Parameter TaskType specifies in which list the object can be found. &#10;&#10;Defines for TaskTypes of Objects: &#10; #define OBJ_CT 1  // cyclic &#10; #define OBJ_RT 2  // realtime &#10; #define OBJ_TT 3  // foreground &#10; #define OBJ_BG 4  // background &#10; #define OBJ_HP 5  // high-priority user" Name="BackUpObject.tasktype"/>
		END_VAR
		VAR_OUTPUT
			retval (EAX) 	: DINT;			//! <Variable Comment="If the function succeeds, it returns ZERO and the object is in the specified backup list. The object can be restored using the function &apos;RestoreObject&apos;. &#10;&#10;If the function fails, a negative error code is returned. &#10;Return Values: &#10;  -1   wrong task type &#10;  -2   wrong object type &#10;  -5   object not found" Name="BackUpObject.retval"/>
		END_VAR;
				//! <Function Comment="This function restores an object from the backup list and puts it back into the update list." Name="RestoreObject"/>
	FUNCTION __CDECL VIRTUAL GLOBAL RestoreObject
		VAR_INPUT
			thispointer 	: pVoid;			//! <Variable Comment="Parameter Thispointer is the thispointer of the object that&apos;s to be restored." Name="RestoreObject.thispointer"/>
			tasktype 	: USINT;			//! <Variable Comment="Parameter TaskType specifies in which (backup) list the object can be found. &#10;&#10;Defines for TaskTypes of Objects: &#10; #define OBJ_CT 1  // cyclic &#10; #define OBJ_RT 2  // realtime &#10; #define OBJ_TT 3  // foreground &#10; #define OBJ_BG 4  // background &#10; #define OBJ_HP 5  // high-priority user" Name="RestoreObject.tasktype"/>
		END_VAR
		VAR_OUTPUT
			retval (EAX) 	: DINT;			//! <Variable Comment="If the function succeeds, it returns ZERO and the object is restored. &#10;&#10;If it fails, a negative error code is returned. &#10;Return Values: &#10;  -1   wrong task type &#10;  -2   wrong object type &#10;  -3   list inserting failed &#10;  -5   object not found" Name="RestoreObject.retval"/>
		END_VAR;
				//! <Function Comment="This function installs a cyclic user-function." Name="AddCyclicFunction"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddCyclicFunction
		VAR_INPUT
			pFunction 	: pVoid;			//! <Variable Comment="Parameter pFunction points to the function to install." Name="AddCyclicFunction.pFunction"/>
			pParam 	: pVoid;			//! <Variable Comment="Parameter pParam points to a user-defined parameter that is passed to the function on its call." Name="AddCyclicFunction.pParam"/>
			udMode 	: UDINT;			//! <Variable Comment="Parameter udMode specifies the cyclic functions task mode (TIMED, ALWAYS..)." Name="AddCyclicFunction.udMode"/>
			udTime 	: UDINT;			//! <Variable Comment="Parameter ud-Time specifies the cyclic functions period (in ms)." Name="AddCyclicFunction.udTime"/>
			udPhase 	: UDINT;			//! <Variable Comment="Parameter udPhase specifies the cyclic functions phase (SCAN, POSTSCAN..)." Name="AddCyclicFunction.udPhase"/>
		END_VAR
		VAR_OUTPUT
			objhandle (EAX) 	: pVoid;			//! <Variable Comment="If the function succeeds, it returns a handle of the installed cyclic-function (which is merely the malloc pointer of the new list-object), and the object will be updated as demanded. If it fails, it returns NIL." Name="AddCyclicFunction.objhandle"/>
		END_VAR;
				//! <Function Comment="This function installs a cyclic object." Name="AddCyclicObject"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddCyclicObject
		VAR_INPUT
			pObj 	: pVoid;			//! <Variable Comment="Parameter pObj points to the object to install." Name="AddCyclicObject.pObj"/>
			udMode 	: UDINT;			//! <Variable Comment="Parameter udMode specifies the objects task mode (TIMED, ALWAYS..)." Name="AddCyclicObject.udMode"/>
			udTime 	: UDINT;			//! <Variable Comment="Parameter udTime specifies the objects period (in ms)." Name="AddCyclicObject.udTime"/>
			udPhase 	: UDINT;			//! <Variable Comment="Parameter udPhase specifies the objects phase (SCAN, POSTSCAN..)." Name="AddCyclicObject.udPhase"/>
		END_VAR
		VAR_OUTPUT
			objhandle (EAX) 	: pVoid;			//! <Variable Comment="If the function succeeds, it returns a handle of the installed object (which is merely the malloc pointer of the new list-object), and the object will be updated as demanded. If it fails, it returns NIL." Name="AddCyclicObject.objhandle"/>
		END_VAR;
				//! <Function Comment="This function installs a realtime user-function." Name="AddRealTimeFunction"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddRealTimeFunction
		VAR_INPUT
			pFunction 	: pVoid;			//! <Variable Comment="Parameter pFunction points to the function to install." Name="AddRealTimeFunction.pFunction"/>
			pParam 	: pVoid;			//! <Variable Comment="Parameter pParam points to a user-defined parameter that is passed to the function on its call." Name="AddRealTimeFunction.pParam"/>
			udMode 	: UDINT;			//! <Variable Comment="Parameter udMode specifies the realtime functions task mode (TIMED, ALWAYS..)." Name="AddRealTimeFunction.udMode"/>
			udTime 	: UDINT;			//! <Variable Comment="Parameter udTime specifies the realtime functions period (in ms)." Name="AddRealTimeFunction.udTime"/>
			udPhase 	: UDINT;			//! <Variable Comment="Parameter udPhase specifies the realtime functions phase (SCAN, POSTSCAN..)." Name="AddRealTimeFunction.udPhase"/>
		END_VAR
		VAR_OUTPUT
			objhandle (EAX) 	: pVoid;			//! <Variable Comment="If the function succeeds, it returns a handle of the installed realtime-function (which is merely the malloc pointer of the new list-object), and the function will be updated as demanded. If it fails, it returns NIL." Name="AddRealTimeFunction.objhandle"/>
		END_VAR;
				//! <Function Comment="This function installs a realtime object." Name="AddRealTimeObject"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddRealTimeObject
		VAR_INPUT
			pObj 	: pVoid;			//! <Variable Comment="Parameter pObj points to the realtime to install." Name="AddRealTimeObject.pObj"/>
			udMode 	: UDINT;			//! <Variable Comment="Parameter udMode specifies the objects task mode (TIMED, ALWAYS..)." Name="AddRealTimeObject.udMode"/>
			udTime 	: UDINT;			//! <Variable Comment="Parameter udTime specifies the objects period (in ms)." Name="AddRealTimeObject.udTime"/>
			udPhase 	: UDINT;			//! <Variable Comment="Parameter udPhase specifies the objects phase (SCAN, POSTSCAN..)." Name="AddRealTimeObject.udPhase"/>
		END_VAR
		VAR_OUTPUT
			objhandle (EAX) 	: pVoid;			//! <Variable Comment="If the function succeeds, it returns a handle of the installed object (which is merely the malloc pointer of the new list-object) and the object is installed. If it fails, it returns NIL." Name="AddRealTimeObject.objhandle"/>
		END_VAR;
				//! <Function Comment="This function installs a user function as a FOREGROUND task." Name="AddForegroundFunction"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddForegroundFunction
		VAR_INPUT
			pFunction 	: pVoid;			//! <Variable Comment="Parameter pFunction points to the thread-function itself." Name="AddForegroundFunction.pFunction"/>
			pParam 	: pVoid;			//! <Variable Comment="Parameter pParam points to a user-defined parameter that is passed to the foreground function on its call." Name="AddForegroundFunction.pParam"/>
			stack 	: UDINT;			//! <Variable Comment="Parameter Stack is the amount of stack the OS-Task (!) has. A value of 8kb is recommended." Name="AddForegroundFunction.stack"/>
		END_VAR
		VAR_OUTPUT
			objhandle (EAX) 	: pVoid;			//! <Variable Comment="If the function succeeds, it returns a handle of the installed foreground function (which is merely the malloc pointer of the new list-object), and the function will be updated as demanded. If it fails, it returns NIL." Name="AddForegroundFunction.objhandle"/>
		END_VAR;
				//! <Function Comment="This function installs an object CyWork() as an OS-Task." Name="AddForegroundObject"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddForegroundObject
		VAR_INPUT
			pObj 	: pVoid;			//! <Variable Comment="Parameter pObj points to the object to install (thispointer)." Name="AddForegroundObject.pObj"/>
			stack 	: UDINT;			//! <Variable Comment="Parameter Stack is the amount of stack the OS-Task (!) has. A value of 8kb is recommended." Name="AddForegroundObject.stack"/>
		END_VAR
		VAR_OUTPUT
			objhandle (EAX) 	: pVoid;			//! <Variable Comment="If the function succeeds, it returns a handle of the installed object (which is merely the malloc pointer of the new list-object), and the object will be updated as demanded. If it fails, it returns NIL." Name="AddForegroundObject.objhandle"/>
		END_VAR;
				//! <Function Comment="This function installs an object method as a High Priority User Task." Name="AddHPUserObject"/>
	FUNCTION __CDECL VIRTUAL GLOBAL AddHPUserObject
		VAR_INPUT
			pMeth 	: pVoid;			//! <Variable Comment="Parameter pMeth points to the object method to call." Name="AddHPUserObject.pMeth"/>
			pThis 	: pVoid;			//! <Variable Comment="Parameter pThis is the objects thispointer." Name="AddHPUserObject.pThis"/>
			nSlot 	: DINT;			//! <Variable Comment="Parameter nSlot specifies the slot number of the task to install." Name="AddHPUserObject.nSlot"/>
		END_VAR
		VAR_OUTPUT
			retval (EAX) 	: DINT;			//! <Variable Comment="If the function succeeds, it returns TRUE and the object is installed. If it fails, it returns FALSE indicating an error or that this task-slot is already installed." Name="AddHPUserObject.retval"/>
		END_VAR;
				//! <Function Comment="This function resets the state of a task list to their original values." Name="ResetTaskState"/>
	FUNCTION __CDECL VIRTUAL GLOBAL ResetTaskState
		VAR_INPUT
			tasktype 	: USINT;			//! <Variable Comment="Parameter TaskType specifies, which task list is to be resetted. &#10;&#10;Defines for TaskTypes of Objects:  &#10; #define OBJ_CT 1  // cyclic &#10; #define OBJ_RT 2  // realtime &#10; #define OBJ_TT 3  // foreground &#10; #define OBJ_BG 4  // background &#10; #define OBJ_HP 5  // high-priority user &#10;&#10;Setting TaskType to a any non-defined value resets ALL task lists." Name="ResetTaskState.tasktype"/>
		END_VAR
		VAR_OUTPUT
			retval (EAX) 	: DINT;			//! <Variable Comment="If the function succeeds, it returns ZERO, if it fails, -1 is returned, indicating that no valid application was found." Name="ResetTaskState.retval"/>
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

//}}LSL_DECLARATION


FUNCTION GLOBAL TAB _TaskObjectControl::@CT_
0$UINT,
2#0100000000001000$UINT, //TY__TASKOBJECTCONTROL
1$UINT, 1$UINT, (SIZEOF(::_TaskObjectControl))$UINT, 
1$UINT, 0$UINT, 0$UINT, 
TO_UDINT(1584830088), "_TaskObjectControl", //Class
TO_UDINT(0), 0, 0$UINT, 0$UINT, //Baseclass
//Servers:
(::_TaskObjectControl.Server0.pMeth)$UINT, _CH_CMD$UINT, 2#0000000000000000$UINT, TO_UDINT(2759080719), "Server0", 
//Clients:
END_FUNCTION


#define USER_CNT__TaskObjectControl 12

TYPE
	_LSL_STD_VMETH	: STRUCT
			CmdTable	: CMDMETH;
			UserFcts	: ARRAY[0..USER_CNT__TaskObjectControl] OF ^Void;
	END_STRUCT;
END_TYPE



//{{LSL_IMPLEMENTATION


//*********************Inserted from <.\OS Interface\code\ObjectControl_01_00.st>*********************



 



#include <Rtos_interfaces.h> // we need this for the SysCIL functions
#include "..\..\Source\code\OsiBaseNew.h"


FUNCTION  _TaskObjectControl::_TaskObjectControl
VAR_OUTPUT
	ret_code		: CONFSTATES;
END_VAR
VAR
    pTask   : ^OS_TASK;
	aMeths	: ARRAY[0..USER_CNT__TaskObjectControl] OF ^void;
	retv    : SYS_ERROR;
END_VAR;

	retv := OS_CILGet("LASALTASK", #pTask$void);

	if retv <> SYS_ERR_NONE then

		TRACE("ERROR: OBJECT-CONTROL Interface not available with this version/platform!");
		ret_code	:= C_UNKNOWN_CONSTR;
    else
		
		aMeths [0]	:= pTask^.GetObjectInfo;
		aMeths [1]	:= pTask^.SetObjectState;

		aMeths [2]  := pTask^.BackupObject;
		aMeths [3]  := pTask^.RestoreObject;

		aMeths [4]  := pTask^.AddCyclicFunction;
		aMeths [5]  := pTask^.AddCyclicObject;
		//aMeths [2]  := pTask^.RemoveCyclicTask
		//aMeths [2]  := pTask^.SignalCyclicTask
		aMeths [6]  := pTask^.AddRTFunction;
		aMeths [7]  := pTask^.AddRTObject;
		//aMeths [2]  := pTask^.RemoveRTTask
		//aMeths [2]  := pTask^.SignalRTTask
		//aMeths [2]  := pTask^.StartMeasCyc
		//aMeths [2]  := pTask^.StopMeasCyc
		//aMeths [2]  := pTask^.StartMeasRT
		//aMeths [2]  := pTask^.StopMeasRT
		aMeths [8]  := pTask^.AddFRGFunction;
		aMeths [9]  := pTask^.AddFRGObject;
		//aMeths [2]  := pTask^.SuspendFRGTask
		//aMeths [2]  := pTask^.ResumeFRGTask
		//aMeths [2]  := pTask^.InitTaskModul
		//aMeths [2]  := pTask^.GetTaskList
		aMeths [10]  := pTask^.AddHPUserObject;
		//aMeths [2]  := pTask^.Dummy2
		//aMeths [2]  := pTask^.Dummy3
		//aMeths [2]  := pTask^.Dummy4
		//aMeths [2]  := pTask^.GetKernelCyclic
		//aMeths [2]  := pTask^.SuspendKernelCyclic
		aMeths [11]  := pTask^.ResetTaskState;

		ret_code	:= InitOsiM_new(#aMeths[0]$void, USER_CNT__TaskObjectControl);
	end_if;

END_FUNCTION //  ObjectControl::ObjectControl

