Herunterladen Inhalt Inhalt Diese Seite drucken

Siemens SIMATIC S7-1500 Funktionshandbuch Seite 294

Vorschau ausblenden Andere Handbücher für SIMATIC S7-1500:
Inhaltsverzeichnis

Werbung

Beispiel C++
Beispiel C++
S7-PLCSIM Advanced
Funktionshandbuch, 05/2021, A5E37039506-AD
// Thread 1 -----------------------------------------------
---
ISimulationRuntimeManager * api = NULL;
ERuntimeErrorCode result = Initialize(&api);
IInstance* psa = NULL;
if (result == SREC_OK)
{
result = api->RegisterInstance(&psa);
}
// Register the internal event object
psa->RegisterOnOperatingStateChangedEvent();
// Thread 2 -----------------------------------------------
---
while (condition)
{
// Wait for the event to be set (timeout after 10s)
bool isEventSet = psa-
>WaitForOnOperatingStateChangedEvent(10000);
if (isEventSet)
{
// Do Something
...
}
}
// Thread 1 -----------------------------------------------
---
ISimulationRuntimeManager * api = NULL;
ERuntimeErrorCode result = Initialize(&api);
IInstance* psa = NULL;
if (result == SREC_OK)
{
result = api->RegisterInstance(&psa);
}
// Create an event object
HANDLE eventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
// Register the user created event object
psa->RegisterOnOperatingStateChangedEvent(&eventHandle);
// Do Something
...
// Clean up the handle
CloseHandle(eventHandle);
// Thread 2 -----------------------------------------------
---
while (condition)
{
// Wait for the event to be set //OR:
WaitForSingleObject(eventHandle, INFINITE); //psa-
>WaitForOnOperatingStateChangedEvent();
// Do Something
...
}
Anwenderschnittstellen (API)
7.6 API IInstances
293

Werbung

Inhaltsverzeichnis
loading

Diese Anleitung auch für:

Simatic s7-plcsim advanced

Inhaltsverzeichnis