Rockwell Automation Publication 1789-UM002K-EN-P - January 2015
151
Program Windows Events to Monitor and Change Controller Execution
Chapter 8
// Use strings to define the event names in which we are interested
// The user will pass in the slot number via the command line
TCHAR sa_mode_change_event_fmt[] = _T("SOFTLOGIX_%02d_MODE_CHANGE");
TCHAR sa_program_event_fmt[] = _T("SOFTLOGIX_%02d_PROGRAM");
TCHAR sa_run_event_fmt[] = _T("SOFTLOGIX_%02d_RUN");
TCHAR sa_test_event_fmt[] = _T("SOFTLOGIX_%02d_TEST");
TCHAR sa_fault_event_fmt[] = _T("SOFTLOGIX_%02d_FAULT");
int main(int argc, char *argv[])
{
int slot = 0;
DWORD status = 0;
TCHAR eventname[_MAX_PATH];
// We will keep the mode event handles in an array for the WaitForMultipleObjects call
HANDLE EventArray[4];
HANDLE *events = &EventArray[0];
int numevents = 0;
// Make sure a slot number is passed in on the command line
argc--, argv++;
if (argc != 1)
{
_tprintf(_T("You must enter a slot number on the command line.\n"));
fflush(stdout);
return 1;
}
slot = atoi(*argv);
(void) GetLastError();
// Create the mode change event. Note: it must be created as auto reset.
_stprintf(eventname, sa_mode_change_event_fmt, slot);
hModeChange = CreateEvent (NULL, FALSE, FALSE, eventname);
if (hModeChange == NULL)
{
_tprintf(_T("Bad mode change handle\n"));
_tprintf(_T("GetLastError() = %d\n"), GetLastError());
return 1;
}
// Create the program mode event. Note: it must be created as manual reset.
_stprintf(eventname, sa_program_event_fmt, slot);
hProgramMode = CreateEvent (NULL, TRUE, FALSE, eventname);
if (hProgramMode == NULL)
{
_tprintf(_T("Bad program mode event handle\n"));
_tprintf(_T("GetLastError() = %d\n"), GetLastError());
return 1;
}
else
{
// Add the program mode event to the event array
EventArray[numevents] = hProgramMode;
nu+;
}
// Create the run mode event. Note: it must be created as manual reset.
_stprintf(eventname, sa_run_event_fmt, slot);
hRunMode = CreateEvent (NULL, TRUE, FALSE, eventname);
if (hRunMode == NULL)
Содержание SoftLogix 5800
Страница 1: ...SoftLogix 5800 System Catalog Numbers 1789 L10 1789 L30 1789 L60 User Manual...
Страница 4: ...4 Rockwell Automation Publication 1789 UM002K EN P January 2015 Summary of Changes Notes...
Страница 104: ...104 Rockwell Automation Publication 1789 UM002K EN P January 2015 Chapter 5 Configure and Use Simulated I O Notes...
Страница 110: ...110 Rockwell Automation Publication 1789 UM002K EN P January 2015 Chapter 6 Execute External Routines 9 Click OK...
Страница 148: ...148 Rockwell Automation Publication 1789 UM002K EN P January 2015 Chapter 7 Develop External Routines Notes...
Страница 256: ...256 Rockwell Automation Publication 1789 UM002K EN P January 2015 Appendix E System Performance Tuning Guidelines Notes...
Страница 262: ...262 Rockwell Automation Publication 1789 UM002K EN P January 2015 Appendix G SoftLogix 5800 Revision History Notes...
Страница 270: ...270 Rockwell Automation Publication 1789 UM002K EN P January 2015 Index...
Страница 271: ......