/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" #include "vehicle/graph/graph_standalone.h" #include "vehicle/graph/graph_catalog.h" #include "vehicle/graph/graph_instance.h" #include "vehicle/graph/blocks/cab.h" #include #include #include #include // command line tools of the vehicle graph. they run without the rest of the simulator; the log service doesn't run // in this mode, so the results are reported directly to the console namespace vgraph { namespace { struct script_event { double time{0.0}; std::string operation; std::string target; double value{0.0}; int line{0}; }; bool load_script(std::string const &Path, std::vector &Events) { std::ifstream file{Path}; if (false == file.is_open()) { std::printf("can't open script file \"%s\"\n", Path.c_str()); return false; } std::string line; int linenumber{0}; while (std::getline(file, line)) { ++linenumber; auto const comment{line.find('#')}; if (comment != std::string::npos) { line.erase(comment); } std::istringstream stream{line}; script_event event; event.line = linenumber; if (false == static_cast(stream >> event.time)) { // empty line continue; } if (false == static_cast(stream >> event.operation >> event.target)) { std::printf("%s:%d: expected: