Working on experimental features

This commit is contained in:
Martino Ferrari
2026-03-24 21:16:24 +01:00
parent 7adbecdb6e
commit e2f47d7410
12 changed files with 2029 additions and 2157 deletions
@@ -1,9 +1,11 @@
#ifndef DEBUGBROKERWRAPPER_H
#define DEBUGBROKERWRAPPER_H
#include "AdvancedErrorManagement.h"
#include "BrokerI.h"
#include "DataSourceI.h"
#include "DebugService.h"
#include "ErrorType.h"
#include "FastPollingMutexSem.h"
#include "HighResolutionTimer.h"
#include "MemoryMapBroker.h"
@@ -23,6 +25,7 @@
#include "MemoryMapSynchronisedMultiBufferInputBroker.h"
#include "MemoryMapSynchronisedMultiBufferOutputBroker.h"
#include "MemoryMapSynchronisedOutputBroker.h"
#include "RealTimeThreadSynchBroker.h"
namespace MARTe {
@@ -86,12 +89,11 @@ public:
StreamString dsPath;
DebugService::GetFullObjectName(dataSourceIn, dsPath);
fprintf(stderr, ">> %s broker for %s [%d]\n",
direction == InputSignals ? "Input" : "Output", dsPath.Buffer(),
numCopies);
MemoryMapBroker *mmb = dynamic_cast<MemoryMapBroker *>(broker);
if (mmb == NULL_PTR(MemoryMapBroker *)) {
fprintf(stderr, ">> Impossible to get broker pointer!!\n");
REPORT_ERROR_STATIC(ErrorManagement::Warning,
"Impossible to get broker pointer for %s!!\n",
dsPath.Buffer());
}
for (uint32 i = 0; i < numCopies; i++) {
@@ -106,8 +108,8 @@ public:
StreamString signalName;
if (!dataSourceIn.GetSignalName(dsIdx, signalName))
signalName = "Unknown";
fprintf(stderr, ">> registering %s.%s [%p]\n", dsPath.Buffer(),
signalName.Buffer(), mmb);
REPORT_ERROR_STATIC(ErrorManagement::Debug, "Registering %s.%s [%p]\n",
dsPath.Buffer(), signalName.Buffer(), mmb);
uint8 dims = 0;
uint32 elems = 1;
@@ -148,18 +150,18 @@ public:
// Register short path (In/Out) for GUI compatibility
gamFullName.Printf("%s.%s.%s", absGamPath.Buffer(), dirStrShort,
signalName.Buffer());
signalInfoPointers[i] =
service->RegisterSignal(addr, type, gamFullName.Buffer(), dims, elems);
signalInfoPointers[i] = service->RegisterSignal(
addr, type, gamFullName.Buffer(), dims, elems);
} else {
// Fallback to short form
gamFullName.Printf("%s.%s.%s", functionName, dirStrShort,
signalName.Buffer());
signalInfoPointers[i] =
service->RegisterSignal(addr, type, gamFullName.Buffer(), dims, elems);
signalInfoPointers[i] = service->RegisterSignal(
addr, type, gamFullName.Buffer(), dims, elems);
}
} else {
signalInfoPointers[i] =
service->RegisterSignal(addr, type, dsFullName.Buffer(), dims, elems);
signalInfoPointers[i] = service->RegisterSignal(
addr, type, dsFullName.Buffer(), dims, elems);
}
}
@@ -199,8 +201,8 @@ public:
virtual bool Init(SignalDirection direction, DataSourceI &ds,
const char8 *const name, void *gamMem) {
bool ret = BaseClass::Init(direction, ds, name, gamMem);
fprintf(stderr, ">> INIT BROKER %s %s\n", name,
direction == InputSignals ? "In" : "Out");
REPORT_ERROR_STATIC(ErrorManagement::Debug, "INIT BROKER %s %s\n", name,
direction == InputSignals ? "In" : "Out");
if (ret) {
numSignals = this->GetNumberOfCopies();
DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers,
@@ -214,8 +216,8 @@ public:
virtual bool Init(SignalDirection direction, DataSourceI &ds,
const char8 *const name, void *gamMem, const bool optim) {
bool ret = BaseClass::Init(direction, ds, name, gamMem, false);
fprintf(stderr, ">> INIT optimized BROKER %s %s\n", name,
direction == InputSignals ? "In" : "Out");
REPORT_ERROR_STATIC(ErrorManagement::Debug, "INIT optimized BROKER %s %s\n",
name, direction == InputSignals ? "In" : "Out");
if (ret) {
numSignals = this->GetNumberOfCopies();
DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers,
@@ -403,6 +405,55 @@ typedef DebugBrokerWrapper<MemoryMapSynchronisedMultiBufferOutputBroker>
DebugMemoryMapSynchronisedMultiBufferOutputBroker;
// LCOV_EXCL_STOP
/**
* @brief Specialized wrapper for RealTimeThreadSynchBroker.
* @details The RealTimeThreadSynchBroker copies data in AddSample() which is
* called from the DataSource thread, not from Execute(). We trace signals
* in Execute() after the data has been safely copied.
*/
class DebugRealTimeThreadSyncBroker : public RealTimeThreadSynchBroker {
public:
DebugRealTimeThreadSyncBroker() : RealTimeThreadSynchBroker() {
service = NULL_PTR(DebugService *);
signalInfoPointers = NULL_PTR(DebugSignalInfo **);
numSignals = 0;
anyActive = false;
}
virtual ~DebugRealTimeThreadSyncBroker() {
if (signalInfoPointers)
delete[] signalInfoPointers;
}
virtual bool Execute() {
bool ret = RealTimeThreadSynchBroker::Execute();
// Trace after data has been safely copied by AddSample
if (ret && (anyActive || (service && service->IsPaused()))) {
DebugBrokerHelper::Process(service, signalInfoPointers, activeIndices,
activeSizes, activeMutex);
}
return ret;
}
virtual bool Init(SignalDirection direction, DataSourceI &ds,
const char8 *const name, void *gamMem) {
bool ret = RealTimeThreadSynchBroker::Init(direction, ds, name, gamMem);
if (ret) {
numSignals = this->GetNumberOfCopies();
DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers,
numSignals, this->copyTable, name,
direction, &anyActive, &activeIndices,
&activeSizes, &activeMutex);
}
return ret;
}
DebugService *service;
DebugSignalInfo **signalInfoPointers;
uint32 numSignals;
volatile bool anyActive;
Vec<uint32> activeIndices;
Vec<uint32> activeSizes;
FastPollingMutexSem activeMutex;
};
// LCOV_EXCL_START
typedef DebugBrokerBuilder<DebugMemoryMapInputBroker>
DebugMemoryMapInputBrokerBuilder;
// LCOV_EXCL_START
@@ -426,6 +477,8 @@ typedef DebugBrokerBuilder<DebugMemoryMapAsyncOutputBroker>
DebugMemoryMapAsyncOutputBrokerBuilder;
typedef DebugBrokerBuilder<DebugMemoryMapAsyncTriggerOutputBroker>
DebugMemoryMapAsyncTriggerOutputBrokerBuilder;
typedef DebugBrokerBuilder<DebugRealTimeThreadSyncBroker>
DebugRealTimeThreadSyncBrokerBuilder;
// LCOV_EXCL_STOP
} // namespace MARTe
File diff suppressed because it is too large Load Diff
@@ -46,7 +46,8 @@ public:
virtual bool Initialise(StructuredDataI &data);
DebugSignalInfo *RegisterSignal(void *memoryAddress, TypeDescriptor type,
const char8 *name, uint8 numberOfDimensions = 0,
const char8 *name,
uint8 numberOfDimensions = 0,
uint32 numberOfElements = 1);
void ProcessSignal(DebugSignalInfo *signalInfo, uint32 size,
uint64 timestamp);
@@ -85,6 +86,13 @@ public:
StreamString path;
};
struct MonitoredState {
Reference obj;
uint32 internalID;
StreamString path;
StreamString lastState;
};
uint32 RegisterMonitorSignal(const char8 *path, uint32 periodMs);
uint32 UnmonitorSignal(const char8 *path);
@@ -92,11 +100,13 @@ private:
void HandleCommand(StreamString cmd, BasicTCPSocket *client);
void UpdateBrokersActiveStatus();
uint32 ExportTree(ReferenceContainer *container, StreamString &json, const char8 *pathPrefix);
uint32 ExportTree(ReferenceContainer *container, StreamString &json,
const char8 *pathPrefix);
void PatchRegistry();
void EnrichWithConfig(const char8 *path, StreamString &json);
static void JsonifyDatabase(ConfigurationDatabase &db, StreamString &json);
static void JsonifyDatabase(ConfigurationDatabase &db, StreamString &json,
StreamString indent = "");
ErrorManagement::ErrorType Server(ExecutionInfo &info);
ErrorManagement::ErrorType Streamer(ExecutionInfo &info);
@@ -143,6 +153,7 @@ private:
Vec<SignalAlias> aliases;
Vec<BrokerInfo> brokers;
Vec<MonitoredSignal> monitoredSignals;
Vec<MonitoredState> monitoredStates;
FastPollingMutexSem mutex;
TraceRingBuffer traceBuffer;
@@ -42,6 +42,7 @@ INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Logger
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4StateMachine
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
@@ -49,6 +50,8 @@ INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
INCLUDES += -I$(MARTe2_Components_DIR)/Source/Components/DataSources/RealTimeThreadSynchronisation
all: $(OBJS) $(SUBPROJ) \
$(BUILD_DIR)/DebugService$(LIBEXT) \