Function WM_OUT_Events(CtrlEntId, Event, @PARAMS)
/***********************************************************************************************************************

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

    Name        :   WM_OUT_Events

    Description :   This function acts as a commuter module for all events related to this window.

    Notes       :   Commuter Modules are automatically called from the Promoted_Events function which is called by the
                    application-specific promoted event handler. This makes it possible to add QuickEvents that need to
                    execute Basic+ logic without having use the Form Designer to make the association, although this is
                    limited to the events which are currently promoted.

                    If the form needs to call the commuter module directly then the QuickEvent parameters should be
                    formatted like this:

                        '@SELF','@EVENT',['@PARAM1','@PARAMx']

    Parameters  :
        CtrlEntId   [in] -- The fully qualified name of the control calling the promoted event
        Event       [in] -- The event being executed. See the Notes section regarding "PRE" events
        Param1-15   [in] -- Additional event parameter holders
        EventFlow  [out] -- Set to 1 or 0 so the calling event knows whether or not to chain forward. See comments in
                            EVENT_SETUP insert

    History     :   (Date, Initials, Notes)
        11/11/2021    djs     Created initial commuter module.
                            

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

#pragma precomp SRP_PreCompiler
#Window WM_OUT

$insert APP_INSERTS
$insert EVENT_SETUP
$insert WM_OUT_EQUATES
$insert POPUP_EQUATES

EQU APPGREEN$  TO 192 + (220*256) + (192*65536)
EQU APPRED$    TO 255 + (128*256) + (128*65536)
EQU APPORANGE$ TO 255 + (176*256) + (0*65536)

Declare subroutine Start_Window
Declare function   Signature_Services

SubclassInfo    = Form_Services('FindSubclassControl')
Subclass        = SubclassInfo<1>

// Update the arguments so that the OpenInsight OLE event will treate the ActiveX event as a native event handler.
If Event EQ 'OLE' then
    Transfer Event to OIEvent
    Transfer Param1 to Event
    Transfer Param2 to Param1
    Transfer Param3 to Param2
*    Transfer Param4 to Param3
*    Transfer Param5 to Param4
*    Transfer Param6 to Param5
*    Transfer Param7 to Param6
*    Transfer Param8 to Param7
end

GoToEvent Event for CtrlEntID

Return EventFlow else EVENT_CONTINUE$


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Event WINDOW.CREATE(CreateParam)    

end event


Event WINDOW.READ()

end event


Event WINDOW.CLOSE(CancelFlag)

end event


Event WINDOW.CLEAR(bSaveKey, bSuppressWarning, bMaintainFocus, CtrlIDFocus)

    Set_Property(@Window, '@ORIG_WFR_CTR_QTY', '')
	Set_Property(@WINDOW:'.EDL_WAFER_COUNTER_QTY','BACKCOLOR', APPGREEN$)

end event


Event SLOT.DBLCLK(CtrlKey, ShiftKey, MouseButton)

    SelPos = Get_Property(CtrlEntID, 'NOTIFYPOS')
    Col    = SelPos<1>
    If Col EQ 2 then
        Row   = SelPos<2>
        List  = Get_Property(CtrlEntID, 'LIST')
        RDSNo = List<Row, Col>
        If RowExists('RDS', RDSNo) then
            Start_Window('RDS_UNLOAD', @Window, RDSNo)
        end
    end
    
end event


Event PUB_SIG_PROFILE.CLICK()
    
    WONo     = Get_Property(@Window:'.WO_NO', 'TEXT')
    CassNo   = Get_Property(@Window:'.OUT_CASS_NO', 'TEXT')
    WOMatKey = WONo:'*':CassNo
    
    If ( (WONo NE '') and (CassNo NE '') ) then
        SigData = Signature_Services('GetSigProfile', WOMatKey, False$)
        Display = ''
        RowCnt = COUNT(SigData<1>,@VM) + (SigData<1> NE '')
        
        FOR I = 1 TO RowCnt
            Display<1,I,1> = SigData<1,I>
            Display<1,I,2> = SigData<2,I>
            Display<1,I,3> = SigData<3,I>
            Display<1,I,4> = SigData<4,I>
        NEXT I
        
        TypeOver = ''
        TypeOver<PDISPLAY$> = Display
        
        void = Popup(@WINDOW,TypeOver,'SIG_PROFILE')   
    end
    
end event


Event EDL_WAFER_COUNTER_QTY.CHANGED(NewData)
	
	QtyBackColor = APPGREEN$
	WONo         = Get_Property(@Window:'.WO_NO', 'TEXT')
	WOStep       = Get_Property(@Window:'.PROC_STEP_NO', 'TEXT')
	Cassette     = Get_Property(@Window:'.OUT_CASS_NO', 'TEXT')
	WMOKey       = WONo:'*':WOStep:'*':Cassette
	If WMOKey NE '**' then
		WafersFilled    = Get_Property(@WINDOW:'.WAFER_CNT','TEXT')
		WaferCounterQty = NewData
		If (WaferCounterQty NE '') then
			If (WaferCounterQty NE WafersFilled) then QtyBackColor = APPRED$
		end else
			QtyBackColor = APPORANGE$
		end
		
		OrigWCQty = Get_Property(@Window, '@ORIG_WFR_CTR_QTY')
		OrigRec   = @Record
		CurrRec   = Get_Property(@Window, 'ATRECORD')
		Savewarn  = (OrigRec NE CurrRec) or (OrigWCQty NE WaferCounterQty)
		Set_Property(@Window, 'SAVEWARN', Savewarn)
	end
	Set_Property(@WINDOW:'.EDL_WAFER_COUNTER_QTY','BACKCOLOR', QtyBackColor)
	
end event

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


