% Installation package for E1100 Firmware 
% Application:	Remove_Applicaton
% Date:    15.12.2004
% Copyright 2004, NTI Ltd.

[D
	
   /Main [B
    
   'PackInst' import

	    
    /ReadyForStopDlg [P
		[A ]
	    	/Result #0 def		
	    	/ReadyDlg 'Ready for Removing Application' 500 150 Create:Form def
	    	
	    	'Label1' '' 'The system is ready for clearing the firmware application layer.' 17 19 ReadyDlg.AddLabel
	    	'Label2' '' 'The procedure will stop the firmware and erase all former application layer 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 158 80 ReadyDlg.AddButton
    		'Cancel' '' 'Cancel' 2 253 80 ReadyDlg.AddButton	
			/Result ReadyDlg.Execute 1 eq def 
		
		[A /Result]
	] def

    /AbortDlg [P
		[A Msg]

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

    /SuccessDlg [P
		[A Msg]

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

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


    
	/InstallProc [B
		'Application Layer Remove Script:' log
		ReadyForStopDlg [B							
			'Stopping Firmware...' log
			PackInst:StopProgram		
			'Erasing application firmware sector...' log     
			4 TalkIntf.ClearInstanceAll
			'' log
			'Resetting Device. Please wait...' log
 	    	ResetDevice                                                                    
 	    	6000 wait
			'' log
			'Installation successfully completed!' log
			'' SuccessDlg
		][B
			'Installation aborted! ' log																				
		] ifelse						

	] def



   /InitPackInst [B
      /DeviceName gknown [B
         /Device Create:Device def
         DeviceName Device.AssignDevice
         /PortName 'PortName' Device.GetDeviceVar def
         Device.DestroyDevice
         'PortName' PortName 1 DeviceName 'LinMotOnline' Device.CreateDevice
         DeviceName /PackInst:OnMessageCallback PackInst:Init
      ] [B
         /PackInst:OnMessageCallback PackInst:InitNew
         /Device PIVar:Device def
         /PortName 'PortName' Device.GetDeviceVar def
      ] ifelse
      [B
         /TalkIntf PIVar:TalkIntf def
         /log [B 'LogTxt' exch PackInst:OnMessageCallback ] def
         #1
      ] [B
         #0
      ] ifelse
   ] def

   PackInst:Exit

]


]