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

//{{LSL_DEFINES
#define SDIASM_OBJECT_PATH            16#88000002   // Object Path for VSDIASmanager Length = 2 (First 2byte), Domain = 0 (3rd byte), Escape Sequence SDIAS (4th byte) 
//}}LSL_DEFINES

//{{LSL_DECLARATION

(*!
<Class
	Name               = "SdiasPLC"
	Revision           = "2.6"
	GUID               = "{8EE0BE0E-BEE7-4218-A4AF-A0AB0DE83F43}"
	RealtimeTask       = "false"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "false"
	HighPriority       = "false"
	Automatic          = "false"
	UpdateMode         = "Prescan"
	IconPath           = ".\Class\s-dias.ico"
	SharedCommandTable = "true"
	Objectsize         = "(730,120)">
	<Channels>
		<Server Name="ClassState" GUID="{CC338568-5E5E-4B72-BB67-E573CD9CE59F}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the state of the SDIAS Manager."/>
		<Server Name="FirmwareVersion" GUID="{110EDFDE-5D00-4525-834D-7E99AA65EEF4}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Server shows the actual FW Version of the Module in the format xx.yy&#13;&#10;&#13;&#10;e.g. 16#0130 means v01.30"/>
		<Server Name="InterfaceState">
		</Server>
		<Server Name="IsoRdTaskDuration" GUID="{6DEF0FB2-2B7B-4859-A498-992DF86A9C33}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Time measurement of last iso read task at SDIAS in [µs]&#13;&#10;The measured time could be higher then the calculated time according to bit 4 &#13;&#10;of the manager option bits (0 .. with preprocessor time, 1 .. only execution time)."/>
		<Server Name="IsoRdTaskMaxDuration" GUID="{7407C9C7-AEDD-478D-94B7-18DEC7EA7537}" Visualized="true" Initialize="false" WriteProtected="false" Retentive="false" Comment="maximal time measurement of iso read task at SDIAS in [µs]"/>
		<Server Name="IsoWrTaskDuration" GUID="{107F6C59-3F86-4945-883C-1730324CE708}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="time measurement of last iso write task at SDIAS in [µs]"/>
		<Server Name="IsoWrTaskMaxDuration" GUID="{732E66FA-8CD0-4FE7-BB47-F47F45CD63D4}" Visualized="true" Initialize="false" WriteProtected="false" Retentive="false" Comment="maximal time measurement of iso write task at SDIAS in [µs]"/>
		<Server Name="ManagerOptionBits" GUID="{1ACFAA3D-1F6C-4193-9962-DACD4520FB4A}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Option Bits:&#13;&#10;Bit 1: Interrupts supported&#13;&#10;Bit 2: Half duplex (SDIAS S2), bus scan required&#13;&#10;Bit 3: Far Memory access supported&#13;&#10;Bit 4: Status wait supported (to differ TimeSliceError and TimeSliceErrorIRQ)&#13;&#10;Bit 5: Execution time selection supported 1&#13;&#10;Bit 6: Task interruption detection supported&#13;&#10;Bit 7: Execution time selection supported 2&#13;&#10;"/>
		<Server Name="ManagerProtocolVersion" GUID="{8A535859-D37E-4F82-A0C2-663478B1E502}" Visualized="false" Initialize="false" WriteProtected="true" Retentive="false" Comment="Server shows the SDIAS Manager Protocol Version of the Module in the format xx.y.z&#13;&#10;e.g. 16#0130 means v01.3.0"/>
		<Server Name="RetryCounter" GUID="{3BC15DE0-3955-4B15-86D2-18FB43792F0F}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Actual Number of Retries on SDIAS-Bus."/>
		<Server Name="SdiasOut_1" GUID="{80FBEABF-F831-4CD7-B6AC-3A0056083736}" Visualized="false" Initialize="false" WriteProtected="true" Retentive="false" Comment="Connect a SDIAS Client Class"/>
		<Client Name="AutoFarMem" Required="true" Internal="false" DefValue="0" Comment="Only valid for simple master CPUs (CP101 or CP102):&#13;&#10;Parameter Values:&#13;&#10;0 ... AutoFarMem is not activated&#13;&#10;1 ... AutoFarMem shall be activated if possible&#13;&#10;Defaultvalue: 0 (deactivated)&#13;&#10;Shown Values:&#13;&#10;1 ... AutoFarMem is activated&#13;&#10;-1 ... AutoFarMem is NOT activated (OS is too old)&#13;&#10;-2 ... AutoFarMem is NOT activated (FPGA is too old)&#13;&#10;-99 ... AutoFarMem is NOT activated (other error)&#13;&#10;AutoFarMem:&#13;&#10;far memory accesses and&#13;&#10;128 byte SDIAS-accesses&#13;&#10;are possible (not AutoFarMem only 4 Byte)."/>
		<Client Name="SdiasHubBase1" Required="true" Internal="true"/>
		<Client Name="SdiasManager1" Required="true" Internal="true"/>
	</Channels>
	<RevDoku>
		<Owner Company="Sigmatek" Author="RamAnd"/>
		<Dokumentation Revision="2.6" Date="08.07.2021" Author="RamAnd" Company="Sigmatek" Description="There could have been default read accesses active, which might have interfered when reading latched values.&#13;&#10;Default read accesses are now disabled after the class took over the control of the local SDIAS from the OS."/>
		<Dokumentation Revision="2.5" Date="30.07.2020" Author="HaeTho" Company="Sigmatek" Description="AutoFarMem (far memory access and 128byte access on SDIAS bus) may be activated for local SDIAS on Simple Master CPUs (CP101 and CP102)"/>
		<Dokumentation Revision="2.4" Date="24.11.2020" Author="EisMic" Company="Sigmatek" Description="Clear the ISO Write memory at connect from VI02x.&#13;&#10;Added a check if the length of the isochronous read/write DO from VARAN is big enough after a reconnect.&#13;&#10;The newinst commando CMD_HWC_REQ_PLLNS_REGULATION is now be forwared to the HwControl.&#13;&#10;Added comment of client CoreSelect."/>
		<Dokumentation Revision="2.3" Date="06.02.2020" Author="PieSte" Company="Sigmatek" Description="(SA 54165) Since v1.85 of SdiasManager the SDO&apos;s at AddAccess() methode failed for modules behind varan (DC06x, SR01x, ..) with VI02x fpga version &gt; 1.6 and &lt;2.0. The SdiasPLC is not affected by this."/>
		<Dokumentation Revision="2.2" Date="16.09.2019" Author="LazJos" Company="Sigmatek" Description="Added support for HWAlarms."/>
		<Dokumentation Revision="2.1" Date="23.10.2018" Author="PieSte" Company="Sigmatek" Description="The procedure in the RtSSW at SdiasManager has been changed so that the step &quot;_PreOperationalWait4DataReady&quot; is called even if the feature &quot;TimeBroadCastSupported&quot; is not available. This is needed to support the UpdateRtPreOp() Methode and DataReady Feature for SDIAS clients."/>
		<Dokumentation Revision="2.0" Date="11.04.2018" Author="EisMic" Company="Sigmatek" Description="Added support to select the CPU-core on which the realtime and the cyclic task of the class should be executed."/>
		<Dokumentation Revision="1.54" Date="27.04.2018" Author="PieSte" Company="Sigmatek" Description="The behavior of Local SDIAS and SDIAS behind Varan was adjusted in the initialization phase. For local SDIAS the bus cycle time is passed to the SDIAS clients before the method AddAccesses() and for SDIAS after VARAN after the method. Now the bus cycle time is available in both variants in the method AddAccesses()."/>
		<Dokumentation Revision="1.53" Date="06.04.2018" Author="LanSte" Company="Sigmatek" Description="Added Server ManagerProtocolVersion"/>
		<Dokumentation Revision="1.52" Date="13.03.2018" Author="LanSte" Company="Sigmatek" Description="Added Broadcast commands with HWTimestamp + ISO Startpoint."/>
		<Dokumentation Revision="1.51" 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="1.50" Date="19.12.2017" Author="EisMic" Company="Sigmatek" Description="Since v1.86 the SDIAS Bus of the CP212 wasn&apos;t working anymore. (SyncOut ID was not found)"/>
		<Dokumentation Revision="1.49" Date="12.12.2017" Author="PieSte&#13;&#10;EisMic" Company="Sigmatek" Description="Added support for far memory access at SdiasManager. &#13;&#10;Added support for IPC321 (improved search of SyncOut-ID for Sdiasmanager)"/>
		<Dokumentation Revision="1.48" Date="20.04.2017" Author="PieSte&#13;&#10;EisMic" Company="Sigmatek" Description="Added sdias time calculation at hardware description file.&#13;&#10;Added manager options bit and steps in initialisation for execution time selection.&#13;&#10;TimeSliceErrorIRQ is now supported if feature is available in FPGA."/>
		<Dokumentation Revision="1.47" Date="13.02.2017" Author="EisMic&#13;&#10;ZoePat" Company="Sigmatek" Description="Feature Support Bits are now shown on server ManagerOptionBits if available.&#13;&#10;SdiasModules can now request to increase the PostInit timeout."/>
		<Dokumentation Revision="1.46" Date="14.11.2016" Author="EisMic" Company="Sigmatek" Description="Removed check for TimeSliceErrorIRQ if write task is interrupted by read task. The check could have led to a SDIAS-Error if SDIAS Safety modules were used or only a small amount of SDIAS modules were used."/>
		<Dokumentation Revision="1.45" Date="11.10.2016" Author="EisMic" Company="Sigmatek" Description="Added support that modules can access the Default-Access-Info in the AddAccesses Method."/>
		<Dokumentation Revision="1.44" Date="08.09.2016" Author="ZoePat" Company="Sigmatek" Description="TimeSliceError and TimeSliceErrorIRQ are now differentiated."/>
		<Dokumentation Revision="1.43" Date="22.04.2016" Author="ZoePat" Company="Sigmatek" Description="Since V1.39 the RT-Postscan of the modules was called 1 rt-cycle to early. This led to a SDIAS-Error if a ICA011/111 was used on a Simple-Master CPU (e.g.: CP101/102)."/>
		<Dokumentation Revision="1.42" Date="17.02.2016" Author="RamAnd" Company="Sigmatek" Description="Calculation of pointers for move DOs and access info has been corrected. If the original pointer is NIL now the resulting pointer also is NIL."/>
		<Dokumentation Revision="1.41" Date="27.01.2016" Author="EisMic" Company="Sigmatek" Description="Added servers for maximal IsoRd/IsoWrTaskDuration."/>
		<Dokumentation Revision="1.40" Date="22.01.2016" Author="PieSte" Company="Sigmatek" Description="Add support for read/write userflash commando at sdiasmanager.h file."/>
		<Dokumentation Revision="1.39" Date="10.12.2015" Author="EisMic" Company="Sigmatek" Description="It is now ensured that the SDIAS-hardwareclasses displays valid server values after Plug&amp;Play, if the classstate is _ClassOk."/>
		<Dokumentation Revision="1.38" Date="11.05.2015" Author="RamAnd" Company="Sigmatek" Description="Corrected initialisation: It could have happened that a partial read list has been executed during startup, which could cause problems on SDIAS modules with FIFO-Buffers."/>
		<Dokumentation Revision="1.37" Date="15.04.2015" Author="RamAnd" Company="Sigmatek" Description="Added another step in initialisation to prevent watchdog error."/>
		<Dokumentation Revision="1.36" Date="15.04.2015" Author="RamAnd" Company="Sigmatek" Description="Added support for VaranMux."/>
		<Dokumentation Revision="1.35" Date="17.03.2015" Author="RamAnd" Company="Sigmatek" Description="Added HW Version for sdias clients."/>
		<Dokumentation Revision="1.34" Date="09.02.2015" Author="PieSte" Company="Sigmatek" Description="Avoid error on local sdias if there is no or wrong hardware at module initialization."/>
		<Dokumentation Revision="1.33" Date="27.01.2015" Author="RamAnd" Company="Sigmatek" Description="Increased the size of the SDO buffer from 30 to 64 (1 SDO for every module).&#13;&#10;If there are errors on single modules which are not required, other modules now work properly.&#13;&#10;The cyclic-method of SDIAS objects is now only called if the correct module hardware is available."/>
		<Dokumentation Revision="1.32" Date="09.12.2014" Author="RamAnd" Company="Sigmatek" Description="It has been possible that a SDIAS error has been triggered caused by issues which were corrected by the following retries."/>
		<Dokumentation Revision="1.31" Date="13.11.2014" Author="RamAnd" Company="Sigmatek" Description="Refresh Retrycounters before crashing with a required or SDIAS error.&#13;&#10;Removed call in interrupt method to save time and stack size."/>
		<Dokumentation Revision="1.30" Date="13.10.2014" Author="RamAnd" Company="Sigmatek" Description="If an error occurs and the project should not crash with SDIAS error, the bus is turned off now."/>
		<Dokumentation Revision="1.29" Date="30.09.2014" Author="RamAnd" Company="Sigmatek" Description="Added possibility to create a SDIAS control access.&#13;&#10;Improved startup and error handling."/>
		<Dokumentation Revision="1.28" Date="11.07.2014" Author="EisMic" Company="Sigmatek" Description="Added support for reading hardware diagnosis and hardwaretree entry."/>
		<Dokumentation Revision="1.27" Date="17.06.2014" Author="RamAnd" Company="Sigmatek" Description="The class no longer crashes if there are no required modules connected or no modules projected."/>
		<Dokumentation Revision="1.26" Date="28.04.2014" Author="ZoePat" Company="Sigmatek" Description="Added support for CP112 (Before a SDIAS error occured at startup)."/>
		<Dokumentation Revision="1.25" Date="15.04.2014" Author="RamAnd" Company="Sigmatek" Description="Corrected creation of isochronous DOs, which was done in cyclic priority and is now down in realtime priority."/>
		<Dokumentation Revision="1.24" Date="10.04.2014" Author="RamAnd" Company="Sigmatek" Description="Corrected initialisation of data objects which could have lead to problems with time synchronisation at safety modules."/>
		<Dokumentation Revision="1.23" Date="10.04.2014" Author="RamAnd" Company="Sigmatek" Description="Added dynamic read and write access, which can change it&apos;s size and offset during runtime."/>
		<Dokumentation Revision="1.22" Date="07.04.2014" Author="RamAnd" Company="Sigmatek" Description="Init start time wasn&apos;t set correctly for the timeout detection during initialization."/>
		<Dokumentation Revision="1.21" Date="06.03.2014" Author="RamAnd" Company="Sigmatek" Description="Corrected memory initialisation to support SDIAS PC. Changed limits of IsoStartPoint from 10-90% to 1-99%."/>
		<Dokumentation Revision="1.20" Date="12.02.2014" Author="RamAnd&#13;&#10;RamAnd" Company="Sigmatek" Description="Corrected error in SDO handling at local SDIAS, where the offset and length of read or write accesses was always delivered as 0 in the callback.&#13;&#10;Added interface to get task info before the payload to detect task errors more accurately."/>
		<Dokumentation Revision="1.10" Date="22.01.2014" Author="RamAnd" Company="Sigmatek" Description="Added support for SDIAS PC."/>
		<Dokumentation Revision="1.0" Date="09.12.2013" Author="RamAnd" Company="Sigmatek" Description="First library version"/>
	</RevDoku>
	<Network Name="SdiasPLC">
		<!-- List of Components in this network -->
		<Components>
			<Object
				Name       = "_base"
				GUID       = "{0876B3F6-7B0D-4DDD-A261-E4AFE2F441AA}"
				Class      = "BusInterfaceSDIASInternal"
				Position   = "(158,120)"
				Visualized = "true">
				<Channels>
					<Server Name="CallCommand"/>
					<Server Name="InterfaceState"/>
					<Client Name="CoreSelect"/>
					<Client Name="CycleTime" Value="1000"/>
					<Client Name="IsoStartPoint" Value="50"/>
					<Client Name="ToHwControl"/>
					<Client Name="ToOSKernel"/>
					<Client Name="ToStdLib"/>
				</Channels>
			</Object>
			<Object
				Name       = "SdiasHubBase1"
				GUID       = "{0E4AC654-3AAF-47F8-801F-8E6412D5D92B}"
				Class      = "SdiasHubBase"
				Position   = "(1650,1080)"
				Visualized = "false">
				<Channels>
					<Server Name="ClassSvr"/>
					<Client Name="SplitterPlace" Value="0"/>
					<Client Name="ToNextSDIAS"/>
				</Channels>
			</Object>
			<Object
				Name       = "SdiasManager1"
				GUID       = "{A6CE8FF7-1B3C-49A6-976D-ED8995566590}"
				Class      = "SdiasManager"
				Position   = "(1050,360)"
				Visualized = "true">
				<Channels>
					<Server Name="ClassState"/>
					<Server Name="FirmwareVersion"/>
					<Server Name="IsoRdTaskDuration"/>
					<Server Name="IsoRdTaskMaxDuration"/>
					<Server Name="IsoTaskErrorCount"/>
					<Server Name="IsoWrTaskDuration"/>
					<Server Name="IsoWrTaskMaxDuration"/>
					<Server Name="ManagerOptionBits"/>
					<Server Name="ManagerProtocolVersion"/>
					<Server Name="RetryCounter"/>
					<Client Name="AutoFarMem" Value="0"/>
					<Client Name="DeviceID" Value="0"/>
					<Client Name="ToBusInterface"/>
					<Client Name="ToMultiTask"/>
					<Client Name="ToStdLib"/>
				</Channels>
			</Object>
		</Components>
		<Comments>
		</Comments>
		<!-- List of Connections in this network -->
		<Connections>
			<Connection Source="this.SdiasManager1" Destination="SdiasManager1.ClassState"/>
			<Connection Source="SdiasManager1.ToBusInterface" Destination="_base.CallCommand" Vertices="(1050,450),(658,270),"/>
			<Connection Source="_base.ToHwControl" Destination="this.ToHwControl" Vertices="(158,210),(38,210),"/>
			<Connection Source="this.InterfaceState" Destination="_base.InterfaceState" Vertices="(2248,210),(658,210),"/>
			<Connection Source="this.SdiasHubBase1" Destination="SdiasHubBase1.ClassSvr"/>
			<Connection Source="SdiasHubBase1.ToNextSDIAS" Destination="SdiasManager1.ClassState" Vertices="(1650,1170),(1634,450),"/>
			<Connection Source="this.FirmwareVersion" Destination="SdiasManager1.FirmwareVersion" Vertices="(2248,450),(1634,570),"/>
			<Connection Source="this.ClassState" Destination="SdiasManager1.ClassState" Vertices="(2248,510),(1634,450),"/>
			<Connection Source="this.RetryCounter" Destination="SdiasManager1.RetryCounter" Vertices="(2248,570),(1634,510),"/>
			<Connection Source="this.SdiasOut_1" Destination="SdiasHubBase1.ClassSvr" Vertices="(2248,990),(2076,1170),"/>
			<Connection Source="_base.CycleTime" Destination="this.CycleTime" Vertices="(158,270),(38,270),"/>
			<Connection Source="_base.IsoStartPoint" Destination="this.IsoStartPoint" Vertices="(158,330),(38,330),"/>
			<Connection Source="this.IsoWrTaskDuration" Destination="SdiasManager1.IsoWrTaskDuration" Vertices="(2248,630),(1634,630),"/>
			<Connection Source="this.IsoWrTaskMaxDuration" Destination="SdiasManager1.IsoWrTaskMaxDuration" Vertices="(2248,690),(1634,690),"/>
			<Connection Source="this.IsoRdTaskDuration" Destination="SdiasManager1.IsoRdTaskDuration" Vertices="(2248,750),(1634,750),"/>
			<Connection Source="this.IsoRdTaskMaxDuration" Destination="SdiasManager1.IsoRdTaskMaxDuration" Vertices="(2248,810),(1634,810),"/>
			<Connection Source="this.ManagerOptionBits" Destination="SdiasManager1.ManagerOptionBits" Vertices="(2248,870),(1634,930),"/>
			<Connection Source="this.ManagerProtocolVersion" Destination="SdiasManager1.ManagerProtocolVersion" Vertices="(2248,930),(1634,990),"/>
			<Connection Source="_base.CoreSelect" Destination="this.CoreSelect" Vertices="(158,510),(38,390),"/>
			<Connection Source="SdiasManager1.AutoFarMem" Destination="this.AutoFarMem" Vertices="(1050,690),(38,450),"/>
		</Connections>
		<!-- Headerfiles -->
		<Options>
		</Options>
	</Network>
</Class>
*)
#pragma using BusInterfaceSDIASInternal

SdiasPLC : CLASS
: BusInterfaceSDIASInternal
  //Servers:
	FirmwareVersion 	: SvrCh_HDINT;
	ClassState 	: SvrCh_t_e_VaranErrors;
	RetryCounter 	: SvrCh_UDINT;
	IsoWrTaskDuration 	: SvrCh_UDINT;
	IsoWrTaskMaxDuration 	: SvrCh_UDINT;
	IsoRdTaskDuration 	: SvrCh_UDINT;
	IsoRdTaskMaxDuration 	: SvrCh_UDINT;
	ManagerOptionBits 	: SvrCh_DINT;
	ManagerProtocolVersion 	: SvrCh_HDINT;
	SdiasOut_1 	: SvrChCmd_DINT;
  //Clients:
	SdiasManager1 	: CltChCmd_SdiasManager;
	SdiasHubBase1 	: CltChCmd_SdiasHubBase;
	AutoFarMem 	: CltCh_DINT;
  //Variables:
		ud_SDIASPosition 	: UDINT;
		a_StrFirmwareVersion : ARRAY [0..10] OF CHAR;

  //Functions:
	
	FUNCTION VIRTUAL GLOBAL InterfaceState::NewInst
		VAR_INPUT
			pPara 	: ^CmdStruct;
			pResult 	: ^results;
		END_VAR
		VAR_OUTPUT
			ret_code 	: iprStates;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FirmwareVersion::Read
		VAR_OUTPUT
			output (EAX) 	: HDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL ClassState::Read
		VAR_OUTPUT
			output (EAX) 	: t_e_VaranErrors;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL RetryCounter::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsoWrTaskDuration::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsoWrTaskMaxDuration::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsoWrTaskMaxDuration::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsoRdTaskDuration::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsoRdTaskMaxDuration::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL IsoRdTaskMaxDuration::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL ManagerOptionBits::Read
		VAR_OUTPUT
			output (EAX) 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL ManagerProtocolVersion::Read
		VAR_OUTPUT
			output (EAX) 	: HDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL SdiasOut_1::Read
		VAR_OUTPUT
			output (EAX) 	: DINT;
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

#pragma using SdiasHubBase
#pragma using SdiasManager


//}}LSL_DECLARATION


FUNCTION GLOBAL TAB SdiasPLC::@CT_
0$UINT,
2#0100000000000000$UINT, //TY_SDIASPLC
2$UINT, 6$UINT, (SIZEOF(::SdiasPLC))$UINT, 
10$UINT, 3$UINT, 0$UINT, 
TO_UDINT(1159122596), "SdiasPLC", //Class
TO_UDINT(3882880897), "BusInterfaceSDIASInternal", 2$UINT, 1$UINT, //Baseclass
//Servers:
(::SdiasPLC.FirmwareVersion.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(389440282), "FirmwareVersion", 
(::SdiasPLC.ClassState.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(1096059024), "ClassState", 
(::SdiasPLC.RetryCounter.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(3383993698), "RetryCounter", 
(::SdiasPLC.IsoWrTaskDuration.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(2734486445), "IsoWrTaskDuration", 
(::SdiasPLC.IsoWrTaskMaxDuration.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(4219599171), "IsoWrTaskMaxDuration", 
(::SdiasPLC.IsoRdTaskDuration.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(851305671), "IsoRdTaskDuration", 
(::SdiasPLC.IsoRdTaskMaxDuration.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(3130606261), "IsoRdTaskMaxDuration", 
(::SdiasPLC.ManagerOptionBits.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(3554748146), "ManagerOptionBits", 
(::SdiasPLC.ManagerProtocolVersion.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(1336107588), "ManagerProtocolVersion", 
(::SdiasPLC.SdiasOut_1.pMeth)$UINT, _CH_CMD$UINT, 2#0000000000000000$UINT, TO_UDINT(1297821089), "SdiasOut_1", 
//Clients:
(::SdiasPLC.SdiasManager1.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(3054961826), "SdiasManager1", TO_UDINT(2118381352), "SdiasManager", 1$UINT, 97$UINT, 
(::SdiasPLC.SdiasHubBase1.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(1699155000), "SdiasHubBase1", TO_UDINT(4173303375), "SdiasHubBase", 1$UINT, 10$UINT, 
(::SdiasPLC.AutoFarMem.pCh)$UINT, _CH_CLT_DATA$UINT, 2#0000000000000110$UINT, TO_UDINT(3920576290), "AutoFarMem", 
END_FUNCTION


#define USER_CNT_SdiasPLC 2

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

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

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

	_memcpy((#vmt.CmdTable)$^USINT, BusInterfaceSDIASInternal::InterfaceState.pMeth, nCmdSize);
	vmt.CmdTable.nCmds		:= nSTDCMD + USER_CNT_SdiasPLC;
	vmt.CmdTable.NewInstr		:= #InterfaceState::NewInst();
	BusInterfaceSDIASInternal::InterfaceState.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF BusInterfaceSDIASInternal::InterfaceState.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	FirmwareVersion.pMeth			:= StoreMethod( #FirmwareVersion::Read(), #M_NO_F() );
	IF FirmwareVersion.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	ClassState.pMeth			:= StoreMethod( #ClassState::Read(), #M_NO_F() );
	IF ClassState.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	RetryCounter.pMeth			:= StoreMethod( #RetryCounter::Read(), #M_NO_F() );
	IF RetryCounter.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	IsoWrTaskDuration.pMeth			:= StoreMethod( #IsoWrTaskDuration::Read(), #M_NO_F() );
	IF IsoWrTaskDuration.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	IsoWrTaskMaxDuration.pMeth			:= StoreMethod( #IsoWrTaskMaxDuration::Read(), #IsoWrTaskMaxDuration::Write() );
	IF IsoWrTaskMaxDuration.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	IsoRdTaskDuration.pMeth			:= StoreMethod( #IsoRdTaskDuration::Read(), #M_NO_F() );
	IF IsoRdTaskDuration.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	IsoRdTaskMaxDuration.pMeth			:= StoreMethod( #IsoRdTaskMaxDuration::Read(), #IsoRdTaskMaxDuration::Write() );
	IF IsoRdTaskMaxDuration.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	ManagerOptionBits.pMeth			:= StoreMethod( #ManagerOptionBits::Read(), #M_NO_F() );
	IF ManagerOptionBits.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	ManagerProtocolVersion.pMeth			:= StoreMethod( #ManagerProtocolVersion::Read(), #M_NO_F() );
	IF ManagerProtocolVersion.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, SdiasOut_1.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #SdiasOut_1::Read();
	SdiasOut_1.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

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

END_FUNCTION

//{{LSL_IMPLEMENTATION


FUNCTION VIRTUAL GLOBAL SdiasPLC::FirmwareVersion::Read
	VAR_OUTPUT
		output (EAX) 	: HDINT;
	END_VAR

	FirmwareVersion := SdiasManager1.FirmwareVersion.Read();
	output := FirmwareVersion;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::ClassState::Read
	VAR_OUTPUT
		output (EAX) 	: t_e_VaranErrors;
	END_VAR

	ClassState := SdiasManager1.ClassState.Read();
	output := ClassState;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::RetryCounter::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	RetryCounter := SdiasManager1.RetryCounter.Read();
	output := RetryCounter;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::SdiasOut_1::Read
	VAR_OUTPUT
		output (EAX) 	: DINT;
	END_VAR

	SdiasOut_1 := SdiasHubBase1.ClassSvr.Read();
	output := SdiasOut_1;

END_FUNCTION

FUNCTION VIRTUAL GLOBAL SdiasPLC::InterfaceState::NewInst
	VAR_INPUT
		pPara 	: ^CmdStruct;
		pResult 	: ^Results;
	END_VAR
	VAR_OUTPUT
		ret_code 	: IprStates;
	END_VAR
  VAR
  	// local variables for the Requested HWTString
    pStr_HWTRequested     : ^CHAR;
  END_VAR

  pStr_HWTRequested := NIL;
  
  ret_code := READY;

  CASE pPara^.uiCmd OF
     
//**********************************************************************************************************************************************************
    CMD_GET_HARDWARE_DIAGNOSIS:
      
      ret_code := ERROR;
      pResult^.aData[0]$t_HWCGetHardwareDiagnosisOut.retcode := _HWC_RETVAL_ERROR;
      
      pStr_HWTRequested     := pPara^.aPara[0]$t_HWCGetHardwareDiagnosisIn.pStr_HardewareTreeEntry;
      
      if pStr_HWTRequested then
      
        // Check for SDIAS String
        if (pStr_HWTRequested)$^UINT^ = 2 then
          
          if (pStr_HWTRequested)$^UDINT^ = SDIASM_OBJECT_PATH then
            
            // Return OK, string was found
            ret_code  := READY;
            pResult^.aData$t_HWCGetHardwareDiagnosisOut.retcode       := _HWC_RETVAL_OK;
            
            pResult^.aData$t_HWCGetHardwareDiagnosisOut.ud_DeviceID   := SdiasManager1.DeviceID.Read();
            
            _itoa(udNumber := FirmwareVersion.Read(), pString := #a_StrFirmwareVersion[0]);  
            pResult^.aData$t_HWCGetHardwareDiagnosisOut.pStr_FWVersion := #a_StrFirmwareVersion[0];
            
          else
          
            // Length 2 and not the SDIAS HWT string is impossible
            ret_code := ERROR;
            pResult^.aData$t_HWCGetHardwareDiagnosisOut.retcode     := _HWC_RETVAL_ERROR_SDIAS_MODULE_NOT_FOUND;
            
          end_if;
          
          return;
        
        else
          // Pass on to base
          ret_code := BusInterfaceSDIASInternal::InterfaceState.NewInst(pPara, pResult);
        end_if;
      end_if;  

//**********************************************************************************************************************************************************
    CMD_GET_HARDWARE_TREE_ENTRY:
      
      ret_code := ERROR;
      pResult^.aData[0]$t_HWCGetHardwareTreeEntryOut.retcode := _HWC_RETVAL_ERROR_VARAN_MODULE_NOT_FOUND;     
     
      pStr_HWTRequested     := pPara^.aPara[0]$t_HWCGetHardwareDiagnosisIn.pStr_HardewareTreeEntry;
      
      //First HWT Path
      if pStr_HWTRequested = nil then
      
        ud_SDIASPosition := SDIASM_OBJECT_PATH;
      
        // Return String of the SDIASmanger
        ret_code := READY;
        pResult^.aData$t_HWCGetHardwareTreeEntryOut.retcode := _HWC_RETVAL_OK_HWTSTR_RETURNED;
        pResult^.aData[0]$t_HWCGetHardwareTreeEntryOut.pStr_NextHardewareTreeEntry := (#ud_SDIASPosition)$^CHAR;
      
      elsif (pStr_HWTRequested)$^UINT^ = 2 then
        
        if pStr_HWTRequested^$UDINT = SDIASM_OBJECT_PATH then
          // Set passed string to nil so that it is identified as the 1st module after the manager
          pPara^.aPara[0]$t_HWCGetHardwareDiagnosisIn.pStr_HardewareTreeEntry := nil;
          pPara^.aPara[0]$t_HWCGetHardwareDiagnosisIn.us_current_index := 4;  // Point to place after SDIAS ESC.
          ret_code := BusInterfaceSDIASInternal::InterfaceState.NewInst(pPara, pResult);
        end_if;
      else
        // Pass on to base
        pPara^.aPara[0]$t_HWCGetHardwareDiagnosisIn.us_current_index := 4;  // Point to place after SDIAS ESC.
        ret_code := BusInterfaceSDIASInternal::InterfaceState.NewInst(pPara, pResult);
      end_if;      

//**********************************************************************************************************************************************************    
    else
      ret_code := BusInterfaceSDIASInternal::InterfaceState.NewInst(pPara, pResult);
  END_CASE;
  
		
END_FUNCTION

FUNCTION VIRTUAL GLOBAL SdiasPLC::IsoWrTaskDuration::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	IsoWrTaskDuration := SdiasManager1.IsoWrTaskDuration.Read();
	output := IsoWrTaskDuration;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::IsoWrTaskMaxDuration::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	IsoWrTaskMaxDuration := SdiasManager1.IsoWrTaskMaxDuration.Read();
	output := IsoWrTaskMaxDuration;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::IsoWrTaskMaxDuration::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	IsoWrTaskMaxDuration := input;
	result := SdiasManager1.IsoWrTaskMaxDuration.Write(IsoWrTaskMaxDuration);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::IsoRdTaskDuration::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	IsoRdTaskDuration := SdiasManager1.IsoRdTaskDuration.Read();
	output := IsoRdTaskDuration;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::IsoRdTaskMaxDuration::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	IsoRdTaskMaxDuration := SdiasManager1.IsoRdTaskMaxDuration.Read();
	output := IsoRdTaskMaxDuration;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::IsoRdTaskMaxDuration::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	IsoRdTaskMaxDuration := input;
	result := SdiasManager1.IsoRdTaskMaxDuration.Write(IsoRdTaskMaxDuration);

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::ManagerOptionBits::Read
	VAR_OUTPUT
		output (EAX) 	: DINT;
	END_VAR

	ManagerOptionBits := SdiasManager1.ManagerOptionBits.Read();
	output := ManagerOptionBits;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL SdiasPLC::ManagerProtocolVersion::Read
	VAR_OUTPUT
		output (EAX) 	: HDINT;
	END_VAR

	ManagerProtocolVersion := SdiasManager1.ManagerProtocolVersion.Read();
	output := ManagerProtocolVersion;

END_FUNCTION
