// #pragma once

// #include <cstdint>
// #include <vector>

// class ITransport {
// public:
//     virtual ~ITransport() = default;

//     virtual bool connect(const char* host, std::uint16_t port) = 0;
//     virtual void disconnect() = 0;

//     virtual bool read_registers(std::uint16_t addr,
//                                 std::uint16_t count,
//                                 std::vector<std::uint16_t>& out) = 0;

//     virtual bool write_registers(std::uint16_t addr,
//                                  const std::vector<std::uint16_t>& values) = 0;
// };
// //Controller가 의존할 유일한 인터페이스

#pragma once

#include <cstdint>
#include <vector>

enum class TransportError {
    None,
    Timeout,
    Disconnected,
    ProtocolError,
    ModbusException
};

class ITransport {
public:
    virtual ~ITransport() = default;

    virtual bool connect(const char* host, std::uint16_t port) = 0;
    virtual void disconnect() = 0;

    virtual bool read_registers(std::uint16_t addr,
                                std::uint16_t count,
                                std::vector<std::uint16_t>& out) = 0;

    virtual bool write_registers(std::uint16_t addr,
                                 const std::vector<std::uint16_t>& values) = 0;

    virtual TransportError last_error() const = 0;
};
//Controller가 의존할 유일한 인터페이스