void ojCmptDestroy(OjCmpt ojCmpt) { RejectComponentControlMessage rejectComponentControl; JausMessage txMessage; int i = 0; if(ojCmpt->run == TRUE) { ojCmpt->run = FALSE; pthread_cond_signal(&ojCmpt->nmi->recvCondition); pthread_join(ojCmpt->thread, NULL); } if(ojCmpt->jaus->controller.active) { // Terminate control of current component rejectComponentControl = rejectComponentControlMessageCreate(); jausAddressCopy(rejectComponentControl->source, ojCmpt->jaus->address); jausAddressCopy(rejectComponentControl->destination, ojCmpt->jaus->controller.address); txMessage = rejectComponentControlMessageToJausMessage(rejectComponentControl); nodeManagerSend(ojCmpt->nmi, txMessage); jausMessageDestroy(txMessage); rejectComponentControlMessageDestroy(rejectComponentControl); } for(i=0; i<OJ_CMPT_MAX_INCOMING_SC_COUNT; i++) { if(ojCmpt->inConnection[i]) { if(ojCmpt->inConnection[i]->isActive) { scManagerTerminateServiceConnection(ojCmpt->nmi, ojCmpt->inConnection[i]); } serviceConnectionDestroy(ojCmpt->inConnection[i]); } } if(ojCmpt->messageCallback) { free(ojCmpt->messageCallback); } if(ojCmpt->nmi) { nodeManagerClose(ojCmpt->nmi); // Close Node Manager Connection } free(ojCmpt->jaus->identification); ojCmpt->jaus->identification = NULL; jausComponentDestroy(ojCmpt->jaus); free(ojCmpt); };
void cmptShutdownState(void) { RejectComponentControlMessage rejectComponentControl; JausMessage txMessage; if(cmpt->controller.active) { // Terminate control of current component rejectComponentControl = rejectComponentControlMessageCreate(); rejectComponentControl->source->id = cmpt->address->id; rejectComponentControl->destination->id = cmpt->controller.address->id; txMessage = rejectComponentControlMessageToJausMessage(rejectComponentControl); nodeManagerSend(cmptNmi, txMessage); jausMessageDestroy(txMessage); rejectComponentControlMessageDestroy(rejectComponentControl); } // USER: Insert Shutdown Code Here, NOTE: Terminate any active service connections }
void gposShutdownState(void) { RejectComponentControlMessage rejectComponentControl; JausMessage txMessage; if(gpos->controller.active) { // Terminate control of current component rejectComponentControl = rejectComponentControlMessageCreate(); rejectComponentControl->source->id = gpos->address->id; rejectComponentControl->destination->id = gpos->controller.address->id; txMessage = rejectComponentControlMessageToJausMessage(rejectComponentControl); nodeManagerSend(gposNmi, txMessage); jausMessageDestroy(txMessage); rejectComponentControlMessageDestroy(rejectComponentControl); } // Remove support for ReportGlovalPose Service Connections scManagerRemoveSupportedMessage(gposNmi, JAUS_REPORT_GLOBAL_POSE); reportGlobalPoseMessageDestroy(gposMessage); }
void wdShutdownState(void) { RejectComponentControlMessage rejectComponentControl; ReleaseComponentControlMessage releaseControl = NULL; JausMessage txMessage; scManagerRemoveSupportedMessage(wdNmi, JAUS_REPORT_COMPONENT_STATUS); if(wd->controller.active) { // Terminate control of current component rejectComponentControl = rejectComponentControlMessageCreate(); jausAddressCopy(rejectComponentControl->source, wd->address); jausAddressCopy(rejectComponentControl->destination, wd->controller.address); txMessage = rejectComponentControlMessageToJausMessage(rejectComponentControl); nodeManagerSend(wdNmi, txMessage); jausMessageDestroy(txMessage); rejectComponentControlMessageDestroy(rejectComponentControl); } // USER: Insert Shutdown Code Here, NOTE: Terminate any active service connections // Release Control if(wdInControl) { //cDebug(4, "wd: Releasing control of PD\n"); releaseControl = releaseComponentControlMessageCreate(); jausAddressCopy(releaseControl->source, wd->address); jausAddressCopy(releaseControl->destination, pd->address); txMessage = releaseComponentControlMessageToJausMessage(releaseControl); nodeManagerSend(wdNmi, txMessage); jausMessageDestroy(txMessage); releaseComponentControlMessageDestroy(releaseControl); wdInControl = JAUS_FALSE; wd->state = JAUS_INITIALIZE_STATE; } if(pdStatusSc->isActive) { scManagerTerminateServiceConnection(wdNmi, pdStatusSc); serviceConnectionDestroy(pdStatusSc); } if(pdWrenchSc->isActive) { scManagerTerminateServiceConnection(wdNmi, pdWrenchSc); serviceConnectionDestroy(pdWrenchSc); } if(gposSc->isActive) { scManagerTerminateServiceConnection(wdNmi, gposSc); serviceConnectionDestroy(gposSc); } if(vssSc->isActive) { scManagerTerminateServiceConnection(wdNmi, vssSc); serviceConnectionDestroy(vssSc); } // Destory Global Messages if(wdSpeed) { setTravelSpeedMessageDestroy(wdSpeed); } if(wdReportGpos) { reportGlobalPoseMessageDestroy(wdReportGpos); } if(wdReportVss) { reportVelocityStateMessageDestroy(wdReportVss); } if(wdReportWrench) { reportWrenchEffortMessageDestroy(wdReportWrench); } // Destroy Global Variables vehicleStateDestroy(vehicleState); jausArrayDestroy(wdWaypoints, (void *)setGlobalWaypointMessageDestroy); setWrenchEffortMessageDestroy(wdWrench); jausComponentDestroy(pd); }