COMPILE FUNCTION KEYBOARD_SIM_SERVICES(@Service, @Params)

Declare Subroutine Errmsg, Error_Services
Declare function Get_Status
#pragma precomp SRP_PreCompiler

$Insert LOGICAL
$Insert SERVICE_SETUP
$Insert REVDOTNETEQUATES
$Insert RDS_EQUATES
$Insert PROD_SPEC_EQUATES
$Insert PRS_STAGE_EQUATES

response = ''

DotNetHandle = StartDotNet("","4.0")

//Specify the DLL
RootPath     = Drive()
rv           = Set_Property.NET(DotNetHandle, "AssemblyName", RootPath:'\IFXAPI\KeyboardSimulator\KeyboardSimulator.dll')
//Define the classes
WebClientAPI = Create_Class.NET(DotNetHandle, "Infineon.Mesa.OpenInsight.Library.KeyboardSimulator.Scan", 0)
errCode      = ''
IF Get_Status(errCode) THEN
                //ErrMsg(errCode)
                
END

GoToService else
	Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
end

    Free_Class.Net(WebClientAPI)

return response

Service SendTencor(ToolName, RDSNo)
    ClearData        = Send_Message.NET(WebClientAPI, "ClearData")
    SetScan          = Send_Message.NET(WebClientAPI, "SetScan", ToolName:@VM:"RDS":@VM:RDSNo,"System.String":@VM:"System.String":@VM:"System.String")
    PSNo             = XLATE('RDS', RDSNo, RDS_PROD_SPEC_ID$, 'X')
    Reactor          = XLATE('RDS', RDSNo, RDS_REACTOR$, 'X')
    SetData          = Send_Message.NET(WebClientAPI, "SetData", RDSNo:@VM:PSNo:@VM:Reactor,"System.String":@VM:"System.String":@VM:"System.String")
    PRSStageKeys     = XLATE('PROD_SPEC', PSNo, PROD_SPEC_PRS_STAGE_KEY$, 'X')
    RecipesToSend    = ''
    SumsOfDefects    = ''
    HazeAveragePPMs  = ''
    SampleQuantities = ''
    index            = 1
    for each PRSStage in PRSStageKeys using @VM
        PRSStageRec = XLATE('PRS_STAGE', PRSStage, '', 'X')
        Recipes     = PRSStageRec<PRS_STAGE_SURFSCAN_RECIPE$>
        IF Recipes NE '' then
            for each Recipe in Recipes using @VM
                RecipesToSend<1,index>     = Recipe
                SumsOfDefects<1,index>     = PRSStageRec<11, index>
                HazeAveragePPMs<1,index>   = PRSStageRec<10, index>
                SampleQuantities<1,index>  = PRSStageRec<23, index>
                index                     += 1 
            Next Recipe
        end
    Next PRSStage
    RecipeIndex = 1
    for each RecipeToSend in RecipesToSend using @VM
        AddRecipe    = Send_Message.NET(WebClientAPI, "AddSurfScanRecipe", RecipeToSend:@VM:SumsOfDefects<1,RecipeIndex>:@VM:HazeAveragePPMs<1,RecipeIndex>:@VM:SampleQuantities<1,RecipeIndex>,"System.String":@VM:"System.String":@VM:"System.String":@VM:"System.String")
        RecipeIndex += 1
    Next RecipeToSend
    IFXWriteData = Send_Message.NET(WebClientAPI, "DDriveWriteData")
    if Get_Status(errcode) then
    	Response = Get_Status(errcode)
    end else
    	Response = 'Success'
    end
    

end service




