//------------------------------------------------------------------------------
static void shutdownPowerlink(void)
{
    UINT                i;

    // NMT_GS_OFF state has not yet been reached
    fGsOff_l = FALSE;

#if !defined(CONFIG_KERNELSTACK_DIRECTLINK) && defined(CONFIG_USE_SYNCTHREAD)
    system_stopSyncThread();
    system_msleep(100);
#endif

    // halt the NMT state machine so the processing of POWERLINK frames stops
    oplk_execNmtCommand(kNmtEventSwitchOff);

    // small loop to implement timeout waiting for thread to terminate
    for (i = 0; i < 1000; i++)
    {
        if (fGsOff_l)
            break;
    }

    printf("Stack is in state off ... Shutdown\n");
    oplk_shutdown();
}
//------------------------------------------------------------------------------
static void shutdownPowerlink(tInstance* pInstance_p)
{
    UNUSED_PARAMETER(pInstance_p);

    PRINTF("Shut down DEMO\n");

    oplk_shutdown();
}
/**
********************************************************************************
\brief  Destructor

Destructs a POWERLINK object.
*******************************************************************************/
Api::~Api()
{
    tOplkError          ret;

    ret = oplk_execNmtCommand(kNmtEventSwitchOff);
    pProcessThread->waitForNmtStateOff();
    ret = oplk_freeProcessImage();
    ret = oplk_shutdown();
}