//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
#include "..\..\Class\MDD2000MngBase\MDD2000MngBase.h"

(*!
<Class
	Name               = "MDD2000_MngInfo"
	Revision           = "1.0"
	GUID               = "{933AA8ED-B968-462A-A8F8-134E6369B046}"
	RealtimeTask       = "false"
	CyclicTask         = "false"
	BackgroundTask     = "false"
	Sigmatek           = "true"
	OSInterface        = "false"
	HighPriority       = "false"
	Automatic          = "false"
	UpdateMode         = "Prescan"
	IconPath           = ".\Class\MDD2000_Mng\MDD2000SafetyDrive.ico"
	SharedCommandTable = "true"
	Objectsize         = "(780,1200)"
	Comment            = "This class provides different informations of the MDD2000 module.">
	<Channels>
		<Server Name="ChangeServiceMode" GUID="{31AFA1A4-6355-48C6-89F6-306A153031FD}" Visualized="true" Initialize="false" WriteProtected="false" Retentive="false" Comment="Reqeust an change to SafetyRunState to enter or to leave the service mode&#13;&#10;1 .. Enter service mode&#13;&#10;2 .. Leave service mode"/>
		<Server Name="FWDateDrive" GUID="{BDCD82BC-585E-4329-B922-3AB2CD712A50}" Class="String" Visualized="true" Initialize="true" WriteProtected="false" Retentive="false" Comment="Shows the firmware date of the drive as string"/>
		<Server Name="FWDateSafety" GUID="{A34E4263-A78B-4FDA-81E5-1A38379F709B}" Class="String" Visualized="true" Initialize="true" WriteProtected="false" Retentive="false" Comment="Shows the build date of the safety firmware."/>
		<Server Name="FwVersionDrive" GUID="{8497DA02-FB03-44F1-AD46-B6FB5977004B}" Class="String" Visualized="true" Initialize="true" WriteProtected="false" Retentive="false" Comment="Shows the firmware version of the drive as string"/>
		<Server Name="FwVersionSafety" GUID="{58141157-1FF1-4B63-AB2F-41548E4D2C15}" Class="String" Visualized="true" Initialize="true" WriteProtected="false" Retentive="false" Comment="Shows the firmware version of the safety controllers."/>
		<Server Name="Hash" GUID="{56BD6B70-4BD9-4313-BE56-C8F9B85A7E24}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the GIT hash of the safety firmware."/>
		<Server Name="SafetyCompilationCRC" GUID="{5039F10C-336E-493C-A1AB-DA7E3AAE3A77}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="CRC of compilation, CRC is calculated of the whole Drive configuration. (Hardware paths, parameters of the Drive... )"/>
		<Server Name="SafetyConfigName" GUID="{136344D1-8476-4133-B455-5F43CE3A4501}" Class="String" Visualized="true" Initialize="true" WriteProtected="false" Retentive="false" Comment="Shows the name of the safety configuration."/>
		<Server Name="SafetyConfigRevision" GUID="{2DB5C81B-A096-444C-9025-67A28A1E9DEC}" Class="String" Visualized="true" Initialize="true" WriteProtected="false" Retentive="false" Comment="Shows the revision of the safety configuration."/>
		<Server Name="SafetyConfigState" GUID="{D167C6E8-6822-4EA8-93EA-D32672E69E22}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the safety config state of the module."/>
		<Server Name="SafetyDriveCRC" GUID="{4F869134-32A0-4CB0-A0E7-32A6DB641BC8}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="CRC of the Drive parameters, CRC is calculated over the parameters of the Drive"/>
		<Server Name="SafetyNumber" GUID="{661DBB5E-28D8-4EB5-BAAE-14B48B57FAA6}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the unique safetynumber of the module."/>
		<Server Name="SafetyRunState" GUID="{E611E296-757A-493C-B210-8D5F3A69AE5C}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the safety runstate of the module."/>
		<Server Name="SafetySubRunState" GUID="{337E670A-DCC4-4AB2-BA7C-F3CD77CF1ED3}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the safety sub runstate of the module."/>
		<Server Name="SC1_CRC" GUID="{1DCAF8B4-B2F7-442B-AE1E-7E2D0BD4BC05}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the CRC of the safety firmware from safety controller 1."/>
		<Server Name="SC2_CRC" GUID="{CF090B56-1B78-4DE0-903E-CFD6445EA756}" Visualized="true" Initialize="false" WriteProtected="true" Retentive="false" Comment="Shows the CRC of the safety firmware from safety controller 2."/>
		<Client Name="strFWBuildDate" Required="true" Internal="true"/>
		<Client Name="strFWVersion" Required="true" Internal="true"/>
		<Client Name="strSafetyConfigName" Required="true" Internal="true"/>
		<Client Name="strSafetyConfigRevision" Required="true" Internal="true"/>
		<Client Name="strSafetyFWBuildDate" Required="true" Internal="true"/>
		<Client Name="strSafetyFWVersion" Required="true" Internal="true"/>
	</Channels>
	<Separators>
		<Servers>
			<SepChn Position="0"/>
			<SepChn Position="3"/>
			<SepChn Position="9"/>
		</Servers>
	</Separators>
	<Dependencies>
		<Files>
			<File Path=".\Class\MDD2000MngBase\MDD2000MngBase.h" Include="true"/>
		</Files>
	</Dependencies>
	<RevDoku>
		<Owner Company="Sigmatek" Author="LanSte"/>
		<Dokumentation Revision="1.0" Date="28.08.2023" Author="LanSte" Company="Sigmatek" Description="First library version."/>
	</RevDoku>
	<Network Name="MDD2000_MngInfo">
		<!-- List of Components in this network -->
		<Components>
			<Object
				Name       = "_base"
				GUID       = "{88DF65F1-296D-40AF-97D4-E4A47AC368DA}"
				Class      = "_DriveSafetyIFParaBase"
				Position   = "(218,120)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="ErrorQuit"/>
					<Server Name="State"/>
					<Client Name="DriveIF"/>
					<Client Name="ErrorCode"/>
					<Client Name="UpdateCyTime" Value="100"/>
				</Channels>
			</Object>
			<Object
				Name       = "strFWBuildDate"
				GUID       = "{EA5631BE-6666-458A-A20D-C61858F00607}"
				Class      = "String"
				Position   = "(210,540)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="Data"/>
					<Client Name="SingleRealloc" Value="1"/>
				</Channels>
			</Object>
			<Object
				Name       = "strFWVersion"
				GUID       = "{410A5CFD-BB71-4577-85DF-2D29C7C4324E}"
				Class      = "String"
				Position   = "(210,390)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="Data"/>
					<Client Name="SingleRealloc" Value="1"/>
				</Channels>
			</Object>
			<Object
				Name       = "strSafetyConfigName"
				GUID       = "{68A64D00-09A2-4FBF-9EC6-AA2D7492FF63}"
				Class      = "String"
				Position   = "(210,1020)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="Data"/>
					<Client Name="SingleRealloc" Value="1"/>
				</Channels>
			</Object>
			<Object
				Name       = "strSafetyConfigRevision"
				GUID       = "{9B5A1984-B245-41A0-BB45-8A90C405A273}"
				Class      = "String"
				Position   = "(210,1200)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="Data"/>
					<Client Name="SingleRealloc" Value="1"/>
				</Channels>
			</Object>
			<Object
				Name       = "strSafetyFWBuildDate"
				GUID       = "{BFC1465D-E82F-4312-B982-1E98A3012360}"
				Class      = "String"
				Position   = "(210,870)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="Data"/>
					<Client Name="SingleRealloc" Value="1"/>
				</Channels>
			</Object>
			<Object
				Name       = "strSafetyFWVersion"
				GUID       = "{8F453D4E-89BE-4423-BFC7-3A3F3DF3B8E9}"
				Class      = "String"
				Position   = "(210,720)"
				Visualized = "true"
				Remotely   = "true">
				<Channels>
					<Server Name="Data"/>
					<Client Name="SingleRealloc" Value="1"/>
				</Channels>
			</Object>
		</Components>
		<Comments>
		</Comments>
		<!-- List of Connections in this network -->
		<Connections>
			<Connection Source="this.State" Destination="_base.State" Vertices="(740,210),(568,210),"/>
			<Connection Source="this.ErrorQuit" Destination="_base.ErrorQuit" Vertices="(740,270),(568,270),"/>
			<Connection Source="_base.DriveIF" Destination="this.DriveIF" Vertices="(218,210),(38,210),"/>
			<Connection Source="_base.ErrorCode" Destination="this.ErrorCode" Vertices="(218,270),(38,270),"/>
			<Connection Source="this.strFWVersion" Destination="strFWVersion.Data"/>
			<Connection Source="this.strFWBuildDate" Destination="strFWBuildDate.Data"/>
			<Connection Source="this.FwVersionDrive" Destination="strFWVersion.Data" Vertices="(740,390),(526,480),"/>
			<Connection Source="this.FWDateDrive" Destination="strFWBuildDate.Data" Vertices="(740,450),(526,630),"/>
			<Connection Source="this.strSafetyFWVersion" Destination="strSafetyFWVersion.Data"/>
			<Connection Source="this.strSafetyFWBuildDate" Destination="strSafetyFWBuildDate.Data"/>
			<Connection Source="this.FwVersionSafety" Destination="strSafetyFWVersion.Data" Vertices="(740,510),(526,810),"/>
			<Connection Source="this.FWDateSafety" Destination="strSafetyFWBuildDate.Data" Vertices="(740,570),(526,960),"/>
			<Connection Source="_base.UpdateCyTime" Destination="this.UpdateCyTime" Vertices="(218,330),(38,330),"/>
			<Connection Source="this.strSafetyConfigName" Destination="strSafetyConfigName.Data"/>
			<Connection Source="this.SafetyConfigName" Destination="strSafetyConfigName.Data" Vertices="(740,1170),(526,1110),"/>
			<Connection Source="this.strSafetyConfigRevision" Destination="strSafetyConfigRevision.Data"/>
			<Connection Source="this.SafetyConfigRevision" Destination="strSafetyConfigRevision.Data" Vertices="(740,1230),(526,1290),"/>
		</Connections>
		<!-- Headerfiles -->
		<Options>
		</Options>
	</Network>
</Class>
*)
#pragma using _DriveSafetyIFParaBase

MDD2000_MngInfo : CLASS
: _DriveSafetyIFParaBase
  //Servers:
	FwVersionDrive 	: SvrChCmd_UDINT;
	FWDateDrive 	: SvrChCmd_UDINT;
	FwVersionSafety 	: SvrChCmd_UDINT;
	FWDateSafety 	: SvrChCmd_UDINT;
	Hash 	: SvrCh_HDINT;
	SC1_CRC 	: SvrCh_HDINT;
	SC2_CRC 	: SvrCh_HDINT;
	SafetyNumber 	: SvrCh_HDINT;
	SafetyRunState 	: SvrCh_t_e_MDD2000SafetyRunState_PTofCls_MDD2000MngBase;
	SafetySubRunState 	: SvrCh_t_e_MDD2000SafetySubRunState_PTofCls_MDD2000MngBase;
	SafetyConfigState 	: SvrCh_t_e_MDD2000SafetyConfigState_PTofCls_MDD2000MngBase;
	SafetyCompilationCRC 	: SvrCh_HDINT;
	SafetyDriveCRC 	: SvrCh_HDINT;
	SafetyConfigName 	: SvrChCmd_UDINT;
	SafetyConfigRevision 	: SvrChCmd_UDINT;
	ChangeServiceMode 	: SvrCh_DINT;
  //Clients:
	strSafetyFWVersion 	: CltChCmd_String;
	strFWBuildDate 	: CltChCmd_String;
	strFWVersion 	: CltChCmd_String;
	strSafetyFWBuildDate 	: CltChCmd_String;
	strSafetyConfigName 	: CltChCmd_String;
	strSafetyConfigRevision 	: CltChCmd_String;
  //Variables:
		TempCfgName : ARRAY [0..35] OF CHAR;

  //Functions:
	
	FUNCTION VIRTUAL GLOBAL Init;
	
	FUNCTION VIRTUAL GLOBAL RefreshPara
		VAR_INPUT
			hParaIndex 	: HINT;
			hsParaSubIndex 	: HSINT;
			bRW 	: DINT;
			bsDataInfo 	: BSINT;
			pValue 	: ^DINT;
		END_VAR;
	
	FUNCTION VIRTUAL GeneralReady;
	
	FUNCTION VIRTUAL GLOBAL UpdateCy
		VAR_INPUT
			StateInfo 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL SafetyReady
		VAR_INPUT
			StateInfo 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL SafetyError
		VAR_INPUT
			StateInfo 	: DINT;
		END_VAR;
	
	FUNCTION VIRTUAL SafetyChanged
		VAR_INPUT
			StateInfo 	: DINT;
		END_VAR;
	
	FUNCTION Bin2Ascii
		VAR_INPUT
			pt 	: ^CHAR;
			value 	: DINT;
			format 	: BINT;
		END_VAR;
	
	FUNCTION SetFwVersion
		VAR_INPUT
			FwVersionInt 	: DINT;
			StringSelect 	: DINT;
		END_VAR;
	
	FUNCTION SetFwDate
		VAR_INPUT
			FWDateInt 	: UDINT;
			StringSelect 	: DINT;
		END_VAR;
	
	FUNCTION SetFwTime;
	
	FUNCTION VIRTUAL GLOBAL FwVersionDrive::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FwVersionDrive::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FWDateDrive::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FWDateDrive::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FwVersionSafety::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FwVersionSafety::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FWDateSafety::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL FWDateSafety::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL SafetyConfigName::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL SafetyConfigName::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL SafetyConfigRevision::Read
		VAR_OUTPUT
			output (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL SafetyConfigRevision::Write
		VAR_INPUT
			input (EAX) 	: UDINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: UDINT;
		END_VAR;
	
	FUNCTION VIRTUAL GLOBAL ChangeServiceMode::Write
		VAR_INPUT
			input (EAX) 	: DINT;
		END_VAR
		VAR_OUTPUT
			result (EAX) 	: DINT;
		END_VAR;
  //Tables:
	FUNCTION @STD
		VAR_OUTPUT
			ret_code	: CONFSTATES;
		END_VAR;
	FUNCTION GLOBAL TAB @CT_;
END_CLASS;

#pragma using String


//}}LSL_DECLARATION


FUNCTION GLOBAL TAB MDD2000_MngInfo::@CT_
0$UINT,
2#0100000000000000$UINT, //TY_MDD2000_MNGINFO
1$UINT, 0$UINT, (SIZEOF(::MDD2000_MngInfo))$UINT, 
16$UINT, 6$UINT, 0$UINT, 
TO_UDINT(4173214021), "MDD2000_MngInfo", //Class
TO_UDINT(1914213293), "_DriveSafetyIFParaBase", 1$UINT, 0$UINT, //Baseclass
//Servers:
(::MDD2000_MngInfo.FwVersionDrive.pMeth)$UINT, _CH_SVR_OBJ$UINT, 2#0000000001000000$UINT, TO_UDINT(1995891270), "FwVersionDrive", 
(::MDD2000_MngInfo.FWDateDrive.pMeth)$UINT, _CH_SVR_OBJ$UINT, 2#0000000001000000$UINT, TO_UDINT(3114269008), "FWDateDrive", 
(::MDD2000_MngInfo.FwVersionSafety.pMeth)$UINT, _CH_SVR_OBJ$UINT, 2#0000000001000000$UINT, TO_UDINT(1932912004), "FwVersionSafety", 
(::MDD2000_MngInfo.FWDateSafety.pMeth)$UINT, _CH_SVR_OBJ$UINT, 2#0000000001000000$UINT, TO_UDINT(2267953614), "FWDateSafety", 
(::MDD2000_MngInfo.Hash.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(3878522636), "Hash", 
(::MDD2000_MngInfo.SC1_CRC.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(473351729), "SC1_CRC", 
(::MDD2000_MngInfo.SC2_CRC.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(1536605409), "SC2_CRC", 
(::MDD2000_MngInfo.SafetyNumber.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(2430374202), "SafetyNumber", 
(::MDD2000_MngInfo.SafetyRunState.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(1037834220), "SafetyRunState", 
(::MDD2000_MngInfo.SafetySubRunState.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(2597476859), "SafetySubRunState", 
(::MDD2000_MngInfo.SafetyConfigState.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(2635917222), "SafetyConfigState", 
(::MDD2000_MngInfo.SafetyCompilationCRC.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(2474248784), "SafetyCompilationCRC", 
(::MDD2000_MngInfo.SafetyDriveCRC.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(3276949537), "SafetyDriveCRC", 
(::MDD2000_MngInfo.SafetyConfigName.pMeth)$UINT, _CH_SVR_OBJ$UINT, 2#0000000001000000$UINT, TO_UDINT(3210868929), "SafetyConfigName", 
(::MDD2000_MngInfo.SafetyConfigRevision.pMeth)$UINT, _CH_SVR_OBJ$UINT, 2#0000000001000000$UINT, TO_UDINT(1083618972), "SafetyConfigRevision", 
(::MDD2000_MngInfo.ChangeServiceMode.pMeth)$UINT, _CH_SVR$UINT, 2#0000000000000000$UINT, TO_UDINT(355990957), "ChangeServiceMode", 
//Clients:
(::MDD2000_MngInfo.strSafetyFWVersion.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(4221005725), "strSafetyFWVersion", TO_UDINT(1850111279), "String", 1$UINT, 11$UINT, 
(::MDD2000_MngInfo.strFWBuildDate.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(2717947821), "strFWBuildDate", TO_UDINT(1850111279), "String", 1$UINT, 11$UINT, 
(::MDD2000_MngInfo.strFWVersion.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(2867381429), "strFWVersion", TO_UDINT(1850111279), "String", 1$UINT, 11$UINT, 
(::MDD2000_MngInfo.strSafetyFWBuildDate.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(3193508376), "strSafetyFWBuildDate", TO_UDINT(1850111279), "String", 1$UINT, 11$UINT, 
(::MDD2000_MngInfo.strSafetyConfigName.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(1969470528), "strSafetyConfigName", TO_UDINT(1850111279), "String", 1$UINT, 11$UINT, 
(::MDD2000_MngInfo.strSafetyConfigRevision.pCh)$UINT, _CH_CLT_OBJ$UINT, 2#0000000000000010$UINT, TO_UDINT(728173554), "strSafetyConfigRevision", TO_UDINT(1850111279), "String", 1$UINT, 11$UINT, 
END_FUNCTION


#define USER_CNT_MDD2000_MngInfo 19

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

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

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

	_memcpy((#vmt.CmdTable)$^USINT, _DriveSafetyIFParaBase::State.pMeth, nCmdSize);
	vmt.CmdTable.nCmds		:= nSTDCMD + USER_CNT_MDD2000_MngInfo;
	vmt.CmdTable.Init		:= #Init();
#pragma warning (disable : 74)
	vmt.UserFcts[2]		:= #RefreshPara();

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

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

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

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

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

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

	IF _DriveSafetyIFParaBase::State.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, FwVersionDrive.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #FwVersionDrive::Read();
	vmt.CmdTable.Write		:= #FwVersionDrive::Write();
	FwVersionDrive.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF FwVersionDrive.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, FWDateDrive.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #FWDateDrive::Read();
	vmt.CmdTable.Write		:= #FWDateDrive::Write();
	FWDateDrive.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF FWDateDrive.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, FwVersionSafety.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #FwVersionSafety::Read();
	vmt.CmdTable.Write		:= #FwVersionSafety::Write();
	FwVersionSafety.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF FwVersionSafety.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, FWDateSafety.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #FWDateSafety::Read();
	vmt.CmdTable.Write		:= #FWDateSafety::Write();
	FWDateSafety.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF FWDateSafety.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, SafetyConfigName.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #SafetyConfigName::Read();
	vmt.CmdTable.Write		:= #SafetyConfigName::Write();
	SafetyConfigName.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF SafetyConfigName.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	_memcpy((#vmt.CmdTable)$^USINT, SafetyConfigRevision.pMeth, SIZEOF(CMDMETH));
	vmt.CmdTable.nCmds		:= nSTDCMD;
	vmt.CmdTable.Read		:= #SafetyConfigRevision::Read();
	vmt.CmdTable.Write		:= #SafetyConfigRevision::Write();
	SafetyConfigRevision.pMeth		:= StoreCmd (pCmd := #vmt.CmdTable, SHARED);

	IF SafetyConfigRevision.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;
	ChangeServiceMode.pMeth			:= StoreMethod( #M_RD_DIRECT(), #ChangeServiceMode::Write() );
	IF ChangeServiceMode.pMeth THEN
		ret_code	:= C_OK;
	ELSE
		ret_code	:= C_OUTOF_NEAR;
		RETURN;
	END_IF;

END_FUNCTION

//{{LSL_IMPLEMENTATION

FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::Init

   // call base class
  _DriveSafetyIFParaBase::Init();

  if _firstscan then
  
    // initialize SafetyRunState (enum <> 0)
    SafetyRunState := t_e_MDD2000SafetyRunState::_INACTIVE;
    
    if (IsAxisConnected() = TRUE) then
      AddParaObjects(dIndex:=MDD2000MNG_PARAIDX_MNGINFO, pThis:=this);// add the object in the list of the axis
    end_if;
  end_if;
  
END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::RefreshPara
	VAR_INPUT
		hParaIndex 	: HINT;
		hsParaSubIndex 	: HSINT;
		bRW 	: DINT;
		bsDataInfo 	: BSINT;
		pValue 	: ^DINT;
	END_VAR
  VAR
    pStr : ^Char;
  	tempStr : Array [0..35] of CHAR;
  END_VAR

  
  case hParaIndex of
  
    //*****************************************************************************
    MDD2000_PID_SIGMATEKPARA_INDEX_INFO:
  
      // check the parameter number
      case hsParaSubIndex of
        
        MDD2000_SPID_I_FW:
          
          SetFWVersion(pValue^,0);
          
        MDD2000_SPID_I_BUILD:
        
          SetFwDate(pValue^$UDINT,0);
          
      end_case;
      
    //*****************************************************************************
    MDD2000_PID_SAFETY_IMG_INFO:
    
      // check the parameter number
      case hsParaSubIndex of
    
        MDD2000_SPID_SAFETY_IMG_FWVERSION:
          SetFWVersion(pValue^,1);
        
        MDD2000_SPID_SAFETY_IMG_GITHASH:
          Hash            := pValue^$HDINT;
          
        MDD2000_SPID_SAFETY_IMG_BUILDDATETIME:
          SetFwDate(pValue^$UDINT,1);
                    
        MDD2000_SPID_SAFETY_IMG_SC1CRC:
          SC1_CRC         := pValue^$HDINT;
          
        MDD2000_SPID_SAFETY_IMG_SC2CRC:
          SC2_CRC         := pValue^$HDINT;
    
      end_case;
      
    //*****************************************************************************
    MDD2000_PID_SAFETY_CFG_INFO:
    
      // check the parameter number
      case hsParaSubIndex of        
    
        MDD2000_SPID_SAFETY_NO:
          SafetyNumber      := pValue^$HDINT;
          
        MDD2000_SPID_SAFETY_CFG_STATE:
          SafetyConfigState$DINT := pValue^;
          
        MDD2000_SPID_SAFETY_CFG_CRC:
          SafetyCompilationCRC   := pValue^$HDINT;
        
        MDD2000_SPID_SAFETY_CFG_NAME_1:
          _memcpy(ptr1:=#TempCfgName[0], ptr2:=pValue, cntr:=8);
          
        MDD2000_SPID_SAFETY_CFG_NAME_2:
          _memcpy(ptr1:=#TempCfgName[8], ptr2:=pValue, cntr:=8);
          
        MDD2000_SPID_SAFETY_CFG_NAME_3:
          _memcpy(ptr1:=#TempCfgName[16], ptr2:=pValue, cntr:=8);
          
        MDD2000_SPID_SAFETY_CFG_NAME_4:
          _memcpy(ptr1:=#TempCfgName[24], ptr2:=pValue, cntr:=8);
          
          sigclib_strcutat(pd:=#tempStr[0], txt:=#TempCfgName[0], chr:=9);  // Get String till the first tab = config name without the version number          
          strSafetyConfigName.TxtSet(dstchrsize:=1, psrc:=#tempStr[0], srcchrsize:=1);
          
          tempStr[0] := 9;
          tempStr[1] := 0;
          pStr := sigclib_strstr(searchee:=#TempCfgName[0], lookfor:=#tempStr[0]); // Get String from the first tab = just the version number
          if pStr then
            pstr += 1;  // Skip Tab
            strSafetyConfigRevision.TxtSet(dstchrsize:=1, psrc:=pstr, srcchrsize:=1);
          end_if;
        
        MDD2000_SPID_SAFETY_CFG_CRC_APP:
          SafetyDriveCRC  := pValue^$HDINT;
          
      end_case;
      
    //*****************************************************************************
    MDD2000_PID_SAFETY_RUN_INFO:
    
      // check the parameter number
      case hsParaSubIndex of        
    
        MDD2000_SPID_SAFETY_RUN_STATE:
          SafetyRunState$DINT    := pValue^;
          
        MDD2000_SPID_SAFETY_RUN_SUBSTATE:
          
          if ((SafetyRunState = t_e_MDD2000SafetyRunState::_CHK_CFG) | (SafetyRunState = t_e_MDD2000SafetyRunState::_PREOP)) then
            SafetySubRunState$UDINT := (SafetyRunState$UDINT * 100) + pValue^$UDINT;  // SafetyRunState is factored in with a multipler of 100 in t_e_MDD2000SafetySubRunState
          else
            SafetySubRunState$UDINT := pValue^$UDINT;
          end_if;

          
          
      end_case;
    
  end_case;


END_FUNCTION

FUNCTION MDD2000_MngInfo::SetFwVersion
	VAR_INPUT
		FwVersionInt 	: DINT;
		StringSelect 	: DINT;
	END_VAR
  VAR
    szValue     : ARRAY[0..19] of CHAR;
    var1 : HDINT;
    var2 : HDINT;
    var3 : HDINT;
  END_VAR
  
  if StringSelect = 0 then
    Bin2Ascii(pt:=#szValue[0], value:=FwVersionInt, format:=16#820);
    strFWVersion.TxtSet(dstchrsize:=1, psrc:=#szValue[0], srcchrsize:=1);
  else
    var1 := (FwVersionInt$HDINT AND 16#000000FF);
    var2 := (FwVersionInt$HDINT AND 16#0000FF00) shr  8;
    var3 := (FwVersionInt$HDINT AND 16#00FF0000) shr 16;
    sigclib_sprintfST(pd:=#szValue[0], "%2x.%02x.%02x", #var1, #var2, #var3);
    strSafetyFWVersion.TxtSet(dstchrsize:=1, psrc:=#szValue[0], srcchrsize:=1);
  end_if;

  
END_FUNCTION

FUNCTION MDD2000_MngInfo::SetFwDate
	VAR_INPUT
		FWDateInt 	: UDINT;
		StringSelect 	: DINT;
	END_VAR
  VAR
    szValue     : ARRAY[0..19] of CHAR;
    szFwDate    : ARRAY[0..99] of CHAR;
    Value       : UDINT;
    tmpYear     : UDINT;
  END_VAR

  // Ermitteln des Tages
  Value := FWDateInt AND 16#003F0000;
  Value := Value SHR 16;
  Bin2Ascii(pt:=#szValue[0], value:=Value$DINT, format:=16#102);
  _strcpy(#szFwDate[0], #szValue[0]);
  _strcat(#szFwDate[0], ".");
  
  // ermitteln des Monats
  Value := FWDateInt AND 16#0F000000;
  Value := Value SHR 24;
  Bin2Ascii(pt:=#szValue[0], value:=Value$DINT, format:=16#102);
  _strcat(#szFwDate[0], #szValue[0]);
  _strcat(#szFwDate[0], ".");

  // ermitteln des Jahres
  Value := FWDateInt AND 16#F0000000;  
  Value := Value SHR 28;
  
  //Newer firmwares >= 2016 are using 2 Bits more, which where originally reserved for day, to have more bits to display year dates.
  //With this change we can display year dates until 2063 instead of 2015, 
  tmpYear := FWDateInt AND 16#00C00000;
  tmpYear := tmpYear SHR 18; //Shift Right 18 instead of 22 because these two bits are bit 4 and 5 for the year
  Value := Value OR tmpYear;
    
  Value += 2000;
  Bin2Ascii(pt:=#szValue[0], value:=Value$DINT, format:=16#800);
  _strcat(#szFwDate[0], #szValue[0]);
  _strcat(#szFwDate[0], " ");
  
  // ermitteln der Stunde
  Value := FWDateInt AND 16#0000FF00;
  Value := Value SHR 8;
  Bin2Ascii(pt:=#szValue[0], value:=Value$DINT, format:=16#102);
  _strcat(#szFwDate[0], #szValue[0]);
  _strcat(#szFwDate[0], ":");
  
  // ermitteln der Minuten
  Value := FWDateInt AND 16#000000FF;
  Bin2Ascii(pt:=#szValue[0], value:=Value$DINT, format:=16#102);
  _strcat(#szFwDate[0], #szValue[0]);

  if StringSelect = 0 then
    strFWBuildDate.TxtSet(dstchrsize:=1, psrc:=#szFwDate[0], srcchrsize:=1);
  else
    strSafetyFWBuildDate.TxtSet(dstchrsize:=1, psrc:=#szFwDate[0], srcchrsize:=1);
  end_if;


END_FUNCTION

FUNCTION MDD2000_MngInfo::Bin2Ascii
	VAR_INPUT
		pt 	: ^CHAR;
		value 	: DINT;
		format 	: BINT;
	END_VAR
  VAR
    tmp    : DINT;
    nk     : UINT;
    dig    : UINT;
    hp     : ^CHAR; 
    pd     : UINT; 
    h      : UINT;
  END_VAR

  if((format AND 16#000F) = 0) then
    format := format OR 16#0800;
  end_if;

  if(format AND 16#0800) then
    tmp  := value;
    if tmp = 0 then
      dig := 1;
    else
      dig := 0;
    end_if;

    while(tmp) do
      
      tmp := tmp / 10;
      dig += 1;
    end_while;

    nk := ((format SHR 4) AND 16#0F);
      
    if(nk >= dig) then
      dig := nk + 1;
    end_if;
      
    format := (format AND 16#FFF0) OR (dig AND 16#000F);
  end_if;


  dig := (format and 16#0F);        // Anzahl der Stellen
  hp  := pt + dig;                  // pointer auf String-Ende
  tmp := value;                     // Zahl
  pd  := (format shr 4) and 16#0F;  // position des Komma

  
  if(value < 0) then    // kontrolle ob Zahl negativ
    hp    += 1;    
    value := -value;    // Zahl * (-1)
    pt^   := '-';       // Erstes Zeichen auf '-' setzen
  end_if; 	 

  if(format and 16#0200) then // Nachnullen löschen
    h := pd; 
    while(h) do               // Nur Nullen hinter Komma
      h -= 1; 
      if((value mod 10) = 0) then // Ist Ziffer Null?
        value := value / 10;      // wenn ja, Null löschen
        pd -= 1; 
      else
        h := 0; 
      end_if; 

    end_while; 
  end_if; 
  
  if(pd <> 0) then       // Komma noch zu setzen?
    hp += 1;
  end_if; 

  hp^ := 0;               // String mit Ascii-0 abschließen
  hp  -= 1;   

  repeat
    hp^   := '0' + TO_USINT(value mod 10);  //akt. Ziffer
    hp    -= 1; 
    pd    -= 1; 
    dig   -= 1; 
    if(pd = 0)then    // Komma setzen?
      hp^ := '.';
      hp -= 1; 
    end_if; 

    value := value / 10;   // nächste Ziffer
    
    if((dig = 0) & (value <> 0)) then // Zahl zu groß 
      pt^   := '?';   // Formatfehler
      value := 0; 
    end_if; 
  until(value = 0) end_repeat; 
 
 
  if(dig > 0) then  // mit Vornullen auffüllen
    repeat          // so lange bis Digits auf Null
      if((format and 16#0100)|(pd$INT >= 0)) then   // Vornullen im 
        hp^ := '0';   // Format angegeben?
      else            // formatfehler (digit zu groß und keine Vornullen) 
        pt^   := '?'; // Formatfehler
        value := 0;
      end_if; 
      pd -= 1;
      hp -= 1;
      if(pd = 0) then // Komma setzen
        hp^ := '.';
        hp -= 1; 
      end_if; 
      dig -= 1;
    until(dig = 0) end_repeat;  // letzte Ziffer?
  end_if;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FwVersionDrive::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	FwVersionDrive := strFWVersion.Data.Read();
	output := FwVersionDrive;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FwVersionDrive::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	FwVersionDrive := input;
	result := (strFWVersion.Data.Write(FwVersionDrive))$UDINT;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FWDateDrive::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	FWDateDrive := strFWBuildDate.Data.Read();
	output := FWDateDrive;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FWDateDrive::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	FWDateDrive := input;
	result := (strFWBuildDate.Data.Write(FWDateDrive))$UDINT;

END_FUNCTION

FUNCTION VIRTUAL MDD2000_MngInfo::GeneralReady

  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SIGMATEKPARA_INDEX_INFO, ParaSubID:=MDD2000_SPID_I_FW        , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SIGMATEKPARA_INDEX_INFO, ParaSubID:=MDD2000_SPID_I_BUILD     , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);

END_FUNCTION


#pragma warning(disable:73);
FUNCTION VIRTUAL MDD2000_MngInfo::SafetyReady
	VAR_INPUT
		StateInfo 	: DINT;
	END_VAR
#pragma warning(default:73);
  
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_IMG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_IMG_FWVERSION, ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_IMG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_IMG_GITHASH  , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_IMG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_IMG_BUILDDATETIME, ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);

  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_IMG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_IMG_SC1CRC   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_IMG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_IMG_SC2CRC   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_NO           , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_STATE    , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_CRC      , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_CRC_APP  , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  
  _memset(dest:=#TempCfgName[0], usByte:=0, cntr:=sizeof(TempCfgName) ); 
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_1   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_2   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_3   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_4   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_RUN_INFO, ParaSubID:=MDD2000_SPID_SAFETY_RUN_STATE    , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_RUN_INFO, ParaSubID:=MDD2000_SPID_SAFETY_RUN_SUBSTATE , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);

END_FUNCTION


FUNCTION VIRTUAL MDD2000_MngInfo::SafetyError
	VAR_INPUT
		StateInfo 	: DINT;
	END_VAR
  
  SafetyChanged(StateInfo:=StateInfo);

END_FUNCTION

#pragma warning(disable:73);
FUNCTION VIRTUAL MDD2000_MngInfo::SafetyChanged
	VAR_INPUT
		StateInfo 	: DINT;
	END_VAR
#pragma warning(default:73);

  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_STATE    , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_CRC      , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_CRC_APP  , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  
  _memset(dest:=#TempCfgName[0], usByte:=0, cntr:=sizeof(TempCfgName) ); 
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_1   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_2   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_3   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_NAME_4   , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_8BYTE, pParaValue:=NIL, pThis:=this);
  
  // AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_RUN_INFO, ParaSubID:=MDD2000_SPID_SAFETY_RUN_STATE    , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
  SafetyRunState := StateInfo$MDD2000MngBase::t_e_MDD2000SafetyRunState;
  AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_RUN_INFO, ParaSubID:=MDD2000_SPID_SAFETY_RUN_SUBSTATE , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);

END_FUNCTION

FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FwVersionSafety::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	FwVersionSafety := strSafetyFWVersion.Data.Read();
	output := FwVersionSafety;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FwVersionSafety::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	FwVersionSafety := input;
	result := (strSafetyFWVersion.Data.Write(FwVersionSafety))$UDINT;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FWDateSafety::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	FWDateSafety := strSafetyFWBuildDate.Data.Read();
	output := FWDateSafety;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::FWDateSafety::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	FWDateSafety := input;
	result := (strSafetyFWBuildDate.Data.Write(FWDateSafety))$UDINT;

END_FUNCTION


FUNCTION MDD2000_MngInfo::SetFwTime

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::UpdateCy
	VAR_INPUT
		StateInfo 	: DINT;
	END_VAR
  
  if (UpdateCyTime > 0) then
  
    // We are waiting for no Parameters
    if (AnzASyncPara) = 0 then
      
      if (ops.tAbsolute - udTimeStampUpdateCy) > UpdateCyTime then 
      
        if ((SafetyRunState = t_e_MDD2000SafetyRunState::_CHK_CFG) | (SafetyRunState = t_e_MDD2000SafetyRunState::_PREOP)) then 
          // Update Subrunstate in Cy only in RunState were it can change
          AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_RUN_INFO, ParaSubID:=MDD2000_SPID_SAFETY_RUN_SUBSTATE , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
        end_if;
        
        if (SafetyRunState = t_e_MDD2000SafetyRunState::_SERVICE) then
          // Update SafetyConfigState in Cy only in RunState were it can change
          AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_STATE  , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
          AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_CRC    , ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
          AddAsyncEntryDS402(ParaID:=MDD2000_PID_SAFETY_CFG_INFO, ParaSubID:=MDD2000_SPID_SAFETY_CFG_CRC_APP, ParaRdWr:=0, ParaSize:=MDD2000MNG_DATASIZE_4BYTE, pParaValue:=NIL, pThis:=this);
        end_if;
        
      end_if;
      
    else
      udTimeStampUpdateCy := ops.tAbsolute;
    end_if;
    
  end_if;
END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::SafetyConfigName::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	SafetyConfigName := strSafetyConfigName.Data.Read();
	output := SafetyConfigName;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::SafetyConfigName::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	SafetyConfigName := input;
	result := (strSafetyConfigName.Data.Write(SafetyConfigName))$UDINT;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::ChangeServiceMode::Write
	VAR_INPUT
		input (EAX) 	: DINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: DINT;
	END_VAR
    VAR
  	MyCmdStruct : CmdStruct;
    MyResult : results;
  END_VAR  

//#define DRIVESAFETYIF_CHANGESAFESERVICEMODE             0x859E
//#define DRIVESAFETYIF_CHANGESAFESERVICEMODE_VER_1            1                   //version 1
//#define DRIVESAFETYIF_CHANGESAFESERVICEMODE_VER_MAX DRIVESAFETYIF_CHANGESAFESERVICEMODE_VER_1   //newest implemented version
//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1
//  aPara[1]$DINT     : Requested Change: 0 .. No Change, 1 .. Enter service mode, 2 .. Leave service mode

//  results
//  uiLng         : 8 Byte
//  aData[0]$DINT : Command Version : max supported version
//  aData[4]$t_e_MDD2000SafetyRunState : SafetyRunState

//  retcode
//  READY
//  ERROR

	ChangeServiceMode := input;  
  
  MyCmdStruct.uiCmd    := DRIVESAFETYIF_CHANGESAFESERVICEMODE;
  MyCmdStruct.aPara[0] := DRIVESAFETYIF_CHANGESAFESERVICEMODE_VER_1;
  MyCmdStruct.aPara[1] := ChangeServiceMode;
    
  DriveIF.NewInst(#MyCmdStruct, #MyResult);
	
	result := ChangeServiceMode;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::SafetyConfigRevision::Read
	VAR_OUTPUT
		output (EAX) 	: UDINT;
	END_VAR

	SafetyConfigRevision := strSafetyConfigRevision.Data.Read();
	output := SafetyConfigRevision;

END_FUNCTION


FUNCTION VIRTUAL GLOBAL MDD2000_MngInfo::SafetyConfigRevision::Write
	VAR_INPUT
		input (EAX) 	: UDINT;
	END_VAR
	VAR_OUTPUT
		result (EAX) 	: UDINT;
	END_VAR

	SafetyConfigRevision := input;
	result := (strSafetyConfigRevision.Data.Write(SafetyConfigRevision))$UDINT;

END_FUNCTION
