Files
dragonpilot/selfdrive/ui/replay/consoleui.h
Dean Lee 3ca8e3653b replay: ncurses GUI (#23608)
* initial version

* print all message's in ncurses window

* show download progress bar

* move all to class ConsoleUI

* timeline

* improve timeline&stats

* fix logMessage

* add warning indicator

* continue

* cleanup

* cast type to int

* simplify seekToFlag

* more

* <=

* handle enter

* add box to logging window

* fix multiple threads problem

* fix concurrency issues

* draw indicator

* many improvements

* more

* fix multipe threads logging

* stop replay before exit

* use lambda instead of std::bind

* cleanup

* small cleanup

* use carFingerPrint

* don't emit signal in replay::stream

* merge car_events into timeline

* cleanup DonloadStats

* cleanup

* rename carname to carFingerprint

* improve alert

* add comments

* add help functions

templete function

* handle term resize

* display replaying status

* rename to INSTANT

* helper function pauseReplay

* more

* cleanup

use rDebug

* no template

* less colors

* remove function mv_add_str

* use BORDER_SIZE

* tune colors

* add spaces

* apply reviews

use /
2022-01-27 13:17:41 -08:00

51 lines
1.3 KiB
C++

#pragma once
#include <array>
#include <QBasicTimer>
#include <QObject>
#include <QSocketNotifier>
#include <QTimer>
#include <QTimerEvent>
#include "selfdrive/ui/replay/replay.h"
#include <ncurses.h>
class ConsoleUI : public QObject {
Q_OBJECT
public:
ConsoleUI(Replay *replay, QObject *parent = 0);
~ConsoleUI();
private:
void initWindows();
void handleKey(char c);
void displayHelp();
void displayTimelineDesc();
void updateTimeline();
void updateSummary();
void updateStatus();
void pauseReplay(bool pause);
enum Status { Waiting, Playing, Paused };
enum Win { Title, Stats, Log, LogBorder, DownloadBar, Timeline, TimelineDesc, Help, CarState, Max};
std::array<WINDOW*, Win::Max> w{};
SubMaster sm;
Replay *replay;
QBasicTimer getch_timer;
QTimer sm_timer;
QSocketNotifier notifier{0, QSocketNotifier::Read, this};
int max_width, max_height;
Status status = Status::Waiting;
signals:
void updateProgressBarSignal(uint64_t cur, uint64_t total, bool success);
void logMessageSignal(ReplyMsgType type, const QString &msg);
private slots:
void readyRead();
void timerEvent(QTimerEvent *ev);
void updateProgressBar(uint64_t cur, uint64_t total, bool success);
void logMessage(ReplyMsgType type, const QString &msg);
};