Ejemplo n.º 1
0
// Function: cmptShutdown
// Access:		Public	
// Description:	This function allows the abstracted component functionality contained in this file to be stoped from an external source.
// 				If the component is in the running state, this function will terminate all threads running in this file
//				This function will also close the Jms connection to the Node Manager and check out the component from the Node Manager
int cmptShutdown(void)
{
	double timeOutSec;

	if(cmpt->state != JAUS_SHUTDOWN_STATE)	// Execute the shutdown routines only if the component is running
	{
		cmptRun = FALSE;

		timeOutSec = getTimeSeconds() + CMPT_THREAD_TIMEOUT_SEC;
		while(cmptThreadRunning)
		{
			usleep(100000);
			if(getTimeSeconds() >= timeOutSec)
			{
				pthread_cancel(cmptThreadId);
				cmptThreadRunning = FALSE;
				cError("cmpt: cmptThread Shutdown Improperly\n");
				break;
			}
		}

		nodeManagerClose(cmptNmi); // Close Node Manager Connection
				
		jausSubsystemDestroy(cmpt->node->subsystem);
		jausNodeDestroy(cmpt->node);
		jausServicesDestroy(cmpt->services);
	
		cmpt->state = JAUS_SHUTDOWN_STATE;

		propertiesDestroy(cmptProperties);
	}

	return 0;
}
Ejemplo n.º 2
0
// Function: wdShutdown
// Access:		Public	
// Description:	This function allows the abstracted component functionality contained in this file to be stoped from an external source.
// 				If the component is in the running state, this function will terminate all threads running in this file
//				This function will also close the Jms connection to the Node Manager and check out the component from the Node Manager
int wdShutdown(void)
{
	double timeOutSec;

	if(wd && wd->state != JAUS_SHUTDOWN_STATE)	// Execute the shutdown routines only if the component is running
	{
		wdRun = FALSE;

		timeOutSec = getTimeSeconds() + WD_THREAD_TIMEOUT_SEC;
		while(wdThreadRunning)
		{
			SLEEP_MS(1000);
			if(getTimeSeconds() >= timeOutSec)
			{
				pthread_cancel(wdThreadId);
				wdThreadRunning = FALSE;
				//cError("wd: wdThread Shutdown Improperly\n");
				break;
			}
		}

		nodeManagerClose(wdNmi); // Close Node Manager Connection
				
		jausSubsystemDestroy(wd->node->subsystem);
		jausNodeDestroy(wd->node);
		jausServicesDestroy(wd->services);
	
		wd->state = JAUS_SHUTDOWN_STATE;

		propertiesDestroy(wdProperties);
	}

	return 0;
}
Ejemplo n.º 3
0
// Function: vehicleSimShutdown
// Access:		Public
// Description:	This function allows the abstracted component functionality contained in this file to be stoped from an external source.
// 				If the component is in the running state, this function will terminate all threads running in this file
//				This function will also close the Jms connection to the Node Manager and check out the component from the Node Manager
int vehicleSimShutdown(void)
{
    double timeOutSec;

    vehicleSimRun = FALSE;

    timeOutSec = ojGetTimeSec() + VEHICLE_SIM_THREAD_TIMEOUT_SEC;
    while(vehicleSimThreadRunning)
    {
        ojSleepMsec(100);
        if(ojGetTimeSec() >= timeOutSec)
        {
            pthread_cancel(vehicleSimThreadId);
            vehicleSimThreadRunning = FALSE;
            //cError("vehicleSim: vehicleSimThread Shutdown Improperly\n");
            break;
        }
    }

    propertiesDestroy(vehicleSimProperties);

    return 0;
}