158
Rockwell Automation Publication 1789-UM002K-EN-P - January 2015
Chapter 8
Program Windows Events to Monitor and Change Controller Execution
Programmatically Saving the
Controller
From an external routine or application, you can programmatically save the
current controller information (tag data values and configuration information).
A programmatic save can use these pre-defined Windows events. Replace the ‘
xx
’
with the 2-digit slot number where the controller resides.
Programming Example: Programmatic Save of Controller
The following example codes show how you can use all of the above events to
programmatically save the contents of a controller. This code uses printf
statements to help track progress through the application.
int savenow(int slot)
{
DWORD status;
WCHAR eventname[_MAX_PATH];
SECURITY_ATTRIBUTES sa;
PSECURITY_DESCRIPTOR pSD;
// Create a NULL DACL to allow other tasks to access the external events.
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD == NULL)
return 1;
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
return 1;
// Add a NULL DACL for full permission for all
if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE))
return 1;
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = TRUE;
// CreateEvent(security, manuallyReset, initialState, eventName);
swprintf(eventname, sa_kicksave_event_fmt, slot);
h_kicksaveEvent = CreateEvent (&sa, FALSE, FALSE, eventname);
printf("h_kicksaveEvent = %d
swprintf(eventname, sa_savepermitted_event_fmt, slot);
h_savePermittedEvent = CreateEvent (&sa, TRUE, FALSE, eventname);
printf("h_savePermittedEvent = %d
swprintf(eventname, sa_savestart_event_fmt, slot);
h_saveStartEvent = CreateEvent (&sa, TRUE, FALSE, eventname);
printf("h_saveStartEvent = %d
Windows Event
Description
SOFTLOGIX_
xx
_KICKSAVE
This incoming event indicates that a save is to be forced in the controller in slot
xx
.
SOFTLOGIX_
xx
_SAVEPERMITTED
This outbound event indicates that a save is permitted in the controller in slot
xx
.
SOFTLOGIX_
xx
_SAVESTART
This outbound event indicates that a save has started in the controller in slot
xx
.
SOFTLOGIX_
xx
_SAVEDONE
This outbound event indicates that a save has completed in the controller in slot
xx
.
SOFTLOGIX_
xx
_SAVELOCK
This event is a handshake between multiple clients. Use this event to prevent multiple clients from attempting to start
a save at the same time in the controller in slot
xx
.
Содержание 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: ......