OpenJAUS

Exclusive Component Control

The JAUS reference architecture defines a method for a component to take exclusive control of another component. This mechanism resolves any ambiguity that might occur if a component were to recieve a commands from multiple sources. With exclusive control, one component requests that only commands from itself will be executed by the component under control. An example of this is when an Operator Control Unit (OCU) requests exclusive control of a vehicle's primitive driver. This prevents wrench commands from other OCUs from being accepted by that primitive driver. This resolves any ambiguity that might occur and ensures safe operation, because the vehicle only performs manuevers commanded to it by a single OCU.

To obtain control of another component, the commanding component must first send a requestComponentControlMessage to the desired component. When that component recieves the message, the OpenJAUS default message processor will automatically accept control if the component is not already under control by another commander (this assumes that a callback function for the requestComponentControlMessage is not registered). After it accepts control it sends the confirmComponentControlMessage to the requesting source. The code below demonstrates how the commanding component would send the requestComponentControlMessage. Notice that the authorityCode field in the request message is set to the authority value of the commanding component. Exclusive component control is automatically given to the component witht the highest authority. This allows a component of higher authority to take control even if the desired component is already under control by one of lower authority.
requestControl = requestComponentControlMessageCreate();			// Create the request control message structure
jausAddressCopy(requestControl->destination, pdAddress);			// Copy the address of the desired component into the destination
requestControl->authorityCode = ojCmptGetAuthority(myCmpt);			// Set the authority to the component's authority
			
message = requestComponentControlMessageToJausMessage(requestControl);		// Convert to a JausMessage type (this serializes the data to send)
ojCmptSendMessage(myCmpt, message);						// Send the message via the node manager
jausMessageDestroy(message);							// Free the allocated JausMessage memory
			
requestComponentControlMessageDestroy(requestControl);				// Free the allocated request control message memory
In order to determine if the control request was accepted, the commanding component usually implements a callback function for the confirm control message. An example of what this callback function might look like is given below:
void confirmControlCallback(OjCmpt myCmpt, JausMessage message)			// Callback function for the confirm control message
{
	ConfirmComponentControlMessage confirmComponentControl;			// Declare the confirm control message variable

	confirmComponentControl = confirmComponentControlMessageFromJausMessage(message);	// Create the message

	if(jausAddressEqual(confirmComponentControl->source, pdAddress))	// Test to confirm desired message source
	{
		// ... Code to confirm control of PD ...			// User code to verify the control has been confirmed
	}

	confirmComponentControlMessageDestroy(confirmComponentControl);		// Free allocated memory

}

 

© OpenJAUS.com 2008
All Rights Reserved