#pragma once

#include <iostream>
#include <string>
#include "StateBase.hpp"
#include "StateVariables.hpp"
#include <bsp.hpp>

class FirstState final : public StateBase
{
public:
	enum Actions : uint8_t
	{
		getGPSTime,
		initLogger,
		numActions
	};

public:
	FirstState(uint32_t timeout = 0);

private:
	StateVariables SV;

	void doStateEntry() final;
	void doStateExit(bool timeeout) final;
	StateNames doStateActions(const event_t& event) final;

	/// getGPSTime action handler.
	/// This action tries to get a GPS timestamp. When that is achieved,
	/// it sets the system clock and moves on to the initLogger action.
	StateNames getGPSTimeActionHandler(const event_t& event);

	/// initLogger action handler.
	/// This action initializes the logger on entry.
	/// If successful, it transitions to the SecondState system state.
	/// @pre System clock is set from a GPS timestamp
	/// @post Logger is initialized
	StateNames initLoggerActionHandler(const event_t& event);

	Actions current_action_;
	GPS& gps_ = getGPS1();
};
