Icarus
Vehicle Simulation as a Transformable Computational Graph, built on Vulcan and Janus
Loading...
Searching...
No Matches
MissionLogger.hpp
Go to the documentation of this file.
1#pragma once
2
10
19
20#include <chrono>
21#include <cmath>
22#include <fstream>
23#include <iomanip>
24#include <iostream>
25#include <map>
26#include <numbers>
27#include <sstream>
28#include <string>
29#include <vector>
30
31namespace icarus {
32
40constexpr const char *Init = "INIT";
41constexpr const char *Provision = "PROVISION";
42constexpr const char *Stage = "STAGE";
43constexpr const char *Run = "RUN";
44constexpr const char *Shutdown = "SHUTDOWN";
45} // namespace LifecycleStrings
46
54 public:
55 using Clock = std::chrono::high_resolution_clock;
56 using TimePoint = Clock::time_point;
57
58 MissionLogger() : startup_time_(Clock::now()) {}
59
60 explicit MissionLogger(const std::string &log_file_path)
61 : startup_time_(Clock::now()), log_file_(log_file_path), log_file_name_(log_file_path) {}
62
63 // === Configuration ===
64
66 void SetConsoleLevel(LogLevel level) { console_.SetLogLevel(level); }
67
69 void SetFileLevel(LogLevel level) { file_level_ = level; }
70
72 void SetVersion(const std::string &version) { version_ = version; }
73
75 void SetBuildType(const std::string &build_type) { build_type_ = build_type; }
76
78 void SetProgressEnabled(bool enabled) { progress_enabled_ = enabled; }
79
81 void SetProfilingEnabled(bool enabled) { profiling_enabled_ = enabled; }
82
84 [[nodiscard]] std::string GetLogFileName() const { return log_file_name_; }
85
87 [[nodiscard]] LogLevel GetConsoleLevel() const { return console_.GetLogLevel(); }
88
90 [[nodiscard]] bool IsProgressEnabled() const { return progress_enabled_; }
91
93 [[nodiscard]] bool IsProfilingEnabled() const { return profiling_enabled_; }
94
96 [[nodiscard]] std::chrono::nanoseconds WallElapsed() const {
97 return Clock::now() - startup_time_;
98 }
99
101 void SetLogFile(const std::string &path) {
102 if (log_file_.is_open()) {
103 log_file_.close();
104 }
105 log_file_name_ = path;
106 if (!path.empty()) {
107 log_file_.open(path);
108 }
109 }
110
111 // === Lifecycle Logging ===
112
114 void LogStartup() {
115 std::string splash = Banner::GetSplashScreen(build_type_, icarus::Version());
116 console_.WriteLine(splash);
117 WriteToFile(splash);
118 }
119
121 void LogSimulationConfig(const std::string &name, const std::string &version,
122 const std::string &description = "") {
123 std::ostringstream oss;
124 oss << "[SIM] Simulation: " << name << " (v" << version << ")";
125 Log(LogLevel::Info, oss.str());
126
127 if (!description.empty()) {
128 // Log first line of description
129 std::string first_line = description;
130 auto pos = first_line.find('\n');
131 if (pos != std::string::npos) {
132 first_line = first_line.substr(0, pos);
133 }
134 if (!first_line.empty()) {
135 Log(LogLevel::Debug, " " + first_line);
136 }
137 }
138 }
139
141 void LogConfigFile(const std::string &path) { Log(LogLevel::Info, "[CFG] Config: " + path); }
142
144 void LogTimeConfig(double t_start, double t_end, double dt) {
145 std::ostringstream oss;
146 oss << "[CFG] Time: start=" << std::fixed << std::setprecision(1) << t_start
147 << "s, end=" << t_end << "s, dt=" << std::setprecision(4) << dt << "s";
148 Log(LogLevel::Info, oss.str());
149 }
150
152 void LogIntegrator(const std::string &type) {
153 Log(LogLevel::Debug, "[CFG] Integrator: " + type);
154 }
155
158
160 void LogPhaseConfig(const PhaseConfig &config) {
161 if (config.definitions.empty()) {
162 return;
163 }
164 std::ostringstream oss;
165 oss << "[PHASE] Configured with " << config.definitions.size()
166 << " phases, initial: " << config.initial_phase;
167 Log(LogLevel::Debug, oss.str());
168 }
169
171 void BeginLifecycle(const char *lifecycle_name) {
172 current_lifecycle_ = lifecycle_name;
173 lifecycle_start_time_ = Clock::now();
174
175 std::string header = Banner::GetLifecycleHeader(lifecycle_name);
176 console_.WriteLine(header);
177 WriteToFile(header);
178 }
179
181 void EndLifecycle(double sim_time = 0.0) {
182 auto elapsed = std::chrono::duration<double>(Clock::now() - lifecycle_start_time_).count();
183 std::ostringstream oss;
184 oss << "[SYS] " << current_lifecycle_ << " phase complete (" << FormatDuration(elapsed)
185 << ")";
186 LogTimed(LogLevel::Info, sim_time, oss.str());
187 }
188
190 [[nodiscard]] std::string GetDictionaryPath() const {
191 if (log_file_name_.empty()) {
192 return "signal_dictionary.dict";
193 }
194 // Extract base name without extension
195 std::string base = log_file_name_;
196 auto dot_pos = base.rfind('.');
197 if (dot_pos != std::string::npos) {
198 base = base.substr(0, dot_pos);
199 }
200 return base + "_signal_dictionary.dict";
201 }
202
204 void LogManifest(const DataDictionary &dict) {
205 FlightManifest manifest(console_);
206 manifest.SetVersion(icarus::Version());
208 manifest.Generate(dict);
209
210 // Also write summary to log file
211 WriteToFile(manifest.GenerateSummary(dict));
212 }
213
215 void LogRunStart(double t_start, double t_end, double dt) {
216 run_start_wall_time_ = Clock::now();
217 std::ostringstream oss;
218 oss << "[SYS] Starting simulation (t=" << std::fixed << std::setprecision(3) << t_start
219 << " → " << std::setprecision(1) << t_end << " s, dt=" << std::setprecision(4) << dt
220 << " s)";
221 LogTimed(LogLevel::Info, t_start, oss.str());
222 }
223
225 void LogRunProgress(double sim_time, double t_end) {
226 double progress = (t_end > 0) ? (sim_time / t_end) * 100.0 : 0.0;
227 auto wall_elapsed =
228 std::chrono::duration<double>(Clock::now() - run_start_wall_time_).count();
229 double rtf = (wall_elapsed > 0) ? sim_time / wall_elapsed : 0.0;
230
231 std::ostringstream oss;
232 oss << "[RUN] Progress: " << std::fixed << std::setprecision(1) << progress << "% ("
233 << std::setprecision(1) << sim_time << "/" << t_end
234 << " s, RTF: " << std::setprecision(1) << rtf << "x)";
235 LogTimed(LogLevel::Trace, sim_time, oss.str());
236 }
237
239 void LogDebrief(double sim_time, double wall_time) {
240 MissionDebrief debrief(console_);
242 debrief.SetExitReason("Reached end of simulation time");
243 debrief.SetTiming(sim_time, wall_time);
244
245 if (profiling_enabled_) {
247 }
248
249 std::string output = debrief.Generate();
250 console_.Write(output);
251 WriteToFile(output);
252 }
253
254 // === Provision Phase Logging ===
255
257 void LogEntityLoad(const std::string &entity_name) {
258 LogTimed(LogLevel::Info, 0.0, "[LOD] Loading Entity: " + entity_name);
259 }
260
262 void LogComponentAdd(const std::string &component_name, const std::string &type,
263 const std::string &config_source = "defaults", bool is_last = false) {
264 std::string prefix = is_last ? "└─" : "├─";
265 std::ostringstream oss;
266 oss << " " << prefix << " [CMP] " << component_name << " (" << type << ")";
267 if (config_source != "defaults") {
268 oss << " [" << config_source << "]";
269 }
270 console_.WriteLine(oss.str());
271 WriteToFile(oss.str());
272 }
273
275 void LogAssetLoad(const std::string &asset_name, const std::string &description) {
276 LogTimed(LogLevel::Debug, 0.0, "[AST] " + asset_name + ": " + description);
277 }
278
280 void LogStateAllocation(std::size_t continuous, std::size_t discrete = 0) {
281 std::ostringstream oss;
282 oss << "[MEM] States: " << continuous << " continuous";
283 if (discrete > 0) {
284 oss << ", " << discrete << " discrete";
285 }
286 LogTimed(LogLevel::Info, 0.0, oss.str());
287 }
288
289 // === Stage Phase Logging ===
290
292 void LogWiring(const std::string &source, const std::string &target, bool is_warning = false) {
293 std::string prefix = is_warning ? "[!WIR]" : "[WIR]";
294 std::ostringstream oss;
295 oss << " ├─ " << source << " >> " << target;
296 if (is_warning) {
297 console_.Warning(oss.str());
298 } else {
299 Log(LogLevel::Debug, oss.str());
300 }
301 }
302
304 void LogWiringWarning(const std::string &message) {
305 LogTimed(LogLevel::Warning, 0.0, "[WIR] " + message);
306 }
307
309 void LogExecutionOrder(const std::vector<std::string> &component_order) {
310 Log(LogLevel::Debug, "[ORD] Execution Order:");
311 for (std::size_t i = 0; i < component_order.size(); ++i) {
312 std::ostringstream oss;
313 oss << " " << (i + 1) << ". " << component_order[i];
314 Log(LogLevel::Debug, oss.str());
315 }
316 }
317
319 void LogSchedulerOrder(double sim_rate_hz, const std::vector<SchedulerGroupConfig> &groups,
320 const std::unordered_map<std::string, int> &divisors) {
321 std::ostringstream header;
322 header << "[SCH] Scheduler (sim rate: " << sim_rate_hz << " Hz)";
323 Log(LogLevel::Debug, header.str());
324
325 for (std::size_t i = 0; i < groups.size(); ++i) {
326 const auto &group = groups[i];
327 auto it = divisors.find(group.name);
328 int divisor = (it != divisors.end()) ? it->second : 1;
329 double group_dt = 1.0 / group.rate_hz;
330
331 std::ostringstream oss;
332 bool is_last = (i == groups.size() - 1);
333 oss << " " << (is_last ? "└─" : "├─") << " [" << group.name << "] "
334 << group.rate_hz << " Hz (÷" << divisor << ", dt=" << std::fixed
335 << std::setprecision(6) << group_dt << "s)";
336 Log(LogLevel::Debug, oss.str());
337
338 for (std::size_t j = 0; j < group.members.size(); ++j) {
339 const auto &member = group.members[j];
340 std::ostringstream mem_oss;
341 bool mem_last = (j == group.members.size() - 1);
342 mem_oss << " " << (is_last ? " " : "│ ") << (mem_last ? "└─" : "├─")
343 << " " << member.component;
344 Log(LogLevel::Debug, mem_oss.str());
345 }
346 }
347 }
348
350 void LogTrimStart(const std::string &mode,
351 const std::vector<std::pair<std::string, double>> &targets) {
352 Log(LogLevel::Info, "[TRM] Trim Solver: " + mode);
353 for (const auto &[name, value] : targets) {
354 std::ostringstream oss;
355 oss << " └─ Target: " << name << " = " << value;
356 Log(LogLevel::Debug, oss.str());
357 }
358 }
359
360 void LogTrimIteration(int iteration, double residual) {
361 std::ostringstream oss;
362 oss << "[TRM] Iteration " << iteration << ": residual = " << std::scientific << residual;
363 Log(LogLevel::Debug, oss.str());
364 }
365
366 void LogTrimConverged(int iterations) {
367 std::ostringstream oss;
368 oss << "[TRM] Converged in " << iterations << " iterations";
369 Log(LogLevel::Info, oss.str());
370 }
371
372 void LogTrimFailed(const std::string &reason) {
373 Log(LogLevel::Error, "[TRM] Trim failed: " + reason);
374 }
375
376 // === Linearization Logging ===
377
380 // Banner
381 Log(LogLevel::Info, "[LIN] ═══════════════════════════════════════════════════════");
382 Log(LogLevel::Info, "[LIN] Linear Model at Operating Point");
383 Log(LogLevel::Info, "[LIN] ═══════════════════════════════════════════════════════");
384
385 // Dimensions (Info level)
386 {
387 std::ostringstream oss;
388 oss << "[LIN] State-Space: A[" << model.A.rows() << "x" << model.A.cols() << "], B["
389 << model.B.rows() << "x" << model.B.cols() << "], C[" << model.C.rows() << "x"
390 << model.C.cols() << "], D[" << model.D.rows() << "x" << model.D.cols() << "]";
391 Log(LogLevel::Info, oss.str());
392 }
393
394 // Operating point (Debug level)
395 Log(LogLevel::Debug, "[LIN] Operating Point (x0):");
396 for (std::size_t i = 0; i < model.state_names.size(); ++i) {
397 std::ostringstream oss;
398 oss << " " << model.state_names[i] << " = " << std::scientific
399 << std::setprecision(4) << model.x0(static_cast<Eigen::Index>(i));
400 Log(LogLevel::Debug, oss.str());
401 }
402
403 // A matrix (Trace level - very verbose)
404 Log(LogLevel::Trace, "[LIN] A Matrix (df/dx):");
405 for (Eigen::Index i = 0; i < model.A.rows(); ++i) {
406 std::ostringstream oss;
407 oss << " [";
408 for (Eigen::Index j = 0; j < model.A.cols(); ++j) {
409 oss << std::fixed << std::setw(12) << std::setprecision(6) << model.A(i, j);
410 if (j < model.A.cols() - 1)
411 oss << ", ";
412 }
413 oss << "]";
414 Log(LogLevel::Trace, oss.str());
415 }
416
417 // Eigenvalue analysis (Info level - important for stability)
418 Log(LogLevel::Info, "[LIN] Eigenvalue Analysis:");
419 auto eigenvalues = model.Eigenvalues();
420 for (Eigen::Index i = 0; i < eigenvalues.size(); ++i) {
421 double real = eigenvalues(i).real();
422 double imag = eigenvalues(i).imag();
423
424 std::ostringstream oss;
425 oss << " λ" << (i + 1) << " = " << std::scientific << std::setprecision(4)
426 << real;
427 if (std::abs(imag) > 1e-10) {
428 oss << (imag >= 0 ? " + " : " - ") << std::abs(imag) << "i";
429 // Compute period from imaginary part
430 double period = 2.0 * std::numbers::pi / std::abs(imag);
431 oss << std::fixed << std::setprecision(1) << " (period: " << period
432 << " s = " << period / 60.0 << " min)";
433 }
434 Log(LogLevel::Info, oss.str());
435 }
436
437 // Stability and controllability (Info level)
438 {
439 std::ostringstream oss;
440 oss << "[LIN] Stability: " << (model.IsStable() ? "STABLE" : "UNSTABLE")
441 << " (Lyapunov sense)";
442 Log(LogLevel::Info, oss.str());
443 }
444 {
445 std::ostringstream oss;
446 oss << "[LIN] Controllability: " << model.ControllabilityRank() << " / "
447 << model.A.rows()
448 << (model.ControllabilityRank() == model.A.rows() ? " (fully controllable)" : "");
449 Log(LogLevel::Info, oss.str());
450 }
451 {
452 std::ostringstream oss;
453 oss << "[LIN] Observability: " << model.ObservabilityRank() << " / " << model.A.rows()
454 << (model.ObservabilityRank() == model.A.rows() ? " (fully observable)" : "");
455 Log(LogLevel::Info, oss.str());
456 }
457
458 Log(LogLevel::Info, "[LIN] ═══════════════════════════════════════════════════════");
459 }
460
461 // === Run Phase Logging ===
462
464 void LogPhaseEvent(const std::string &from_phase, const std::string &to_phase,
465 double sim_time) {
466 LogTimed(LogLevel::Event, sim_time,
467 "[PHS] Phase transition: " + from_phase + " -> " + to_phase);
468 }
469
471 void LogEvent(const std::string &event_name, double sim_time, const std::string &details = "") {
472 std::string msg = "[EVT] " + event_name;
473 if (!details.empty()) {
474 msg += ": " + details;
475 }
476 LogTimed(LogLevel::Event, sim_time, msg);
477 }
478
480 void LogRunWarning(const std::string &source, const std::string &message, double sim_time) {
481 LogTimed(LogLevel::Warning, sim_time, "[" + source + "] " + message);
482 }
483
485 void LogRunError(const std::string &source, const std::string &message, double sim_time) {
486 LogTimed(LogLevel::Error, sim_time, "[" + source + "] " + message);
487 }
488
490 void UpdateProgress(double sim_time, double t_max,
491 const std::map<std::string, double> &key_values = {}) {
492 if (!progress_enabled_ || !console_.IsTerminal()) {
493 return;
494 }
495
496 double progress = (t_max > 0) ? (sim_time / t_max) : 0.0;
497 int filled = static_cast<int>(progress * static_cast<double>(progress_width_));
498
499 std::ostringstream oss;
500 oss << "\r[RUN] Time: " << std::fixed << std::setprecision(2) << sim_time << "s | [";
501
502 for (int i = 0; i < progress_width_; ++i) {
503 if (i < filled) {
504 oss << "█";
505 } else {
506 oss << "░";
507 }
508 }
509
510 oss << "] " << static_cast<int>(progress * 100) << "%";
511
512 for (const auto &[key, value] : key_values) {
513 oss << " | " << key << ": " << std::fixed << std::setprecision(1) << value;
514 }
515
516 std::cout << oss.str() << std::flush;
517 }
518
521 if (progress_enabled_ && console_.IsTerminal()) {
522 std::cout << "\r" << std::string(120, ' ') << "\r" << std::flush;
523 }
524 }
525
526 // === Profiling ===
527
529 void BeginComponentTiming(const std::string &component_name) {
530 if (!profiling_enabled_) {
531 return;
532 }
533 current_timed_component_ = component_name;
534 component_start_time_ = Clock::now();
535 }
536
539 if (!profiling_enabled_ || current_timed_component_.empty()) {
540 return;
541 }
542
543 auto elapsed =
544 std::chrono::duration<double, std::micro>(Clock::now() - component_start_time_).count();
545
546 auto &stats = component_stats_[current_timed_component_];
547 stats.name = current_timed_component_;
548 stats.call_count++;
549 stats.total_time_us += elapsed;
550 stats.max_time_us = std::max(stats.max_time_us, elapsed);
551 stats.avg_time_us = stats.total_time_us / static_cast<double>(stats.call_count);
552
553 current_timed_component_.clear();
554 }
555
557 [[nodiscard]] std::vector<ComponentStats> GetProfilingStats() const {
558 std::vector<ComponentStats> result;
559 result.reserve(component_stats_.size());
560
561 // Calculate total time for percentage
562 double total_time = 0.0;
563 for (const auto &[name, stats] : component_stats_) {
564 total_time += stats.total_time_us;
565 }
566
567 for (auto [name, stats] : component_stats_) {
568 if (total_time > 0) {
569 stats.percent_load = (stats.total_time_us / total_time) * 100.0;
570 }
571 result.push_back(stats);
572 }
573
574 return result;
575 }
576
577 // === Low-Level Access ===
578
580 [[nodiscard]] Console &GetConsole() { return console_; }
581 [[nodiscard]] const Console &GetConsole() const { return console_; }
582
584 void Log(LogLevel level, const std::string &message) {
585 console_.Log(level, message);
586 if (log_file_.is_open() && level >= file_level_) {
587 log_file_ << LevelPrefix(level) << " " << StripAnsi(message) << "\n";
588 log_file_.flush();
589 }
590 }
591
592 void LogTimed(LogLevel level, double sim_time, const std::string &message) {
593 std::string formatted = FormatTime(sim_time) + " " + message;
594 console_.Log(level, formatted);
595 if (log_file_.is_open() && level >= file_level_) {
596 log_file_ << LevelPrefix(level) << " " << StripAnsi(formatted) << "\n";
597 log_file_.flush();
598 }
599 }
600
601 private:
602 Console console_;
603 std::ofstream log_file_;
604 std::string log_file_name_;
605 LogLevel file_level_ = LogLevel::Debug;
606
607 // Simulation metadata
608 std::string version_ = icarus::Version();
609#ifdef NDEBUG
610 std::string build_type_ = "RELEASE";
611#else
612 std::string build_type_ = "DEBUG";
613#endif
614
615 // Timing
616 TimePoint startup_time_;
617 TimePoint lifecycle_start_time_;
618 TimePoint run_start_wall_time_;
619 std::string current_lifecycle_ = LifecycleStrings::Init;
620
621 // Progress display
622 bool progress_enabled_ = true;
623 int progress_width_ = 40;
624
625 // Profiling
626 bool profiling_enabled_ = false;
627 std::map<std::string, ComponentStats> component_stats_;
628 std::string current_timed_component_;
629 TimePoint component_start_time_;
630
631 // Helpers
632 [[nodiscard]] double GetWallClockSeconds() const {
633 return std::chrono::duration<double>(Clock::now() - startup_time_).count();
634 }
635
637 [[nodiscard]] static std::string FormatTime(double t) {
638 std::ostringstream oss;
639 if (t >= 1000.0 || t <= -1000.0) {
640 oss << "[" << std::scientific << std::setprecision(2) << t << "]";
641 } else {
642 oss << "[" << std::fixed << std::setprecision(6) << t << "]";
643 }
644 return oss.str();
645 }
646
648 [[nodiscard]] static std::string FormatDuration(double seconds) {
649 std::ostringstream oss;
650 if (seconds < 0.001) {
651 oss << std::fixed << std::setprecision(1) << (seconds * 1e6) << "μs";
652 } else if (seconds < 1.0) {
653 oss << std::fixed << std::setprecision(2) << (seconds * 1000) << "ms";
654 } else {
655 oss << std::fixed << std::setprecision(2) << seconds << "s";
656 }
657 return oss.str();
658 }
659
660 void WriteToFile(const std::string &message) {
661 if (log_file_.is_open()) {
662 log_file_ << StripAnsi(message) << "\n";
663 log_file_.flush();
664 }
665 }
666
667 [[nodiscard]] static std::string LevelPrefix(LogLevel level) {
668 switch (level) {
669 case LogLevel::Trace:
670 return "[TRC]";
671 case LogLevel::Debug:
672 return "[DBG]";
673 case LogLevel::Info:
674 return "[INF]";
675 case LogLevel::Event:
676 return "[EVT]";
678 return "[WRN]";
679 case LogLevel::Error:
680 return "[ERR]";
681 case LogLevel::Fatal:
682 return "[FTL]";
683 }
684 return "[???]";
685 }
686
687 [[nodiscard]] static std::string StripAnsi(const std::string &s) {
688 std::string result;
689 result.reserve(s.size());
690 bool in_escape = false;
691 for (char c : s) {
692 if (c == '\033') {
693 in_escape = true;
694 } else if (in_escape && c == 'm') {
695 in_escape = false;
696 } else if (!in_escape) {
697 result += c;
698 }
699 }
700 return result;
701 }
702};
703
704} // namespace icarus
ASCII art banners and headers.
Console abstraction with ANSI color support.
Core type definitions, concepts, and configuration for Icarus.
Complete catalog of simulation interface.
ASCII Data Dictionary formatter.
Shutdown statistics and profiling report.
Simulator and subsystem configuration structs.
Core types for staging subsystem (trim, linearization, symbolic).
static std::string GetLifecycleHeader(const std::string &lifecycle_name)
Get a section header.
Definition Banner.hpp:28
static std::string GetSplashScreen(const std::string &build_type="RELEASE", const std::string &version="0.1.0")
Get the main Icarus splash screen (ASCII art logo).
Definition Banner.hpp:20
Console output with color and formatting support.
Definition Console.hpp:111
bool IsTerminal() const
Check if stdout is a terminal (supports ANSI codes).
Definition Console.hpp:116
Generate Flight Manifest (ASCII Data Dictionary).
Definition FlightManifest.hpp:38
std::string GenerateSummary(const DataDictionary &dict) const
Generate summary string (for console).
Definition FlightManifest.hpp:94
void SetVersion(const std::string &version)
Set simulation version string.
Definition FlightManifest.hpp:48
void SetOutputPath(const std::filesystem::path &path)
Set output file path (default: "signal_dictionary.dict").
Definition FlightManifest.hpp:45
void Generate(const DataDictionary &dict)
Generate manifest: write full to file, summary to console.
Definition FlightManifest.hpp:61
Mission Debrief generator.
Definition MissionDebrief.hpp:51
std::string Generate() const
Generate the full debrief string.
Definition MissionDebrief.hpp:74
void SetTiming(double sim_time, double wall_time)
Set timing information.
Definition MissionDebrief.hpp:62
void SetExitReason(const std::string &reason)
Set exit reason message.
Definition MissionDebrief.hpp:59
void SetExitStatus(ExitStatus status)
Set exit status.
Definition MissionDebrief.hpp:56
void SetProfilingData(const std::vector< ComponentStats > &stats)
Set profiling data.
Definition MissionDebrief.hpp:71
void LogRunError(const std::string &source, const std::string &message, double sim_time)
Log error during run.
Definition MissionLogger.hpp:485
LogLevel GetConsoleLevel() const
Get current console level.
Definition MissionLogger.hpp:87
void BeginComponentTiming(const std::string &component_name)
Begin timing a component.
Definition MissionLogger.hpp:529
void LogStateAllocation(std::size_t continuous, std::size_t discrete=0)
Log state vector allocation.
Definition MissionLogger.hpp:280
void LogAssetLoad(const std::string &asset_name, const std::string &description)
Log static asset loading.
Definition MissionLogger.hpp:275
void LogSimulationConfig(const std::string &name, const std::string &version, const std::string &description="")
Log simulation configuration info (from YAML).
Definition MissionLogger.hpp:121
void LogPhaseConfig(const PhaseConfig &config)
Log phase configuration.
Definition MissionLogger.hpp:160
void SetFileLevel(LogLevel level)
Set file log level (log file output).
Definition MissionLogger.hpp:69
void UpdateProgress(double sim_time, double t_max, const std::map< std::string, double > &key_values={})
Update progress display (single-line, \r overwrite).
Definition MissionLogger.hpp:490
MissionLogger()
Definition MissionLogger.hpp:58
void LogTimeConfig(double t_start, double t_end, double dt)
Log time configuration.
Definition MissionLogger.hpp:144
void LogEntityLoad(const std::string &entity_name)
Log entity loading.
Definition MissionLogger.hpp:257
void LogComponentAdd(const std::string &component_name, const std::string &type, const std::string &config_source="defaults", bool is_last=false)
Log component addition (tree format).
Definition MissionLogger.hpp:262
void LogWiring(const std::string &source, const std::string &target, bool is_warning=false)
Log signal wiring.
Definition MissionLogger.hpp:292
void BeginLifecycle(const char *lifecycle_name)
Begin a lifecycle phase.
Definition MissionLogger.hpp:171
void Log(LogLevel level, const std::string &message)
Log raw message.
Definition MissionLogger.hpp:584
void EndComponentTiming()
End timing for current component.
Definition MissionLogger.hpp:538
void LogRunWarning(const std::string &source, const std::string &message, double sim_time)
Log warning during run.
Definition MissionLogger.hpp:480
void LogTrimStart(const std::string &mode, const std::vector< std::pair< std::string, double > > &targets)
Log trim solver progress.
Definition MissionLogger.hpp:350
void LogManifest(const DataDictionary &dict)
Log the Flight Manifest (Data Dictionary).
Definition MissionLogger.hpp:204
Clock::time_point TimePoint
Definition MissionLogger.hpp:56
std::string GetDictionaryPath() const
Get the signal dictionary output path (derived from log file name).
Definition MissionLogger.hpp:190
void SetVersion(const std::string &version)
Set simulation version string.
Definition MissionLogger.hpp:72
void LogRunStart(double t_start, double t_end, double dt)
Log simulation run start (entering RUN phase).
Definition MissionLogger.hpp:215
void SetLogFile(const std::string &path)
Set log file path (closes existing if open).
Definition MissionLogger.hpp:101
MissionLogger(const std::string &log_file_path)
Definition MissionLogger.hpp:60
std::string GetLogFileName() const
Get current log file name.
Definition MissionLogger.hpp:84
void LogSchedulerOrder(double sim_rate_hz, const std::vector< SchedulerGroupConfig > &groups, const std::unordered_map< std::string, int > &divisors)
Log scheduler execution order with groups and rates (Debug level).
Definition MissionLogger.hpp:319
void LogIntegrator(IntegratorType type)
Log integrator type (enum version).
Definition MissionLogger.hpp:157
void LogTimed(LogLevel level, double sim_time, const std::string &message)
Definition MissionLogger.hpp:592
bool IsProgressEnabled() const
Check if progress is enabled.
Definition MissionLogger.hpp:90
Console & GetConsole()
Get underlying console.
Definition MissionLogger.hpp:580
void LogRunProgress(double sim_time, double t_end)
Log periodic run progress.
Definition MissionLogger.hpp:225
void LogIntegrator(const std::string &type)
Log integrator type.
Definition MissionLogger.hpp:152
void LogLinearModel(const staging::LinearModel &model)
Log linear model summary (called after linearization).
Definition MissionLogger.hpp:379
std::chrono::nanoseconds WallElapsed() const
Get total wall time elapsed since startup.
Definition MissionLogger.hpp:96
void LogPhaseEvent(const std::string &from_phase, const std::string &to_phase, double sim_time)
Log phase transition event.
Definition MissionLogger.hpp:464
void LogExecutionOrder(const std::vector< std::string > &component_order)
Log topological sort order.
Definition MissionLogger.hpp:309
void SetBuildType(const std::string &build_type)
Set build type (DEBUG/RELEASE) - auto-detected by default.
Definition MissionLogger.hpp:75
void LogConfigFile(const std::string &path)
Log configuration file path.
Definition MissionLogger.hpp:141
void LogTrimConverged(int iterations)
Definition MissionLogger.hpp:366
void LogStartup()
Log simulation startup (splash screen) - uses Icarus engine version.
Definition MissionLogger.hpp:114
void EndLifecycle(double sim_time=0.0)
End current lifecycle phase (pass current sim time for consistent timestamps).
Definition MissionLogger.hpp:181
std::chrono::high_resolution_clock Clock
Definition MissionLogger.hpp:55
bool IsProfilingEnabled() const
Check if profiling is enabled.
Definition MissionLogger.hpp:93
void LogTrimIteration(int iteration, double residual)
Definition MissionLogger.hpp:360
void ClearProgress()
Clear progress line (call after Run completes).
Definition MissionLogger.hpp:520
void LogWiringWarning(const std::string &message)
Log wiring warning (multiple writers, etc.).
Definition MissionLogger.hpp:304
std::vector< ComponentStats > GetProfilingStats() const
Get profiling statistics.
Definition MissionLogger.hpp:557
void LogEvent(const std::string &event_name, double sim_time, const std::string &details="")
Log notable event (apogee, impact, etc.).
Definition MissionLogger.hpp:471
const Console & GetConsole() const
Definition MissionLogger.hpp:581
void LogDebrief(double sim_time, double wall_time)
Log mission debrief (shutdown statistics).
Definition MissionLogger.hpp:239
void SetProfilingEnabled(bool enabled)
Enable/disable profiling.
Definition MissionLogger.hpp:81
void SetProgressEnabled(bool enabled)
Enable/disable progress display during Run.
Definition MissionLogger.hpp:78
void SetConsoleLevel(LogLevel level)
Set console log level (terminal output).
Definition MissionLogger.hpp:66
void LogTrimFailed(const std::string &reason)
Definition MissionLogger.hpp:372
Simulation phase names for logging banners.
Definition MissionLogger.hpp:39
constexpr const char * Run
Definition MissionLogger.hpp:43
constexpr const char * Provision
Definition MissionLogger.hpp:41
constexpr const char * Stage
Definition MissionLogger.hpp:42
constexpr const char * Init
Definition MissionLogger.hpp:40
constexpr const char * Shutdown
Definition MissionLogger.hpp:44
Definition AggregationTypes.hpp:13
@ EndConditionMet
End condition triggered.
Definition MissionDebrief.hpp:28
const char * to_string(SignalKind kind)
Convert SignalKind to string.
Definition Signal.hpp:86
IntegratorType
Available integrator methods.
Definition IntegratorTypes.hpp:27
constexpr const char * Version()
Version string (derived from components).
Definition CoreTypes.hpp:152
LogLevel
Log severity levels.
Definition Console.hpp:35
@ Warning
Potential issues.
Definition Console.hpp:40
@ Info
Normal operation.
Definition Console.hpp:38
@ Fatal
Unrecoverable errors.
Definition Console.hpp:42
@ Error
Recoverable errors.
Definition Console.hpp:41
@ Event
Simulation events (phase changes, etc.).
Definition Console.hpp:39
@ Debug
Debugging info.
Definition Console.hpp:37
@ Trace
Most verbose, internal debugging.
Definition Console.hpp:36
Complete catalog of simulation interface.
Definition DataDictionary.hpp:45
Configuration for phase management.
Definition PhaseManager.hpp:40
std::map< std::string, int32_t > definitions
Phase name to integer mapping (e.g., {"GROUND": 0, "BOOST": 1, ...}).
Definition PhaseManager.hpp:42
std::string initial_phase
Initial phase name.
Definition PhaseManager.hpp:45
Linear state-space model.
Definition LinearModel.hpp:31
bool IsStable() const
Check if system is stable (all eigenvalues have negative real part).
Definition LinearModel.hpp:367
std::vector< std::string > state_names
Definition LinearModel.hpp:37
Eigen::MatrixXd B
Input matrix (n_states x n_inputs).
Definition LinearModel.hpp:33
int ObservabilityRank() const
Compute observability matrix rank.
Definition LinearModel.hpp:343
Eigen::MatrixXd D
Feedthrough matrix (n_outputs x n_inputs).
Definition LinearModel.hpp:35
Eigen::MatrixXd C
Output matrix (n_outputs x n_states).
Definition LinearModel.hpp:34
Eigen::MatrixXd A
State matrix (n_states x n_states).
Definition LinearModel.hpp:32
Eigen::VectorXcd Eigenvalues() const
Get eigenvalues of A matrix.
Definition LinearModel.hpp:380
Eigen::VectorXd x0
Operating point where linearization was performed.
Definition LinearModel.hpp:42
int ControllabilityRank() const
Compute controllability matrix rank.
Definition LinearModel.hpp:314