2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QtCore>
|
|
|
|
|
#include <QApplication>
|
2022-09-08 16:07:22 +01:00
|
|
|
#include <cstdint>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <QThread>
|
2022-09-17 20:55:17 +01:00
|
|
|
#include <QTimer>
|
2021-04-24 20:23:17 +01:00
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
#include "src/Helpers/Thread.hpp"
|
2022-12-26 21:47:09 +00:00
|
|
|
#include "src/Services/PathService.hpp"
|
2021-12-31 17:05:31 +00:00
|
|
|
#include "src/ProjectConfig.hpp"
|
2022-01-02 20:44:39 +00:00
|
|
|
#include "src/ProjectSettings.hpp"
|
2021-09-27 23:09:20 +01:00
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
#include "src/EventManager/EventListener.hpp"
|
2022-09-07 22:25:28 +01:00
|
|
|
#include "src/EventManager/Events/Events.hpp"
|
|
|
|
|
|
2022-12-26 21:27:19 +00:00
|
|
|
#include "src/Services/TargetControllerService.hpp"
|
2022-09-07 22:25:28 +01:00
|
|
|
#include "src/Targets/TargetState.hpp"
|
|
|
|
|
|
|
|
|
|
#include "InsightSignals.hpp"
|
2021-09-27 23:09:20 +01:00
|
|
|
|
|
|
|
|
#include "InsightWorker/InsightWorker.hpp"
|
2021-08-22 20:46:52 +01:00
|
|
|
#include "UserInterfaces/InsightWindow/InsightWindow.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
namespace Bloom
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The Insight component provides a GUI for insight into the target's GPIO state.
|
|
|
|
|
* Insight relies heavily on the Qt framework - it's practically a small Qt application. Each supported target
|
|
|
|
|
* package variant implements a custom Qt widget that presents the user with the current state of the target's GPIO
|
|
|
|
|
* pins, as well as the ability to manipulate the pin states of output pins by clicking on them.
|
|
|
|
|
*
|
|
|
|
|
* The Insight component occupies the Bloom's main thread. See Application::run() for more.
|
|
|
|
|
*/
|
2023-05-29 22:40:11 +01:00
|
|
|
class Insight: public QObject
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
2021-10-18 00:33:41 +01:00
|
|
|
Q_OBJECT
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
public:
|
2021-08-11 00:07:12 +01:00
|
|
|
/**
|
|
|
|
|
* Insight constructor.
|
|
|
|
|
*
|
|
|
|
|
* Note: We use the comma operator in the application() initializer to set the Qt::AA_ShareOpenGLContexts
|
|
|
|
|
* attribute, as this is required by Qt before creating a QCoreApplication instance.
|
|
|
|
|
*
|
|
|
|
|
* @param eventManager
|
|
|
|
|
*/
|
2021-12-31 19:45:15 +00:00
|
|
|
explicit Insight(
|
2022-02-09 17:47:05 +00:00
|
|
|
EventListener& eventListener,
|
2021-12-31 19:45:15 +00:00
|
|
|
const ProjectConfig& projectConfig,
|
|
|
|
|
const EnvironmentConfig& environmentConfig,
|
2022-01-02 20:44:39 +00:00
|
|
|
const InsightConfig& insightConfig,
|
2023-05-29 22:40:11 +01:00
|
|
|
InsightProjectSettings& insightProjectSettings,
|
|
|
|
|
QApplication* parent
|
2022-02-09 17:47:05 +00:00
|
|
|
);
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-05-24 23:12:36 +01:00
|
|
|
/**
|
|
|
|
|
* Opens main window and obtains focus.
|
|
|
|
|
*/
|
2023-06-10 15:50:11 +01:00
|
|
|
void activateMainWindow();
|
2023-05-24 23:12:36 +01:00
|
|
|
|
2022-02-09 17:47:05 +00:00
|
|
|
/**
|
|
|
|
|
* Shuts down Insight. Called when the user closes the Insight window or a ShutdownApplication event is fired.
|
|
|
|
|
*/
|
|
|
|
|
void shutdown();
|
|
|
|
|
|
2021-10-18 00:33:41 +01:00
|
|
|
private:
|
2022-09-08 16:07:22 +01:00
|
|
|
static constexpr std::uint8_t INSIGHT_WORKER_COUNT = 3;
|
2021-10-18 00:33:41 +01:00
|
|
|
|
2021-12-31 17:05:31 +00:00
|
|
|
ProjectConfig projectConfig;
|
2021-10-18 00:33:41 +01:00
|
|
|
EnvironmentConfig environmentConfig;
|
|
|
|
|
InsightConfig insightConfig;
|
|
|
|
|
|
2022-01-22 16:14:03 +00:00
|
|
|
InsightProjectSettings& insightProjectSettings;
|
2022-01-02 20:44:39 +00:00
|
|
|
|
2022-02-09 17:47:05 +00:00
|
|
|
EventListener& eventListener;
|
2023-05-21 21:08:25 +01:00
|
|
|
Services::TargetControllerService targetControllerService = Services::TargetControllerService();
|
2021-10-18 00:33:41 +01:00
|
|
|
|
2023-06-10 15:50:11 +01:00
|
|
|
Targets::TargetDescriptor targetDescriptor = this->targetControllerService.getTargetDescriptor();
|
|
|
|
|
|
|
|
|
|
QString globalStylesheet;
|
|
|
|
|
|
2022-09-08 16:07:22 +01:00
|
|
|
std::map<decltype(InsightWorker::id), std::pair<InsightWorker*, QThread*>> insightWorkersById;
|
2023-06-10 15:50:11 +01:00
|
|
|
InsightWindow* mainWindow = nullptr;
|
2021-10-18 00:33:41 +01:00
|
|
|
|
2022-09-07 22:25:28 +01:00
|
|
|
Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN;
|
2022-09-17 20:55:17 +01:00
|
|
|
bool targetStepping = false;
|
|
|
|
|
QTimer* targetResumeTimer = nullptr;
|
|
|
|
|
|
2022-09-07 22:25:28 +01:00
|
|
|
InsightSignals* insightSignals = InsightSignals::instance();
|
2021-10-18 00:33:41 +01:00
|
|
|
|
2023-06-10 15:50:11 +01:00
|
|
|
void refreshTargetState();
|
|
|
|
|
void onInsightWindowDestroyed();
|
2022-09-07 22:25:28 +01:00
|
|
|
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
|
|
|
|
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
|
|
|
|
void onTargetResetEvent(const Events::TargetReset& event);
|
|
|
|
|
void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event);
|
2022-12-10 21:38:08 +00:00
|
|
|
void onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event);
|
2022-09-07 22:25:28 +01:00
|
|
|
void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event);
|
|
|
|
|
void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|