Sounds.cpp – Rockwell Automation 1789-L10_L30_L60 SoftLogix 5800 System User Manual User Manual

Page 131

Advertising
background image

Rockwell Automation Publication 1789-UM002J-EN-P - December 2012

131

Develop External Routines

Chapter 7

Sounds.cpp

// Sounds.cpp : Defines the entry point for the DLL application.

#include "stdafx.h"
#include "RA_ExternalRoutines.h"
#include <Mmsystem.h>
#include <process.h>

HANDLE

hTerminate = NULL;

// DllMain needs to create a global event which all threads need to check for.
// This event will be used to tell the threads that the DLL is being unloaded
// and that it is time to terminate.
//
// Not creating and using this event can lead to access violations in the threads which
// will cause the SoftLogix controller to terminate and display a red X across the module.

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved

)

{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:

hTerminate = CreateEvent (NULL, TRUE, FALSE, NULL);
return (TRUE);

case DLL_PROCESS_DETACH:

SetEvent (hTerminate);
Sleep (50); // give threads the chance to act on termination notice.
return (TRUE);

case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:

return (TRUE);

}

return (FALSE);
}

typedef enum rungStates {

FIRST_SCAN,
RUNG_TRUE,
RUNG_FALSE,
INVALID_STATE

} RUNGSTATES;

RUNGSTATES rungState = INVALID_STATE;

HANDLE hControllerState;

Advertising