//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               = "DiasMasterC"
	Revision           = "1.83"
	GUID               = "{B07083C4-51E6-11D6-B05D-0010609208CF}"
	RealtimeTask       = "true"
	DefRealtime        = "1 ms"
	DefRealtimeIndex   = "0"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "false"
	HighPriority       = "true"
	Automatic          = "false"
	UpdateMode         = "Postscan"
	IconPath           = ".\Class\DiasMasterC\toolbox.ICO"
	SharedCommandTable = "true"
	Objectsize         = "(546,120)"
	Comment            = "class for every CPU to communicate with DIAS and CDIAS hardwaremodules">
	<Channels>
		<Server
			Name           = "Chipstate"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "true"
			Comment        = "Errorstate of Bus and Risc ">
		</Server>
		<Server
			Name           = "Control"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "false">
		</Server>
		<Server
			Name           = "DIASRetryCounter"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "false"
			Comment        = "Retrys on diasbus">
		</Server>
		<Server
			Name           = "MasterON"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "true"
			Comment        = "1 = Master is running | 0 = Master is off">
		</Server>
		<Server
			Name           = "Release"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "true"
			Comment        = "IPC: Hardware and software release(Bit 0-15 Softwareversion, Bit16-31 Hardwareversion); CIPC: only one value for hardware and software release(Bit0-7); Release=16#FFFFFFFF (Fehler Master nicht vorhanden)">
		</Server>
		<Server
			Name           = "RiscState"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "true"
			Comment        = "State if realtime and cyclic is on/off&#13;&#10;Bit 0..3: Real time program on/off&#13;&#10;Bit 4..7: Cyclic program on/off">
		</Server>
		<Server
			Name           = "TimeAtRtPreEnd"
			Initialize     = "false"
			Visualized     = "true"
			WriteProtected = "true"
			Comment        = "Time between End of Rt-RISCC Programm and beginning user Rt-Programm">
		</Server>
		<Client Name="DiasMasterPostScan" Required="true" Internal="true"/>
		<Client Name="EEPROM" Required="true" Internal="true"/>
		<Client Name="I2CCDIAS" Required="true" Internal="true"/>
		<Client Name="SyncCall" Required="false" Internal="true"/>
		<Client Name="WatchdogDias0" Required="true" Internal="true"/>
	</Channels>
	<Dependencies>
		<Files>
			<File Path=".\Class\DiasMasterC\MasterSettings.h" Include="false"/>
		</Files>
	</Dependencies>
	<RevDoku>
		<Owner Company="Sigmatek" Author="AscFra"/>
		<Dokumentation Revision="1.83" Date="21.12.2020" Author="RamAnd" Company="Sigmatek" Description="On linux platforms there is no local DIAS/CDIAS therefore the class now doesn&apos;t try to initialize the local busses there anymore."/>
		<Dokumentation Revision="1.82" Date="05.08.2020" Author="FurDom" Company="Sigmatek" Description="changed in BaseClass (2.23 =&gt; 2.24); Tracelogging changed. Trace messages for timeslice errors and watchdog errors are set in the function WriteRTLogs() /CyWork."/>
		<Dokumentation Revision="1.81" Date="24.07.2018" Author="RamAnd" Company="Sigmatek" Description="Prevent required error crash when current target platform is LARS."/>
		<Dokumentation Revision="1.80" Date="19.07.2018" Author="EisMic" Company="Sigmatek" Description="Corrected duplicate realtimecall if class was used with HwControl and a realtime task time &gt;= 2ms was used. Concerns only CIPC and CCL9xx."/>
		<Dokumentation Revision="1.79" Date="18.09.2017" Author="LanSte" Company="Sigmatek" Description="Added NewInst Commands to check if the Post-Init is done."/>
		<Dokumentation Revision="1.78" Date="13.07.2017" Author="ZoePat" Company="Sigmatek" Description="Added WhoAmI=16#35 (ETV_Edge) to list of modules that trigger the CCLWatchdog."/>
		<Dokumentation Revision="1.77" Date="20.06.2016" Author="ZoePat" Company="Sigmatek" Description="Moved realtime logmessages to cyclic task to prevent possible rtruntime error."/>
		<Dokumentation Revision="1.76" Date="10.05.2016" Author="RamAnd" Company="Sigmatek" Description="Suppressed warning that would occur with target ARM on compiler version 30 or higher."/>
		<Dokumentation Revision="1.75" Date="09.07.2015" Author="PieSte" Company="Sigmatek" Description="Corrected cast for pointer at baseclass. Concerns only ARM cpu."/>
		<Dokumentation Revision="1.74" Date="28.10.2014" Author="RamAnd" Company="Sigmatek" Description="Stopped cyclic hardware class calls if an error has been reported by HwControl."/>
		<Dokumentation Revision="1.73" Date="02.10.2014" Author="LanSte" Company="Sigmatek" Description="Fixed compiler error when importing DiasMasterC without a HWControl in Project. The compiler error was caused by a missing type."/>
		<Dokumentation Revision="1.72" Date="11.07.2014" Author="LanSte" Company="Sigmatek" Description="Added support for reading hardware diagnosis."/>
		<Dokumentation Revision="1.71" Date="29.07.2014" Author="RamAnd" Company="Sigmatek" Description="DiasError is now also triggered for asynchron methods (direct accesses). Can be disabled with #define DIASMASTER_DISABLE_DIAS_ERROR_ON_DIRECT_ACCESS in DiasMasterMain.h."/>
		<Dokumentation Revision="1.70" Date="04.12.2013" Author="LanSte&#13;&#10;RamAnd" Company="Sigmatek" Description="AWL deactivated for ARM.&#13;&#10;Arraysize of OldRetryCounters was limited to 64, which is a problem if more than 64 modules are placed on DIAS (if place number is given at runtime)."/>
		<Dokumentation Revision="1.60" Date="16.02.2011" Author="BleErn" Company="Sigmatek" Description="Content of corresponding LASAL Hardware Description file (.lhd) which is necessary for the hardware editor has been updated"/>
		<Dokumentation Revision="1.59" Date="15.11.2010" Author="BleErn" Company="Sigmatek" Description="Moved headerfile MasterSettings.h from DiasMasterMain back to DiasMasterC"/>
		<Dokumentation Revision="1.58" Date="21.10.2010" Author="BleErn" Company="Sigmatek" Description="Removed client &quot;PreventMasterError&quot; which was a relict from development"/>
		<Dokumentation Revision="1.57" Date="15.10.2010" Author="RamAnd" Company="Sigmatek" Description="Added method AddMovDO for the move command in the VM."/>
		<Dokumentation Revision="1.56" Date="24.08.2010" Author="BleErn / RamAnd" Company="Sigmatek" Description="Version check of OS-Methods for CDIAS access was wrong. &#13;&#10;Corrected comment of Server Rt_Load."/>
		<Dokumentation Revision="1.55" Date="23.06.2010" Author="WocPet" Company="Sigmatek" Description="changes in base class :&#13;&#10;Added functionality to write retry-counter values to classes if we are intelligent master,&#13;&#10;also set class state server to 16#ffff if MasterOn ist zero&#13;&#10;New client &quot;PreventMasterError&quot; added"/>
		<Dokumentation Revision="1.54" Date="13.07.2010" Author="BleErn" Company="Sigmatek" Description="Content of corresponding LASAL Hardware Description file (.lhd) which is necessary for the hardware editor has been corrected"/>
		<Dokumentation Revision="1.53" Date="03.03.2010" Author="BleErn" Company="Sigmatek" Description="Added RtPostScan functionality"/>
		<Dokumentation Revision="1.52" Date="01.03.2010" Author="RamAnd" Company="Sigmatek" Description="Support for Edge CPUs added"/>
		<Dokumentation Revision="1.51" Date="15.07.2009" Author="RamAnd" Company="Sigmatek" Description="Changes in BaseClass (1.61 =&gt; 1.62)"/>
		<Dokumentation Revision="1.50" Date="18.02.2009" Author="RamAnd" Company="Sigmatek" Description="Changes in BaseClass (1.60 =&gt; 1.61)"/>
	</RevDoku>
	<Network Name="DiasMasterC">
		<!-- List of Components in this network -->
		<Components>
			<Object
				Name       = "_base"
				GUID       = "{C0AFB24B-0D6C-48DD-ACB6-82622349FA4B}"
				Class      = "DiasMasterMain"
				Position   = "(630,420)"
				Visualized = "true"
				RealTime   = "1 ms">
				<Channels>
					<Server Name="Chipstate"/>
					<Server Name="Control"/>
					<Server Name="CyTimeIM_us"/>
					<Server Name="DIASRetryCounter"/>
					<Server Name="HwControl"/>
					<Server Name="MasterON"/>
					<Server Name="Release"/>
					<Server Name="RiscState"/>
					<Server Name="Rt_Load"/>
					<Server Name="RtTimeIM_us"/>
					<Server Name="TimeAtRtPreEnd"/>
					<Client Name="RtDebug"/>
					<Client Name="SyncCall"/>
					<Client Name="To_HwControl"/>
					<Client Name="To_Multitask"/>
					<Client Name="To_OSKernel"/>
					<Client Name="To_StdLib"/>
					<Client Name="To_TaskObjectControl"/>
					<Client Name="WaitSync"/>
				</Channels>
			</Object>
			<Object
				Name       = "DiasMasterPostScan"
				GUID       = "{EFD87804-BE03-4B0D-BF0F-ABC07ADFDEEF}"
				Class      = "DiasMasterPostScan"
				Position   = "(420,1200)"
				Visualized = "true"
				CyclicTime = "always">
				<Channels>
					<Server Name="Server0"/>
					<Client Name="MasterConnect"/>
				</Channels>
			</Object>
			<Object
				Name       = "EEPROM"
				GUID       = "{99B539E7-7156-4166-B447-BBC4AEC3B5CD}"
				Class      = "EEPROM"
				Position   = "(210,990)"
				Visualized = "true">
				<Channels>
					<Server Name="Server0"/>
					<Client Name="MasterConnect"/>
				</Channels>
			</Object>
			<Object
				Name       = "I2CCDIAS"
				GUID       = "{2CC95891-6E7F-48C0-BAF4-0364C161BFE1}"
				Class      = "I2CCDIAS"
				Position   = "(240,720)"
				Visualized = "true">
				<Channels>
					<Server Name="Control"/>
					<Client Name="MasterConnect"/>
					<Client Name="To_OSKernel"/>
				</Channels>
			</Object>
			<Object
				Name       = "SyncCall"
				GUID       = "{A6AE7BF5-D52F-42BB-A0CA-A2D976637369}"
				Class      = "SyncCall"
				Position   = "(1020,1170)"
				Visualized = "true">
				<Channels>
					<Server Name="State"/>
					<Client Name="MasterConnect"/>
					<Client Name="Place" Value="0"/>
				</Channels>
			</Object>
			<Object
				Name       = "WatchdogDias0"
				GUID       = "{3C9B5AF9-BEED-4D0F-856C-614C36D23D0C}"
				Class      = "WatchdogDias"
				Position   = "(240,480)"
				Visualized = "true">
				<Channels>
					<Server Name="State"/>
					<Client Name="MasterConnect"/>
					<Client Name="Place" Value="0"/>
				</Channels>
			</Object>
		</Components>
		<Comments>
		</Comments>
		<!-- List of Connections in this network -->
		<Connections>
			<Connection Source="this.Control" Destination="_base.Control" Vertices="(1492,210),(930,510),"/>
			<Connection Source="this.Release" Destination="_base.Release" Vertices="(1492,270),(930,570),"/>
			<Connection Source="this.Chipstate" Destination="_base.Chipstate" Vertices="(1492,330),(930,630),"/>
			<Connection Source="this.RiscState" Destination="_base.RiscState" Vertices="(1492,390),(930,690),"/>
			<Connection Source="this.TimeAtRtPreEnd" Destination="_base.TimeAtRtPreEnd" Vertices="(1492,450),(930,750),"/>
			<Connection Source="this.DIASRetryCounter" Destination="_base.DIASRetryCounter" Vertices="(1492,510),(930,810),"/>
			<Connection Source="this.MasterON" Destination="_base.MasterON" Vertices="(1492,570),(930,870),"/>
			<Connection Source="_base.WaitSync" Destination="this.WaitSync" Vertices="(630,570),(38,210),"/>
			<Connection Source="DiasMasterPostScan.MasterConnect" Destination="_base.Control" Vertices="(420,1290),(930,510),"/>
			<Connection Source="EEPROM.MasterConnect" Destination="_base.Control" Vertices="(210,1080),(930,510),"/>
			<Connection Source="I2CCDIAS.MasterConnect" Destination="_base.Control" Vertices="(240,810),(930,510),"/>
			<Connection Source="WatchdogDias0.MasterConnect" Destination="_base.Control" Vertices="(240,570),(930,510),"/>
			<Connection Source="SyncCall.MasterConnect" Destination="_base.Control" Vertices="(1020,1260),(930,510),"/>
			<Connection Source="_base.SyncCall" Destination="SyncCall.State" Vertices="(630,630),(1320,1260),"/>
			<Connection Source="this.Rt_Load" Destination="_base.Rt_Load" Vertices="(1492,630),(930,930),"/>
			<Connection Source="_base.RtDebug" Destination="this.RtDebug" Vertices="(630,690),(38,270),"/>
			<Connection Source="this.HwControl" Destination="_base.HwControl" Vertices="(1492,810),(930,1110),"/>
			<Connection Source="_base.To_HwControl" Destination="this.To_HwControl" Vertices="(630,750),(38,330),"/>
			<Connection Source="this.DiasMasterPostScan" Destination="DiasMasterPostScan.Server0"/>
			<Connection Source="this.EEPROM" Destination="EEPROM.Server0"/>
			<Connection Source="this.I2CCDIAS" Destination="I2CCDIAS.Control"/>
			<Connection Source="this.WatchdogDias0" Destination="WatchdogDias0.State"/>
			<Connection Source="this.RtTimeIM_us" Destination="_base.RtTimeIM_us" Vertices="(1492,690),(930,990),"/>
			<Connection Source="this.CyTimeIM_us" Destination="_base.CyTimeIM_us" Vertices="(1492,750),(930,1050),"/>
		</Connections>
		<!-- Headerfiles -->
		<Options>
		</Options>
	</Network>
</Class>
*)
#pragma using DiasMasterMain

DiasMasterC : CLASS
: DiasMasterMain
  //Servers:
  //Clients:
	DiasMasterPostScan 	: CltChCmd_DiasMasterPostScan;
	EEPROM 	: CltChCmd_EEPROM;
	I2CCDIAS 	: CltChCmd_I2CCDIAS;
	WatchdogDias0 	: CltChCmd_WatchdogDias;
	virtual SyncCall 	: CltChCmd_SyncCall;
  //Variables:
  //Functions:
	
	FUNCTION VIRTUAL GLOBAL ReadEEData
		VAR_INPUT
			Adress 	: UDINT;
			pData 	: ^USINT;
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;
		END_VAR;
				//! <Function Comment="[#ENGLISH]&#13;&#10;read one Byte from C-DIAS bus on Board&#13;&#10;" Name="I2CReadOneByte"/>
	FUNCTION VIRTUAL GLOBAL I2CReadOneByte
		VAR_INPUT
			AdressCDIAS 	: UINT;
			pData 	: ^USINT;
		END_VAR
		VAR_OUTPUT
			result 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL I2CWriteOneByte
		VAR_INPUT
			AdressCDIAS 	: UINT;
			pData 	: ^USINT;
		END_VAR
		VAR_OUTPUT
			result 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL WriteEEData
		VAR_INPUT
			Adress 	: UDINT;
			pData 	: ^USINT;
			ui_length 	: UINT;
			ui_offset 	: UINT;
		END_VAR
		VAR_OUTPUT
			retval 	: DINT;
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

#pragma using DiasMasterPostScan
#pragma using EEPROM
#pragma using I2CCDIAS
#pragma using SyncCall
#pragma using WatchdogDias


//}}LSL_DECLARATION


FUNCTION GLOBAL TAB DiasMasterC::@CT_
0$UINT,
2#0010000000000000$UINT, //TY_DIASMASTERC
1$UINT, 83$UINT, (SIZEOF(::DiasMasterC))$UINT, 
0$UINT, 5$UINT, 0$UINT, 
TO_UDINT(3069482179), "DiasMasterC", //Class
TO_UDINT(3792535737), "DiasMasterMain", 2$UINT, 25$UINT, //Baseclass
//Servers:
//Clients:
(::DiasMasterC.DiasMasterPostScan.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(3076475114), "DiasMasterPostScan", TO_UDINT(3076475114), "DiasMasterPostScan", 1$UINT, 0$UINT, 
(::DiasMasterC.EEPROM.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(2784851678), "EEPROM", TO_UDINT(2784851678), "EEPROM", 1$UINT, 11$UINT, 
(::DiasMasterC.I2CCDIAS.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(2326720416), "I2CCDIAS", TO_UDINT(2326720416), "I2CCDIAS", 1$UINT, 6$UINT, 
(::DiasMasterC.WatchdogDias0.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(2287664271), "WatchdogDias0", TO_UDINT(1573657038), "WatchdogDias", 2$UINT, 11$UINT, 
(::DiasMasterC.SyncCall.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000000$UINT, TO_UDINT(4187542331), "SyncCall", TO_UDINT(4187542331), "SyncCall", 1$UINT, 21$UINT, 
END_FUNCTION


#define USER_CNT_DiasMasterC 71

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

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

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

	_memcpy((#vmt.CmdTable)$^USINT, DiasMaster::Control.pMeth, nCmdSize);
	vmt.CmdTable.nCmds		:= nSTDCMD + USER_CNT_DiasMasterC;
#pragma warning (disable : 74)
	vmt.UserFcts[18]		:= #ReadEEData();

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

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

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

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

	IF DiasMaster::Control.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	DIASRetryCounter.pMeth			:= StoreMethod( DIASRetryCounter.pMeth^.pRd, #M_WR_DIRECT() );
	IF DIASRetryCounter.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;

END_FUNCTION

//{{LSL_IMPLEMENTATION
(**********************************************************************************
*
*	Class to control Dias- and CDias-Bus on all target platforms
*	Created : Sigmatek / 2003
*	Changes :
*
*
*   FOR NEWER CHANGES SEE REVISION DOCUMENTATION IN CLASS PROPERTIES
*
*
*		1.48 => 1.49	/	16.10.2007	/	Mark:	//#SR000
*			- [DB 707]: remove offset restriction in function WriteEEData
*		1.47 => 1.48	/	16.03.2007	/	Mark:	//#SR000
*			- [DB 528]: insert functions to write to cdias eeprom
*			- Changes in base class DiasMasterMain => 1.55
*		1.46 => 1.47
*			Changes in base class DiasMasterMain => 1.54
*		1.45 => 1.46
*			Changes in base class DiasMasterMain => 1.51
*		1.43 => 1.45
*			Changes in base class DiasMasterMain => 1.51
*		1.43 => 1.44
*			Changes in base class DiasMasterMain => 1.49
*		1.42 => 1.43
*			Changes in base class DiasMasterMain => 1.47
*			change define OSVersionDIASIO back to 16#1150 (was bug in Display_DET081)
*		1.41 => 1.42	/	24.02.2006	/	no Mark
*			change define OSVersionDIASIO to 16#FFFF
*		1.40 => 1.41	/	10.02.2006	/	no Mark
*			Changes in base class DiasMasterMain => 1.46
*		1.39 => 1.40	/	22.11.2005	/	no Mark
*			Changes in base class DiasMasterMain => 1.44
*		1.38 => 1.39	/	22.11.2005	/	noMark
*			Changes in base class DiasMasterMain => 1.42
*		1.37 => 1.38	/	25.10.2005	/ 	no Mark
*			Changes in base class DiasMasterMain => 1.40
*		1.36 => 1.37	/	24.10.2005	/ 	no Mark
*			Changes in base class DiasMasterMain => 1.39
*		1.35 => 1.36	/	11.10.2005	/ 	no Mark
*			Changes in class EEPROM
*		1.34 => 1.35	/	30.09.2005	/	no Mark
*			Changes in base class DiasMasterMain => 1.38
*		1.33 => 1.34	/	30.08.2005	/	no Mark
*			Changes in base class DiasMasterMain => 1.37
*		1.32 => 1.33	/	31.05.2005	/	no Mark
*			Changes in base class DiasMasterMain => 1.35
*			add Methods IRQScan and AddIRQScan for intelligent master
*		1.31 => 1.32 / 21.04.2005 / no Mark / ws
*			Changes in base class DiasMasterMain
*		1.30 => 1.31	/	31.03.2005	/	no Mark
*			added some Error questioning for intelligent Master program
*			splitt IM - Memory half for realtime and half for cyclic (old was: cyclic 1/4 and realtime 3/4) 
*			Change 1.32 => 1.33 of Class DiasMasterMain
*		1.29 => 1.30	/	22.03.2005	/	no Mark
*			make compatible to 200us CIPC (have to activate #define DiasMaster200us in MasterSettings.h)
*			add class SyncCall to make a sync every 1ms at a Realtime of 200µs
*			Change 1.31 => 1.32 of Class DiasMasterMain
*		1.28 => 1.29	/	08.05.2005	/	no Mark
*			make compatible with CCL081 (changes in base class)
*		1.27 => 1.28	/	21.01.2005
*			Do not use the #define TEMPMAX (cable breech in temperature measurement modules) anymore
*			Set a client at the respective modules instead!
*		1.26 => 1.27	/	11.01.2005	
*			Change 1.28 => 1.29 of Class DiasMasterMain
*		0.26 => 1.26 / 23.12.2004 / no Mark / ws
*			compatibility with Lasal Class 2
*			removed visible flags from internal servers
*		0.25 => 0.26	/	27.11.2004	
*			Change 0.27 => 0.28 of Class - DiasMasterMain
*		0.24 => 0.25
*			Change 0.26 => 0.27 of Class DiasMasterMain 
*			Change 0.6 => 0.7 of Class WatchdogDias
*			Now there is a define to set the watchdogtime to max (DiasMasterC\MasterSettings.h "define MaxWatchdog")
*			The retrycounter didn't work correct
*		0.23 => 0.24
*			Change 0.25 => 0.26 of Class DiasMasterMain 
*		0.22 => 0.23
*			Change 0.24 => 0.25 of Class DiasMasterMain 
*		0.21 => 0.22
*			Change 0.2 => 0.3 of Class - I2CCDIAS
*			Change 0.23 => 0.24 of Class DiasMasterMain 
*		0.20 => 0.21
*			Change 0.22 => 0.23 of Class - DiasMasterMain
*		0.19 => 0.20
*			Change 0.5 => 0.6 of Class WatchdogDias
*		0.18 => 0.19
*			Change 0.21 => 0.22 of Class - DiasMasterMain
*		0.17 => 0.18
*			Change 0.20 => 0.21 of Class - DiasMasterMain
*		0.16 => 0.17
*			Change 0.19 => 0.20 of Class - DiasMasterMain
*		0.15 => 0.16
*			Change 0.18 => 0.19 of Class - DiasMasterMain
*		0.14 => 0.15
*			Change 0.17 => 0.18 of Class - DiasMasterMain
*		0.13 => 0.14
*			Change 0.16 => 0.17 of Class - DiasMasterMain
*		0.12 => 0.13
*			Change 0.15 => 0.16 of Class - DiasMasterMain
*		0.11 => 0.12
*			Change 0.14 => 0.15 of Class - DiasMasterMain
*		0.10 => 0.11
*			Change 0.13 => 0.14 of Class - DiasMasterMain
*
*
**********************************************************************************)

//[#ENGLISH]
//read one Byte from C-DIAS bus on Board
FUNCTION VIRTUAL GLOBAL DiasMasterC::I2CReadOneByte
VAR_INPUT
	AdressCDIAS		: UINT;
	pData		: ^USINT;
END_VAR
VAR_OUTPUT
	result		: DINT;
END_VAR

	result := I2CCDIAS.I2CReadOneByte(AdressCDIAS, pData);

END_FUNCTION //VIRTUAL GLOBAL DiasMasterC::I2CReadOneByte

FUNCTION VIRTUAL GLOBAL DiasMasterC::ReadEEData
VAR_INPUT
	Adress		: UDINT;
	pData		: ^USINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR
VAR
	i : UDINT;
END_VAR

	Adress := Adress*16#100; // because it is always the place 
	for i := 0 to 255 do 
     retval:= I2CCDIAS.I2CReadOneByte(Adress$UINT, pData);
	 pData +=1;
	 Adress +=1;
	end_for;

END_FUNCTION //VIRTUAL GLOBAL DiasMasterC::ReadEEData

FUNCTION VIRTUAL GLOBAL DiasMasterC::I2CWriteOneByte			//#SR000
VAR_INPUT
	AdressCDIAS		: UINT;
	pData		: ^USINT;
END_VAR
VAR_OUTPUT
	result		: DINT;
END_VAR

	result := I2CCDIAS.I2CWriteOneByte(AdressCDIAS, pData);

END_FUNCTION //VIRTUAL GLOBAL DiasMasterC::I2CWriteOneByte

FUNCTION VIRTUAL GLOBAL DiasMasterC::WriteEEData				//#SR000
VAR_INPUT
	Adress		: UDINT;
	pData		: ^USINT;
	ui_length	: UINT;
	ui_offset	: UINT;
END_VAR
VAR_OUTPUT
	retval		: DINT;
END_VAR
VAR
	i : UDINT;
END_VAR

	//look for length
	if ( ui_length + ui_offset > 16#100 ) then
		retval := -2;
		return;
	end_if;
	
	//look for length
	if ( ui_offset > 16#FF ) then		//#SR001 (Offset restriction from 16#80 to 16#FF is in OS )
		retval := -3;
		return;
	end_if;
		
	Adress := Adress * 16#100 + ui_offset; // because it is always the place 
	for i := 0 to ui_length - 1 do 
		retval:= I2CCDIAS.I2CWriteOneByte( Adress$UINT, pData );
		pData += 1;
		Adress += 1;
	end_for;

END_FUNCTION //VIRTUAL GLOBAL DiasMasterC::WriteEEData

