% Installation package for E1100/B1100 Controllers 
% Release: 3.9 Build 20080825
% Date:    25.08.2008
% Copyright 2005-2008, NTI AG.

[D
	
   %/Main [B
    
   /Init [B
   
   	/ProgFlag exch def
   	ProgFlag [B
   		/FilePath 'FirmwareFiles\FirmwareE1100\' def
   	]
   	[B
   		/FilePath '' def	
   	] ifelse 
   	
   	'PackInst' nknown not [B 'PackInst' import ] if

		% Release Definitions
   	'RelInfo3R9' nknown not [B 'RelInfo3R9' import ] if

 		/ReleaseVersion RelInfo3R9:RelVer def
		/ReleaseSubVersion RelInfo3R9:RelSubVer def
		/ReleaseBuildInfo RelInfo3R9:RelInfoStr def

	   /OSSWVersion	$3 def
	   /OSSWSubVersion $9 def
	   /OSSWBetaInfo 'b01' def 
	   /OSTreeVersion	$3 def
	   /OSTreeSubVersion $9 def
	   /OSTreeBetaInfo 'b01' def  
		 /OSDir 'OS' def
		 /OSLoaderFile 'OSLoader' def
		 /OSLoadSW [B	 OSLoader:LoadSW ] def
		 
	   /MCSWVersion	$3 def
	   /MCSWSubVersion $9 def
	   /MCSWBetaInfo 'b01' def
	   /MCTreeVersion	$3 def
	   /MCTreeSubVersion $9 def
	   /MCTreeBetaInfo 'b01' def
		 /MCDir 'MC_SW' def
		 /MCLoaderFile 'MCLoader' def
		 /MCLoadSW [B	 MCLoader:LoadSW ] def

		%Interfaces
		/LinRS [D
			/Name 'LinRS'
			/Caption 'LinRS'			
			/Description 'Protocol for RS232/RS485 communication'
			/IntfSWVersion $3 
			/IntfSWSubVersion $9
			/IntfSWBetaInfo 'b01'
			/IntfTreeVersion $3
			/IntfTreeSubVersion $9
			/IntfTreeBetaInfo 'b01'
			/IntfDir	'LinRS'
			/IntfLoaderFile 'LinRSLoader'
			/IntfLoadSW [B LinRSLoader:LoadSW ]		
		] def			
		/DeviceNet [D
			/Name 'DeviceNet'
			/Caption 'DeviceNet'
			/Description 'DeviceNet'
			/IntfSWVersion $3
			/IntfSWSubVersion $9
			/IntfSWBetaInfo 'b01'
			/IntfTreeVersion $3
			/IntfTreeSubVersion $9
			/IntfTreeBetaInfo 'b01'
			/IntfDir	'DeviceNet'
			/IntfLoaderFile 'DNLoader'
			/IntfLoadSW [B DNLoader:LoadSW ]		
		] def			
		/CanOpen [D
			/Name 'CanOpen'
			/Caption 'CanOpen'
			/Description 'CanOpen'
			/IntfSWVersion $3
			/IntfSWSubVersion $9
			/IntfSWBetaInfo 'b01'
			/IntfTreeVersion $3
			/IntfTreeSubVersion $9
			/IntfTreeBetaInfo 'b01'
			/IntfDir	'CanOpen'		
			/IntfLoaderFile 'COLoader'
			/IntfLoadSW [B COLoader:LoadSW ]		
		] def			
		/Profibus [D
			/Name 'Profibus'
			/Caption 'Profibus DP'		
			/Description 'Profibus DP'
			/IntfSWVersion $3
			/IntfSWSubVersion $9
			/IntfSWBetaInfo 'b01'
			/IntfTreeVersion $3
			/IntfTreeSubVersion $9
			/IntfTreeBetaInfo 'b01'
			/IntfDir 'Profibus'
			/IntfLoaderFile 'DPLoader'
			/IntfLoadSW [B DPLoader:LoadSW ]		
		] def	
		/CTIOIntf [D
			/Name 'CTIOIntf'
			/Caption 'CT IO Interface'		
			/Description 'Command Table digital IO Interface'
			/IntfSWVersion $3
			/IntfSWSubVersion $9
			/IntfSWBetaInfo 'b01'
			/IntfTreeVersion $3
			/IntfTreeSubVersion $9
			/IntfTreeBetaInfo 'b01'
			/IntfDir 'CmdTabIO'
			/IntfLoaderFile 'CmdTabIOLoader'
			/IntfLoadSW [B CmdTabIOLoader:LoadSW ]		
		] def	
																
		/None [D
			/Name 'None'
			/Caption 'None'		
		] def
						
		%Applications
		/EasySteps [D
			/Name 'EasySteps'
			/Caption 'EasySteps'			
			/Description 'Easy Steps Application'
			/ApplSWVersion $3 
			/ApplSWSubVersion $9
			/ApplSWBetaInfo 'b01'
			/ApplTreeVersion $3
			/ApplTreeSubVersion $9
			/ApplTreeBetaInfo 'b01'
			/ApplDir	'Applications\EasySteps'
			/ApplLoaderFile 'EasyStepsLoader'
			/ApplLoadSW [B EasyStepsLoader:LoadSW ]		
		] def			
		/MasterSlave [D
			/Name 'MasterSlave'
			/Caption 'MasterSlave'			
			/Description 'Master Slave Application'
			/ApplSWVersion $3 
			/ApplSWSubVersion $9
			/ApplSWBetaInfo 'b01'
			/ApplTreeVersion $3
			/ApplTreeSubVersion $9
			/ApplTreeBetaInfo 'b01'
			/ApplDir	'Applications\MasterSlave'
			/ApplLoaderFile 'MasterSlaveLoader'
			/ApplLoadSW [B MasterSlaveLoader:LoadSW ]		
		] def			
		/AutoStart [D
			/Name 'AutoStart'
			/Caption 'AutoStart'			
			/Description 'Auto Start Application'
			/ApplSWVersion $3 
			/ApplSWSubVersion $9
			/ApplSWBetaInfo 'b01'
			/ApplTreeVersion $3
			/ApplTreeSubVersion $9
			/ApplTreeBetaInfo 'b01'
			/ApplDir	'Applications\AutoStart'
			/ApplLoaderFile 'AutoStartLoader'
			/ApplLoadSW [B AutoStartLoader:LoadSW ]		
		] def			

	    /Controllers [A
			%E1100MP
			[D
			   /Name 'E1100-MP'
			   /TypeID $411
			   /TypeSupported 0	
			]
			%E1100MPHC
			[D
			   /Name 'E1100-MP-HC'
			   /TypeID $421
			   /TypeSupported 0	
			]
			%E1100MT
			[D
			   /Name 'E1100-MT'
			   /TypeID $431
			   /TypeSupported 0	
			]
			%E1100MTHC
			[D
			   /Name 'E1100-MT-HC'
			   /TypeID $441
			   /TypeSupported 0	
			]
			%E1100GP
			[D
			   /Name 'E1100-GP'
			   /TypeID $451
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0102
			   		$0103
			   		$0104		   		   		
			   		$0105
			   ]
			   /SupportedDSWVersions [A
			   		$2
			   ]		   
			   /PowerExtension 'LC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
					  CTIOIntf
			   		LinRS
			   		CanOpen
			   		DeviceNet
					  None
			   ]	
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100GPHC
			[D
			   /Name 'E1100-GP-HC'
			   /TypeID $461
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0102
			   		$0103		   		   		
			   		$0104
			   		$0105
			   ]
			   /SupportedDSWVersions [A
			   		$2
			   ]		   
			   /PowerExtension 'HC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
					  CTIOIntf
			   		LinRS
			   		CanOpen
			   		DeviceNet
					  None
			   ]	
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]

			%E1100GPXC
			[D
			   /Name 'E1100-GP-XC'
			   /TypeID $541
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0105
			   ]
			   /SupportedDSWVersions [A
			   		$2
			   ]		   
			   /PowerExtension 'XC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
					  CTIOIntf
			   		LinRS
			   		CanOpen
			   		DeviceNet
					  None
			   ]	
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]

			%E1100RS
			[D
			   /Name 'E1100-RS'
			   /TypeID $471
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0102
			   		$0103		   		   		
					  $0104
					  $0106 
					  $0107
			   ]
			   /SupportedDSWVersions [A
			   		$2
			   		$4
			   ]		   
			   /PowerExtension 'LC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   	 	LinRS
			   		None
			   ]			   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100RSHC
			[D
			   /Name 'E1100-RS-HC'
			   /TypeID $481
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0102
			   		$0103		   		   		
						$0104
						$0105
						$0106
						$0107
			   ]
			   /SupportedDSWVersions [A
			   		$2
			   		$4
			   ]		   
			   /PowerExtension 'HC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   	 	LinRS
			   		None
			   ]	
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100RSXC
			[D
			   /Name 'E1100-RS-XC'
			   /TypeID $511
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0104   		
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$2
			   ]		   		 
	   		 /PowerExtension 'XC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		LinRS
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100DN
			[D
			   /Name 'E1100-DN'
			   /TypeID $491
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0104
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
			   /PowerExtension 'LC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		DeviceNet
			   		None
			   ]		   		   	
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100DNHC
			[D
			   /Name 'E1100-DN-HC'
			   /TypeID $4A1
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0104
			   		$0105
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
   		   /PowerExtension 'HC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		DeviceNet
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100DNXC
			[D
			   /Name 'E1100-DN-XC'
			   /TypeID $521
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0104   		
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
	   		 /PowerExtension 'XC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		DeviceNet
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100CO
			[D
			   /Name 'E1100-CO'
			   /TypeID $4B1
			   /TypeSupported 1
	   		   /SupportedHWVersions [A
			   		$0104
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
	   		 /PowerExtension 'LC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		CanOpen
			   		None
			   ]		   		   		
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100COHC
			[D
			   /Name 'E1100-CO-HC'
			   /TypeID $4C1
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0104
			   		$0105
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		   
   		   /PowerExtension 'HC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		CanOpen
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1100COXC
			[D
			   /Name 'E1100-CO-XC'
			   /TypeID $4F1
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0104   		
			   		$0105
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
	   		 /PowerExtension 'XC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		CanOpen
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1130DP
			[D
			   /Name 'E1130-DP'
			   /TypeID $4D1
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0104 
			   		$0106			   		  		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
	   		 /PowerExtension 'LC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		Profibus
			   		LinRS
			   		CanOpen
			   		DeviceNet
			   		None
			   ]		   		   	
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1130DPHC
			[D
			   /Name 'E1130-DP-HC'
			   /TypeID $4E1
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0104   		
			   		$0105
			   		$0106  		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		   
   		   /PowerExtension 'HC'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		Profibus
			   		LinRS
			   		CanOpen
			   		DeviceNet
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]	
			%E1130DPXC
			[D
			   /Name 'E1130-DP-XC'
			   /TypeID $531
			   /TypeSupported 1	
			   /SupportedHWVersions [A
			   		$0104   		
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		 
	   		 /PowerExtension 'XC'  
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		Profibus
			   		LinRS
			   		CanOpen
			   		DeviceNet
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]
			%E1130DPHV
			[D
			   /Name 'E1130-DP-HV'
			   /TypeID $501
			   /TypeSupported 1
			   /SupportedHWVersions [A
			   		$0104   		
			   		$0106   		
			   		$0107
			   ]
			   /SupportedDSWVersions [A
			   		$4
			   ]		   		   
	   		 /PowerExtension 'HCHV'
			   /EloTypeExt 'E1100'
			   /EasyStepsParExt ''
			   /Interfaces [A
			   		Profibus
			   		LinRS
			   		CanOpen
			   		DeviceNet
			   		None
			   ]		   
  			 /Applications [A
	   				None
            EasySteps
            MasterSlave
            AutoStart
				 ]			   	
			]	
		% B1100 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	      % B1100-GP
			  [D
			    /Name 'B1100-GP'
			    /TypeID $0D61
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'LC'
  			  /EloTypeExt 'B1100'
 			   /EasyStepsParExt ''
			    /Interfaces [A
			   		CanOpen
			   		LinRS
			   		DeviceNet
					  None
			    ]			   	
					/Applications [A
	   				None
 						EasySteps
					]			   	
			  ]
			  % B1100-GP-HC
			  [D
			    /Name 'B1100-GP-HC'
			    /TypeID $0D71
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'HC'
  			  /EloTypeExt 'B1100'
			   /EasyStepsParExt ''
			    /Interfaces [A
			   		CanOpen
			   		LinRS
			   		DeviceNet
					  None
			    ]			   	
					/Applications [A
	   				None
 						EasySteps
					]			   	
			  ]
			  % B1100-GP-XC
			  [D
			    /Name 'B1100-GP-XC'
			    /TypeID $0D81
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'XC'
  			  /EloTypeExt 'B1100'
			   /EasyStepsParExt ''
			    /Interfaces [A
			   		CanOpen
			   		LinRS
			   		DeviceNet
					  None
			    ]			   	
					/Applications [A
	   				None
 						EasySteps
					]			   	
			  ]
	      % B1100-VF
			  [D
			    /Name 'B1100-VF'
			    /TypeID $0D31
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'LC'
  			  /EloTypeExt 'B1100'
			   /EasyStepsParExt ''
			    /Interfaces [A
					  None
			    ]			   	
					/Applications [A
 						EasySteps
	   				None
					]			   	
			  ]
			  % B1100-VF-HC
			  [D
			    /Name 'B1100-VF-HC'
			    /TypeID $0D41
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'HC'
  			  /EloTypeExt 'B1100'
			   /EasyStepsParExt ''
			    /Interfaces [A
					  None
			    ]			   	
					/Applications [A
 						EasySteps
	   				None
					]			   	
			  ]
			  % B1100-VF-XC
			  [D
			    /Name 'B1100-VF-XC'
			    /TypeID $0D51
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'XC'
  			  /EloTypeExt 'B1100'
			   /EasyStepsParExt ''
			    /Interfaces [A
					  None
			    ]			   	
					/Applications [A
 						EasySteps
	   				None
					]			   	
			  ]
	      % B1100-PP
			  [D
			    /Name 'B1100-PP'
			    /TypeID $0D01
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'LCPP'
  			  /EloTypeExt 'B1100'
  		    /EasyStepsParExt 'PP'
			    /Interfaces [A
					  None
			    ]			   	
					/Applications [A
 						EasySteps
					]			   	
			  ]
			  % B1100-PP-HC
			  [D
			    /Name 'B1100-PP-HC'
			    /TypeID $0D11
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'HCPP'
  			  /EloTypeExt 'B1100'
  		    /EasyStepsParExt 'PP'
			    /Interfaces [A
					  None
			    ]			   	
					/Applications [A
 						EasySteps
					]			   	
			  ]
			  % B1100-PP-XC
			  [D
			    /Name 'B1100-PP-XC'
			    /TypeID $0D21
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			      $0103
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'XCPP'
  			  /EloTypeExt 'B1100'
  		    /EasyStepsParExt 'PP'
			    /Interfaces [A
					  None
			    ]			   	
					/Applications [A
 						EasySteps
					]			   	
			  ]
			  % B1100-KR
			  [D
			    /Name 'B1100-I1-LV'
			    /TypeID $0D91
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'HC'
  			  /EloTypeExt 'B1100'
  		    /EasyStepsParExt ''
			    /Interfaces [A
			   		CanOpen
			   		LinRS
			   		DeviceNet
					  None
			    ]			   	
					/Applications [A
	   				None
					]			   	
			  ]
			  
			  % B1100-I2 (Krones with 100V FET)
			  [D
			    /Name 'B1100-I2'
			    /TypeID $0DA1
			    /TypeSupported 1	
 			    /SupportedHWVersions [A
			      $0102
			    ]
			    /SupportedDSWVersions [A
			   		$10
			    ]		   
			    /PowerExtension 'HC'
  			  /EloTypeExt 'B1100'
  		    /EasyStepsParExt ''
			    /Interfaces [A
			   		CanOpen
			   		LinRS
			   		DeviceNet
					  None
			    ]			   	
					/Applications [A
	   				None
					]			   	
			  ]
		] def
			

    /WriteStringToElo [P
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % This procedure writes an string value of the  %
      % protected block to the ELO          %
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      [A /Address /InString ]
      
      /StrLength InString length def
      0 2 StrLength 2 sub [B
          /TmpIndex exch def
          /TmpAddr Address TmpIndex add def
          /TmpData InString TmpIndex 1 getsubstr ord def
          /TmpIndex TmpIndex 1 add def
          TmpIndex StrLength lt [B
            /TmpData TmpData InString TmpIndex 1 getsubstr ord 256 mul add def
          ] if 
          TmpAddr TmpData WriteWordToElo
      ] for
      
        [A ]
    ] def
  
   /WriteWordToElo [B
   	TalkIntf.WriteMemory
   ] def
   
   /ReadMemory [B 
      TalkIntf.ReadMemory     
      TalkIntf.GetResult 0 eq 
      [B TalkIntf.GetData ]
      [B 'TalkError: ' TalkIntf.GetResult cvs add raisese ] ifelse
   ] def
  
   /StartProgram [B 
      TalkIntf.StartProgram
      TalkIntf.GetResult 0 ne
      [B 'TalkError: ' TalkIntf.GetResult cvs add raisese ] if
   ] def

   /ResetDevice [B 
      TalkIntf.ResetDevice
      TalkIntf.GetResult 0 ne
      [B 'TalkError: ' TalkIntf.GetResult cvs add raisese ] if
   ] def

    
	/GetEloType [B
    Offset $680 add ReadMemory
  ] def
	
	/GetEloVersion [B
		Offset $682 add ReadMemory
	] def
	
	/GetEloSWVersion [B
		Offset $102A add ReadMemory	
	] def

	/GetEloTypeStr [P
	  [A ]
	  	/EloName '' def 
      	/StringEndFound #0 def 
      	Offset $690 add 2 Offset $69E add [B
      		/WordAddr exch def
      		StringEndFound not [B
      			/Value WordAddr ReadMemory def
				Value $FF and 0 ne [B	
					/EloName EloName Value $FF and chr add def
				    Value 8 shr 0 ne [B
			          	/EloName EloName Value 8 shr chr add def              
					]
					[B
						/StringEndFound #1 def
					] ifelse
				]	
				[B
					/StringEndFound #1 def
				] ifelse
	 		]if
      	] for 
    
	  [A EloName]
	] def

	/CheckEloIsKnown [P
		[A Type]
			/IsKnown False def
			Controllers [B
				/TempEloDict exch def
				TempEloDict.TypeID Type eq [B
					/IsKnown True def
				] if 
			] forall		
		[A IsKnown]
	] def

	/CheckHWVersionCompatible [P
		[A HWVersion Controller]
			/Result #0 def		
			Controller /SupportedHWVersions known [B
				Controller.SupportedHWVersions [B
					HWVersion eq [B
						/Result #1 def	
					] if 
				] forall
			] if		
		[A Result]
	] def

	/CheckEloSWVersionCompatible [P
		[A EloSWVersion Controller]
			/Result #0 def		
			Controller /SupportedDSWVersions known [B
				Controller.SupportedDSWVersions [B
					EloSWVersion eq [B
						/Result #1 def	
					] if 
				] forall
			] if		
		[A Result]
	] def

	/GetEloDict [P
		[A Type]
			/EloDict Controllers 1 get def
			Controllers [B
				/TempEloDict exch def
				TempEloDict.TypeID Type eq [B
					/EloDict TempEloDict def
				] if 
			] forall		
		[A EloDict]
	] def


  	/SelectIntf [P
    	[A /IntfArray]

    	% init variables
    	/Result #0 def		
		/IntfSel IntfArray 0 get def
 
    	% create choose interface dialog
    	/IntfDlg 'Choose Interface' 218 140 Create:Form def
    	% add ok/cancel buttons
    	75 25 IntfDlg.SetButtonSize
    	'Ok' '' 'Ok' 1 17 70 IntfDlg.AddButton
    	'Cancel' '' 'Cancel' 2 112 70 IntfDlg.AddButton

    	%add Interface combo box


    	% create label and combo box
    	'IntfLabel' '' 'Interface:' 17 19 IntfDlg.AddLabel

    	99 21 IntfDlg.SetComboSize
    	'IntfCombo' '' 88 16 IntfDlg.AddCombo

    	% create one entry for each interface
		/First 1 def
		IntfArray [B
			/TmpIntf exch def
			'IntfCombo' TmpIntf.Caption IntfDlg.AddString
			First 1 eq [B
				'IntfCombo' TmpIntf.Caption IntfDlg.SetStrVal
				/First 0 def
			] if
		] forall    
		/TmpIntf IntfArray 0 get def

    	% execute dialog
    	IntfDlg.Execute 1 eq [B
   			/IntfCaption 'IntfCombo' IntfDlg.GetStrVal def      		
      		IntfArray [B
				/TmpIntf exch def
    			TmpIntf.Caption IntfCaption eq [B
    				/IntfSel TmpIntf def	
    			] if	  			
      		] forall
      		/Result #1 def
    	] if
    	[A /IntfSel /Result]
  	] def


  	/SelectAppl [P
    	[A /ApplArray]

    	% init variables
    	/Result #0 def		
		  /ApplSel ApplArray 0 get def
 
    	% create choose application dialog
    	/ApplDlg 'Choose Application' 218 140 Create:Form def
    	% add ok/cancel buttons
    	75 25 ApplDlg.SetButtonSize
    	'Ok' '' 'Ok' 1 17 70 ApplDlg.AddButton
    	'Cancel' '' 'Cancel' 2 112 70 ApplDlg.AddButton

    	%add application combo box


    	% create label and combo box
    	'ApplLabel' '' 'Application:' 17 19 ApplDlg.AddLabel

    	99 21 ApplDlg.SetComboSize
    	'ApplCombo' '' 88 16 ApplDlg.AddCombo

    	% create one entry for each application
		/First 1 def
		ApplArray [B
			/TmpAppl exch def
			'ApplCombo' TmpAppl.Caption ApplDlg.AddString
			First 1 eq [B
				'ApplCombo' TmpAppl.Caption ApplDlg.SetStrVal
				/First 0 def
			] if
		] forall    
		/TmpAppl ApplArray 0 get def

    	% execute dialog
    	ApplDlg.Execute 1 eq [B
   			/ApplCaption 'ApplCombo' ApplDlg.GetStrVal def      		
      		ApplArray [B
				/TmpAppl exch def
    			TmpAppl.Caption ApplCaption eq [B
    				/ApplSel TmpAppl def	
    			] if	  			
      		] forall
      		/Result #1 def
    	] if
    	[A /ApplSel /Result]
  	] def

    
    /ReadyForStopDlg [P
		[A ]
	    	/Result #0 def		
	    	/ReadyDlg 'Ready to Download' 400 150 Create:Form def
	    	
	    	'Label1' '' 'The System is ready to download the firmware.' 17 19 ReadyDlg.AddLabel
	    	'Label2' '' 'The download procedure will erase all former settings.' 17 32 ReadyDlg.AddLabel
	    	'Label3' '' 'Do you want to continue?' 17 55 ReadyDlg.AddLabel
	    		    	
	    	% add ok/cancel buttons
    		75 25 ReadyDlg.SetButtonSize
    		'Ok' '' 'Ok' 1 108 80 ReadyDlg.AddButton
    		'Cancel' '' 'Cancel' 2 203 80 ReadyDlg.AddButton	
			/Result ReadyDlg.Execute 1 eq def 
		
		[A /Result]
	] def

    /AbortDlg [P
		[A Msg]

	    	/AbortDlg 'Abort' 368 150 Create:Form def
	    	
   	    	'AbortLbl' '' 'Installation aborted!' 92 19 AbortDlg.AddLabel
   	    	'AbortMsg' '' Msg 92 49 AbortDlg.AddLabel
	    	   	
	    	% add ok button
    		75 25 AbortDlg.SetButtonSize
    		'Ok' '' 'Ok' 1 146 80 AbortDlg.AddButton
			AbortDlg.Execute
		[A ]
	] def

    /SuccessDlg [P
		[A Msg]

	    	/SuccessDlg 'Success' 368 140 Create:Form def
	    	
   	    	'SuccessLbl' '' 'Installation successfully completed!' 92 19 SuccessDlg.AddLabel
   	    	   	
	    	% add ok button
    		75 25 SuccessDlg.SetButtonSize
    		'Ok' '' 'Ok' 1 146 70 SuccessDlg.AddButton
			SuccessDlg.Execute
		[A ]
	] def



    /FileCheck [P
    	[A ]
    		/Result #1 def
    		/MissingFile '' def
    		% OS
 			  Result [B	
  				/FileName FilePath OSDir add '\' add OSLoaderFile add def
  				FileName '.stx' add FileExist [B
  					OSLoaderFile nknown not [B FileName import ] if
					  #0 OSLoadSW not [B
	 					  /Result #0 def 
						  /MissingFile exch def
  					] if
  				][B
 					  /Result #0 def 
 					  /MissingFile FileName def
 				  ] ifelse
 			  ] if
 			% MC  
 			Result [B	
  				/FileName FilePath MCDir add '\' add MCLoaderFile add def
  				FileName '.stx' add FileExist [B
  					MCLoaderFile nknown not [B FileName import ] if
 					#0 MCLoadSW not [B
	 					/Result #0 def 
 						/MissingFile exch def
  					] if
  				][B
 					/Result #0 def 
 					/MissingFile FileName def
 				] ifelse
 			] if
 			% Interface
 			Result [B	
  				IntfSel.Name 'None' ne [B
  					/FileName FilePath IntfSel.IntfDir add '\' add IntfSel.IntfLoaderFile add def
  					FileName '.stx' add FileExist [B
  						IntfSel.IntfLoaderFile nknown not [B FileName import ] if
 						#0 IntfSel.IntfLoadSW not [B
	 						/Result #0 def 
 							/MissingFile exch def
  						] if
  					][B
 						/Result #0 def 
 						/MissingFile FileName def
 					] ifelse
 				] if
 			] if 			  
 			% Application
 			Result [B	
  				ApplSel.Name 'None' ne [B
  					/FileName FilePath ApplSel.ApplDir add '\' add ApplSel.ApplLoaderFile add def
  					FileName '.stx' add FileExist [B
  						ApplSel.ApplLoaderFile nknown not [B FileName import ] if
 						#0 ApplSel.ApplLoadSW not [B
	 						/Result #0 def 
 							/MissingFile exch def
  						] if
  					][B
 						/Result #0 def 
 						/MissingFile FileName def
 					] ifelse
 				] if
 			] if 			  
 
    	[A /MissingFile /Result]
    ] def
	    
	/ReleaseString  ReleaseVersion cvs '.' add ReleaseSubVersion cvs add ' ' add ReleaseBuildInfo add def

]

	/InstallProc [P
	
		[A ]
		
		/Continue #1 def
		'Installing Firmware Release ' ReleaseString add  log
      '' log
      'Checking Servo Controller...' log
      /EloType  GetEloType def
		  EloType CheckEloIsKnown [B
			/Controller EloType GetEloDict def
			%'Device Type: ' Controller.Name add log
			'Device Text: ' GetEloTypeStr add log
			'Device Type ID: 0' EloType 16 cvrs add 'h' add log
			Controller.TypeSupported 1 eq [B
				'Device Type Supported: True' log
				/EloHWVersion GetEloVersion def
				'Device HW Version: 0' EloHWVersion 16 cvrs add 'h' add log	
				EloHWVersion Controller CheckHWVersionCompatible [B 
					'Device HW Version Supported: True' log	
					/EloSWVersion GetEloSWVersion def
					'Device SW Version: ' EloSWVersion cvs add log
					EloSWVersion Controller CheckEloSWVersionCompatible [B 
						'Device SW ID Supported: True' log		    
						'' log
						
						/PowerExtension Controller.PowerExtension def
						/EloTypeExt Controller.EloTypeExt def
						/EasyStepsParExt Controller.EasyStepsParExt def

            % Interfaces						
						Controller.Interfaces Count 0 eq [B
							/NoIntf #1 def	
						][B
							/NoIntf #0 def
						] ifelse
								
						'Interfaces compatible with Controller: ' log
						Controller.Interfaces [B
							/IntfInfo exch def
							IntfInfo.Name 'No' ne [B
								'- ' IntfInfo.Caption add log
							] if
						] forall
						/Continue #1 def

						Controller.Interfaces count 1 gt [B
							ProgFlag not [B														
								Controller.Interfaces SelectIntf [B
									/IntfSel exch def
									IntfSel.Caption ' selected.' add log				
								][B
									/IntfSel exch def
									'Installation aborted! No Interface selected!' log				
									/Continue #0 def
								] ifelse
							]
							[B
								Controller.Interfaces [B
									/IntfSel exch def
									ExitLoop								
								] forall
							] ifelse	
						][B  	
							NoIntf not [B
								Controller.Interfaces [B
								  /IntfSel exch def  
								] forall  
								IntfSel.Caption ' Interface selected.' add log				
							] if
						] ifelse
						
            Continue [B
	            % Applications
							Controller.Applications Count 0 eq [B
								/NoAppl #1 def	
							][B
								/NoAppl #0 def
							] ifelse
									
							'Applications compatible with Controller: ' log
							Controller.Applications [B
								/ApplInfo exch def
								ApplInfo.Name 'None' ne [B
									'- ' ApplInfo.Caption add log
								] if
							] forall
							/Continue #1 def
	
							Controller.Applications count 1 gt [B
								ProgFlag not [B														
									Controller.Applications SelectAppl [B
										/ApplSel exch def
										ApplSel.Caption ' selected.' add log				
									][B
										/ApplSel exch def
										'Installation aborted! No Application selected!' log				
										/Continue #0 def
									] ifelse
								]
								[B
									Controller.Applications [B
										/ApplSel exch def
										ExitLoop								
									] forall
								] ifelse	
							][B  	
								NoAppl not [B
									Controller.Applications [B
									  /ApplSel exch def  
									] forall  
									ApplSel.Caption ' Application selected.' add log				
								] if
							] ifelse
						] if	

						Continue [B
							'' log
							'Checking files...'  log	
							
							FileCheck [B
								'...all necessary files have been found.' log	
								'' log

								ProgFlag not [B
									/Bool ReadyForStopDlg def
								]
								[B
									/Bool #1 def
								] ifelse
								
								Bool [B							
									'Starting download procedure...' log
									'' log
									Continue [B
										#1 OSLoadSW
										/Continue exch def
										/MissingFile exch def
										'' log
									] if
									Continue [B
										#1 MCLoadSW
										/Continue exch def
										/MissingFile exch def
										'' log
									] if
									Continue [B
										IntfSel.Name 'None' ne [B
											#1 IntfSel.IntfLoadSW
											/Continue exch def
											/MissingFile exch def
											'' log
										] if
									] if
									Continue [B
										ApplSel.Name 'None' ne [B
											#1 ApplSel.ApplLoadSW
											/Continue exch def
											/MissingFile exch def
											'' log
										] if
									] if
									Continue [B
									
										/TalkVersion PIVar:TalkVersion $F0 and def
										
											%B1100
           									TalkVersion $40 eq [B	
											/ReleaseInfoAddr		Offset $830 add def
											/ReleaseVersionAddr 	Offset $850 add def
											/ReleaseSubVersionAddr	Offset $852 add def
										    ]if
											
											%E1100 
           									TalkVersion $20 eq [B	
											/ReleaseInfoAddr		Offset $748 add def
											/ReleaseVersionAddr 	Offset $7A8 add def
											/ReleaseSubVersionAddr	Offset $7AA add def
										    ]if
         								
										'Writing Release Info...' log
									
										ReleaseInfoAddr ReleaseString 32 ' ' padr WriteStringToElo
										ReleaseVersionAddr ReleaseVersion WriteWordToElo
										ReleaseSubVersionAddr ReleaseSubVersion WriteWordToElo

										'' log
										'Resetting Device. Please wait...' log
					     	      		ResetDevice                                                                                            
    		    						6000 wait

									] if

									Continue not [B
										'Installation aborted! ' log
										'' AbortDlg														
									][B
										'Installation successfully completed!' log
   	                ProgFlag not [B
   		                SuccessDlg
   	                ] if
									] ifelse
								][B
									'Installation aborted! ' log																				
								] ifelse						
							][B
								/MissingFile exch def
								'Installation aborted! ' log				
								
								'File not found: \' MissingFile add log
								'File not found: \' MissingFile add AbortDlg								
							] ifelse								
						] if		
								
					][B
						'Device SW ID Supported: False' log				
						'' log
						'Installation aborted! ' log
						'Device SW ID not supported!' AbortDlg
					] ifelse
				][B
					'Device HW Version Supported: False' log				
					'' log
					'Installation aborted! '
					'The Version ' EloHWVersion 16 cvrs add 'h' add 
					' of the Controller ' add Controller.Name add 
					' is not compatible with this firmware release!' add log
					'HW Version not supported!' AbortDlg				
				] ifelse
			][B
				'Device Type Supported: False' log	
				'' log
				'Installation aborted! '
				'The Controller ' add Controller.Name add 
				' is not compatible with this firmware release!' add log
				'Device Type not supported!' AbortDlg							
			] ifelse
		][B
			'Device Type: 0' EloType 16 cvrs add 'h' add log
			'' log
			'Installation aborted! Unknown  Device Type!' log
			'Unknown  Device Type!' AbortDlg
		] ifelse       	
		
		[A /Continue ]
		
	]


   /InitPackInst [B
      ProgFlag [B
        	/DevName exch def        	        	
         /Device Create:Device def
         DevName Device.AssignDevice
         DevName /PackInst:OnMessageCallback PackInst:Init
      ] [B
         /PackInst:OnMessageCallback PackInst:InitNew
         /Device PIVar:Device def
         /PortName 'PortName' Device.GetDeviceVar def
      ] ifelse
      /InitResult exch def
      InitResult [B
         /TalkIntf PIVar:TalkIntf def
         /TalkVersion PIVar:TalkVersion $F0 and def
         TalkVersion [B
           $40 [B /Offset $300000 def ]
           $20 [B /Offset $200000 def ]
         ]
         [B
           'Installation aborted! Unknown talk protocol version!' raisese
         ] case
         /log [B 'LogTxt' exch PackInst:OnMessageCallback ] def
         #1
      ] [B
         #0
      ] ifelse
   ]

   /PackInstExit [B
     PackInst:Exit
   ]

]