Compile function NDW_VIEW_TEST_RUN_EVENTS(CtrlEntId, Event, @PARAMS)
#pragma precomp SRP_PreCompiler
#window NDW_VIEW_TEST_RUN

Declare function Test_Run_Services
Declare subroutine Set_Property

$Insert TEST_RUN_OBJ_EQUATES

GoToEvent Event for CtrlEntId else
    // Event not implemented
end

Return EventFlow or 1

//-----------------------------------------------------------------------------
// EVENT HANDLERS
//-----------------------------------------------------------------------------

Event WINDOW.CREATE(CreateParam)
    debug
    If CreateParam NE '' then
        TestRunID = CreateParam
        If RowExists('TEST_RUN', TestRunID) then
            GoSub GetTestRunData
        end else
            //todo error message
        end
    end
    
End Event

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

GetTestRunData:
    debug
    TRRec = ''
    If Assigned(TestRunID) AND RowExists('TEST_RUN', TestRunID) then
        TRRec = Test_Run_Services('GetTestRunObj', TestRunID)
        Set_Property(@window : '.EDL_REASON', 'TEXT', TRRec<TEST_RUN_OBJ_RUN_TYPE$>)
        Set_Property(@Window : '.EDL_RDS', 'TEXT', TRRec<TEST_RUN_OBJ_RDS_ID$>)
        Set_Property(@Window : '.EDL_PSN', 'TEXT', TRRec<TEST_RUN_OBJ_PROD_SPEC_ID$>)
        Set_Property(@Window : '.EDL_EQUIP_TYPE', 'TEXT', TRRec<TEST_RUN_OBJ_EQUIPMENT_TYPE$>)
        Set_Property(@Window : '.EDL_EQUIP_ID', 'TEXT', TRRec<TEST_RUN_OBJ_EQUIPMENT_ID$>)
        Set_Property(@Window : '.EDL_USER', 'TEXT', TRRec<TEST_RUN_OBJ_LSL_USER_ID$>)
        Set_Property(@Window : '.EDL_DTM', 'TEXT', TRRec<TEST_RUN_OBJ_RUN_DTM$>)
        
        TestWaferProds = TRRec<TEST_RUN_OBJ_TEST_RUN_WAFER_PRODS$>
        TestWaferQtys  = TRRec<TEST_RUN_OBJ_TEST_RUN_WAFER_PRODS_QTYS$>
        TWUsageData    = ''
        for each TestWaferProd in TestWaferProds using @VM setting tPos
            TWUsageData<-1> = TestWaferProd : @VM : TestWaferQtys<tPos>
        Next TestWaferProd
        Set_Property(@Window : '.EDT_TW_USAGE', 'LIST', TWUsageData)
    end
return


