Programming example: outbound events – Rockwell Automation 1789-L10_L30_L60 SoftLogix 5800 System User Manual User Manual

Page 148

Advertising
background image

148

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

Chapter 8

Program Windows Events to Monitor and Change Controller Execution

Programming Example: Outbound Events

This example monitors a controller for mode changes and displays the controller
mode whenever a change occurs.

/****************************************************************************
** **
** SOFTLOGIX 5800 OUTBOUND EVENTS EXAMPLE CODE **
** COPYRIGHT (c) 2003 ALLEN-BRADLEY COMPANY, L.L.C. **
** **
** All rights reserved, except as specifically licensed in writing. **
** The following work constitutes example program code and is intended **
** merely to illustrate useful programming techniques. The user is **
** responsible for applying the code correctly. The code is provided **
** AS IS without warranty and is in no way guaranteed to be error-free. **
****************************************************************************/

/****************************************************************************
*
* FILE: OutBoundEventExample.cpp
*
* FULL DESC:
*
* This is an example command mode application that will indicate when
* a SoftLogix5800 controller changes modes. It uses the new Outbound
* Event support that is being introduced with version 12 of the
* SoftLogix5800 product.
*
* It should be compiled using the Microsoft Visual Studio compiler.
* You can use the following steps to compile and run this example.
*
* 1) Open a Windows command prompt window by choosing
* Start->Run, and entering cmd for the command line.
* 2) Make sure that the Microsoft Visual Studio compiler bin
* directory is in your path.
* 3) Execute the compiler using the following command
* cl OutBoundEventExample.cpp
* 4) Run the resultant executable using the following command
* OutBoundEventExample 3
* The 3 in the example above indicates the slot number for
* the controller for which you want to monitor mode changes.
*
* This example code waits for the controller mode change event,
* and after receiving the mode change event, checks the controller
* mode events to determine and display the new controller mode.
*
* Copyright Allen-Bradley Company, Inc. 2003
*
****************************************************************************/
#include <stdio.h>
#include <windows.h>
#include <tchar.h>

// Define event handle variables
HANDLE hModeChange = 0;
HANDLE hProgramMode = 0;
HANDLE hRunMode = 0;
HANDLE hTestMode = 0;
HANDLE hFaultMode = 0;

Advertising