[D
	/LoadSW [P
		[A LoadFlag ]	% LoadFlag = False -> Check only if Files are existing 	
		
		/Result #1 def
		/MissingFile '' def	
		
		/SWFile FilePath IntfSel.IntfDir add '\' add IntfSel.IntfSWFileName add IntfSWTypeExt add def
		/SWFile SWFile '_V' add IntfSel.SWVersion cvs add 'S' add IntfSel.SWSubVersion cvs add def 
		IntfSel.SWBetaInfo '' ne [B
			/SWFile SWFile '_' add IntfSel.SWBetaInfo add def
		] if
		/SWFile SWFile '.HX3' add def
		
		
%		currentdict /IntfTreeTypeExt known [B
%			/IntfTypeExtUse IntfTreeTypeExt def  
%		] [B
%			/IntfTypeExtUse IntfTypeExt def  
%		] ifelse 
		
		/TreeFile FilePath IntfSel.IntfDir add '\' add IntfSel.IntfTreeFileName add IntfTreeTypeExt add def
		
		/TreeFile TreeFile '_V' add IntfSel.TreeVersion cvs add 'S' add IntfSel.TreeSubVersion cvs add def 
		IntfSel.TreeBetaInfo '' ne [B
			/TreeFile TreeFile '_' add IntfSel.TreeBetaInfo add def
		] if
		/TreeFile TreeFile '.HX2' add def
		
		/DefaultParFile FilePath IntfSel.IntfDir add '\' add IntfSel.IntfTreeFileName add IntfTreeTypeExt add def
		/DefaultParFile DefaultParFile '_V' add IntfSel.TreeVersion cvs add 'S' add IntfSel.TreeSubVersion cvs add def 
		IntfSel.TreeBetaInfo '' ne [B
			/DefaultParFile DefaultParFile '_' add IntfSel.TreeBetaInfo add def
		] if
		/DefaultParFile DefaultParFile '.GR3' add def
		
		% check if files are existing
		Result [B
			SWFile FileExist not [B
				/Result #0 def 
				/MissingFile SWFile def
			] if
		] if
		Result [B
			TreeFile FileExist not [B
				/Result #0 def 
				/MissingFile TreeFile def
			] if
		] if
		Result [B
			DefaultParFile FileExist not [B
				/Result #0 def 
				/MissingFile DefaultParFile def
			] if
		] if
		Result [B
			IntfSel /IntfSpecificSetup known [B
				/SpecificSetupName IntfSel.IntfSpecificSetup def		    
				#0 'IntfLoader:' SpecificSetupName add cvn exec			    
				/MissingFile exch def
				/Result exch def
			] if
		] if
		
		
		Result LoadFlag and [B
			'Erasing interface firmware sector...' log     
			3 TalkIntf.ClearInstanceAll
%			'Downloading interface software...' log
			'Downloading ' SWFile add log
			SWFile dup loadobj exch PackInst:DownloadHX3File
%			'Downloading interface parameter tree...' log     		
			'Downloading ' TreeFile add log     		
			TreeFile dup loadobj exch PackInst:DownloadHX2File		
			'Updating UPID list...' log
			TalkIntf.UpdateUPIDList
			TalkIntf.GetResult 0 ne [B 
				ResetDevice 
				10000 wait
			] if      
%			'Downloading interface default parameters...' log
			'Downloading ' DefaultParFile add log
			DefaultParFile dup loadobj exch PackInst:DownloadGR3File
			IntfSel /IntfSpecificSetup known [B				
				'Interface specific setup...' log
				LoadFlag 'IntfLoader:' SpecificSetupName add cvn exec
				/MissingFile exch def	%MissingFile and Result gives back 150930 ka
				/Result exch def
			] if
		] if
		[A /MissingFile /Result]
	]
	
	/EthernetIPSetup_SG6_CM [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def
		
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		
		LoadFlag [B

		/ModuleTypeAddress 		$A3000000 def		
		/ModuleHWVersionAddress $A3000002 def
		
		/ModuleHWVersion		$0201 def % latest HW Version: Version 2, No Revision
		
		/ModuleType  ModuleTypeAddress ReadMemory def  		
	
			% check Module Type
			ModuleType $90 eq[B
				/ModuleHWVersionRead  ModuleHWVersionAddress ReadMemory def  
				
				% check HW module version
				ModuleHWVersionRead ModuleHWVersion ge[B
				
%						'downloading module firmware...' log     		
						'Downloading ' ModuleParFile add log     		
						ModuleParFile dup loadobj exch PackInst:DownloadHX2file	
				][B
					/Result #0 def 
					'Warning: Wrong HW Module Version!' log
				] ifelse 
			]
			[B
				/Result #0 def 
				'Warning: Wrong HW Module Type connected!' log
			] ifelse 
			
		] if
		[A /Result /MissingFile] 
	]
	
	/EtherCATSetup [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		LoadFlag [B
			/ModuleType  $A3000000 ReadMemory def            
			ModuleType $10 eq [B
%				'Downloading module parameter...' log     		
				'Downloading ' ModuleParFile add log     		
				ModuleParFile dup loadobj exch PackInst:DownloadHX2File	
				/Value $A200068E ReadMemory def
				$A400001C Value WriteWordToElo
				/Value $A200068C ReadMemory def
				$A400001E Value WriteWordToElo			
			]
			[B
				/Result #0 def 
				'Warning: EtherCAT module is not connected!' log
			] ifelse  
		] if
		[A /Result /MissingFile] 
	]
	
	/EtherCATSetup_C1100 [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		LoadFlag [B
%			'downloading module parameter...' log     		
			'downloading ' moduleparfile add log     		
			moduleparfile dup loadobj exch packinst:downloadhx2file		
		] if
		[A /Result /MissingFile] 
	]

	/EtherCATSetup_C1200 [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		LoadFlag [B
%			'Downloading module parameter...' log     		
			'Downloading ' ModuleParFile add log     		
			ModuleParFile dup loadobj exch packinst:DownloadHX2File	
			/value $a200068e readmemory def
			$a400001c value writewordtoelo
			/value $a200068c readmemory def
			$a400001e value writewordtoelo			
		] if
		[A /Result /MissingFile] 
	]
	
	/EtherCATSetup_SG6_MP [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def
		
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		
		LoadFlag [B

		/ModuleTypeAddress 		$A3000000 def		
		/ModuleFWTypeAddress 	$A3000070 def		
		/ModuleFWVersionAddress $A3000072 def
		/ModuleHWVersionAddress $A3000002 def
		
		/ModuleFWVersion		$0101 def	% latest FW Version: Version 1, No Revision
		/ModuleFWVersionErased	$FFFF def	
		
		/ModuleFWType			$0400 def % FW Type EC
				
		/ModuleHWVersion		$0101 def	% latest HW Version: Version 1, No Revision
		   
		% stop FW to put FPGA in reset state, in order to always correctly access the RT EEprom
		PackInst:StopProgram	
		1000 wait   
		   
		/ModuleType  ModuleTypeAddress ReadMemory def  		
	
			% check Module Type
			ModuleType $90 eq[B
				/ModuleFWTypeRead  	  ModuleFWTypeAddress ReadMemory def            
				/ModuleFWVersionRead  ModuleFWVersionAddress ReadMemory def       
				/ModuleHWVersionRead  ModuleHWVersionAddress ReadMemory def  
				
				% check HW module version
				ModuleHWVersionRead ModuleHWVersion ge[B
				
%						'downloading module firmware...' log     		
						'Downloading ' ModuleParFile add log     		
						ModuleParFile dup loadobj exch PackInst:DownloadHX2file	
						
					ModuleFWTypeAddress ModuleFWType WriteWordToElo
					ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
				]
			]
			[B
				/Result #0 def 
				'Warning: Wrong HW Module Type connected!' log
			] ifelse 
			
		] if
		[A /Result /MissingFile] 
	]
	
	/ProfiNetSetup [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def

		/ModuleParFile1 FilePath IntfSel.IntfDir add IntfSel.IntfModulePar1 add def
		ModuleParFile1 FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile1 def			    
		] if 
		%/ModuleParFile2 FilePath IntfSel.IntfDir add IntfSel.IntfModulePar2 add def
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		
		LoadFlag [B
			/ModuleType  			$A3000000 ReadMemory def  
			/ModuleFWTypeAddress 	$A3000070 def		
			/ModuleFWVersionAddress $A3000072 def
			/ModuleHWVersionAddress $A3000002 def
			/ModuleFWVersion		$0101 def	
			/ModuleFWVersionErased	$FFFF def	
			/ModuleFWVersionRead  	ModuleFWVersionAddress ReadMemory def       

			ModuleType $70 eq [B

				/PN_Flash_CRCRead  	$C00001A2 ReadMemory def 
				/PN_Flash_CRC 		$1F1E def 	
				% check CRC to decide if second part of PN FW has to be reloaded
				PN_Flash_CRCRead	PN_Flash_CRC ne [B
				
					ModuleFWVersionAddress ModuleFWVersionErased WriteWordToElo
					
						% Erase whole RT Flash with special bulkerase command
						$31 chr $66 chr add $66 chr add $66 chr add $A7 chr add $78 chr add $56 chr add $34 chr add $12 chr add TalkIntf.GenericCmd
						15000 wait
						ResetDevice 
						15000 wait
					
						%'defaulting module parameters...' log     		
						%ModuleParFile1 dup loadobj exch PackInst:DownloadHX2file			

						%'downloading module firmware...' log     		
						%ModuleParFile2 dup loadobj exch PackInst:DownloadHX2file	
						
%						'downloading module firmware and parameters...' log     		
						'Downloading ' ModuleParFile add log     		
						ModuleParFile dup loadobj exch PackInst:DownloadHX2file	
						
					ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
				] 
				[B
%					'defaulting module parameters...' log     		
					'Defaulting ' ModuleParFile1 add log     		
					ModuleParFile1 dup loadobj exch PackInst:DownloadHX2file			
				] ifelse 			
			]
			[B
				/Result #0 def 
				'Warning: ProfiNet module is not connected!' log
			] ifelse  
		] if
		[A /Result /MissingFile] 
	]

	/ProfiNetSetup_SG6 [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def

		/ModuleParFile1 FilePath IntfSel.IntfDir add IntfSel.IntfModulePar1 add def
		ModuleParFile1 FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile1 def			    
		] if 
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		
		LoadFlag [B
			/ModuleType  			$A3000000 ReadMemory def  
			/ModuleFWTypeAddress 	$A3000070 def		
			/ModuleFWVersionAddress $A3000072 def
			/ModuleHWVersionAddress $A3000002 def
			/ModuleFWVersion		$0101 def	
			/ModuleFWVersionErased	$FFFF def	
			/ModuleFWVersionRead  	ModuleFWVersionAddress ReadMemory def       

			ModuleType $70 eq [B

				/PN_Flash_CRCRead  	$900001A2 ReadMemory def 
				/PN_Flash_CRC 		$1F1E def				
				% check CRC to decide if second part of PN FW has to be reloaded
				PN_Flash_CRCRead	PN_Flash_CRC ne [B
				
					ModuleFWVersionAddress ModuleFWVersionErased WriteWordToElo
					
						% Erase whole RT Flash with special bulkerase command
						$31 chr $66 chr add $66 chr add $66 chr add $A7 chr add $78 chr add $56 chr add $34 chr add $12 chr add TalkIntf.GenericCmd
						15000 wait
						ResetDevice 
						15000 wait
					
%						'downloading module firmware and parameters...' log     		
						'Downloading ' ModuleParFile add log     		
						ModuleParFile dup loadobj exch PackInst:DownloadHX2file	
						
					ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
				] 
				[B
%					'defaulting module parameters...' log     		
					'Defaulting ' ModuleParFile1 add log     		
					ModuleParFile1 dup loadobj exch PackInst:DownloadHX2file			
				] ifelse 			
			]
			[B
				/Result #0 def 
				'Warning: ProfiNet module is not connected!' log
			] ifelse  
		] if
		[A /Result /MissingFile] 
	]

	
	/ProfiNetSetup_C1150 [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def

		/ModuleParFile1 FilePath IntfSel.IntfDir add IntfSel.IntfModulePar1 add def
		ModuleParFile1 FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile1 def			    
		] if 
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		
		LoadFlag [B
			/ModuleFWVersionAddress $301062 def
			/ModuleFWVersion		$0101 def	
			/ModuleFWVersionErased	$FFFF def	
			/ModuleFWVersionRead  	ModuleFWVersionAddress ReadMemory def       
			
				/PN_Flash_CRCRead  	$805E ReadMemory def 
				/PN_Flash_CRC 		$1F1E def
				% check CRC to decide if second part of PN FW has to be reloaded
				PN_Flash_CRCRead	PN_Flash_CRC ne [B
				
					ModuleFWVersionAddress ModuleFWVersionErased WriteWordToElo
					
						% Erase whole RT Flash with special bulkerase command
						$31 chr $66 chr add $66 chr add $66 chr add $78 chr add $56 chr add $34 chr add $12 chr add TalkIntf.GenericCmd
						15000 wait
						ResetDevice 
						15000 wait
					
%						'downloading module firmware...' log     		
						'Downloading ' ModuleParFile add log     		
						ModuleParFile dup loadobj exch PackInst:DownloadHX2file	
						
					ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
				] 
				[B
%					'defaulting module parameters...' log     		
					'Defaulting ' ModuleParFile1 add log     		
					ModuleParFile1 dup loadobj exch PackInst:DownloadHX2file			
				] ifelse
				
		] if
		[A /Result /MissingFile] 
	]

	/ProfiNetSetup_SG6_MP [P
		[A /LoadFlag ]
		/Result #1 def
		/MissingFile '' def
		
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
		ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 
		
		LoadFlag [B

		/ModuleTypeAddress 		$A3000000 def		
		/ModuleFWTypeAddress 	$A3000070 def		
		/ModuleFWVersionAddress $A3000072 def
		/ModuleHWVersionAddress $A3000002 def
		
		/ModuleFWVersion		$0101 def	% latest FW Version: Version 1, No Revision
		/ModuleFWVersionErased	$FFFF def	
		
		/ModuleFWType			$0700 def % FW Type PN	
				
		/ModuleHWVersion		$0101 def	% latest HW Version: Version 1, No Revision
		
		% stop FW to put FPGA in reset state, in order to always correctly access the RT EEprom
		PackInst:StopProgram	
		1000 wait 
		
		/ModuleType  ModuleTypeAddress ReadMemory def  		
	
			% check Module Type
			ModuleType $90 eq[B
				/ModuleFWTypeRead  	  ModuleFWTypeAddress ReadMemory def            
				/ModuleFWVersionRead  ModuleFWVersionAddress ReadMemory def       
				/ModuleHWVersionRead  ModuleHWVersionAddress ReadMemory def  
				
				% check HW module version
				ModuleHWVersionRead ModuleHWVersion ge[B
				
						% Erase whole RT Flash with special bulkerase command
						$31 chr $66 chr add $66 chr add $66 chr add $A7 chr add $78 chr add $56 chr add $34 chr add $12 chr add TalkIntf.GenericCmd
						60000 wait
						ResetDevice 
						15000 wait
				
%						'downloading module firmware...' log     		
						'Downloading ' ModuleParFile add log     		
						ModuleParFile dup loadobj exch PackInst:DownloadHX2file	
						
					ModuleFWTypeAddress ModuleFWType WriteWordToElo
					ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
				][B
					/Result #0 def 
					'Warning: Wrong HW Module Version!' log
				] ifelse 
			]
			[B
				/Result #0 def 
				'Warning: Wrong HW Module Type connected!' log
			] ifelse 
		] if
		[A /Result /MissingFile] 
	]
	
	/POWERLINKSetup [P
		[A /LoadFlag ]
		
		/ModuleFWType		$0100 def		% PL
		/ModuleHWVersion	$0103 def		% latest HW Version: Version 1, Revision B
		
		/ModuleTypeAddress $A3000000 def		
		/ModuleFWTypeAddress $A3000070 def		
		/ModuleFWVersionAddress $A3000072 def
		/ModuleHWVersionAddress $A3000002 def
		
		/Result #1 def
		/MissingFile '' def
		
		/ModuleType  ModuleTypeAddress ReadMemory def  		
	
		% check Module Type
		ModuleType $40 eq[B
			/ModuleFWTypeRead  ModuleFWTypeAddress ReadMemory def            
			/ModuleFWVersionRead  ModuleFWVersionAddress ReadMemory def       
			/ModuleHWVersionRead  ModuleHWVersionAddress ReadMemory def  
		
			% check HW module version
			ModuleHWVersionRead ModuleHWVersion ge[B
				% Module HW >= V1.0.2 
				/ModuleFWVersion	$0103 def	% latest compatibel FW Version: Version 1, Subversion 3
				
				/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
				ModuleParFile FileExist not [B
					/Result #0 def 
					/MissingFile ModuleParFile def			    
				] 
				[B
					ModuleFWTypeRead ModuleFWType eq[B
						LoadFlag  ModuleFWVersionRead ModuleFWVersion ne and[B
%							'Programming FPGA...' log     	
							'Downloading ' ModuleParFile add log     	
							/JTAG_START_EXECUTION $A5A5 def
							/JTAG_Execute $C0000200 def
							JTAG_Execute JTAG_START_EXECUTION WriteWordToElo						
							ModuleParFile dup loadobj exch PackInst:DownloadHX2File	
							ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
							'Done' log	
						]if
					] 
					[B
						/Result #0 def
						'Warning: POWERLINK module is not connected!' log					
					] ifelse
				] ifelse
			]
			[B
				% Module HW < V1.0.2
				/ModuleFWVersion	$0102 def	% latest compatibel FW Version: Version 1, Subversion 2
				
				/ModulePar '\FPGA\EPLHUB_FPGA_V1_2.HX2'	def
				/ModuleParFile FilePath IntfSel.IntfDir add ModulePar add def
				ModuleParFile FileExist not [B
					/Result #0 def 
					/MissingFile ModuleParFile def			    
				]
				[B				
					ModuleFWTypeRead ModuleFWType eq[B
						LoadFlag  ModuleFWVersionRead ModuleFWVersion ne and[B
%							'Programming FPGA...' log     	
							'Downloading ' ModuleParFile add log     	
							/JTAG_START_EXECUTION $A5A5 def
							/JTAG_Execute $C0000200 def
							JTAG_Execute JTAG_START_EXECUTION WriteWordToElo						
							ModuleParFile dup loadobj exch PackInst:DownloadHX2File	
							ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
							'Done' log	
						]if
					] 
					[B
						/Result #0 def 
						'Warning: POWERLINK module is not connected!' log					
					] ifelse
				]ifelse
				
			]ifelse
		]
		[B
			ModuleType $20 eq[B
				/Result #1 def 
			]
			[B
				/Result #0 def 
				'Warning: Wrong HW Module Type connected!' log
			] ifelse 
		] ifelse 
		
		[A /Result /MissingFile] 
	]
	
	/POWERLINKSetup_C1250 [P
		[A /LoadFlag ]
		
		/ModuleFWType		$0100 def		% PL
		/ModuleHWVersion	$0103 def		% latest HW Version: Version 1, Revision B
		
		/ModuleTypeAddress $A3000000 def		
		/ModuleFWTypeAddress $A3000070 def		
		/ModuleFWVersionAddress $A3000072 def
		/ModuleHWVersionAddress $A3000002 def
		
		/Result #1 def
		/MissingFile '' def
		
		/ModuleType  ModuleTypeAddress ReadMemory def  		
	
		% check Module Type
		ModuleType $40 eq[B
			/ModuleFWTypeRead  ModuleFWTypeAddress ReadMemory def            
			/ModuleFWVersionRead  ModuleFWVersionAddress ReadMemory def       
			/ModuleHWVersionRead  ModuleHWVersionAddress ReadMemory def  
		
			% check HW module version
			ModuleHWVersionRead ModuleHWVersion ge[B
				% Module HW >= V1.0.2 
				/ModuleFWVersion	$0201 def	% latest compatibel FW Version: Version 2, Subversion 1
				
				/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
				ModuleParFile FileExist not [B
					/Result #0 def 
					/MissingFile ModuleParFile def			    
				] 
				[B
					ModuleFWTypeRead ModuleFWType eq[B
						LoadFlag  ModuleFWVersionRead ModuleFWVersion ne and[B
%							'Programming FPGA...' log     	
							'Downloading ' ModuleParFile add log     	
							/JTAG_START_EXECUTION $A5A5 def
							/JTAG_Execute $90000200 def
							JTAG_Execute JTAG_START_EXECUTION WriteWordToElo						
							ModuleParFile dup loadobj exch PackInst:DownloadHX2File	
							ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
							'Done' log	
						]if
					] 
					[B
						/Result #0 def 
						'Warning: POWERLINK module is not connected!' log					
					] ifelse
				] ifelse
			]
			[B
				/Result #0 def 
				'Warning: POWERLINK module HW Version older than V1.0.2!' log	
			]ifelse
		]
		[B
			ModuleType $20 eq[B
				/Result #1 def 
			]
			[B
				/Result #0 def 
				'Warning: Wrong HW Module Type connected!' log
			] ifelse 
		] ifelse 
		
		[A /Result /MissingFile] 
	]
	
	/SERCOSIIISetup [P
		[A /LoadFlag ]
		
		/ModuleFWType		$0200 def		% SC
		/ModuleFWVersion	$0102 def		% Version 1, Subversion 2
		
		/ModuleFWTypeAddress $A3000070 def		
		/ModuleFWVersionAddress $A3000072 def
		
		/Result #1 def
		/MissingFile '' def
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
			ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 

		/ModuleFWTypeRead  ModuleFWTypeAddress ReadMemory def            
		/ModuleFWVersionRead  ModuleFWVersionAddress ReadMemory def            

		LoadFlag ModuleFWTypeRead ModuleFWType ne ModuleFWVersionRead ModuleFWVersion ne or and [B
			/ModuleType  $A3000000 ReadMemory def            
			ModuleType $40 eq [B
%				'Programming FPGA...' log     	
				'Downloading ' ModuleParFile add log     	
				/JTAG_START_EXECUTION $A5A5 def
				/JTAG_Execute $C0000200 def
				JTAG_Execute JTAG_START_EXECUTION WriteWordToElo						
				ModuleParFile dup loadobj exch PackInst:DownloadHX2File	
				ModuleFWTypeAddress ModuleFWType WriteWordToElo
				ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
			]
			[B
				/Result #0 def 
				'Warning: SERCOSIII module is not connected!' log
			] ifelse 
		] 
		[B
			'Done' log					
		] ifelse
		[A /Result /MissingFile] 
	]
	
	
	/SERCOSIIISetup_C1250 [P
		[A /LoadFlag ]
		
		/ModuleFWType		$0200 def		% SC
		/ModuleFWVersion	$0201 def		% Version 2, Subversion 1 --> sercon100s V2.8
		
		/ModuleFWTypeAddress $A3000070 def		
		/ModuleFWVersionAddress $A3000072 def
		
		/Result #1 def
		/MissingFile '' def
		/ModuleParFile FilePath IntfSel.IntfDir add IntfSel.IntfModulePar add def
			ModuleParFile FileExist not [B
			/Result #0 def 
			/MissingFile ModuleParFile def			    
		] if 

		/ModuleFWTypeRead  ModuleFWTypeAddress ReadMemory def            
		/ModuleFWVersionRead  ModuleFWVersionAddress ReadMemory def            

		LoadFlag ModuleFWTypeRead ModuleFWType ne ModuleFWVersionRead ModuleFWVersion lt or and [B
			/ModuleType  $A3000000 ReadMemory def            
			ModuleType $40 eq [B
%				'Programming FPGA...' log     	
				'Downloading ' ModuleParFile add log     	
				/JTAG_START_EXECUTION $A5A5 def
				/JTAG_Execute $90000200 def
				JTAG_Execute JTAG_START_EXECUTION WriteWordToElo						
				ModuleParFile dup loadobj exch PackInst:DownloadHX2File	
				ModuleFWTypeAddress ModuleFWType WriteWordToElo
				ModuleFWVersionAddress ModuleFWVersion WriteWordToElo
			]
			[B
				/Result #0 def 
				'Warning: SERCOSIII module is not connected!' log
			] ifelse 
		] 
		[B
			'Done' log					
		] ifelse
		[A /Result /MissingFile] 
	]
	
]
