#pragma once
#include <string>
#include <vector>

namespace MC {

// ── plan.xml element structs ──────────────────────────────────────────────────

struct PlanTrack {
    std::string id;
    int         x = 0, y = 0;
    std::string type;   // straight / curve / dcrossing / dir
    std::string ori;    // east / west / north / south
};

struct PlanBlock {
    std::string id;
    int         x = 0, y = 0;
    std::string ori;
    int         visW = 4;
    int         visH = 1;
    std::string locId; // runtime occupancy
};

struct PlanSensor {
    std::string id;
    int         addr  = 0;
    int         x = -1, y = -1;
    std::string ori;
    std::string blockId;
    std::string role;  // entering / arrived / leaving
};

struct RouteSwitchCmd {
    std::string switchId;
    std::string cmd;    // straight / turnout
};

struct PlanRoute {
    std::string id;
    std::string fromBlock;
    std::string toBlock;
    std::vector<RouteSwitchCmd> switchCmds;
};

struct PlanSwitch {
    std::string id;
    std::string type;       // left / right / threeway / dcrossing
    int         x = 0, y = 0;
    std::string ori;
    int         addr = 0;
    int         port = 0;
    std::string protocol = "MM";
    bool        straight = true;
};

struct PlanSignal {
    std::string id;
    int         x = 0, y = 0;
    std::string ori;
    std::string blockId;
};

struct PlanLoco {
    std::string id;
    std::string name;
    int         addr = 0;
    std::string protocol = "MM";
};

// ── Top-level plan ────────────────────────────────────────────────────────────
struct RocrailPlan {
    std::string              title;
    std::vector<PlanBlock>   blocks;
    std::vector<PlanTrack>   tracks;
    std::vector<PlanSensor>  sensors;
    std::vector<PlanSwitch>  switches;
    std::vector<PlanSignal>  signals;
    std::vector<PlanRoute>   routes;
    std::vector<PlanLoco>    locos;
};

} // namespace MC
