tEplKernel PUBLIC EplEventkProcess(tEplEvent* pEvent_p) { tEplKernel Ret; tEplEventSource EventSource; Ret = kEplSuccessful; #if (EPL_USE_SHAREDBUFF != FALSE) \ && (EPL_EVENT_USE_KERNEL_QUEUE != FALSE) // error handling if event queue is full if (EplEventkInstance_g.m_uiUserToKernelFullCount > 0) { // UserToKernel event queue has run out of space -> kEplNmtEventInternComError #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) tEplEvent Event; tEplNmtEvent NmtEvent; #endif // directly call NMTk process function, because event queue is full #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) NmtEvent = kEplNmtEventInternComError; Event.m_EventSink = kEplEventSinkNmtk; Event.m_NetTime.m_dwNanoSec = 0; Event.m_NetTime.m_dwSec = 0; Event.m_EventType = kEplEventTypeNmtEvent; Event.m_pArg = &NmtEvent; Event.m_uiSize = sizeof(NmtEvent); Ret = EplNmtkProcess(&Event); #endif // NMT state machine changed to reset (i.e. NMT_GS_RESET_COMMUNICATION) // now, it is safe to reset the counter and empty the event queue ShbCirResetBuffer (EplEventkInstance_g.m_pShbUserToKernelInstance, 1000, NULL); EplEventkInstance_g.m_uiUserToKernelFullCount = 0; TGT_DBG_SIGNAL_TRACE_POINT(22); // also discard the current event (it doesn't matter if we lose another event) goto Exit; } #endif // check m_EventSink switch(pEvent_p->m_EventSink) { // NMT-Kernel-Modul case kEplEventSinkNmtk: { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) Ret = EplNmtkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceNmtk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif BENCHMARK_MOD_27_RESET(0); #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) if ((pEvent_p->m_EventType == kEplEventTypeNmtEvent) && (*((tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllCeSoa)) { BENCHMARK_MOD_27_SET(0); #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) // forward SoA event to DLLk module for cycle preprocessing Ret = EplDllkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceDllk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif BENCHMARK_MOD_27_RESET(0); } #endif break; } // events for Dllk module case kEplEventSinkDllk: { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) Ret = EplDllkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceDllk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif break; } // events for DllkCal module case kEplEventSinkDllkCal: { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) Ret = EplDllkCalProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceDllk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif break; } #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) // events for PDO CAL module case kEplEventSinkPdokCal: { Ret = EplPdokCalProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourcePdok; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } break; } #endif #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) // events for Error handler module case kEplEventSinkErrk: { // only call error handler if DLL is present Ret = EplErrorHandlerkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceErrk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } break; } #endif // unknown sink default: { Ret = kEplEventUnknownSink; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(pEvent_p->m_EventSink), &pEvent_p->m_EventSink); } } // end of switch(pEvent_p->m_EventSink) #if (EPL_USE_SHAREDBUFF != FALSE) \ && (EPL_EVENT_USE_KERNEL_QUEUE != FALSE) Exit: #endif return Ret; }
tEplKernel EplEventkProcess(tEplEvent *pEvent_p) { tEplKernel Ret; tEplEventSource EventSource; Ret = kEplSuccessful; // error handling if event queue is full if (EplEventkInstance_g.m_uiUserToKernelFullCount > 0) { // UserToKernel event queue has run out of space -> kEplNmtEventInternComError #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) tEplEvent Event; tEplNmtEvent NmtEvent; #endif #ifndef EPL_NO_FIFO tShbError ShbError; #endif // directly call NMTk process function, because event queue is full #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) NmtEvent = kEplNmtEventInternComError; Event.m_EventSink = kEplEventSinkNmtk; Event.m_NetTime.m_dwNanoSec = 0; Event.m_NetTime.m_dwSec = 0; Event.m_EventType = kEplEventTypeNmtEvent; Event.m_pArg = &NmtEvent; Event.m_uiSize = sizeof(NmtEvent); Ret = EplNmtkProcess(&Event); #endif // NMT state machine changed to reset (i.e. NMT_GS_RESET_COMMUNICATION) // now, it is safe to reset the counter and empty the event queue #ifndef EPL_NO_FIFO ShbError = ShbCirResetBuffer(EplEventkInstance_g. m_pShbUserToKernelInstance, 1000, NULL); #endif EplEventkInstance_g.m_uiUserToKernelFullCount = 0; TGT_DBG_SIGNAL_TRACE_POINT(22); // also discard the current event (it doesn't matter if we lose another event) goto Exit; } // check m_EventSink switch (pEvent_p->m_EventSink) { case kEplEventSinkSync: { if (EplEventkInstance_g.m_pfnCbSync != NULL) { Ret = EplEventkInstance_g.m_pfnCbSync(); if (Ret == kEplSuccessful) { #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) // mark TPDOs as valid Ret = EplPdokCalSetTpdosValid(TRUE); #endif } else if ((Ret != kEplReject) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceSyncCb; // Error event for API layer EplEventkPostError (kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } } break; } // NMT-Kernel-Modul case kEplEventSinkNmtk: { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) Ret = EplNmtkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceNmtk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) if ((pEvent_p->m_EventType == kEplEventTypeNmtEvent) && ((*((tEplNmtEvent *) pEvent_p->m_pArg) == kEplNmtEventDllCeSoa) #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) || (*((tEplNmtEvent *) pEvent_p->m_pArg) == kEplNmtEventDllMeSoaSent) #endif )) { // forward SoA event to error handler Ret = EplErrorHandlerkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceErrk; // Error event for API layer EplEventkPostError (kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) // forward SoA event to PDO module pEvent_p->m_EventType = kEplEventTypePdoSoa; Ret = EplPdokProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourcePdok; // Error event for API layer EplEventkPostError (kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif } break; #endif } // events for Dllk module case kEplEventSinkDllk: { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) Ret = EplDllkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceDllk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif break; } // events for DllkCal module case kEplEventSinkDllkCal: { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) Ret = EplDllkCalProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceDllk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif break; } // case kEplEventSinkPdok: { // PDO-Module #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) Ret = EplPdokProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourcePdok; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } #endif break; } // events for Error handler module case kEplEventSinkErrk: { // only call error handler if DLL is present #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) Ret = EplErrorHandlerkProcess(pEvent_p); if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { EventSource = kEplEventSourceErrk; // Error event for API layer EplEventkPostError(kEplEventSourceEventk, Ret, sizeof(EventSource), &EventSource); } break; #endif } // unknown sink default: { Ret = kEplEventUnknownSink; } } // end of switch(pEvent_p->m_EventSink) Exit: return Ret; }