void BinarySearchTree::removeAllNodes(METADATA* node) { if(node != NULL) { removeAllNodes(node->left); removeAllNodes(node->right); std::cout << "Removing node - key: " << node->key << "\t" << node->value << std::endl; delete node; } }
Scene::~Scene() { // Unbind our active camera from the audio listener if (_activeCamera) { AudioListener* audioListener = AudioListener::getInstance(); if (audioListener && (audioListener->getCamera() == _activeCamera)) { audioListener->setCamera(NULL); } SAFE_RELEASE(_activeCamera); } // Remove all nodes from the scene removeAllNodes(); }
Scene::~Scene() { // Unbind our active camera from the audio listener if (_activeCamera) { AudioListener* audioListener = AudioListener::getInstance(); if (audioListener && (audioListener->getCamera() == _activeCamera)) { audioListener->setCamera(NULL); } SAFE_RELEASE(_activeCamera); } // Remove all nodes from the scene removeAllNodes(); // Remove the scene from global list std::vector<Scene*>::iterator itr = std::find(__sceneList.begin(), __sceneList.end(), this); if (itr != __sceneList.end()) __sceneList.erase(itr); }
/** ******************************************************************************** \brief Constructor Constructs a POWERLINK object. \param pMainWindow_p pointer to main window \param uiNodeId_p node ID of the POWERLINK node \param devName_p device name of the network interface *******************************************************************************/ EplApi::EplApi(MainWindow *pMainWindow_p, unsigned int uiNodeId_p, QString devName_p) { const char* sHostname = HOSTNAME; tEplKernel EplRet; EplState* pEplState; EplOutput* pEplOutput; EplInput* pEplInput; EplCnState* pEplCnState; char devName[256]; pEplState = pMainWindow_p->getEplStateWidget(); pEplOutput = pMainWindow_p->getEplOutputWidget(); pEplInput = pMainWindow_p->getEplInputWidget(); pEplCnState = pMainWindow_p->getEplCnStateWidget(); pEplProcessThread = new EplProcessThread; QObject::connect(pEplProcessThread, SIGNAL(eplStatusChanged(int)), pEplState, SLOT(setEplStatusLed(int))); QObject::connect(pEplProcessThread, SIGNAL(nmtStateChanged(const QString&)), pEplState, SLOT(setNmtStateText(const QString &))); QObject::connect(pEplProcessThread, SIGNAL(nodeAppeared(int)), pEplInput, SLOT(addNode(int))); QObject::connect(pEplProcessThread, SIGNAL(allNodesRemoved()), pEplInput, SLOT(removeAllNodes())); QObject::connect(pEplProcessThread, SIGNAL(nodeDisappeared(int)), pEplInput, SLOT(removeNode(int))); QObject::connect(pEplProcessThread, SIGNAL(nodeAppeared(int)), pEplOutput, SLOT(addNode(int))); QObject::connect(pEplProcessThread, SIGNAL(nodeDisappeared(int)), pEplOutput, SLOT(removeNode(int))); QObject::connect(pEplProcessThread, SIGNAL(allNodesRemoved()), pEplOutput, SLOT(removeAllNodes())); QObject::connect(pEplProcessThread, SIGNAL(nodeAppeared(int)), pEplCnState, SLOT(addNode(int))); QObject::connect(pEplProcessThread, SIGNAL(nodeDisappeared(int)), pEplCnState, SLOT(removeNode(int))); QObject::connect(pEplProcessThread, SIGNAL(allNodesRemoved()), pEplCnState, SLOT(removeAllNodes())); QObject::connect(pEplProcessThread, SIGNAL(nodeStatusChanged(int, int)), pEplCnState, SLOT(setState(int, int))); pEplDataInOutThread = new EplDataInOutThread; QObject::connect(pEplDataInOutThread, SIGNAL(processImageOutChanged(unsigned int, unsigned int)), pEplOutput, SLOT(setValue(unsigned int, unsigned int))); QObject::connect(pEplDataInOutThread, SIGNAL(processImageInChanged(unsigned int, unsigned int)), pEplInput, SLOT(setLeds(unsigned int, unsigned int))); EPL_MEMSET(&EplApiInitParam, 0, sizeof (EplApiInitParam)); EplApiInitParam.m_uiSizeOfStruct = sizeof (EplApiInitParam); EplApiInitParam.m_uiNodeId = uiNodeId_p; EplApiInitParam.m_dwIpAddress = (IP_ADDR & 0xFFFFFF00) | EplApiInitParam.m_uiNodeId; EplApiInitParam.m_fAsyncOnly = FALSE; EplApiInitParam.m_dwFeatureFlags = -1; EplApiInitParam.m_dwCycleLen = CYCLE_LEN; // required for error detection EplApiInitParam.m_uiIsochrTxMaxPayload = 256; // const EplApiInitParam.m_uiIsochrRxMaxPayload = 256; // const EplApiInitParam.m_dwPresMaxLatency = 50000; // const; only required for IdentRes EplApiInitParam.m_uiPreqActPayloadLimit = 36; // required for initialisation (+28 bytes) EplApiInitParam.m_uiPresActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes) EplApiInitParam.m_dwAsndMaxLatency = 150000; // const; only required for IdentRes EplApiInitParam.m_uiMultiplCycleCnt = 0; // required for error detection EplApiInitParam.m_uiAsyncMtu = 1500; // required to set up max frame size EplApiInitParam.m_uiPrescaler = 2; // required for sync EplApiInitParam.m_dwLossOfFrameTolerance = 500000; EplApiInitParam.m_dwAsyncSlotTimeout = 3000000; EplApiInitParam.m_dwWaitSocPreq = 150000; EplApiInitParam.m_dwDeviceType = -1; // NMT_DeviceType_U32 EplApiInitParam.m_dwVendorId = -1; // NMT_IdentityObject_REC.VendorId_U32 EplApiInitParam.m_dwProductCode = -1; // NMT_IdentityObject_REC.ProductCode_U32 EplApiInitParam.m_dwRevisionNumber = -1; // NMT_IdentityObject_REC.RevisionNo_U32 EplApiInitParam.m_dwSerialNumber = -1; // NMT_IdentityObject_REC.SerialNo_U32 EplApiInitParam.m_dwSubnetMask = SUBNET_MASK; EplApiInitParam.m_dwDefaultGateway = 0; EPL_MEMCPY(EplApiInitParam.m_sHostname, sHostname, sizeof(EplApiInitParam.m_sHostname)); EplApiInitParam.m_uiSyncNodeId = EPL_C_ADR_SYNC_ON_SOA; EplApiInitParam.m_fSyncOnPrcNode = FALSE; // set callback functions EplApiInitParam.m_pfnCbEvent = pEplProcessThread->getEventCbFunc(); /* write 00:00:00:00:00:00 to MAC address, so that the driver uses the real hardware address */ EPL_MEMCPY(EplApiInitParam.m_abMacAddress, abMacAddr, sizeof (EplApiInitParam.m_abMacAddress)); #ifdef CONFIG_POWERLINK_USERSTACK EplApiInitParam.m_HwParam.m_pszDevName = devName_p.toAscii().data(); EplApiInitParam.m_pfnObdInitRam = EplObdInitRam; EplApiInitParam.m_pfnCbSync = pEplDataInOutThread->getSyncCbFunc(); #else // Sync call back function not required for init from user space EplApiInitParam.m_pfnCbSync = NULL; #endif // init EPL EplRet = EplApiInitialize(&EplApiInitParam); if(EplRet != kEplSuccessful) { printf("%s: EplApiInitialize() failed\n", __FUNCTION__); QMessageBox::critical(0, "POWERLINK demo", QString("Initialization of openPOWERLINK Stack failed.\n") + "Error code: 0x"+ QString::number(EplRet, 16) + "\nThe most common error source are an unsupported Ethernet controller or the kernel module is not loaded." "\nFor further information please consult the manual."); goto Exit; } #ifdef CONFIG_POWERLINK_USERSTACK EplRet = EplApiSetCdcFilename(pszCdcFilename_g); if(EplRet != kEplSuccessful) { goto Exit; } #endif EplRet = pEplDataInOutThread->SetupProcessImage(); if (EplRet != kEplSuccessful) { printf("%s: pEplDataInOutThread->SetupProcessImage() failed\n", __FUNCTION__); goto Exit; } printf("Setup Process Image Successfull\n"); // start the EPL stack EplRet = EplApiExecNmtCommand(kEplNmtEventSwReset); // start process thread pEplProcessThread->start(); #ifndef CONFIG_POWERLINK_USERSTACK // start data in out thread pEplDataInOutThread->start(); #endif Exit: printf("%s: returns 0x%X\n", __FUNCTION__, EplRet); }
//------------------------------------------------------------------------------ Api::Api(MainWindow* pMainWindow_p, UINT nodeId_p, QString devName_p) { tOplkError ret; State* pState; Output* pOutput; Input* pInput; CnState* pCnState; pState = pMainWindow_p->getStateWidget(); pOutput = pMainWindow_p->getOutputWidget(); pInput = pMainWindow_p->getInputWidget(); pCnState = pMainWindow_p->getCnStateWidget(); pProcessThread = new ProcessThread(pMainWindow_p); QObject::connect(pProcessThread, SIGNAL(oplkStatusChanged(int)), pState, SLOT(setStatusLed(int))); QObject::connect(pProcessThread, SIGNAL(nmtStateChanged(const QString&)), pState, SLOT(setNmtStateText(const QString &))); QObject::connect(pProcessThread, SIGNAL(nodeAppeared(int)), pInput, SLOT(addNode(int))); QObject::connect(pProcessThread, SIGNAL(allNodesRemoved()), pInput, SLOT(removeAllNodes())); QObject::connect(pProcessThread, SIGNAL(nodeDisappeared(int)), pInput, SLOT(removeNode(int))); QObject::connect(pProcessThread, SIGNAL(nodeAppeared(int)), pOutput, SLOT(addNode(int))); QObject::connect(pProcessThread, SIGNAL(nodeDisappeared(int)), pOutput, SLOT(removeNode(int))); QObject::connect(pProcessThread, SIGNAL(allNodesRemoved()), pOutput, SLOT(removeAllNodes())); QObject::connect(pProcessThread, SIGNAL(nodeAppeared(int)), pCnState, SLOT(addNode(int))); QObject::connect(pProcessThread, SIGNAL(nodeDisappeared(int)), pCnState, SLOT(removeNode(int))); QObject::connect(pProcessThread, SIGNAL(allNodesRemoved()), pCnState, SLOT(removeAllNodes())); QObject::connect(pProcessThread, SIGNAL(nodeStatusChanged(int, int)), pCnState, SLOT(setState(int, int))); QObject::connect(pProcessThread, SIGNAL(printLog(const QString&)), pMainWindow_p, SLOT(printlog(const QString&))); pDataInOutThread = new DataInOutThread; QObject::connect(pDataInOutThread, SIGNAL(processImageOutChanged(int, int)), pOutput, SLOT(setValue(int, int))); QObject::connect(pDataInOutThread, SIGNAL(processImageInChanged(int, int)), pInput, SLOT(setLeds(int, int))); OPLK_MEMSET(&initParam, 0, sizeof(initParam)); initParam.sizeOfInitParam = sizeof(initParam); initParam.nodeId = nodeId_p; initParam.ipAddress = (IP_ADDR & 0xFFFFFF00) | initParam.nodeId; initParam.fAsyncOnly = FALSE; initParam.featureFlags = UINT_MAX; initParam.cycleLen = CYCLE_LEN; // required for error detection initParam.isochrTxMaxPayload = 256; // const initParam.isochrRxMaxPayload = 256; // const initParam.presMaxLatency = 50000; // const; only required for IdentRes initParam.preqActPayloadLimit = 36; // required for initialisation (+28 bytes) initParam.presActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes) initParam.asndMaxLatency = 150000; // const; only required for IdentRes initParam.multiplCylceCnt = 0; // required for error detection initParam.asyncMtu = 1500; // required to set up max frame size initParam.prescaler = 2; // required for sync initParam.lossOfFrameTolerance = 500000; initParam.asyncSlotTimeout = 3000000; initParam.waitSocPreq = 150000; initParam.deviceType = UINT_MAX; // NMT_DeviceType_U32 initParam.vendorId = UINT_MAX; // NMT_IdentityObject_REC.VendorId_U32 initParam.productCode = UINT_MAX; // NMT_IdentityObject_REC.ProductCode_U32 initParam.revisionNumber = UINT_MAX; // NMT_IdentityObject_REC.RevisionNo_U32 initParam.serialNumber = UINT_MAX; // NMT_IdentityObject_REC.SerialNo_U32 initParam.subnetMask = SUBNET_MASK; initParam.defaultGateway = DEFAULT_GATEWAY; sprintf((char*)initParam.sHostname, "%02x-%08x", initParam.nodeId, initParam.vendorId); initParam.syncNodeId = C_ADR_SYNC_ON_SOA; initParam.fSyncOnPrcNode = FALSE; // set callback functions initParam.pfnCbEvent = pProcessThread->getEventCbFunc(); /* write 00:00:00:00:00:00 to MAC address, so that the driver uses the real hardware address */ OPLK_MEMCPY(initParam.aMacAddress, abMacAddr, sizeof(initParam.aMacAddress)); // Copy the selected interface string to a local variable strcpy(devName_g, devName_p.toStdString().c_str()); initParam.hwParam.pDevName = devName_g; #if defined(CONFIG_KERNELSTACK_DIRECTLINK) initParam.pfnCbSync = pDataInOutThread->getSyncCbFunc(); #else initParam.pfnCbSync = NULL; #endif // init POWERLINK ret = oplk_init(&initParam); if (ret != kErrorOk) { QMessageBox::critical(0, "POWERLINK demo", QString("Initialization of openPOWERLINK Stack failed.\n") + "Error code: 0x"+ QString::number(ret, 16) + "\nThe most common error source are an unsupported Ethernet controller or the kernel module is not loaded." "\nFor further information please consult the manual."); goto Exit; } ret = oplk_setCdcFilename(pszCdcFilename_g); if (ret != kErrorOk) { goto Exit; } ret = pDataInOutThread->setupProcessImage(); if (ret != kErrorOk) { QMessageBox::critical(0, "POWERLINK demo", QString("Initialization of process image failed.\n") + "Error code: 0x"+ QString::number(ret, 16)); goto Exit; } // start the openPOWERLINK stack ret = oplk_execNmtCommand(kNmtEventSwReset); // start process thread pProcessThread->start(); #if !defined(CONFIG_KERNELSTACK_DIRECTLINK) // start data in out thread pDataInOutThread->start(); #endif Exit: return; }
CDoubleLinkedList::~CDoubleLinkedList() { removeAllNodes(); };
void BinarySearchTree::removeAll() { removeAllNodes(root); root = NULL; size = 0; }