#include "console.hpp" #include #include #include #include using namespace clockmodel; int main() { Bus first, second; std::string mode; std::getline(std::cin, mode); std::string line; while (std::getline(std::cin, line)) { if (mode == "T") { std::cout << encode(command(first, second, line)); continue; } std::istringstream input(line); if (mode == "E") { Reply reply; input >> reply.status; std::uint64_t word; while (input >> word) { reply.values.push_back(static_cast(word)); } std::cout << encode(reply); continue; } std::string selector, operation; input >> selector >> operation; Bus& bus = selector == "a" ? first : second; Arg id = 0, reg = 0, value = 0; input >> id; Reply reply; if (operation == "read") { input >> reg; reply = bus.read(id, reg); } else if (operation == "write") { input >> reg >> value; reply = bus.write(id, reg, value); } else if (operation == "configure") { Arg clock, reset, enable, data; input >> clock >> reset >> enable >> data; reply = bus.configure(id, clock, reset, enable, data); } else if (operation == "burst") { std::vector values; while (input >> value) { values.push_back(value); } reply = bus.burst(id, values); } else if (operation == "drain") { input >> value; reply = bus.drain(id, value); } else if (operation == "history") { input >> value; reply = bus.history(id, value); } else if (operation == "snapshot") { reply = bus.snapshot(id); } else if (operation == "clear") { reply = bus.clear(id); } std::cout << reply.status << ' ' << reply.values.size(); for (Word word : reply.values) { std::cout << ' ' << word; } std::cout << '\n'; } return 0; }