//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               = "Hub_Base_Root"
	Revision           = "2.11"
	GUID               = "{64ED1FC4-EA8C-4B30-98C0-5BA271C4FFE8}"
	RealtimeTask       = "false"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "false"
	HighPriority       = "false"
	Automatic          = "false"
	UpdateMode         = "Prescan"
	IconPath           = ".\Class\Tool.ico"
	SharedCommandTable = "true"
	Objectsize         = "(284,120)">
	<Channels>
		<Server Name="Control">
		</Server>
		<Client Name="VaranConnect" Required="true" Internal="false"/>
	</Channels>
	<RevDoku>
		<Owner Company="Sigmatek" Author="renste"/>
		<Dokumentation Revision="2.11" Date="23.01.2018" Author="RamAnd" Company="Sigmatek" Description="Log messages have been standardized for easier maintenance, easier use in any class and to allow spam filtering. Code for the logging functions is now only located in HwControl."/>
		<Dokumentation Revision="2.10" Date="18.07.2013" Author="RamAnd" Company="Sigmatek" Description="Added NewInst forwarding"/>
		<Dokumentation Revision="2.6" Date="27.06.2011" Author="RamAnd" Company="Sigmatek" Description="Support of sorting VARAN commands by priority added (needed for communication between safety-modules)."/>
		<Dokumentation Revision="2.5" Date="12.04.2011" Author="BleErn" Company="Sigmatek" Description="Fixed call of method &quot;GetNsTimeBPLLTicks()&quot;"/>
		<Dokumentation Revision="2.4" Date="14.10.2010" Author="RamAnd" Company="Sigmatek" Description="Added method AddMovDO for the move command in the VM."/>
		<Dokumentation Revision="2.3" Date="19.07.2010" Author="RamAnd" Company="Sigmatek" Description="Added new method GetNsTimeBPLLTicks for easier internal time measurements"/>
		<Dokumentation Revision="2.2" Date="31.05.2010" Author="BleErn" Company="Sigmatek" Description="Added support for RtPostScan"/>
		<Dokumentation Revision="2.1" Date="02.09.2009" Author="RamAnd" Company="Sigmatek" Description="Added functions for safety and hardware tree"/>
		<Dokumentation Revision="2.0" Date="05.08.2009" Author="ObeChr" Company="Sigmatek" Description="Added Method: AllowRequiredError"/>
		<Dokumentation Revision="1.9" Date="16.07.2009" Author="ObeChr" Company="Sigmatek" Description="Added method: UseVaranRtPostScan"/>
		<Dokumentation Revision="1.8" Date="16.04.2009" Author="RamAnd" Company="Sigmatek" Description="Added 2 new methods: GetDocumentation and GetSerialNo"/>
	</RevDoku>
	<Network Name="Hub_Base_Root">
		<!-- List of Components in this network -->
		<Components>
			<Object
				Name       = "_base"
				GUID       = "{9AB540D8-20C2-4DAA-AEC9-3A69220696B3}"
				Class      = "Hub_Base"
				Position   = "(270,120)"
				Visualized = "true">
				<Channels>
					<Server Name="Control"/>
					<Client Name="Splitter_Place" Value="0"/>
					<Client Name="VaranIn"/>
				</Channels>
			</Object>
		</Components>
		<Comments>
		</Comments>
		<!-- List of Connections in this network -->
		<Connections>
			<Connection Source="this.Control" Destination="_base.Control" Vertices="(868,210),(696,210),"/>
			<Connection Source="_base.Splitter_Place" Destination="this.Splitter_Place" Vertices="(270,270),(38,210),"/>
		</Connections>
		<!-- Headerfiles -->
		<Options>
		</Options>
	</Network>
</Class>
*)
#pragma using Hub_Base

Hub_Base_Root : CLASS
: Hub_Base
  //Servers:
  //Clients:
	VaranConnect 	: CltChCmd_VaranManager_Base;
  //Variables:
  //Functions:
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to add a realtime or cyclic task to VaranMaster&#13;&#10;=================================================================================================&#13;&#10;" Name="AddVaranTask"/>
	FUNCTION VIRTUAL GLOBAL AddVaranTask
		VAR_INPUT
			ud_dol_type 	: UDINT;			//! <Variable Comment=" Type of DOL (see lsl_st_varan.h)" Name="AddVaranTask.ud_dol_type"/>
			p_this 	: ^void;			//! <Variable Comment=" Thispointer of connected varan class" Name="AddVaranTask.p_this"/>
			callOptions 	: USINT := CALL_OPTION_RT_PRESCAN;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to add a read data object to varan master and install a varan task&#13;&#10;=================================================================================================&#13;&#10;" Name="AddRdDO"/>
	FUNCTION VIRTUAL GLOBAL AddRdDO
		VAR_INPUT
			p_us_position_info 	: ^USINT;			//! <Variable Comment="path of varan" Name="AddRdDO.p_us_position_info"/>
			ud_dol_type 	: UDINT;
			p_ud_handle 	: ^UDINT;			//! <Variable Comment=" pointer to variable to set right handle" Name="AddRdDO.p_ud_handle"/>
			ud_address 	: UDINT;			//! <Variable Comment="address to write" Name="AddRdDO.ud_address"/>
			ud_length 	: UDINT;			//! <Variable Comment="length of data (max. 128Byte)" Name="AddRdDO.ud_length"/>
			p_ud_data 	: ^UDINT;			//! <Variable Comment="pointer to data should be written" Name="AddRdDO.p_ud_data"/>
			ud_type 	: UDINT;			//! <Variable Comment="0=control area, 1=memory area" Name="AddRdDO.ud_type"/>
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;			//! <Variable Comment=" 0=OK, negative=error (look lsl_st_varan.h)" Name="AddRdDO.sd_retval"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to add a write data object to varan master and install a varan task&#13;&#10;=================================================================================================&#13;&#10;" Name="AddWrDO"/>
	FUNCTION VIRTUAL GLOBAL AddWrDO
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			ud_dol_type 	: UDINT;
			p_ud_handle 	: ^UDINT;
			ud_address 	: UDINT;
			ud_length 	: UDINT;
			p_ud_data 	: ^UDINT;
			ud_type 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to add a read/write data object to varan master and install a varan task&#13;&#10;=================================================================================================&#13;&#10;[&gt;p_ud_data_write] pointer to variable to get pointer to data&#13;&#10;" Name="AddRdWrDO"/>
	FUNCTION VIRTUAL GLOBAL AddRdWrDO
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			ud_dol_type 	: UDINT;
			p_ud_handle 	: ^UDINT;
			ud_address_read 	: UDINT;			//! <Variable Comment=" Address of read data object" Name="AddRdWrDO.ud_address_read"/>
			ud_length_read 	: UDINT;			//! <Variable Comment=" Length of read data object" Name="AddRdWrDO.ud_length_read"/>
			p_ud_data_read 	: ^UDINT;			//! <Variable Comment=" pointer to variable to get pointer to data" Name="AddRdWrDO.p_ud_data_read"/>
			ud_address_write 	: UDINT;			//! <Variable Comment=" Address of write data object" Name="AddRdWrDO.ud_address_write"/>
			ud_length_write 	: UDINT;			//! <Variable Comment=" Length of write data object" Name="AddRdWrDO.ud_length_write"/>
			p_ud_data_write 	: ^UDINT;			//! <Variable Comment=" pointer to variable to get pointer to data" Name="AddRdWrDO.p_ud_data_write"/>
			ud_type 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL AddMovDO
		VAR_INPUT
			ud_dol_type 	: UDINT;
			p_ud_handle 	: ^UDINT;
			p_ud_MovSettings 	: ^UDINT;
			ud_type 	: UDINT;			//! <Variable Comment="access type is always memory, but we may want to have some priority for this access" Name="AddMovDO.ud_type"/>
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function executes a data object list of VaranManager&#13;&#10;=================================================================================================&#13;&#10;" Name="ExecuteDOL"/>
	FUNCTION VIRTUAL GLOBAL ExecuteDOL
		VAR_INPUT
			ud_dol_type 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function clears a data object list of VaranManager&#13;&#10;=================================================================================================&#13;&#10;" Name="ClearDOL"/>
	FUNCTION VIRTUAL GLOBAL ClearDOL
		VAR_INPUT
			ud_dol_type 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to read a direct access data object&#13;&#10;=================================================================================================&#13;&#10;" Name="RdDO"/>
	FUNCTION VIRTUAL GLOBAL RdDO
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			ud_address 	: UDINT;
			ud_length 	: UDINT;
			p_ud_data 	: ^UDINT;
			ud_type 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to write a direct access data object&#13;&#10;=================================================================================================&#13;&#10;" Name="WrDO"/>
	FUNCTION VIRTUAL GLOBAL WrDO
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			ud_address 	: UDINT;
			ud_length 	: UDINT;
			p_ud_data 	: ^UDINT;
			ud_type 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to get Pll - Time of VaranMaster&#13;&#10;=================================================================================================&#13;&#10;" Name="GetVaranTime"/>
	FUNCTION VIRTUAL GLOBAL GetVaranTime
		VAR_INPUT
			p_ud_IsoStartPoint 	: ^UDINT := NIL;
		END_VAR
		VAR_OUTPUT
			ud_varan_time 	: UDINT;			//! <Variable Comment=" Varantime in ns" Name="GetVaranTime.ud_varan_time"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to get Varan class position in a string&#13;&#10;=================================================================================================&#13;&#10;" Name="GetVaranPosition"/>
	FUNCTION VIRTUAL GLOBAL GetVaranPosition
		VAR_INPUT
			p_us_info 	: ^USINT;			//! <Variable Comment=" pointer to save position info (first byte is length)" Name="GetVaranPosition.p_us_info"/>
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to install callback function for hot plug and play&#13;&#10;=================================================================================================&#13;&#10;" Name="SetObjectCallback"/>
	FUNCTION VIRTUAL GLOBAL SetObjectCallback
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			ud_action_ptr 	: UDINT;			//! <Variable Comment="pointer to function" Name="SetObjectCallback.ud_action_ptr"/>
			ud_thisp 	: UDINT;			//! <Variable Comment="thispointer" Name="SetObjectCallback.ud_thisp"/>
			sd_required 	: DINT;			//! <Variable Comment="is class required" Name="SetObjectCallback.sd_required"/>
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function sets Master off&#13;&#10;=================================================================================================&#13;&#10;" Name="SetManagerOff"/>
	FUNCTION VIRTUAL GLOBAL SetManagerOff
		VAR_INPUT
			e_error 	: t_e_VaranErrors;			//! <Variable Comment="reason why varan master is set off" Name="SetManagerOff.e_error"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;" Name="SetVaranError"/>
	FUNCTION VIRTUAL GLOBAL SetVaranError
		VAR_INPUT
			p_Node 	: ^USINT;			//! <Variable Comment="pointer to Node string" Name="SetVaranError.p_Node"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function give back a nono second counter value of VaranMaster&#13;&#10;=================================================================================================&#13;&#10;" Name="GetNsTime"/>
	FUNCTION VIRTUAL GLOBAL GetNsTime
		VAR_OUTPUT
			ud_ns_counter 	: UDINT;			//! <Variable Comment="nano second counter value" Name="GetNsTime.ud_ns_counter"/>
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL GetNsTimeBPLLTicks
		VAR_OUTPUT
			ud_ns_counter 	: UDINT;			//! <Variable Comment="time since last tick" Name="GetNsTimeBPLLTicks.ud_ns_counter"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to get pointer to node information&#13;&#10;=================================================================================================&#13;&#10;" Name="GetNodeInfo"/>
	FUNCTION VIRTUAL GLOBAL GetNodeInfo
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			p_node_info 	: ^PLSL_VARANNODEINFO;			//! <Variable Comment="pointer to node info" Name="GetNodeInfo.p_node_info"/>
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to get Varan Master number&#13;&#10;=================================================================================================&#13;&#10;" Name="GetManagerNumber"/>
	FUNCTION VIRTUAL GLOBAL GetManagerNumber
		VAR_INPUT
			p_varan 	: ^pVoid;			//! <Variable Comment="address of pointer to varan" Name="GetManagerNumber.p_varan"/>
		END_VAR
		VAR_OUTPUT
			ud_manager_number 	: UDINT;			//! <Variable Comment="number of varan master" Name="GetManagerNumber.ud_manager_number"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function returns state of Varan manger class&#13;&#10;=================================================================================================&#13;&#10;" Name="GetManagerState"/>
	FUNCTION VIRTUAL GLOBAL GetManagerState
		VAR_OUTPUT
			e_state 	: t_e_VaranErrors;			//! <Variable Comment="error of varan manager" Name="GetManagerState.e_state"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to read SPI data&#13;&#10;=================================================================================================&#13;&#10;" Name="ReadSPIData"/>
	FUNCTION VIRTUAL GLOBAL ReadSPIData
		VAR_INPUT
			p_us_position_info 	: ^USINT;			//! <Variable Comment="nodestring of varan client" Name="ReadSPIData.p_us_position_info"/>
			ud_offset 	: UDINT;			//! <Variable Comment="offset in SPI flash" Name="ReadSPIData.ud_offset"/>
			ud_length 	: UDINT;			//! <Variable Comment="length of data to read (if MSB is set, access is done on the last page in SPI)" Name="ReadSPIData.ud_length"/>
			p_data 	: ^USINT;			//! <Variable Comment="pointer to allocated memory for read data" Name="ReadSPIData.p_data"/>
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;			//! <Variable Comment="0...success&#13;&#10;or else negative errorcode is returned" Name="ReadSPIData.sd_retval"/>
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to get sync frame counter&#13;&#10;=================================================================================================&#13;&#10;" Name="GetSyncFrameCounter"/>
	FUNCTION VIRTUAL GLOBAL GetSyncFrameCounter
		VAR_OUTPUT
			us_frame_counter 	: USINT;			//! <Variable Comment=" sync frame counter" Name="GetSyncFrameCounter.us_frame_counter"/>
		END_VAR;
				//! <Function Comment="[#DEUTSCH]&#13;&#10;=================================================================================================&#13;&#10;Function to disable device in cyclic&#13;&#10;=================================================================================================&#13;&#10;" Name="SetDisableDevice"/>
	FUNCTION VIRTUAL GLOBAL SetDisableDevice
		VAR_INPUT
			p_us_position_info 	: ^USINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL GetDocumentation
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			p_dpne 	: ^CHAR;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL GetSerialNo
		VAR_INPUT
			p_us_position_info 	: ^USINT;
			p_SerialNo 	: ^CHAR;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL AllowRequiredError
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
	
	FUNCTION AWL VIRTUAL GLOBAL SetObjectThisp
		VAR_INPUT
			p_us_ObjectPath 	: ^USINT;
			ud_thisp 	: UDINT;
		END_VAR
		VAR_OUTPUT
			sd_retval 	: DINT;
		END_VAR;
	
	FUNCTION AWL VIRTUAL GLOBAL GetObjectThisp
		VAR_INPUT
			p_us_ObjectPath 	: ^USINT;
		END_VAR
		VAR_OUTPUT
			ud_thisp 	: UDINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;=================================================================================================&#13;&#10;Function to look if class is disabled&#13;&#10;=================================================================================================&#13;&#10;" Name="IsDeviceDisabled"/>
	FUNCTION VIRTUAL GLOBAL IsDeviceDisabled
		VAR_OUTPUT
			b_disabled 	: BOOL;			//! <Variable Comment="TRUE -&gt; Device disabled" Name="IsDeviceDisabled.b_disabled"/>
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsTransparent
		VAR_OUTPUT
			isTransparent 	: BOOL;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL Control::NewInst
		VAR_INPUT
			pPara 	: ^CmdStruct;
			pResult 	: ^results;
		END_VAR
		VAR_OUTPUT
			ret_code 	: iprStates;
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

#pragma usingLtd VaranManager_Base


//}}LSL_DECLARATION


FUNCTION GLOBAL TAB Hub_Base_Root::@CT_
0$UINT,
2#0100000000000000$UINT, //TY_HUB_BASE_ROOT
2$UINT, 11$UINT, (SIZEOF(::Hub_Base_Root))$UINT, 
0$UINT, 1$UINT, 0$UINT, 
TO_UDINT(1770276445), "Hub_Base_Root", //Class
TO_UDINT(3238133653), "Hub_Base", 1$UINT, 21$UINT, //Baseclass
//Servers:
//Clients:
(::Hub_Base_Root.VaranConnect.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(564966969), "VaranConnect", TO_UDINT(4035182347), "VaranManager_Base", 1$UINT, 26$UINT, 
END_FUNCTION


#define USER_CNT_Hub_Base_Root 30

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

FUNCTION Hub_Base_Root::@STD
	VAR_OUTPUT
		ret_code	: CONFSTATES;
	END_VAR
	VAR
		vmt	: _LSL_STD_VMETH;
		nCmdSize	: UINT;
	END_VAR

	ret_code	:= Hub_Base::@STD();
	IF ret_code <> C_OK THEN
		RETURN;
	END_IF;
	nCmdSize		:= VaranManager_Base::Control.pMeth^.nCmds$UINT*SIZEOF(pVoid) + CMDMETH.Init;

	_memcpy((#vmt.CmdTable)$^USINT, VaranManager_Base::Control.pMeth, nCmdSize);
	vmt.CmdTable.nCmds		:= nSTDCMD + USER_CNT_Hub_Base_Root;
	vmt.CmdTable.NewInstr		:= #Control::NewInst();
#pragma warning (disable : 74)
	vmt.UserFcts[0]		:= #AddVaranTask();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

END_FUNCTION

//{{LSL_IMPLEMENTATION

(************************************************************************************
*
*	Base class for Root Hubs
*	Created : Sigmatek	/	SR	/	March-April 2006
*	Changes : 
*
*
*     FOR NEWER CHANGES SEE REVISION DOCUMENTATION IN CLASS PROPERTIES
*
*
*   1.6 => 1.7	/	26.05.2008
*			- [DB 863]: - add function to disable device in cyclic
*   1.5 => 1.6  /   18.04.2008
*			- [DB 852]: extend method GetVaranTime to get the IsoStartPoint
*		1.4 => 1.5	/ 	17.12.2007
*			- [DB 713]:	add function to log messages and log device error
*		1.3 => 1.4	/ 	03.10.2007
*			- add function to get "SyncFrame Counter" 
*		1.2 => 1.3	/ 	04.04.2007
*			- [DB 541]: insert function to read SPI data
*		1.1 => 1.2	/	03.01.2007
*			[DB 418]: insert functions to disable and enable port
*		1.0 => 1.1	/	28.11.2006
*			first library version
*		0.2 => 1.0	/	09.10.2006
*			initial version
*		0.1 => 0.2	/	13.06.2006
*			second testversion 
*		0.0	=> 0.1	/	10.04.2006
*			first testversion for fair in Hannover
*
************************************************************************************)
//[#ENGLISH]
//=================================================================================================
//Function to add a realtime or cyclic task to VaranMaster
//=================================================================================================
//[>ud_dol_type] type of DOL list( Realtime = 3, cyclic = 4 )
//[>p_this] Thispointer of connected varan class
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::AddVaranTask
	VAR_INPUT
		ud_dol_type 	: UDINT;
		p_this 	: ^void;
		callOptions 	: USINT;
	END_VAR

	VaranConnect.AddVaranTask	( ud_dol_type	:= ud_dol_type
								, p_this		:= p_this
                , callOptions := callOptions
								);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::AddVaranTask
//[#ENGLISH]
//=================================================================================================
//Function to add a read data object to varan master and install a varan task
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_dol_type] pointer to variable to set right handle
//[>p_ud_handle]pointer to variable to set right handle
//[>ud_address] Address of data object
//[>ud_length] Length of data object
//[>p_ud_data] pointer to variable to get pointer to data
//[>ud_type]0=control area, 1=memory area
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::AddRdDO
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_dol_type			: UDINT;
	p_ud_handle			: ^UDINT;
	ud_address			: UDINT;
	ud_length			: UDINT;
	p_ud_data			: ^UDINT;
	ud_type				: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval			: DINT;
END_VAR

	sd_retval := VaranConnect.AddRdDO	( p_us_position_info:= p_us_position_info
										, ud_dol_type		:= ud_dol_type
										, p_ud_handle		:= p_ud_handle
										, ud_address		:= ud_address
										, ud_length			:= ud_length
										, p_ud_data			:= p_ud_data
										, ud_type			:= ud_type
										);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::AddRdDO
//[#ENGLISH]
//=================================================================================================
//Function to add a write data object to varan master and install a varan task
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_dol_type] pointer to variable to set right handle
//[>p_ud_handle]pointer to variable to set right handle
//[>ud_address] Address of data object
//[>ud_length] Length of data object
//[>p_ud_data] pointer to variable to get pointer to data
//[>ud_type]0=control area, 1=memory area
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::AddWrDO
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_dol_type			: UDINT;
	p_ud_handle			: ^UDINT;
	ud_address			: UDINT;
	ud_length			: UDINT;
	p_ud_data			: ^UDINT;
	ud_type				: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := VaranConnect.AddWrDO	( p_us_position_info:= p_us_position_info
										, ud_dol_type		:= ud_dol_type
										, p_ud_handle		:= p_ud_handle
										, ud_address		:= ud_address
										, ud_length			:= ud_length
										, p_ud_data			:= p_ud_data
										, ud_type			:= ud_type
										);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::AddWrDO
//[#ENGLISH]
//=================================================================================================
//Function to add a read/write data object to varan master and install a varan task
//=================================================================================================
//[>p_ud_data_write] pointer to variable to get pointer to data
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_dol_type] type of DOL list( 1=direct access, 2=IRQ, 3=realtime, 4=cyclic )
//[>p_ud_handle] pointer to variable to set right handle
//[>ud_address_read] Address of read data object
//[>ud_length_read] Length of read data object
//[>p_ud_data_read] pointer to variable to get pointer to data
//[>ud_address_write] Address of write data object
//[>ud_length_write] Length of write data object
//[>p_ud_data_write] pointer to variable to get pointer to data
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::AddRdWrDO
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_dol_type			: UDINT;
	p_ud_handle			: ^UDINT;
	ud_address_read		: UDINT;
	ud_length_read		: UDINT;
	p_ud_data_read		: ^UDINT;
	ud_address_write	: UDINT;
	ud_length_write		: UDINT;
	p_ud_data_write		: ^UDINT;
	ud_type				: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := VaranConnect.AddRdWrDO	( p_us_position_info:= p_us_position_info
										, ud_dol_type		:= ud_dol_type
										, p_ud_handle		:= p_ud_handle
										, ud_address_read	:= ud_address_read
										, ud_length_read	:= ud_length_read
										, p_ud_data_read	:= p_ud_data_read
										, ud_address_write	:= ud_address_write
										, ud_length_write	:= ud_length_write
										, p_ud_data_write	:= p_ud_data_write
										, ud_type			:= ud_type
										);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::AddRdWrDO
//[#ENGLISH]
//=================================================================================================
//Function executes a data object list of VaranManager
//=================================================================================================
//[>ud_dol_type] type of DOL list( 1=direct access, 2=IRQ, 3=realtime, 4=cyclic )
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::ExecuteDOL
VAR_INPUT
	ud_dol_type		: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := VaranConnect.ExecuteDOL( ud_dol_type := ud_dol_type );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::ExecuteDOL
//[#ENGLISH]
//=================================================================================================
//Function clears a data object list of VaranManager
//=================================================================================================
//[>ud_dol_type] Type of DOL (see lsl_st_varan.h)
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)

FUNCTION VIRTUAL GLOBAL Hub_Base_Root::ClearDOL
VAR_INPUT
	ud_dol_type		: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := VaranConnect.ClearDOL( ud_dol_type := ud_dol_type );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::ClearDOL
//[#ENGLISH]
//=================================================================================================
//Function to get Pll - Time of VaranMaster
//=================================================================================================
//[<ud_varan_time] Varantime in ns
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetVaranTime
VAR_INPUT
	p_ud_IsoStartPoint	: ^UDINT;
END_VAR
VAR_OUTPUT
	ud_varan_time		: UDINT;
END_VAR

	ud_varan_time := VaranConnect.GetVaranTime( p_ud_IsoStartPoint );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetPllTime
//[#ENGLISH]
//=================================================================================================
//Function to get Varan class position in a string
//=================================================================================================
//[>p_us_info] pointer to save position info (first byte is length)
//[<sd_retval]0=OK, -1=to many hubs( max.15 )
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetVaranPosition
VAR_INPUT
	p_us_info		: ^USINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	//we are the root class
	sd_retval := 0;

	//if pointer is NIL do nothing
	if ( p_us_info <> NIL ) then	

		//increase length
		p_us_info^ += 1;

		//if max length is reached
		if ( p_us_info^ <= VARAN_MAX_DEPTH - 1 ) then
			
			//enter place on right position
			( p_us_info + p_us_info^ )^ := TO_USINT( Splitter_Place );
	
		else
			sd_retval := -1;
		end_if;	
	else
		sd_retval := -2;
	end_if;

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetVaranPosition
//[#ENGLISH]
//=================================================================================================
//Function to read a direct access data object
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_address]address to read
//[>ud_length]length of data should read
//[>p_ud_data]variable to get pointer to readed data
//[>ud_type] 0=control area, 1=memory area
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::RdDO
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_address			: UDINT;
	ud_length			: UDINT;
	p_ud_data			: ^UDINT;
	ud_type				: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval			: DINT;
END_VAR

	sd_retval := VaranConnect.RdDO	( p_us_position_info:= p_us_position_info
									, ud_address		:= ud_address
									, ud_length			:= ud_length
									, p_ud_data			:= p_ud_data
									, ud_type			:= ud_type
									);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::RdDO
//[#ENGLISH]
//=================================================================================================
//Function to write a direct access data object
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_address]address to write
//[>ud_length]length of data should be written
//[>p_ud_data]pointer to data should be written
//[>ud_type]0=control area, 1=memory area
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::WrDO
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_address			: UDINT;
	ud_length			: UDINT;
	p_ud_data			: ^UDINT;
	ud_type				: UDINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := VaranConnect.WrDO	( p_us_position_info:= p_us_position_info
									, ud_address		:= ud_address
									, ud_length			:= ud_length
									, p_ud_data			:= p_ud_data
									, ud_type			:= ud_type
									);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::WrDO
//[#ENGLISH]
//=================================================================================================
//Function to install callback function for hot plug and play
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_action_ptr]pointer to function
//[>ud_thisp]thispointer
//[>sd_required]is class required
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::SetObjectCallback
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_action_ptr		: UDINT;
	ud_thisp			: UDINT;
	sd_required			: DINT;
END_VAR
VAR_OUTPUT
	sd_retval			: DINT;
END_VAR

	sd_retval := VaranConnect.SetObjectCallback	( p_us_position_info:= p_us_position_info
												, ud_action_ptr		:= ud_action_ptr
												, ud_thisp			:= ud_thisp
												, sd_required		:= sd_required
												);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::SetObjectCallback
//[#ENGLISH]
//=================================================================================================
//Function sets Master off
//=================================================================================================
//[>e_error]reason why varan master is set off
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::SetManagerOff
VAR_INPUT
	e_error		: t_e_VaranErrors;
END_VAR

	VaranConnect.SetManagerOff( e_error := e_error );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::SetManagerOff
//[#ENGLISH]
//[>p_Node]pointer to Node string
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::SetVaranError
VAR_INPUT
	p_Node		: ^USINT;
END_VAR

	VaranConnect.SetVaranError( p_Node := p_Node );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::SetVaranError
//[#ENGLISH]
//=================================================================================================
//Function give back a nono second counter value of VaranMaster
//=================================================================================================
//[<ud_ns_counter]nano second counter value

FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetNsTime
VAR_OUTPUT
	ud_ns_counter		: UDINT;
END_VAR

	ud_ns_counter := VaranConnect.GetNsTime();

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetNsTime
//[#ENGLISH]
//=================================================================================================
//Function to get pointer to node information
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>p_node_info]pointer to node info
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetNodeInfo
VAR_INPUT
	p_us_position_info	: ^USINT;
	p_node_info			: ^PLSL_VARANNODEINFO;
END_VAR
VAR_OUTPUT
	sd_retval			: DINT;
END_VAR

	sd_retval := VaranConnect.GetNodeInfo	( p_us_position_info	:= p_us_position_info
											, p_node_info			:= p_node_info
											);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetNodeInfo
//[#ENGLISH]
//=================================================================================================
//Function to get Varan Master number
//=================================================================================================
//[>p_varan]address of pointer to varan
//[<ud_manager_number]number of varan master
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetManagerNumber
VAR_INPUT
	p_varan				: ^pVoid;
END_VAR
VAR_OUTPUT
	ud_manager_number	: UDINT;
END_VAR

	ud_manager_number := VaranConnect.GetManagerNumber( p_varan := p_varan );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetMasterNumber
//[#ENGLISH]
//=================================================================================================
//Function returns state of Varan manger class
//=================================================================================================
//[<e_state]error of varan manager
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetManagerState
VAR_OUTPUT
	e_state		: t_e_VaranErrors;
END_VAR

	e_state := VaranConnect.GetManagerState();

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetManagerState
//[#ENGLISH]
//=================================================================================================
//Function to look if class is disabled
//=================================================================================================
//[<b_disabled]TRUE -> Device disabled
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::IsDeviceDisabled
VAR_OUTPUT
	b_disabled		: BOOL;
END_VAR

	//we are root we can't be disabled
	b_disabled := FALSE;

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::IsDeviceDisabled
//[#ENGLISH]
//=================================================================================================
//Function to read SPI data
//=================================================================================================
//[>p_us_position_info]pointer to position info( first byte is length)
//[>ud_offset]offset in SPI flash
//[>ud_length]length of data (max. 128Byte)
//[>p_data]pointer to allocated memory for read data
//[<sd_retval] 0=OK, negative=error (look lsl_st_varan.h)
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::ReadSPIData
VAR_INPUT
	p_us_position_info	: ^USINT;
	ud_offset			: UDINT;
	ud_length			: UDINT;
	p_data				: ^USINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := VaranConnect.ReadSPIData	( p_us_position_info	:= p_us_position_info
											, ud_offset				:= ud_offset
											, ud_length				:= ud_length
											, p_data 				:= p_data
											);

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::ReadSPIData
//[#ENGLISH]
//=================================================================================================
//Function to get sync frame counter
//=================================================================================================
//[<us_frame_counter] sync frame counter
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetSyncFrameCounter
VAR_OUTPUT
	us_frame_counter		: USINT;
END_VAR

	us_frame_counter := VaranConnect.GetSyncFrameCounter();

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::GetSyncFramCounter

//=================================================================================================
//Function to disable device in cyclic
//=================================================================================================
//[>p_us_position_info]path of varan
FUNCTION VIRTUAL GLOBAL Hub_Base_Root::SetDisableDevice
VAR_INPUT
	p_us_position_info		: ^USINT;
END_VAR
VAR_OUTPUT
	sd_retval		: DINT;
END_VAR

	sd_retval := Varanconnect.SetDisableDevice( p_us_position_info := p_us_position_info );

END_FUNCTION //VIRTUAL GLOBAL Hub_Base_Root::SetDisableDevice


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetDocumentation
	VAR_INPUT
		p_us_position_info 	: ^USINT;
		p_dpne 	: ^CHAR;
	END_VAR
	VAR_OUTPUT
		sd_retval 	: DINT;
	END_VAR

  sd_retval := VaranConnect.GetDocumentation(p_us_position_info, p_dpne);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetSerialNo
	VAR_INPUT
		p_us_position_info 	: ^USINT;
		p_SerialNo 	: ^CHAR;
	END_VAR
	VAR_OUTPUT
		sd_retval 	: DINT;
	END_VAR

  sd_retval := VaranConnect.GetSerialNo(p_us_position_info, p_SerialNo);

END_FUNCTION





FUNCTION VIRTUAL GLOBAL Hub_Base_Root::AllowRequiredError
	VAR_OUTPUT
		sd_retval 	: DINT;
	END_VAR
  
  sd_retval := VaranConnect.AllowRequiredError();

END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetObjectThisp
	VAR_INPUT
		p_us_ObjectPath 	: ^USINT;
	END_VAR
	VAR_OUTPUT
		ud_thisp 	: UDINT;
	END_VAR
  
  ud_thisp := VaranConnect.GetObjectThisp(p_us_ObjectPath:=p_us_ObjectPath);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::SetObjectThisp
	VAR_INPUT
		p_us_ObjectPath 	: ^USINT;
		ud_thisp 	: UDINT;
	END_VAR
	VAR_OUTPUT
		sd_retval 	: DINT;
	END_VAR

  sd_retval := VaranConnect.SetObjectThisp(p_us_ObjectPath:=p_us_ObjectPath, ud_thisp:=ud_thisp);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::AddMovDO
	VAR_INPUT
		ud_dol_type 	: UDINT;
		p_ud_handle 	: ^UDINT;
		p_ud_MovSettings 	: ^UDINT;
		ud_type 	: UDINT;
	END_VAR
	VAR_OUTPUT
		sd_retval 	: DINT;
	END_VAR

  sd_retval := VaranConnect.AddMovDO(ud_dol_type:=ud_dol_type
                                   , p_ud_handle:=p_ud_handle
                                   , p_ud_MovSettings:=p_ud_MovSettings,
                                     ud_type:=ud_type);


END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::IsTransparent
	VAR_OUTPUT
		isTransparent 	: BOOL;
	END_VAR

  isTransparent := FALSE;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::GetNsTimeBPLLTicks
	VAR_OUTPUT
		ud_ns_counter 	: UDINT;
	END_VAR

  ud_ns_counter := VaranConnect.GetNsTimeBPLLTicks();

END_FUNCTION


FUNCTION VIRTUAL GLOBAL Hub_Base_Root::Control::NewInst
	VAR_INPUT
		pPara 	: ^CmdStruct;
		pResult 	: ^Results;
	END_VAR
	VAR_OUTPUT
		ret_code 	: IprStates;
	END_VAR

	ret_code := VaranConnect.NewInst(pPara, pResult);

END_FUNCTION
