Rockwell Automation 1789-L10_L30_L60 SoftLogix 5800 System User Manual User Manual

Page 133

Advertising
background image

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

133

Develop External Routines

Chapter 7

while (!exitThread)
{

// This example uses an arbitrary timeout of 5 seconds
// to determine whether the controller is still in run mode.
// If this time expires, we can assume that the controller
// is no longer in run mode, and we can terminate this thread.

// Note: The 5000 millisecond timeout value can be adjusted
// to a value that fits the requirements for your specific
// application.

status = WaitForMultipleObjects (2, hArrayHandles, FALSE, 5000);
switch (status)
{
case WAIT_OBJECT_0:

if (oldRungState != rungState)
{

oldRungState = rungState;
switch (oldRungState) {
case FIRST_SCAN:

PlaySound("FIRSTSCAN");
break;

case RUNG_TRUE:

PlaySound("RUNGTRUE");
break;

case RUNG_FALSE:

PlaySound("RUNGFALSE");
break;

default:

exitThread = TRUE;

}

}
break;

case WAIT_OBJECT_0 + 1:

exitThread = TRUE;

case WAIT_TIMEOUT:
case WAIT_ABANDONED:
case WAIT_FAILED:

exitThread = TRUE;

}

}

CloseHandle(hController);
_endthread();

}

Advertising