#pragma once

#include <string>
#include <cstdio>
#include <cstdint>
#include <memory.h>

class CTD
{
  public:
	CTD(std::string id) : ctdID(id)
	{
	}

	enum CTDCmdNums : uint8_t
	{
		getPressureCN = 0,
		startCPModeCN,
		numCmds,
	};

	struct CTDSample
	{
		float pressure_dBar;
		float tempDegC;
		float salinityPPS;
		uint64_t sysTickCount;
		uint8_t msg[256];
	};

	virtual int8_t getPressure(CTDSample& currentsample) = 0;
	virtual int8_t setCPMode() = 0;
	virtual void defineCommands() = 0;
	void ctdLogEngLine(CTDSample& sample, std::string comment);
	virtual void startFastPressureTimer() = 0;
	virtual void stopFastPressureTimer() = 0;

	virtual void start() = 0;
	virtual void stop() = 0;
	virtual bool doSelftest() = 0;

	void logEngFileHeader();

  protected:
	virtual ~CTD() = default;

	const std::string ctdID;

	void clearSample(CTDSample& currentSample)
	{
		currentSample.pressure_dBar = 0.0;
		currentSample.tempDegC = 0.0;
		currentSample.salinityPPS = 0.0;
		currentSample.sysTickCount = 0;
		memset(currentSample.msg, 0, sizeof(currentSample.msg));
	}
};
