//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               = "_CanLib"
	Revision           = "1.10"
	GUID               = "{F7CB933C-3F92-464F-87A5-B5C984EBD780}"
	RealtimeTask       = "false"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "false"
	HighPriority       = "false"
	Automatic          = "false"
	UpdateMode         = "Prescan"
	IconPath           = ".\Class\_CanLib\port in out.ico"
	SharedCommandTable = "true"
	Objectsize         = "(314,120)"
	Comment            = "Can standard interface class">
	<Channels>
		<Server Name="CanBus" GUID="{BF716426-E966-4889-A126-00EC213ABFBC}" Visualized="true" Initialize="true" DefValue="1" WriteProtected="true" Retentive="false" Comment="which CanbusSystem [1,2,...](as initvalue)"/>
		<Server Name="Command" GUID="{F2E35EDC-EC38-404F-8628-971D9597C94C}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Connect a object client"/>
		<Client Name="To_Can" Required="false" Internal="false" Comment="is connected automatically"/>
	</Channels>
	<RevDoku>
		<Owner Company="Sigmatek GmbH &amp; Co KG"/>
		<Dokumentation Revision="1.10" Date="2013-01-07" Author="spimar" Company="Sigmatek GmbH &amp; Co KG" Description="Improvement: Changed default init value from server &quot;CanBus&quot; to 1."/>
		<Dokumentation Revision="1.8" Date="15.06.2009" Author="ObeChr" Company="Sigmatek" Description="Add Comments for methods"/>
	</RevDoku>
</Class>
*)
_CanLib : CLASS
  //Servers:
	Command 	: SvrChCmd_DINT;
	CanBus 	: SvrCh_DINT;
  //Clients:
	To_Can 	: CltChCmd__Can;
  //Variables:
  //Functions:
				//! <Function Comment="Checks whether the CAN interface is installed." Name="IsInstalled"/>
	FUNCTION VIRTUAL GLOBAL IsInstalled
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = CAN interface is installed, otherwise error code." Name="IsInstalled.retval"/>
		END_VAR;
				//! <Function Comment="This function returns the station number of an active CAN interface." Name="GetMyStation"/>
	FUNCTION VIRTUAL GLOBAL GetMyStation
		VAR_INPUT
			Station 	: ^USINT;			//! <Variable Comment="target address to where the station number should be written." Name="GetMyStation.Station"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="GetMyStation.retval"/>
		END_VAR;
				//! <Function Comment="This function sets the station number of a local CAN interface." Name="SetMyStation"/>
	FUNCTION VIRTUAL GLOBAL SetMyStation
		VAR_INPUT
			Station 	: USINT;			//! <Variable Comment="Station number." Name="SetMyStation.Station"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="SetMyStation.retval"/>
		END_VAR;
				//! <Function Comment="This function supplies the baud rate of a local CAN interface." Name="GetBaudrate"/>
	FUNCTION VIRTUAL GLOBAL GetBaudrate
		VAR_INPUT
			Baudrate 	: ^USINT;			//! <Variable Comment="target address to where the baud rate should be written. &#13;&#10;0: 615 kBit/s&#13;&#10;1: 500 kBit/s &#13;&#10;2: 250 kBit/s&#13;&#10;3: 125 kBit/s&#13;&#10;4: 100 kBit/s &#13;&#10;5: 50 kBit/s&#13;&#10;6: 20 kBit/s &#13;&#10;7: 1 MBit/s" Name="GetBaudrate.Baudrate"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="GetBaudrate.retval"/>
		END_VAR;
				//! <Function Comment="This function sets the baud rate of a local CAN interface." Name="SetBaudrate"/>
	FUNCTION VIRTUAL GLOBAL SetBaudrate
		VAR_INPUT
			Baudrate 	: USINT;			//! <Variable Comment="0: 615 kBit/s&#13;&#10;1: 500 kBit/s&#13;&#10;2: 250 kBit/s &#13;&#10;3: 125 kBit/s&#13;&#10;4: 100 kBit/s&#13;&#10;5: 50 kBit/s&#13;&#10;6: 20 kBit/s &#13;&#10;7: 1 MBit/s" Name="SetBaudrate.Baudrate"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="SetBaudrate.retval"/>
		END_VAR;
				//! <Function Comment="Sends an object to the CAN bus." Name="CanTxObj"/>
	FUNCTION VIRTUAL GLOBAL CanTxObj
		VAR_INPUT
			ObjNr 	: INT;			//! <Variable Comment="Object number (max. 2047)." Name="CanTxObj.ObjNr"/>
			length 	: USINT;			//! <Variable Comment="Data length (max. 8)." Name="CanTxObj.length"/>
			data 	: pVoid;			//! <Variable Comment="Data pointer." Name="CanTxObj.data"/>
		END_VAR
		VAR_OUTPUT
			retval 	: INT;			//! <Variable Comment="0: OK&#13;&#10;1: wrong CAN interface (1 of 2) &#13;&#10;2: Data length greater than 8 of ObjNr greater than 2047 &#13;&#10;4: Buffer full" Name="CanTxObj.retval"/>
		END_VAR;
				//! <Function Comment="Adds an object to the CAN bus. Use for RX objects only." Name="AddCanObj"/>
	FUNCTION VIRTUAL GLOBAL AddCanObj
		VAR_INPUT
			ObjNr 	: INT;			//! <Variable Comment="Object number (max. 2047)." Name="AddCanObj.ObjNr"/>
			Length 	: USINT;			//! <Variable Comment="Data length (max. 8) ." Name="AddCanObj.Length"/>
			Mode 	: USINT;			//! <Variable Comment="0: RX without Interrupt&#13;&#10;1: RX with Interrupt&#13;&#10;2: Tx (use function CanTxObject)" Name="AddCanObj.Mode"/>
			ActionPtr 	: pVoid;			//! <Variable Comment="Pointer to the function called by the Interrupt." Name="AddCanObj.ActionPtr"/>
			ThisPointer 	: pVoid;			//! <Variable Comment="Thispointer." Name="AddCanObj.ThisPointer"/>
		END_VAR
		VAR_OUTPUT
			retVal 	: DINT;			//! <Variable Comment="0-11: Nr. CAN-Objects used &#13;&#10;-2: Length &gt; 8&#13;&#10;-3: ObjNr &gt; 2047&#13;&#10;-4: Mode &gt; 2&#13;&#10;-5: No User CAN-Object available" Name="AddCanObj.retVal"/>
		END_VAR;
				//! <Function Comment="Login on new CAN object; it is used for the ComLink" Name="LoginIntoCanNew"/>
	FUNCTION VIRTUAL GLOBAL LoginIntoCanNew
		VAR_INPUT
			CanStation 	: USINT;			//! <Variable Comment="CAN-Station number." Name="LoginIntoCanNew.CanStation"/>
			TxObjNr 	: INT;			//! <Variable Comment="Object number." Name="LoginIntoCanNew.TxObjNr"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="LoginIntoCanNew.retval"/>
		END_VAR;
				//! <Function Comment="This function initializes the filter in order to hear more than one CAN object." Name="InitBasicCanObject"/>
	FUNCTION VIRTUAL GLOBAL InitBasicCanObject
		VAR_INPUT
			ObjNr 	: INT;			//! <Variable Comment="Object number (max. 2047)." Name="InitBasicCanObject.ObjNr"/>
			mask 	: INT;			//! <Variable Comment="Bit mask to select CAN-Ojects.&#13;&#10;16#7FF: no objects except ObjNr are filtered&#13;&#10;16#000: all objects are filtered" Name="InitBasicCanObject.mask"/>
			ActionPointer 	: pVoid;			//! <Variable Comment="Pointer to the function called by the interrupt." Name="InitBasicCanObject.ActionPointer"/>
			ThisPointer 	: pVoid;			//! <Variable Comment="Thispointer." Name="InitBasicCanObject.ThisPointer"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0: Function successful&#13;&#10;-1: Wrong CAN interface Number &#13;&#10;-2: Object number &gt; 2047" Name="InitBasicCanObject.retval"/>
		END_VAR;
				//! <Function Comment="Sets the Remote Transmit Request Flag of the receiving object.  this sends a request to the corresponding send object. after the object is received, the RTR flag is reset." Name="Set_RTR_Flag"/>
	FUNCTION VIRTUAL GLOBAL Set_RTR_Flag
		VAR_INPUT
			handle 	: DINT;			//! <Variable Comment="Number of the  Can-Object used (return value of the AddCanObj function)" Name="Set_RTR_Flag.handle"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = OK&#13;&#10;-1 = wrong handle" Name="Set_RTR_Flag.retval"/>
		END_VAR;
				//! <Function Comment="without a function" Name="CanTxObjHandle"/>
	FUNCTION VIRTUAL GLOBAL CanTxObjHandle
		VAR_INPUT
			handle 	: DINT;			//! <Variable Comment="Number of the  Can-Object used (return value of the AddCanObj function)" Name="CanTxObjHandle.handle"/>
			data 	: pVoid;			//! <Variable Comment="Data Pointer" Name="CanTxObjHandle.data"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment=" 0 = OK&#13;&#10;-1 = transmitter not ready&#13;&#10;-2 = no object available&#13;&#10;-3 = wrong handle&#13;&#10;-4 = class not initialized" Name="CanTxObjHandle.retval"/>
		END_VAR;
				//! <Function Comment="without function&#13;&#10;" Name="CanRxObjHandle"/>
	FUNCTION VIRTUAL GLOBAL CanRxObjHandle
		VAR_INPUT
			handle 	: DINT;			//! <Variable Comment="Number of the  Can-Object used (return value of the AddCanObj function)" Name="CanRxObjHandle.handle"/>
			pData 	: pVoid;			//! <Variable Comment="pointer to the memory space in which the data should be written" Name="CanRxObjHandle.pData"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = OK&#13;&#10;-1 = no current data available&#13;&#10;-2 = no receive object&#13;&#10;-3 = wrong handle" Name="CanRxObjHandle.retval"/>
		END_VAR;
				//! <Function Comment="without function" Name="RedefCanObj"/>
	FUNCTION VIRTUAL GLOBAL RedefCanObj
		VAR_INPUT
			handle 	: DINT;			//! <Variable Comment="Number of the CAN-Object used (return value of the AddCanObj function)" Name="RedefCanObj.handle"/>
			ObjNr 	: DINT;			//! <Variable Comment="Object number (max. 2047)" Name="RedefCanObj.ObjNr"/>
			Length 	: USINT;			//! <Variable Comment="Data length (max. 8)" Name="RedefCanObj.Length"/>
			Mode 	: USINT;			//! <Variable Comment="0: RX without interrupt&#13;&#10;1: RX with interrupt&#13;&#10;2: TX without interrupt" Name="RedefCanObj.Mode"/>
			ActionPtr 	: pVoid;			//! <Variable Comment="pointer to the memory space in which the data should be written" Name="RedefCanObj.ActionPtr"/>
			ThisPtr 	: pVoid;			//! <Variable Comment="Thispointer" Name="RedefCanObj.ThisPtr"/>
			mask 	: INT := 0;			//! <Variable Comment="Bit mask to select CAN-Ojects.&#13;&#10;16#7FF: no objects except ObjNr are filtered&#13;&#10;16#000: all objects are filtered" Name="RedefCanObj.mask"/>
		END_VAR
		VAR_OUTPUT
			retVal 	: DINT;			//! <Variable Comment="0-31: Number of the Can-Object used&#13;&#10;-1: No valid Handle&#13;&#10;-2: Length &gt; 8&#13;&#10;-3: ObjNr &gt; 2047&#13;&#10;-4: Mode &gt; 2&#13;&#10;-5: Can Object is not defined" Name="RedefCanObj.retVal"/>
		END_VAR;
				//! <Function Comment="without function" Name="ChkObjExists"/>
	FUNCTION VIRTUAL GLOBAL ChkObjExists
		VAR_INPUT
			ObjNr 	: INT;			//! <Variable Comment="Objectnumber (max. 2047)" Name="ChkObjExists.ObjNr"/>
			Mode 	: USINT;			//! <Variable Comment="0: RX without Interrupt&#13;&#10;1: RX with Interrupt&#13;&#10;2: TX without Interrupt" Name="ChkObjExists.Mode"/>
		END_VAR
		VAR_OUTPUT
			handle 	: DINT;			//! <Variable Comment="0-31: Nr. CAN-Objects used &#13;&#10;-1: no object found" Name="ChkObjExists.handle"/>
		END_VAR;
				//! <Function Comment="deletes a can object" Name="DelCanObj"/>
	FUNCTION VIRTUAL GLOBAL DelCanObj
		VAR_INPUT
			Handle 	: DINT;			//! <Variable Comment="the handle of the object which should be deleted" Name="DelCanObj.Handle"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="DelCanObj.retval"/>
		END_VAR;
				//! <Function Comment="deletes the basic can object" Name="DelBasicCanObj"/>
	FUNCTION VIRTUAL GLOBAL DelBasicCanObj
		VAR_INPUT
			Handle 	: DINT := -1;			//! <Variable Comment="This parameter is only used for the CCA021 module" Name="DelBasicCanObj.Handle"/>
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;			//! <Variable Comment="0 = Function successful, otherwise error code." Name="DelBasicCanObj.retval"/>
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

#pragma usingLtd _Can


//}}LSL_DECLARATION


FUNCTION GLOBAL TAB _CanLib::@CT_
0$UINT,
2#0100000000000000$UINT, //TY__CANLIB
1$UINT, 10$UINT, (SIZEOF(::_CanLib))$UINT, 
2$UINT, 1$UINT, 0$UINT, 
TO_UDINT(529317953), "_CanLib", //Class
TO_UDINT(0), 0, 0$UINT, 0$UINT, //Baseclass
//Servers:
(::_CanLib.Command.pMeth)$UINT, _CH_CMD$UINT, 2#0000000000000000$UINT, TO_UDINT(2978944206), "Command", 
(::_CanLib.CanBus.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(1625716583), "CanBus", 
//Clients:
(::_CanLib.To_Can.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000000$UINT, TO_UDINT(1707743844), "To_Can", TO_UDINT(3102794146), "_Can", 0$UINT, 5$UINT, 
END_FUNCTION


#define USER_CNT__CanLib 16

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

FUNCTION _CanLib::@STD
	VAR_OUTPUT
		ret_code	: CONFSTATES;
	END_VAR
	VAR
		vmt	: _LSL_STD_VMETH;
	END_VAR

	//Command Methods
	InitCmdTable (nCmd := nSTDCMD + USER_CNT__CanLib, pCmd := #vmt.CmdTable);
#pragma warning (disable : 74)
	vmt.UserFcts[0]		:= #IsInstalled();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[1]		:= #GetMyStation();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[2]		:= #SetMyStation();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[3]		:= #GetBaudrate();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[4]		:= #SetBaudrate();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[5]		:= #CanTxObj();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[6]		:= #AddCanObj();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[7]		:= #LoginIntoCanNew();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[8]		:= #InitBasicCanObject();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[9]		:= #Set_RTR_Flag();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[10]		:= #CanTxObjHandle();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[11]		:= #CanRxObjHandle();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[12]		:= #RedefCanObj();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[13]		:= #ChkObjExists();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[14]		:= #DelCanObj();

#pragma warning (default : 74)
#pragma warning (disable : 74)
	vmt.UserFcts[15]		:= #DelBasicCanObj();

#pragma warning (default : 74)
	Command.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF Command.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;

END_FUNCTION

//{{LSL_IMPLEMENTATION

(*************************************************************************************
*
*	Standard CanBus interface class for systemclass
*	Created : BS / KW47 / 2003
*	Changes :
*
*
*   FOR NEWER CHANGES SEE REVISION DOCUMENTATION IN CLASS PROPERTIES
*
*
*   1.6 => 1.7  / 05.01.2009  / Mark: //#PH001
*     add the methods RedefCanObj, DelCanObj and DelBasicCanObj
*		1.5 => 1.6	/	18.07.2007	/	Mark:	//#HUDAV00
*			add TxRmtFrame function of _CAN in SetRTRFlag HUBDAV00
*		1.4 => 1.5	/	19.03.2007	/	Mark:	//#SR003
*			- [DB 533]: insert new function to find existing object
*		1.3 => 1.4	/ 	15.09.2005	/	Mark:	//#SR002
*			Prototype for new function
*		1.2	=>	1.3	/	18.07.2005	/	Mark:	//#SR001
*			Prototypes for new functions
*		1.1 => 1.2	/	08.02.2005	/	Mark:	//#SR000
*			New Prototype for RTR Mode (only for CCA021)
*		1.0 => 1.1 
*			CanBus Client to CanBus Server (to ensure that the uses writes a initvalue)
*
*************************************************************************************)

FUNCTION VIRTUAL GLOBAL _CanLib::IsInstalled
VAR_OUTPUT
	retval		: DINT;
END_VAR
	
	retval := To_Can.IsInstalled(CanNR:=CanBus$USINT);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::GetMyStation
VAR_INPUT
	Station		: ^USINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := To_Can.GetMyStation(CanNR:=CanBus$USINT, Station);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::SetMyStation
VAR_INPUT
	Station		: USINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := To_Can.SetMyStation(CanNR:=CanBus$USINT, Station);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::GetBaudrate
VAR_INPUT
	Baudrate		: ^USINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := To_Can.GetBaudrate(CanNR:=CanBus$USINT, Baudrate);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::SetBaudrate
VAR_INPUT
	Baudrate		: USINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := To_Can.SetBaudrate(CanNR:=CanBus$USINT, Baudrate);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::CanTxObj
VAR_INPUT
	ObjNr		: INT;
	length		: USINT;
	data		: pVoid;
END_VAR
VAR_OUTPUT
	retval		: INT;
END_VAR

	retval := To_Can.CanTxObj(CanNr:=CanBus$USINT, ObjNr, length, data);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::AddCanObj
VAR_INPUT
	ObjNr		: INT;
	Length		: USINT;
	Mode		: USINT;
	ActionPtr		: pVoid;
	ThisPointer		: pVoid;
END_VAR
VAR_OUTPUT
	retVal		: DINT;
END_VAR

	retval := To_Can.AddCanObj(CanNr:=CanBus$USINT, ObjNr, length, mode, actionptr, thispointer);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::LoginIntoCanNew
VAR_INPUT
	CanStation		: USINT;
	TxObjNr		: INT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := To_Can.LoginIntoCanNew(CanNr:=CanBus$USINT, CanStation, TxObjNr);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::InitBasicCanObject
VAR_INPUT
	ObjNr		: INT;
	mask		: INT;
	ActionPointer		: pVoid;
	ThisPointer		: pVoid;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := To_Can.InitBasicCanObject(CanNr:=CanBus$USINT, ObjNr, mask, actionpointer, thispointer);

END_FUNCTION

#pragma warning (disable:73) 
FUNCTION VIRTUAL GLOBAL _CanLib::Set_RTR_Flag
VAR_INPUT
	handle		: DINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR
  
  //retval := 0; #HUBDAV00
  retval := To_Can.TxRmtFrame(CanNr:=CanBus$USINT, Handle:=handle);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::CanTxObjHandle
VAR_INPUT
	handle		: DINT;
	data		: pvoid;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := 0;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::CanRxObjHandle
VAR_INPUT
	handle		: DINT;
	pData		: pVoid;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR

	retval := 0;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::RedefCanObj
VAR_INPUT
	handle		: DINT;
	ObjNr		: DINT;
	Length		: USINT;
	Mode		: USINT;
	ActionPtr	: pvoid;
	ThisPtr		: pvoid;
	mask		: INT;
END_VAR
VAR_OUTPUT
	retVal		: DINT;
END_VAR

  // first delete the can object
  To_Can.DelCanObj(CanNr:=CanBus$USINT, Handle:=handle);
  
  //now create the new one
  retVal := To_Can.AddCanObj( CanNr:=CanBus$USINT, 
                              ObjNr:=ObjNr$INT, 
                              length:=Length, 
                              mode:=Mode, 
                              actionptr:=ActionPtr, 
                              thispointer:=ThisPtr);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::ChkObjExists
VAR_INPUT
	ObjNr		: INT;
	Mode		: USINT;
END_VAR
VAR_OUTPUT
	handle		: DINT;
END_VAR
	handle := -1;
END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::DelCanObj
	VAR_INPUT
		Handle 	: DINT;
	END_VAR
	VAR_OUTPUT
		retval 	: DINT;
	END_VAR

  retval  := To_Can.DelCanObj(CanNr:=CanBus$USINT, Handle:=Handle);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL _CanLib::DelBasicCanObj
	VAR_INPUT
		Handle 	: DINT;
	END_VAR
	VAR_OUTPUT
		retval 	: DINT;
	END_VAR

  retval  := To_Can.DelBasicCanObj(CanNr:=CanBus$USINT);

END_FUNCTION
#pragma warning (default:73)