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...
152 Rockwell Automation Publication 1789-UM002K-EN-P - January 2015
Chapter 8 Program Windows Events to Monitor and Change Controller Execution
{
_tprintf(_T("Bad run mode event handle\n"));
_tprintf(_T("GetLastError() = %d\n"), GetLastError());
return 1;
}
else
{
// Add the run mode event to the event array
EventArray[numevents] = hRunMode;
numevents++;
}
// Create the test mode event. Note: it must be created as manual reset.
_stprintf(eventname, sa_test_event_fmt, slot);
hTestMode = CreateEvent (NULL, TRUE, FALSE, eventname);
if (hTestMode == NULL)
{
_tprintf(_T("Bad test mode event handle\n"));
_tprintf(_T("GetLastError() = %d\n"), GetLastError());
return 1;
}
else
{
// Add the test mode event to the event array
EventArray[numevents] = hTestMode;
numevents++;
}
// Create the fault mode event. Note: it must be created as manual reset.
_stprintf(eventname, sa_fault_event_fmt, slot);
hFaultMode = CreateEvent (NULL, TRUE, FALSE, eventname);
if (hFaultMode == NULL)
{
_tprintf(_T("Bad fault mode event handle\n"));
_tprintf(_T("GetLastError() = %d\n"), GetLastError());
return 1;
}
else
{
// Add the fault mode event to the event array
EventArray[numevents] = hFaultMode;
numevents++;
}
// We are now ready to start waiting for mode changes!
_tprintf(_T("Ready\n"));
fflush(stdout);
// Loop forever, waiting for mode changes. The user must perform a control-c to
// stop the application
while (1)
{
// First we wait for the single mode change event. The mode change event is an
// automatic reset event that is set by the SoftLogix controller every time the
// controller is changing modes. Once the mode change event is set, we need to
// check the state of the acutal mode events.
status = WaitForSingleObject(hModeChange,INFINITE);
switch (status)
{
case WAIT_OBJECT_0:

Table of Contents

Related product manuals