#include "SurfaceOpsState.hpp"
#include "ErrorHandler.hpp"
#include "Logger.hpp"
#include <bsp.hpp>

using std::cout;
using std::endl;

void SurfaceOpsState::doStateEntry()
{
	StdStateEntry();

	currentAction = firstAction;
	nextAction = firstAction;
	previousAction = firstAction;
}

void SurfaceOpsState::doStateActions()
{
	switch(currentAction)
	{
		case firstAction:
			nextAction = firstAction;
			break;
		case numActions: // TODO probably don't need a case for lastAction
			cout << "Anchor state action: lastAction" << endl;
			break;
		default:
			cout << "**Error: Anchor state unhandled action" << endl;
	}

	if(nextAction != currentAction)
		processActionChange();
}

StateNames SurfaceOpsState::checkEvents()
{
	if(currentAction == numActions)
	{
		return submerge;
	}
	else
	{
		return recovery;
	}
}

void SurfaceOpsState::doStateExit(bool timeout)
{
	// TODO Be sure to clean up any hanging actions
	StdStateExit(timeout);
}

void SurfaceOpsState::defineActionLabels()
{
	actionLabel[static_cast<int>(Actions::firstAction)] = "firstAction";
	actionLabel[static_cast<int>(Actions::numActions)] = "last action";
}
