Function SVC_Dopant(Service, Param1, Param2, Param3, Param4, Param5, Param6, Param7)

/******************************************************************************************************** 

    This program is proprietary and is not to be used by or disclosed to others, nor is it to
    be copied without written permission.

    Name        :   SVC Dopant

    Description :   

    Tags		:	[SRP]

    Parameters  :

    History (Date, Initials, Notes)
        01/18/10    fjt     Initial development

********************************************************************************************************/

$insert SRP_APP_INSERTS
$insert SERVICE_INSERT

Declare function   SRP_Rotate_Array, SRP_Clean_Array

GoSub Init
Begin Case
	Case Service _eqc "Color"	
	Case Service _eqc "Check"				; GoSub Check
	Case Service _eqc "Qualify"				; GoSub Qualify
	Case Service _eqc "Reactor"				; GoSub Reactor
End Case

Return Ans


!----- SERVICES -----------------------------------------------------------------------------------------


Init:
	Equ Sched_Win$ to "WO_MASTER_SCHEDULER"
	Equ Ctrl$	   to Sched_Win$:".OLE_SCHEDULE"
	Equ Table$	   to "WO_MAST_SCHED"
	Equ Info$	   to Sched_Win$:".EDT_INFO"
return


Check:
	Dopant = Param1
	Source = Param2
	React  = Param3
	
	Rec.R  = Xlate("REACTOR", React, "", "X")
	List   = Xlate("GAS_SRC", Rec.R<5>, 1, "X")
	Swap @VM with @FM in List

 	GoSub Gas_Types
	Locate Source in List using @FM setting Pos then Check.1 = "G" else Check.1 = "R"
	Locate Dopant in List using @FM setting Pos then Check.2 = "G" else Check.2 = "R"
	
	GoSub Colors
	
	Ans<1> = Check.1
	Ans<2> = Check.2
	Ans<3> = Check.1 EQ "G" and Check.2 EQ "G"
	Param1 = Dopant
	Param2 = Source
return


Qualify:
	React      = Param3
	PSN 	   = Param4
	Rec.P      = Xlate("PROD_SPEC", PSN, "", "X")
	
	Param1 = Rec.P<013> ;// Qualified
	Param2 = Rec.P<121> ;// Blocked
	
	If Param1 EQ "" then
		Check.1 = "G"
	end else
		Locate React in Param1 using @VM setting Pos then Check.1 = "G" else Check.1 = "R"
	end

	If Param2 EQ "" then
		Check.2 = "G"
	end else
		Locate React in Param2 using @VM setting Pos then Check.2 = "R" else Check.2 = "G"
	end
	
	GoSub Colors
	Ans<1> = Check.1
	Ans<2> = Check.2
	Convert @VM to ", " in Param1
	Convert @VM to ", " in Param2
return


Reactor:
	For i = 20 to 69
		Rec = Xlate("REACTOR", i, "", "X")
		rv  = Xlate("GAS_SRC", Rec<5>, 1, "X")
		Swap @VM with @FM in rv
		Ans := rv :@FM
	Next i
	If Ans[-1,1] EQ @FM then Ans[-1,1] = ""
 	Ans = SRP_Clean_Array(Ans, @FM, "UNIQUE")
return


!----- INTERNAL ROUTINES --------------------------------------------------------------------------------


Colors:
	Red   = "Vertical(Gradient(Red L=90, Red L=80, 30%), Gradient(Red L=75, Red L=80), Border(Red, None, Red, None))"
	Green = "Vertical(Gradient(Green L=90, Green L=80, 30%), Gradient(Green L=75, Green L=80), Border(Green, None, Green, None))"
	
	// Source 
	Begin Case
		Case Check.1 EQ "R" ; Check.1 = Red
		Case Check.1 EQ "G" ; Check.1 = Green
	End Case

	// Dopant 
	Begin Case
		Case Check.2 EQ "R" ; Check.2 = Red
		Case Check.2 EQ "G" ; Check.2 = Green
	End Case
return


Gas_Types:
	// Confirmed Types
	Gas = "AsH3_1000,B2H6_1%,PH3_50,GeH4_10%,N2,SiH2Cl2,SiH4,SiHCl3,SiH4_2%"

	For i = 1 to 2
		If i EQ 1 then Val = Source else Val = Dopant
		
		// Dopant
		Swap "1000 ppm Arsenic"						with "AsH3_1000" in Val
		Swap "Heavy Dope – Arsine 1000ppm (0.1%)"	with "AsH3_1000" in Val
		Swap "1% Boron"								with "B2H6_1%"   in Val
		Swap "Heavy Dope – Diborane 1%"				with "B2H6_1%"   in Val
		Swap "Phosphorus"							with "PH3_50"    in Val
		Swap "Phosphine 50 ppm"						with "PH3_50"    in Val
		Swap "Boron/Germanium"						with "GeH4_10%"  in Val
		Swap "Heavy Dope – Germane 10%"				with "GeH4_10%"  in Val
		// Source
		Swap "Dichlorosilane"						with "SiH2Cl2"   in Val
		Swap "Silane"								with "SiH4"		 in Val
		Swap "Trichlorosilane"						with "SiHCl3"	 in Val
		Swap "Silane 2%"							with "SiH4_2%"	 in Val
		// Other
		Swap "Nitrogen"								with "N2"		 in Val
		
		If i EQ 1 then Source = Val else Dopant = Val
	Next i
return

