JausBoolean jausSubsystemFreeMemory(JausSubsystem subsystem) { if(subsystem->nodes == NULL) { return JAUS_FALSE; } else { jausArrayDestroy(subsystem->nodes, free); } return JAUS_TRUE; }
// Services Vector Destructor void jausServicesDestroy(JausArray jausServices) { jausArrayDestroy(jausServices, (void *)jausServiceDestroy); }
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); }
void jausNodeDestroy(JausNode node) { jausArrayDestroy(node->components, (void *)jausComponentDestroy); if(node->identification) free(node->identification); free(node); }
void lmListDestroy(LargeMessageList msgList) { jausArrayDestroy(msgList->messages, (void *)jausMessageDestroy); jausAddressDestroy(msgList->source); free(msgList); }
void lmHandlerDestroy(LargeMessageHandler lmh) { jausArrayDestroy(lmh->messageLists, (void *)lmListDestroy); free(lmh); }
void jausSubsystemDestroy(JausSubsystem subsystem) { jausArrayDestroy(subsystem->nodes, (void *)jausNodeDestroy); if(subsystem->identification) free(subsystem->identification); free(subsystem); }