EasyManua.ls Logo

Allen-Bradley SoftLogix 5800

Allen-Bradley SoftLogix 5800
272 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Rockwell Automation Publication 1789-UM002K-EN-P - January 2015 133
Develop External Routines Chapter 7
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();
}
extern "C" __declspec(dllexport) void SayRungState(EXT_ROUTINE_CONTROL * pERCtrl)
{
pERCtrl->ctrlWord.EN = pERCtrl->ctrlWord.EnableIn;
rungState = INVALID_STATE;
// Only create the thread on prescan.
if (pERCtrl->ctrlWord.ScanType == 1)
{
hControllerState = CreateEvent(NULL, FALSE, TRUE, NULL);
if (hControllerState)
{
HANDLE hThread;
hThread = (HANDLE) _beginthread (RungStateThread,
0, // stack size
hControllerState); // arglist
if (hThread != INVALID_HANDLE_VALUE)
{
// The following code will set the thread's priority to the
// same priority as the task that invoked the external routine.
// If the thread is not performing time-critical work, then
// it is recommended that you set its priority to
// THREAD_PRIORITY_IDLE, i.e.
// SetThreadPriority (hThread, THREAD_PRIORITY_IDLE);
SetThreadPriority (hThread,
GetThreadPriority(GetCurrentThread()));
}
}

Table of Contents

Related product manuals