//
///		NAME
//
///		SHORT DESCRIPTION
//
///		Description:
///			LONG DESCRIPTION
///
///		Return
///			VALUE and DESCRIPTION
//
STATUS SystemManager::triggerShutdown(void)
{
	SystemManagerMessage  message;
	MessageManager<SystemManagerMessage> messageManager;

	// Post an activate message
	message.major_type = SYSTEM_TRANSITION_TO_SHUTDOWN;
	messageManager.postMessage(SystemManager::queue_id, message, QUEUE_TIMEOUT_INFINITE);

	// Post an activate message
	message.major_type = SYSTEM_SHUTDOWN;
	messageManager.postMessage(SystemManager::queue_id, message, QUEUE_TIMEOUT_INFINITE);

	return STATUS_SUCCESS;
}
示例#2
0
//
///     NAME
//
///     SHORT DESCRIPTION
//
///     Description:
///         LONG DESCRIPTION
///
///     Return
///         VALUE and DESCRIPTION
//
STATUS SystemManager::systemLoop(void) 
{
    STATUS                                  status = STATUS_FAILURE;
    MessageManager<SystemManagerMessage>    messageManager;
    SystemManagerMessage                    message;
    
    // Create a message queue
    QueueManager::createQueue(SystemManager::queue_id, MAX_QUEUE_SIZE_DEFAULT);
    
    // Post an activate message
    message.major_type = SYSTEM_ACTIVATE;
    messageManager.postMessage(SystemManager::queue_id, message, QUEUE_TIMEOUT_INFINITE);
    
    // Start loop
    while(1) 
    {
        status = messageManager.getMessage(SystemManager::queue_id,
                                           message,
                                           QUEUE_TIMEOUT_DEFAULT);
        
        if(status == STATUS_SUCCESS)
        {
            LogManager::logMessage(MODULE_SYSTEM_MANAGER,
                                   DEBUG_LEVEL,
                                   NULL,
                                   "Received Message, Major Type: %lu",
                                   message.major_type);
            
            switch(mState)
            {
                case SYSTEM_MANAGER_INIT:
                    status = initProcessing(message);
                    break;
                
                case SYSTEM_MANAGER_ACTIVE:
                    status = activeProcessing(message);
                    break;
                
                case SYSTEM_MANAGER_SHUTDOWN:
                    status = shutdownProcessing(message);
                    break;
                
                default:
                    break;
            }
            
            if(status == STATUS_SHUTDOWN_SUCCESS)
            {
                break;
            }
        }
    }
    
    mThreadGroup.join_all();
    
    LogManager::logMessage(MODULE_SYSTEM_MANAGER,
                           DEBUG_LEVEL,
                           NULL,
                           "All Threads Joined Succesfully.");
    
    return STATUS_SUCCESS;
}