Compare commits
4 Commits
56bb3536fc
...
optimized
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8f04856ed | ||
|
|
dfb399bbba | ||
|
|
aaf69c0949 | ||
|
|
ec29bd5148 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
Build/
|
||||
Build_Coverage/
|
||||
bin/
|
||||
*.o
|
||||
*.so
|
||||
|
||||
@@ -15,8 +15,16 @@ add_definitions(-DENVIRONMENT=Linux)
|
||||
add_definitions(-DMARTe2_TEST_ENVIRONMENT=GTest) # Optional
|
||||
add_definitions(-DUSE_PTHREAD)
|
||||
|
||||
# Add -pthread flag
|
||||
# Add -pthread and coverage flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
option(ENABLE_COVERAGE "Enable coverage reporting" OFF)
|
||||
if(ENABLE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L0Types
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#include "MemoryMapBroker.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "ObjectBuilder.h"
|
||||
#include "Vector.h"
|
||||
#include "FastPollingMutexSem.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
#include "Atomic.h"
|
||||
|
||||
// Original broker headers
|
||||
#include "MemoryMapInputBroker.h"
|
||||
@@ -17,65 +21,69 @@
|
||||
#include "MemoryMapMultiBufferOutputBroker.h"
|
||||
#include "MemoryMapSynchronisedMultiBufferInputBroker.h"
|
||||
#include "MemoryMapSynchronisedMultiBufferOutputBroker.h"
|
||||
#include "MemoryMapAsyncOutputBroker.h"
|
||||
#include "MemoryMapAsyncTriggerOutputBroker.h"
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
/**
|
||||
* @brief Base implementation for all debug brokers.
|
||||
* @brief Helper for optimized signal processing within brokers.
|
||||
*/
|
||||
class DebugBrokerHelper {
|
||||
public:
|
||||
static void Process(BrokerI* broker, DebugService* service, DebugSignalInfo** signalInfoPointers, uint32 numSignals) {
|
||||
static void Process(DebugService* service, BrokerInfo& info) {
|
||||
if (service == NULL_PTR(DebugService*)) return;
|
||||
|
||||
while (service->IsPaused()) {
|
||||
Sleep::MSec(10);
|
||||
}
|
||||
|
||||
if (signalInfoPointers != NULL_PTR(DebugSignalInfo**)) {
|
||||
for (uint32 i = 0; i < numSignals; i++) {
|
||||
DebugSignalInfo *s = signalInfoPointers[i];
|
||||
if (s != NULL_PTR(DebugSignalInfo*)) {
|
||||
if (s->isTracing || s->isForcing) {
|
||||
uint32 size = broker->GetCopyByteSize(i);
|
||||
service->ProcessSignal(s, size);
|
||||
}
|
||||
if (*info.anyActiveFlag) {
|
||||
uint32 idx = info.currentSetIdx;
|
||||
BrokerActiveSet& set = info.sets[idx];
|
||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1000000.0);
|
||||
|
||||
for (uint32 i = 0; i < set.numForced; i++) {
|
||||
SignalExecuteInfo& s = set.forcedSignals[i];
|
||||
DebugService::CopySignal(s.memoryAddress, s.forcedValue, s.size);
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < set.numTraced; i++) {
|
||||
SignalExecuteInfo& s = set.tracedSignals[i];
|
||||
(void)service->traceBuffer.Push(s.internalID, ts, s.memoryAddress, s.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void InitSignals(MemoryMapBroker* broker, DataSourceI &dataSourceIn, DebugService* &service, DebugSignalInfo** &signalInfoPointers, uint32 &numSignals, MemoryMapBrokerCopyTableEntry* copyTable, const char8* functionName, SignalDirection direction) {
|
||||
numSignals = broker->GetNumberOfCopies();
|
||||
if (numSignals > 0) {
|
||||
signalInfoPointers = new DebugSignalInfo*[numSignals];
|
||||
for (uint32 i=0; i<numSignals; i++) signalInfoPointers[i] = NULL_PTR(DebugSignalInfo*);
|
||||
static void InitSignals(BrokerI* broker, DataSourceI &dataSourceIn, DebugService* &service, DebugSignalInfo** &signalInfoPointers, uint32 numCopies, MemoryMapBrokerCopyTableEntry* copyTable, const char8* functionName, SignalDirection direction, volatile bool* anyActiveFlag) {
|
||||
if (numCopies > 0) {
|
||||
signalInfoPointers = new DebugSignalInfo*[numCopies];
|
||||
for (uint32 i=0; i<numCopies; i++) signalInfoPointers[i] = NULL_PTR(DebugSignalInfo*);
|
||||
}
|
||||
|
||||
ReferenceContainer *root = ObjectRegistryDatabase::Instance();
|
||||
Reference serviceRef = root->Find("DebugService");
|
||||
if (serviceRef.IsValid()) {
|
||||
service = dynamic_cast<DebugService*>(serviceRef.operator->());
|
||||
}
|
||||
if (service == NULL_PTR(DebugService*)) service = DebugService::Instance();
|
||||
|
||||
if (service && (copyTable != NULL_PTR(MemoryMapBrokerCopyTableEntry*))) {
|
||||
StreamString dsPath;
|
||||
DebugService::GetFullObjectName(dataSourceIn, dsPath);
|
||||
MemoryMapBroker* mmb = dynamic_cast<MemoryMapBroker*>(broker);
|
||||
|
||||
for (uint32 i = 0; i < numSignals; i++) {
|
||||
for (uint32 i = 0; i < numCopies; i++) {
|
||||
void *addr = copyTable[i].dataSourcePointer;
|
||||
TypeDescriptor type = copyTable[i].type;
|
||||
uint32 dsIdx = i;
|
||||
if (mmb != NULL_PTR(MemoryMapBroker*)) dsIdx = mmb->GetDSCopySignalIndex(i);
|
||||
|
||||
uint32 dsIdx = broker->GetDSCopySignalIndex(i);
|
||||
StreamString signalName;
|
||||
if (!dataSourceIn.GetSignalName(dsIdx, signalName)) signalName = "Unknown";
|
||||
if (!dataSourceIn.GetSignalName(dsIdx, signalName)) {
|
||||
signalName.Printf("Signal_%u", dsIdx);
|
||||
}
|
||||
|
||||
// 1. Register canonical DataSource name (Absolute, No Root prefix)
|
||||
StreamString dsFullName;
|
||||
dsFullName.Printf("%s.%s", dsPath.Buffer(), signalName.Buffer());
|
||||
StreamString dsFullName = dsPath;
|
||||
if (dsFullName.Size() > 0) dsFullName += ".";
|
||||
dsFullName += signalName;
|
||||
service->RegisterSignal(addr, type, dsFullName.Buffer());
|
||||
|
||||
// 2. Also register absolute GAM alias
|
||||
if (functionName != NULL_PTR(const char8*)) {
|
||||
StreamString gamFullName;
|
||||
const char8* dirStr = (direction == InputSignals) ? "In" : "Out";
|
||||
@@ -83,82 +91,157 @@ public:
|
||||
if (gamRef.IsValid()) {
|
||||
StreamString absGamPath;
|
||||
DebugService::GetFullObjectName(*(gamRef.operator->()), absGamPath);
|
||||
gamFullName.Printf("%s.%s.%s", absGamPath.Buffer(), dirStr, signalName.Buffer());
|
||||
gamFullName = absGamPath;
|
||||
} else {
|
||||
gamFullName.Printf("%s.%s.%s", functionName, dirStr, signalName.Buffer());
|
||||
gamFullName = functionName;
|
||||
}
|
||||
gamFullName += ".";
|
||||
gamFullName += dirStr;
|
||||
gamFullName += ".";
|
||||
gamFullName += signalName;
|
||||
signalInfoPointers[i] = service->RegisterSignal(addr, type, gamFullName.Buffer());
|
||||
} else {
|
||||
signalInfoPointers[i] = service->RegisterSignal(addr, type, dsFullName.Buffer());
|
||||
}
|
||||
}
|
||||
service->RegisterBroker(signalInfoPointers, numCopies, mmb, anyActiveFlag);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define DECLARE_DEBUG_BROKER_COMMON(BaseClass) \
|
||||
Debug##BaseClass() : BaseClass() { \
|
||||
service = NULL_PTR(DebugService*); \
|
||||
signalInfoPointers = NULL_PTR(DebugSignalInfo**); \
|
||||
numSignals = 0; \
|
||||
} \
|
||||
virtual ~Debug##BaseClass() { \
|
||||
if (signalInfoPointers) delete[] signalInfoPointers; \
|
||||
} \
|
||||
virtual bool Execute() { \
|
||||
bool ret = BaseClass::Execute(); \
|
||||
if (ret) DebugBrokerHelper::Process(this, service, signalInfoPointers, numSignals); \
|
||||
return ret; \
|
||||
} \
|
||||
private: \
|
||||
DebugService *service; \
|
||||
DebugSignalInfo **signalInfoPointers; \
|
||||
uint32 numSignals;
|
||||
|
||||
#define DECLARE_DEBUG_BROKER(BaseClass) \
|
||||
class Debug##BaseClass : public BaseClass { \
|
||||
public: \
|
||||
DECLARE_DEBUG_BROKER_COMMON(BaseClass) \
|
||||
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem) { \
|
||||
bool ret = BaseClass::Init(direction, ds, name, gamMem); \
|
||||
if (ret) DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers, numSignals, this->copyTable, name, direction); \
|
||||
return ret; \
|
||||
} \
|
||||
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem, const bool optim) { \
|
||||
bool ret = BaseClass::Init(direction, ds, name, gamMem, optim); \
|
||||
if (ret) DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers, numSignals, this->copyTable, name, direction); \
|
||||
return ret; \
|
||||
} \
|
||||
}; \
|
||||
class Debug##BaseClass##Builder : public ObjectBuilder { \
|
||||
public: \
|
||||
virtual Object *Build(HeapI* const heap) const { return new (heap) Debug##BaseClass(); } \
|
||||
class DebugMemoryMapInputBroker : public MemoryMapInputBroker, public DebugBrokerI {
|
||||
public:
|
||||
DebugMemoryMapInputBroker() : MemoryMapInputBroker(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||
}
|
||||
virtual void SetService(DebugService* s) { service = s; }
|
||||
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||
virtual bool Execute() {
|
||||
bool ret = MemoryMapInputBroker::Execute();
|
||||
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||
return ret;
|
||||
}
|
||||
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem) {
|
||||
bool ret = MemoryMapInputBroker::Init(direction, ds, name, gamMem);
|
||||
if (ret) {
|
||||
DebugSignalInfo** sigPtrs = NULL;
|
||||
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, GetNumberOfCopies(), this->copyTable, name, direction, &anyActive);
|
||||
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
DebugService* service;
|
||||
BrokerInfo* infoPtr;
|
||||
volatile bool anyActive;
|
||||
};
|
||||
|
||||
#define DECLARE_DEBUG_BROKER_NO_OPTIM(BaseClass) \
|
||||
class Debug##BaseClass : public BaseClass { \
|
||||
public: \
|
||||
DECLARE_DEBUG_BROKER_COMMON(BaseClass) \
|
||||
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem) { \
|
||||
bool ret = BaseClass::Init(direction, ds, name, gamMem); \
|
||||
if (ret) DebugBrokerHelper::InitSignals(this, ds, service, signalInfoPointers, numSignals, this->copyTable, name, direction); \
|
||||
return ret; \
|
||||
} \
|
||||
}; \
|
||||
class Debug##BaseClass##Builder : public ObjectBuilder { \
|
||||
public: \
|
||||
virtual Object *Build(HeapI* const heap) const { return new (heap) Debug##BaseClass(); } \
|
||||
template <typename T>
|
||||
class DebugGenericBroker : public T, public DebugBrokerI {
|
||||
public:
|
||||
DebugGenericBroker() : T(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||
}
|
||||
virtual void SetService(DebugService* s) { service = s; }
|
||||
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||
virtual bool Execute() {
|
||||
bool ret = T::Execute();
|
||||
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||
return ret;
|
||||
}
|
||||
virtual bool Init(SignalDirection direction, DataSourceI &ds, const char8 *const name, void *gamMem) {
|
||||
bool ret = T::Init(direction, ds, name, gamMem);
|
||||
if (ret) {
|
||||
DebugSignalInfo** sigPtrs = NULL;
|
||||
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, this->GetNumberOfCopies(), this->copyTable, name, direction, &anyActive);
|
||||
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
DebugService* service;
|
||||
BrokerInfo* infoPtr;
|
||||
volatile bool anyActive;
|
||||
};
|
||||
|
||||
DECLARE_DEBUG_BROKER(MemoryMapInputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapOutputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapSynchronisedInputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapSynchronisedOutputBroker)
|
||||
DECLARE_DEBUG_BROKER_NO_OPTIM(MemoryMapInterpolatedInputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapMultiBufferInputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapMultiBufferOutputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapSynchronisedMultiBufferInputBroker)
|
||||
DECLARE_DEBUG_BROKER(MemoryMapSynchronisedMultiBufferOutputBroker)
|
||||
class DebugMemoryMapAsyncOutputBroker : public MemoryMapAsyncOutputBroker, public DebugBrokerI {
|
||||
public:
|
||||
DebugMemoryMapAsyncOutputBroker() : MemoryMapAsyncOutputBroker(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||
}
|
||||
virtual void SetService(DebugService* s) { service = s; }
|
||||
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||
virtual bool Execute() {
|
||||
bool ret = MemoryMapAsyncOutputBroker::Execute();
|
||||
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||
return ret;
|
||||
}
|
||||
virtual bool InitWithBufferParameters(const SignalDirection d, DataSourceI &ds, const char8* n, void* m, const uint32 nb, const ProcessorType& c, const uint32 s) {
|
||||
bool ret = MemoryMapAsyncOutputBroker::InitWithBufferParameters(d, ds, n, m, nb, c, s);
|
||||
if (ret) {
|
||||
DebugSignalInfo** sigPtrs = NULL;
|
||||
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, this->GetNumberOfCopies(), this->copyTable, n, d, &anyActive);
|
||||
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
DebugService* service;
|
||||
BrokerInfo* infoPtr;
|
||||
volatile bool anyActive;
|
||||
};
|
||||
|
||||
class DebugMemoryMapAsyncTriggerOutputBroker : public MemoryMapAsyncTriggerOutputBroker, public DebugBrokerI {
|
||||
public:
|
||||
DebugMemoryMapAsyncTriggerOutputBroker() : MemoryMapAsyncTriggerOutputBroker(), service(NULL), infoPtr(NULL), anyActive(false) {
|
||||
(void)ObjectRegistryDatabase::Instance()->Insert(Reference(this));
|
||||
}
|
||||
virtual void SetService(DebugService* s) { service = s; }
|
||||
virtual bool IsLinked() const { return infoPtr != NULL; }
|
||||
virtual bool Execute() {
|
||||
bool ret = MemoryMapAsyncTriggerOutputBroker::Execute();
|
||||
if (ret && infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||
return ret;
|
||||
}
|
||||
virtual bool InitWithTriggerParameters(const SignalDirection d, DataSourceI &ds, const char8* n, void* m, const uint32 nb, const uint32 pre, const uint32 post, const ProcessorType& c, const uint32 s) {
|
||||
bool ret = MemoryMapAsyncTriggerOutputBroker::InitWithTriggerParameters(d, ds, n, m, nb, pre, post, c, s);
|
||||
if (ret) {
|
||||
DebugSignalInfo** sigPtrs = NULL;
|
||||
DebugBrokerHelper::InitSignals(this, ds, service, sigPtrs, this->GetNumberOfCopies(), this->copyTable, n, d, &anyActive);
|
||||
if (service) infoPtr = service->GetBrokerInfo(service->numberOfBrokers - 1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
DebugService* service;
|
||||
BrokerInfo* infoPtr;
|
||||
volatile bool anyActive;
|
||||
};
|
||||
|
||||
typedef DebugGenericBroker<MemoryMapOutputBroker> DebugMemoryMapOutputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapSynchronisedInputBroker> DebugMemoryMapSynchronisedInputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapSynchronisedOutputBroker> DebugMemoryMapSynchronisedOutputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapInterpolatedInputBroker> DebugMemoryMapInterpolatedInputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapMultiBufferInputBroker> DebugMemoryMapMultiBufferInputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapMultiBufferOutputBroker> DebugMemoryMapMultiBufferOutputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapSynchronisedMultiBufferInputBroker> DebugMemoryMapSynchronisedMultiBufferInputBroker;
|
||||
typedef DebugGenericBroker<MemoryMapSynchronisedMultiBufferOutputBroker> DebugMemoryMapSynchronisedMultiBufferOutputBroker;
|
||||
|
||||
template <typename T>
|
||||
class DebugBrokerBuilder : public ObjectBuilder {
|
||||
public:
|
||||
virtual Object *Build(HeapI* const heap) const {
|
||||
return new (heap) T();
|
||||
}
|
||||
};
|
||||
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapInputBroker> DebugMemoryMapInputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapOutputBroker> DebugMemoryMapOutputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedInputBroker> DebugMemoryMapSynchronisedInputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedOutputBroker> DebugMemoryMapSynchronisedOutputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapInterpolatedInputBroker> DebugMemoryMapInterpolatedInputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapMultiBufferInputBroker> DebugMemoryMapMultiBufferInputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapMultiBufferOutputBroker> DebugMemoryMapMultiBufferOutputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedMultiBufferInputBroker> DebugMemoryMapSynchronisedMultiBufferInputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapSynchronisedMultiBufferOutputBroker> DebugMemoryMapSynchronisedMultiBufferOutputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapAsyncOutputBroker> DebugMemoryMapAsyncOutputBrokerBuilder;
|
||||
typedef DebugBrokerBuilder<DebugMemoryMapAsyncTriggerOutputBroker> DebugMemoryMapAsyncTriggerOutputBrokerBuilder;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "CompilerTypes.h"
|
||||
#include "TypeDescriptor.h"
|
||||
#include "StreamString.h"
|
||||
#include <cstring> // For memcpy
|
||||
#include <cstring>
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
@@ -29,6 +29,10 @@ struct TraceHeader {
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @brief Ring buffer for high-frequency signal tracing.
|
||||
* @details New format per sample: [ID:4][Timestamp:8][Size:4][Data:N]
|
||||
*/
|
||||
class TraceRingBuffer {
|
||||
public:
|
||||
TraceRingBuffer() {
|
||||
@@ -55,12 +59,11 @@ public:
|
||||
return (buffer != NULL_PTR(uint8*));
|
||||
}
|
||||
|
||||
bool Push(uint32 signalID, void* data, uint32 size) {
|
||||
uint32 packetSize = 4 + 4 + size;
|
||||
bool Push(uint32 signalID, uint64 timestamp, void* data, uint32 size) {
|
||||
uint32 packetSize = 4 + 8 + 4 + size; // ID + TS + Size + Data
|
||||
uint32 read = readIndex;
|
||||
uint32 write = writeIndex;
|
||||
|
||||
// Calculate available space
|
||||
uint32 available = 0;
|
||||
if (read <= write) {
|
||||
available = bufferSize - (write - read) - 1;
|
||||
@@ -70,35 +73,31 @@ public:
|
||||
|
||||
if (available < packetSize) return false;
|
||||
|
||||
// Use temporary write index to ensure atomic update
|
||||
uint32 tempWrite = write;
|
||||
WriteToBuffer(&tempWrite, &signalID, 4);
|
||||
WriteToBuffer(&tempWrite, ×tamp, 8);
|
||||
WriteToBuffer(&tempWrite, &size, 4);
|
||||
WriteToBuffer(&tempWrite, data, size);
|
||||
|
||||
// Memory Barrier to ensure data is visible before index update
|
||||
// __sync_synchronize();
|
||||
|
||||
// Final atomic update
|
||||
writeIndex = tempWrite;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pop(uint32 &signalID, void* dataBuffer, uint32 &size, uint32 maxSize) {
|
||||
bool Pop(uint32 &signalID, uint64 ×tamp, void* dataBuffer, uint32 &size, uint32 maxSize) {
|
||||
uint32 read = readIndex;
|
||||
uint32 write = writeIndex;
|
||||
if (read == write) return false;
|
||||
|
||||
uint32 tempRead = read;
|
||||
uint32 tempId = 0;
|
||||
uint64 tempTs = 0;
|
||||
uint32 tempSize = 0;
|
||||
|
||||
// Peek header
|
||||
ReadFromBuffer(&tempRead, &tempId, 4);
|
||||
ReadFromBuffer(&tempRead, &tempTs, 8);
|
||||
ReadFromBuffer(&tempRead, &tempSize, 4);
|
||||
|
||||
if (tempSize > maxSize) {
|
||||
// Error case: drop data up to writeIndex (resync)
|
||||
readIndex = write;
|
||||
return false;
|
||||
}
|
||||
@@ -106,11 +105,9 @@ public:
|
||||
ReadFromBuffer(&tempRead, dataBuffer, tempSize);
|
||||
|
||||
signalID = tempId;
|
||||
timestamp = tempTs;
|
||||
size = tempSize;
|
||||
|
||||
// Memory Barrier
|
||||
// __sync_synchronize();
|
||||
|
||||
readIndex = tempRead;
|
||||
return true;
|
||||
}
|
||||
@@ -126,7 +123,6 @@ private:
|
||||
void WriteToBuffer(uint32 *idx, void* src, uint32 count) {
|
||||
uint32 current = *idx;
|
||||
uint32 spaceToEnd = bufferSize - current;
|
||||
|
||||
if (count <= spaceToEnd) {
|
||||
std::memcpy(&buffer[current], src, count);
|
||||
*idx = (current + count) % bufferSize;
|
||||
@@ -141,7 +137,6 @@ private:
|
||||
void ReadFromBuffer(uint32 *idx, void* dst, uint32 count) {
|
||||
uint32 current = *idx;
|
||||
uint32 spaceToEnd = bufferSize - current;
|
||||
|
||||
if (count <= spaceToEnd) {
|
||||
std::memcpy(dst, &buffer[current], count);
|
||||
*idx = (current + count) % bufferSize;
|
||||
|
||||
@@ -13,6 +13,42 @@
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
class MemoryMapBroker;
|
||||
class DebugService;
|
||||
|
||||
/**
|
||||
* @brief Interface for instrumented brokers to allow service adoption.
|
||||
*/
|
||||
class DebugBrokerI {
|
||||
public:
|
||||
virtual ~DebugBrokerI() {}
|
||||
virtual void SetService(DebugService* service) = 0;
|
||||
virtual bool IsLinked() const = 0;
|
||||
};
|
||||
|
||||
struct SignalExecuteInfo {
|
||||
void* memoryAddress;
|
||||
void* forcedValue;
|
||||
uint32 internalID;
|
||||
uint32 size;
|
||||
};
|
||||
|
||||
struct BrokerActiveSet {
|
||||
SignalExecuteInfo* forcedSignals;
|
||||
uint32 numForced;
|
||||
SignalExecuteInfo* tracedSignals;
|
||||
uint32 numTraced;
|
||||
};
|
||||
|
||||
struct BrokerInfo {
|
||||
DebugSignalInfo** signalPointers;
|
||||
uint32 numSignals;
|
||||
MemoryMapBroker* broker;
|
||||
BrokerActiveSet sets[2];
|
||||
volatile uint32 currentSetIdx;
|
||||
volatile bool* anyActiveFlag;
|
||||
};
|
||||
|
||||
struct SignalAlias {
|
||||
StreamString name;
|
||||
uint32 signalIndex;
|
||||
@@ -20,6 +56,7 @@ struct SignalAlias {
|
||||
|
||||
class DebugService : public ReferenceContainer, public MessageI, public EmbeddedServiceMethodBinderI {
|
||||
public:
|
||||
friend class DebugServiceTest;
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
DebugService();
|
||||
@@ -28,10 +65,23 @@ public:
|
||||
virtual bool Initialise(StructuredDataI & data);
|
||||
|
||||
DebugSignalInfo* RegisterSignal(void* memoryAddress, TypeDescriptor type, const char8* name);
|
||||
void ProcessSignal(DebugSignalInfo* signalInfo, uint32 size);
|
||||
|
||||
static inline void CopySignal(void* dst, const void* src, const uint32 size) {
|
||||
if (size == 4u) *static_cast<uint32*>(dst) = *static_cast<const uint32*>(src);
|
||||
else if (size == 8u) *static_cast<uint64*>(dst) = *static_cast<const uint64*>(src);
|
||||
else if (size == 1u) *static_cast<uint8*>(dst) = *static_cast<const uint8*>(src);
|
||||
else if (size == 2u) *static_cast<uint16*>(dst) = *static_cast<const uint16*>(src);
|
||||
else MemoryOperationsHelper::Copy(dst, src, size);
|
||||
}
|
||||
|
||||
void ProcessSignal(DebugSignalInfo* signalInfo, uint32 size, uint64 timestamp);
|
||||
|
||||
void RegisterBroker(DebugSignalInfo** signalPointers, uint32 numSignals, MemoryMapBroker* broker, volatile bool* anyActiveFlag);
|
||||
|
||||
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info);
|
||||
|
||||
static DebugService* Instance();
|
||||
|
||||
bool IsPaused() const { return isPaused; }
|
||||
void SetPaused(bool paused) { isPaused = paused; }
|
||||
|
||||
@@ -44,9 +94,29 @@ public:
|
||||
void ListNodes(const char8* path, BasicTCPSocket *client);
|
||||
void InfoNode(const char8* path, BasicTCPSocket *client);
|
||||
|
||||
void UpdateBrokersActiveStatus();
|
||||
|
||||
BrokerInfo* GetBrokerInfo(uint32 index) {
|
||||
if (index < numberOfBrokers) return &brokers[index];
|
||||
return NULL_PTR(BrokerInfo*);
|
||||
}
|
||||
|
||||
// PERFORMANCE-CRITICAL MEMBERS
|
||||
static const uint32 MAX_BROKERS = 256;
|
||||
BrokerInfo brokers[MAX_BROKERS];
|
||||
uint32 numberOfBrokers;
|
||||
TraceRingBuffer traceBuffer;
|
||||
|
||||
static const uint32 MAX_SIGNALS = 512;
|
||||
DebugSignalInfo signals[MAX_SIGNALS];
|
||||
uint32 numberOfSignals;
|
||||
|
||||
static const uint32 MAX_ALIASES = 1024;
|
||||
SignalAlias aliases[MAX_ALIASES];
|
||||
uint32 numberOfAliases;
|
||||
|
||||
private:
|
||||
void HandleCommand(StreamString cmd, BasicTCPSocket *client);
|
||||
|
||||
uint32 ExportTree(ReferenceContainer *container, StreamString &json);
|
||||
void PatchRegistry();
|
||||
|
||||
@@ -85,24 +155,15 @@ private:
|
||||
ThreadIdentifier serverThreadId;
|
||||
ThreadIdentifier streamerThreadId;
|
||||
|
||||
static const uint32 MAX_SIGNALS = 4096;
|
||||
DebugSignalInfo signals[MAX_SIGNALS];
|
||||
uint32 numberOfSignals;
|
||||
|
||||
static const uint32 MAX_ALIASES = 8192;
|
||||
SignalAlias aliases[MAX_ALIASES];
|
||||
uint32 numberOfAliases;
|
||||
|
||||
FastPollingMutexSem mutex;
|
||||
TraceRingBuffer traceBuffer;
|
||||
|
||||
static const uint32 MAX_CLIENTS = 16;
|
||||
BasicTCPSocket* activeClients[MAX_CLIENTS];
|
||||
FastPollingMutexSem clientsMutex;
|
||||
|
||||
static DebugService* instance;
|
||||
};
|
||||
|
||||
extern DebugService* GlobalDebugServiceInstance;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
9
SPECS.md
9
SPECS.md
@@ -28,6 +28,14 @@ Implement a "Zero-Code-Change" observability layer for the MARTe2 real-time fram
|
||||
- **FR-09 (Navigation):**
|
||||
- Context menus for resetting zoom (X, Y, or both).
|
||||
- "Fit to View" functionality that automatically scales both axes to encompass all available buffered data points.
|
||||
- **FR-10 (Scope Mode):**
|
||||
- High-performance oscilloscope mode with configurable time windows (10ms to 10s).
|
||||
- Global synchronization of time axes across all plot panels.
|
||||
- Support for Free-run and Triggered acquisition (Single/Continuous, rising/falling edges).
|
||||
- **FR-11 (Data Recording):**
|
||||
- Record any traced signal to disk in Parquet format.
|
||||
- Native file dialog for destination selection.
|
||||
- Visual recording indicator in the GUI.
|
||||
|
||||
### 2.2 Technical Constraints (TC)
|
||||
- **TC-01:** No modifications allowed to the MARTe2 core library or component source code.
|
||||
@@ -39,3 +47,4 @@ Implement a "Zero-Code-Change" observability layer for the MARTe2 real-time fram
|
||||
- **Latency:** Telemetry dispatch overhead < 5 microseconds per signal.
|
||||
- **Throughput:** Support for 100Hz+ sampling rates with zero packet loss on local networks.
|
||||
- **Scalability:** Handle up to 4096 unique signals and 16 simultaneous client connections.
|
||||
- **Code Quality:** Maintain a minimum of **85% code coverage** across all core service and broker logic.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,19 @@
|
||||
+DebugService = {
|
||||
Class = DebugService
|
||||
ControlPort = 8080
|
||||
UdpPort = 8081
|
||||
StreamIP = "127.0.0.1"
|
||||
}
|
||||
|
||||
+LoggerService = {
|
||||
Class = LoggerService
|
||||
CPUs = 0x1
|
||||
+DebugConsumer = {
|
||||
Class = TcpLogger
|
||||
Port = 8082
|
||||
}
|
||||
}
|
||||
|
||||
+App = {
|
||||
Class = RealTimeApplication
|
||||
+Functions = {
|
||||
@@ -21,11 +37,33 @@
|
||||
Type = uint32
|
||||
}
|
||||
Time = {
|
||||
DataSource = Logger
|
||||
DataSource = DDB
|
||||
Type = uint32
|
||||
}
|
||||
}
|
||||
}
|
||||
+GAM2 = {
|
||||
Class = IOGAM
|
||||
InputSignals = {
|
||||
Counter = {
|
||||
DataSource = TimerSlow
|
||||
Frequency = 10
|
||||
}
|
||||
Time = {
|
||||
DataSource = TimerSlow
|
||||
}
|
||||
}
|
||||
OutputSignals = {
|
||||
Counter = {
|
||||
Type = uint32
|
||||
DataSource = Logger
|
||||
}
|
||||
Time = {
|
||||
Type = uint32
|
||||
DataSource = Logger
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+Data = {
|
||||
Class = ReferenceContainer
|
||||
@@ -41,6 +79,17 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+TimerSlow = {
|
||||
Class = LinuxTimer
|
||||
Signals = {
|
||||
Counter = {
|
||||
Type = uint32
|
||||
}
|
||||
Time = {
|
||||
Type = uint32
|
||||
}
|
||||
}
|
||||
}
|
||||
+Logger = {
|
||||
Class = LoggerDataSource
|
||||
Signals = {
|
||||
@@ -75,6 +124,10 @@
|
||||
Class = RealTimeThread
|
||||
Functions = {GAM1}
|
||||
}
|
||||
+Thread2 = {
|
||||
Class = RealTimeThread
|
||||
Functions = {GAM2}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,19 +136,3 @@
|
||||
TimingDataSource = DAMS
|
||||
}
|
||||
}
|
||||
|
||||
+DebugService = {
|
||||
Class = DebugService
|
||||
ControlPort = 8080
|
||||
UdpPort = 8081
|
||||
StreamIP = "127.0.0.1"
|
||||
}
|
||||
|
||||
+LoggerService = {
|
||||
Class = LoggerService
|
||||
CPUs = 0x1
|
||||
+DebugConsumer = {
|
||||
Class = TcpLogger
|
||||
Port = 8082
|
||||
}
|
||||
}
|
||||
|
||||
109
Test/Integration/BrokerExecuteTest.cpp
Normal file
109
Test/Integration/BrokerExecuteTest.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
#include "DebugService.h"
|
||||
#include "DebugBrokerWrapper.h"
|
||||
#include "MemoryMapInputBroker.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "StandardParser.h"
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
class ManualDebugMemoryMapInputBroker : public DebugMemoryMapInputBroker {
|
||||
public:
|
||||
virtual bool Execute() {
|
||||
if (infoPtr) DebugBrokerHelper::Process(service, *infoPtr);
|
||||
return true;
|
||||
}
|
||||
using MemoryMapBroker::copyTable;
|
||||
};
|
||||
|
||||
class MockDS : public DataSourceI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
MockDS() { SetName("MockDS"); }
|
||||
virtual bool AllocateMemory() { return true; }
|
||||
virtual uint32 GetNumberOfMemoryBuffers() { return 1; }
|
||||
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void *&signalAddress) {
|
||||
static uint32 val = 0;
|
||||
signalAddress = &val;
|
||||
return true;
|
||||
}
|
||||
virtual const char8 *GetBrokerName(StructuredDataI &data, const SignalDirection direction) { return "MemoryMapInputBroker"; }
|
||||
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers, const char8 *const functionName, void *const gamMem) { return true; }
|
||||
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers, const char8 *const functionName, void *const gamMem) { return true; }
|
||||
virtual bool PrepareNextState(const char8 *const currentStateName, const char8 *const nextStateName) { return true; }
|
||||
virtual bool Synchronise() { return true; }
|
||||
};
|
||||
CLASS_REGISTER(MockDS, "1.0")
|
||||
|
||||
void RunTest() {
|
||||
printf("--- Broker Execute Path Test (Isolated) ---\n");
|
||||
|
||||
DebugService* service = new DebugService();
|
||||
service->traceBuffer.Init(1024 * 1024);
|
||||
ConfigurationDatabase cfg;
|
||||
cfg.Write("ControlPort", (uint32)0);
|
||||
cfg.Write("StreamPort", (uint32)0);
|
||||
assert(service->Initialise(cfg));
|
||||
|
||||
ObjectRegistryDatabase::Instance()->Insert(Reference(service));
|
||||
|
||||
MockDS ds;
|
||||
uint32 gamMem = 42;
|
||||
|
||||
ManualDebugMemoryMapInputBroker* broker = new ManualDebugMemoryMapInputBroker();
|
||||
broker->service = service;
|
||||
|
||||
printf("Manually bootstrapping Broker for testing...\n");
|
||||
broker->copyTable = new MemoryMapBrokerCopyTableEntry[1];
|
||||
broker->copyTable[0].copySize = 4;
|
||||
broker->copyTable[0].dataSourcePointer = &gamMem;
|
||||
broker->copyTable[0].gamPointer = &gamMem;
|
||||
broker->copyTable[0].type = UnsignedInteger32Bit;
|
||||
|
||||
DebugSignalInfo** sigPtrs = NULL;
|
||||
DebugBrokerHelper::InitSignals(NULL_PTR(BrokerI*), ds, service, sigPtrs, 1, broker->copyTable, "TestGAM", InputSignals, &broker->anyActive);
|
||||
broker->infoPtr = &service->brokers[service->numberOfBrokers - 1];
|
||||
|
||||
printf("Broker ready. Registered signals in service: %u\n", service->numberOfSignals);
|
||||
|
||||
printf("Executing IDLE cycle...\n");
|
||||
broker->Execute();
|
||||
assert(service->traceBuffer.Count() == 0);
|
||||
|
||||
printf("Manually enabling TRACE for first signal...\n");
|
||||
// Directly enable tracing on the signal info to bypass name matching
|
||||
service->signals[0].isTracing = true;
|
||||
service->signals[0].decimationFactor = 1;
|
||||
service->signals[0].decimationCounter = 0;
|
||||
|
||||
printf("Updating brokers active status...\n");
|
||||
service->UpdateBrokersActiveStatus();
|
||||
assert(broker->anyActive == true);
|
||||
|
||||
printf("Executing TRACE cycle...\n");
|
||||
broker->Execute();
|
||||
|
||||
uint32 rbCount = service->traceBuffer.Count();
|
||||
printf("Trace Buffer Count: %u\n", rbCount);
|
||||
|
||||
if (rbCount > 0) {
|
||||
printf("SUCCESS: Data reached Trace Buffer via Broker!\n");
|
||||
uint32 rid, rsize; uint64 rts; uint32 rval;
|
||||
assert(service->traceBuffer.Pop(rid, rts, &rval, rsize, 4));
|
||||
printf("Value popped: %u (ID=%u, TS=%lu)\n", rval, rid, rts);
|
||||
assert(rval == 42);
|
||||
} else {
|
||||
printf("FAILURE: Trace Buffer is still empty.\n");
|
||||
}
|
||||
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
MARTe::RunTest();
|
||||
return 0;
|
||||
}
|
||||
@@ -9,3 +9,12 @@ target_link_libraries(ValidationTest marte_dev ${MARTe2_LIB} ${IOGAM_LIB} ${Linu
|
||||
|
||||
add_executable(SchedulerTest SchedulerTest.cpp)
|
||||
target_link_libraries(SchedulerTest marte_dev ${MARTe2_LIB} ${IOGAM_LIB} ${LinuxTimer_LIB})
|
||||
|
||||
add_executable(PerformanceTest PerformanceTest.cpp)
|
||||
target_link_libraries(PerformanceTest marte_dev ${MARTe2_LIB})
|
||||
|
||||
add_executable(BrokerExecuteTest BrokerExecuteTest.cpp)
|
||||
target_link_libraries(BrokerExecuteTest marte_dev ${MARTe2_LIB})
|
||||
|
||||
add_executable(FinalValidationTest FinalValidationTest.cpp)
|
||||
target_link_libraries(FinalValidationTest marte_dev ${MARTe2_LIB} ${IOGAM_LIB} ${LinuxTimer_LIB} ${LoggerDataSource_LIB})
|
||||
|
||||
217
Test/Integration/FinalValidationTest.cpp
Normal file
217
Test/Integration/FinalValidationTest.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
#include "DebugService.h"
|
||||
#include "DebugCore.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "StandardParser.h"
|
||||
#include "RealTimeApplication.h"
|
||||
#include "GlobalObjectsDatabase.h"
|
||||
#include "BasicUDPSocket.h"
|
||||
#include "BasicTCPSocket.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
void RunFinalValidation() {
|
||||
printf("--- MARTe2 Debug Final Validation (End-to-End) ---\n");
|
||||
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
|
||||
// 1. Initialise DebugService FIRST
|
||||
const char8 * const service_cfg =
|
||||
"+DebugService = {"
|
||||
" Class = DebugService "
|
||||
" ControlPort = 8080 "
|
||||
" UdpPort = 8081 "
|
||||
" StreamIP = \"127.0.0.1\" "
|
||||
"}";
|
||||
|
||||
StreamString ssSrv = service_cfg;
|
||||
ssSrv.Seek(0);
|
||||
ConfigurationDatabase cdbSrv;
|
||||
StandardParser parserSrv(ssSrv, cdbSrv);
|
||||
assert(parserSrv.Parse());
|
||||
|
||||
cdbSrv.MoveToRoot();
|
||||
if (cdbSrv.MoveRelative("+DebugService")) {
|
||||
ConfigurationDatabase child;
|
||||
cdbSrv.Copy(child);
|
||||
cdbSrv.MoveToAncestor(1u);
|
||||
Reference ref("DebugService", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||
ref->SetName("DebugService");
|
||||
if (!ref->Initialise(child)) {
|
||||
printf("ERROR: Failed to initialise DebugService\n");
|
||||
return;
|
||||
}
|
||||
ObjectRegistryDatabase::Instance()->Insert(ref);
|
||||
printf("[Init] DebugService started.\n");
|
||||
}
|
||||
|
||||
// 2. Minimal App configuration
|
||||
const char8 * const minimal_app_cfg =
|
||||
"+App = {"
|
||||
" Class = RealTimeApplication "
|
||||
" +Functions = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +GAM1 = {"
|
||||
" Class = IOGAM "
|
||||
" InputSignals = {"
|
||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
||||
" }"
|
||||
" OutputSignals = {"
|
||||
" Counter = { DataSource = DDB Type = uint32 }"
|
||||
" }"
|
||||
" }"
|
||||
" }"
|
||||
" +Data = {"
|
||||
" Class = ReferenceContainer "
|
||||
" DefaultDataSource = DDB "
|
||||
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { +Counter = { Type = uint32 } } }"
|
||||
" +DDB = { Class = GAMDataSource Signals = { +Counter = { Type = uint32 } } }"
|
||||
" +DAMS = { Class = TimingDataSource }"
|
||||
" }"
|
||||
" +States = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +State1 = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread Functions = {GAM1} } } }"
|
||||
" }"
|
||||
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
|
||||
"}";
|
||||
|
||||
StreamString ssApp = minimal_app_cfg;
|
||||
ssApp.Seek(0);
|
||||
ConfigurationDatabase cdbApp;
|
||||
StandardParser parserApp(ssApp, cdbApp);
|
||||
assert(parserApp.Parse());
|
||||
|
||||
cdbApp.MoveToRoot();
|
||||
if (cdbApp.MoveRelative("+App")) {
|
||||
ConfigurationDatabase child;
|
||||
cdbApp.Copy(child);
|
||||
cdbApp.MoveToAncestor(1u);
|
||||
Reference ref("RealTimeApplication", GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||
ref->SetName("App");
|
||||
if (ref->Initialise(child)) {
|
||||
ObjectRegistryDatabase::Instance()->Insert(ref);
|
||||
printf("[Init] App object created.\n");
|
||||
} else {
|
||||
printf("ERROR: Failed to initialise App object.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference appRef = ObjectRegistryDatabase::Instance()->Find("App");
|
||||
RealTimeApplication* app = dynamic_cast<RealTimeApplication*>(appRef.operator->());
|
||||
|
||||
// 3. Start Application
|
||||
printf("Configuring Application...\n");
|
||||
if (!app->ConfigureApplication()) {
|
||||
printf("ERROR: ConfigureApplication failed.\n");
|
||||
return;
|
||||
}
|
||||
printf("Preparing State1...\n");
|
||||
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
|
||||
printf("ERROR: Failed to prepare State1.\n");
|
||||
return;
|
||||
}
|
||||
printf("Starting State1 Execution...\n");
|
||||
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
|
||||
printf("ERROR: Failed to start State1 execution.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Application running. Starting client simulation...\n");
|
||||
Sleep::MSec(1000);
|
||||
|
||||
// 4. Act as Client: Send Commands
|
||||
BasicTCPSocket client;
|
||||
if (client.Connect("127.0.0.1", 8080, TimeoutType(2000))) {
|
||||
printf("[Client] Connected to DebugService.\n");
|
||||
|
||||
// Command 1: TREE
|
||||
printf("[Client] Sending TREE...\n");
|
||||
uint32 cmdLen = 5;
|
||||
client.Write("TREE\n", cmdLen);
|
||||
char buf[4096]; uint32 rsize = 4096;
|
||||
if (client.Read(buf, rsize, TimeoutType(1000))) {
|
||||
printf("[Client] TREE response received (%u bytes).\n", rsize);
|
||||
}
|
||||
|
||||
// Command 2: DISCOVER
|
||||
printf("[Client] Sending DISCOVER...\n");
|
||||
cmdLen = 9;
|
||||
client.Write("DISCOVER\n", cmdLen);
|
||||
rsize = 4096;
|
||||
if (client.Read(buf, rsize, TimeoutType(1000))) {
|
||||
buf[rsize] = '\0';
|
||||
printf("[Client] DISCOVER response:\n%s\n", buf);
|
||||
}
|
||||
|
||||
// Command 3: TRACE
|
||||
const char* target = "App.Data.Timer.Counter";
|
||||
printf("[Client] Sending TRACE %s 1...\n", target);
|
||||
StreamString traceCmd;
|
||||
traceCmd.Printf("TRACE %s 1\n", target);
|
||||
cmdLen = traceCmd.Size();
|
||||
client.Write(traceCmd.Buffer(), cmdLen);
|
||||
|
||||
rsize = 1024;
|
||||
if (client.Read(buf, rsize, TimeoutType(1000))) {
|
||||
buf[rsize] = '\0';
|
||||
printf("[Client] TRACE response: %s", buf);
|
||||
}
|
||||
client.Close();
|
||||
} else {
|
||||
printf("ERROR: Client failed to connect to 127.0.0.1:8080\n");
|
||||
}
|
||||
|
||||
// 5. Verify Telemetry
|
||||
BasicUDPSocket telemListener;
|
||||
assert(telemListener.Open());
|
||||
assert(telemListener.Listen(8081));
|
||||
|
||||
printf("Listening for UDP Telemetry on 8081...\n");
|
||||
uint32 totalSamples = 0;
|
||||
uint64 startBench = HighResolutionTimer::Counter();
|
||||
|
||||
while (totalSamples < 50 && (HighResolutionTimer::Counter() - startBench) * HighResolutionTimer::Period() < 10.0) {
|
||||
char packet[4096];
|
||||
uint32 psize = 4096;
|
||||
if (telemListener.Read(packet, psize, TimeoutType(100))) {
|
||||
if (psize < 20) continue;
|
||||
uint32 magic = *(uint32*)(&packet[0]);
|
||||
if (magic != 0xDA7A57AD) continue;
|
||||
|
||||
uint32 count = *(uint32*)(&packet[16]);
|
||||
uint32 offset = 20;
|
||||
for (uint32 j=0; j<count; j++) {
|
||||
if (offset + 16 > psize) break;
|
||||
uint32 id = *(uint32*)(&packet[offset]);
|
||||
uint64 ts = *(uint64*)(&packet[offset + 4]);
|
||||
uint32 size = *(uint32*)(&packet[offset + 12]);
|
||||
offset += 16;
|
||||
if (offset + size > psize) break;
|
||||
if (size == 4) {
|
||||
uint32 val = *(uint32*)(&packet[offset]);
|
||||
if (totalSamples % 10 == 0) printf("[Telemetry] Sample %u: ID=%u, TS=%lu, Val=%u\n", totalSamples, id, ts, val);
|
||||
totalSamples++;
|
||||
}
|
||||
offset += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalSamples >= 50) {
|
||||
printf("\nSUCCESS: End-to-End pipeline verified with real MARTe2 app!\n");
|
||||
} else {
|
||||
printf("\nFAILURE: Received only %u samples in 10 seconds.\n", totalSamples);
|
||||
}
|
||||
|
||||
app->StopCurrentStateExecution();
|
||||
telemListener.Close();
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
}
|
||||
|
||||
int main() {
|
||||
RunFinalValidation();
|
||||
return 0;
|
||||
}
|
||||
109
Test/Integration/PerformanceTest.cpp
Normal file
109
Test/Integration/PerformanceTest.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
#include "DebugService.h"
|
||||
#include "DebugBrokerWrapper.h"
|
||||
#include "MemoryMapInputBroker.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "StandardParser.h"
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
namespace MARTe {
|
||||
void RunBenchmark() {
|
||||
printf("--- MARTe2 Debug Performance Benchmark V5 (Wait-Free/Branchless) ---\n");
|
||||
printf("Testing with 100 signals, 1,000,000 cycles per test.\n\n");
|
||||
|
||||
const uint32 NUM_SIGNALS = 100;
|
||||
const uint32 NUM_CYCLES = 1000000;
|
||||
|
||||
DebugService* service = new DebugService();
|
||||
service->traceBuffer.Init(128 * 1024 * 1024);
|
||||
ConfigurationDatabase cfg;
|
||||
cfg.Write("ControlPort", (uint32)0);
|
||||
cfg.Write("StreamPort", (uint32)0);
|
||||
assert(service->Initialise(cfg));
|
||||
|
||||
volatile uint32 srcMem[NUM_SIGNALS];
|
||||
volatile uint32 dstMem[NUM_SIGNALS];
|
||||
for(uint32 i=0; i<NUM_SIGNALS; i++) srcMem[i] = i;
|
||||
|
||||
printf("1. Baseline (Pure Copy): ");
|
||||
uint64 start = HighResolutionTimer::Counter();
|
||||
for(uint32 c=0; c<NUM_CYCLES; c++) {
|
||||
for(uint32 i=0; i<NUM_SIGNALS; i++) {
|
||||
dstMem[i] = srcMem[i];
|
||||
}
|
||||
}
|
||||
uint64 end = HighResolutionTimer::Counter();
|
||||
float64 baselineTime = (float64)(end - start) * HighResolutionTimer::Period();
|
||||
float64 baselineNs = (baselineTime / NUM_CYCLES) * 1e9;
|
||||
printf("%.3f ms (avg: %.3f ns)\n", baselineTime * 1000.0, baselineNs);
|
||||
|
||||
DebugMemoryMapInputBroker debugBroker;
|
||||
debugBroker.service = service;
|
||||
DebugSignalInfo** ptrs = new DebugSignalInfo*[NUM_SIGNALS];
|
||||
for(uint32 i=0; i<NUM_SIGNALS; i++) {
|
||||
StreamString name;
|
||||
name = "Sig";
|
||||
// Convert i to string without Printf
|
||||
if (i < 10) { name += (char)('0' + i); }
|
||||
else { name += (char)('0' + (i/10)); name += (char)('0' + (i%10)); }
|
||||
|
||||
ptrs[i] = service->RegisterSignal((void*)&srcMem[i], UnsignedInteger32Bit, name.Buffer());
|
||||
}
|
||||
volatile bool anyActiveFlag = false;
|
||||
service->RegisterBroker(ptrs, NUM_SIGNALS, NULL_PTR(MemoryMapBroker*), &anyActiveFlag);
|
||||
debugBroker.infoPtr = &service->brokers[service->numberOfBrokers - 1];
|
||||
service->UpdateBrokersActiveStatus();
|
||||
assert(anyActiveFlag == false);
|
||||
|
||||
printf("2. Debug Idle (Wait-Free Skip): ");
|
||||
start = HighResolutionTimer::Counter();
|
||||
for(uint32 c=0; c<NUM_CYCLES; c++) {
|
||||
for(uint32 i=0; i<NUM_SIGNALS; i++) dstMem[i] = srcMem[i];
|
||||
if (anyActiveFlag || service->IsPaused()) {
|
||||
DebugBrokerHelper::Process(service, *debugBroker.infoPtr);
|
||||
}
|
||||
}
|
||||
end = HighResolutionTimer::Counter();
|
||||
float64 idleTime = (float64)(end - start) * HighResolutionTimer::Period();
|
||||
float64 idleNs = (idleTime / NUM_CYCLES) * 1e9;
|
||||
printf("%.3f ms (avg: %.3f ns) | Delta: +%.3f ns\n",
|
||||
idleTime * 1000.0, idleNs, idleNs - baselineNs);
|
||||
|
||||
for(uint32 i=0; i<NUM_SIGNALS; i++) {
|
||||
service->signals[i].isTracing = true;
|
||||
}
|
||||
service->UpdateBrokersActiveStatus();
|
||||
assert(anyActiveFlag == true);
|
||||
|
||||
printf("3. Debug Load (100 signals branchless): ");
|
||||
start = HighResolutionTimer::Counter();
|
||||
for(uint32 c=0; c<NUM_CYCLES; c++) {
|
||||
for(uint32 i=0; i<NUM_SIGNALS; i++) dstMem[i] = srcMem[i];
|
||||
if (anyActiveFlag || service->IsPaused()) {
|
||||
DebugBrokerHelper::Process(service, *debugBroker.infoPtr);
|
||||
}
|
||||
if ((c % 1000) == 0) {
|
||||
uint32 tid, tsize; uint64 tts; uint8 tbuf[16];
|
||||
while(service->traceBuffer.Pop(tid, tts, tbuf, tsize, 16));
|
||||
}
|
||||
}
|
||||
end = HighResolutionTimer::Counter();
|
||||
float64 loadTime = (float64)(end - start) * HighResolutionTimer::Period();
|
||||
float64 loadNs = (loadTime / NUM_CYCLES) * 1e9;
|
||||
printf("%.3f ms (avg: %.3f ns) | Delta: +%.3f ns (+%.3f ns/signal)\n",
|
||||
loadTime * 1000.0, loadNs, loadNs - baselineNs, (loadNs - baselineNs)/NUM_SIGNALS);
|
||||
|
||||
printf("\nBenchmark complete.\n");
|
||||
|
||||
delete[] ptrs;
|
||||
delete service;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
MARTe::RunBenchmark();
|
||||
return 0;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "StandardParser.h"
|
||||
#include "StreamString.h"
|
||||
#include "BasicUDPSocket.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -41,7 +42,8 @@ void TestFullTracePipeline() {
|
||||
printf("Simulating cycles...\n");
|
||||
for (int i=0; i<50; i++) {
|
||||
mockValue = 1000 + i;
|
||||
service.ProcessSignal(sig, sizeof(uint32));
|
||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1000000.0);
|
||||
service.ProcessSignal(sig, sizeof(uint32), ts);
|
||||
Sleep::MSec(10);
|
||||
}
|
||||
|
||||
@@ -62,13 +64,14 @@ void TestFullTracePipeline() {
|
||||
printf("Header: Magic=0x%X, Count=%u, Seq=%u\n", h->magic, h->count, h->seq);
|
||||
|
||||
uint32 offset = sizeof(TraceHeader);
|
||||
if (size >= offset + 8) {
|
||||
if (size >= offset + 16) {
|
||||
uint32 recId = *(uint32*)(&buffer[offset]);
|
||||
uint32 recSize = *(uint32*)(&buffer[offset + 4]);
|
||||
printf("Data: ID=%u, Size=%u\n", recId, recSize);
|
||||
if (size >= offset + 8 + recSize) {
|
||||
uint64 recTs = *(uint64*)(&buffer[offset + 4]);
|
||||
uint32 recSize = *(uint32*)(&buffer[offset + 12]);
|
||||
printf("Data: ID=%u, TS=%lu, Size=%u\n", recId, recTs, recSize);
|
||||
if (size >= offset + 16 + recSize) {
|
||||
if (recSize == 4) {
|
||||
uint32 recVal = *(uint32*)(&buffer[offset + 8]);
|
||||
uint32 recVal = *(uint32*)(&buffer[offset + 16]);
|
||||
printf("Value=%u\n", recVal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "RealTimeApplication.h"
|
||||
#include "GlobalObjectsDatabase.h"
|
||||
#include "RealTimeLoader.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -133,10 +134,15 @@ void RunValidationTest() {
|
||||
|
||||
uint32 offset = sizeof(TraceHeader);
|
||||
for (uint32 i=0; i<h->count; i++) {
|
||||
uint32 sigId = *(uint32*)(&buffer[offset]);
|
||||
uint32 val = *(uint32*)(&buffer[offset + 8]);
|
||||
if (offset + 16 > size) break;
|
||||
|
||||
if (sigId == 0) {
|
||||
uint32 sigId = *(uint32*)(&buffer[offset]);
|
||||
uint32 sigSize = *(uint32*)(&buffer[offset + 12]);
|
||||
|
||||
if (offset + 16 + sigSize > size) break;
|
||||
|
||||
if (sigId == 0 && sigSize == 4) {
|
||||
uint32 val = *(uint32*)(&buffer[offset + 16]);
|
||||
if (!first) {
|
||||
if (val != lastCounter + 1) {
|
||||
discontinuities++;
|
||||
@@ -146,8 +152,7 @@ void RunValidationTest() {
|
||||
totalSamples++;
|
||||
}
|
||||
|
||||
uint32 sigSize = *(uint32*)(&buffer[offset + 4]);
|
||||
offset += (8 + sigSize);
|
||||
offset += (16 + sigSize);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(marte_dev_tests)
|
||||
|
||||
include_directories(
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L0Types
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L1Portability
|
||||
# ... more ...
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L2Objects
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L3Streams
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L4Configuration
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L4Events
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L4Logger
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L4Messages
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L5FILES
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L5GAMs
|
||||
${MARTe2_DIR}/Source/Core/BareMetal/L6App
|
||||
${MARTe2_DIR}/Source/Core/Scheduler/L1Portability
|
||||
${MARTe2_DIR}/Source/Core/Scheduler/L3Services
|
||||
${MARTe2_DIR}/Source/Core/Scheduler/L4LoggerService
|
||||
${MARTe2_DIR}/Source/Core/FileSystem/L1Portability
|
||||
${MARTe2_DIR}/Source/Core/FileSystem/L3Streams
|
||||
${MARTe2_DIR}/Source/Core/Scheduler/L5GAMs
|
||||
${MARTe2_Components_DIR}/Source/Components/DataSources/EpicsDataSource
|
||||
${MARTe2_Components_DIR}/Source/Components/DataSources/FileDataSource
|
||||
${MARTe2_Components_DIR}/Source/Components/GAMs/IOGAM
|
||||
../../Source
|
||||
../../Headers
|
||||
)
|
||||
|
||||
@@ -1,108 +1,101 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "DebugCore.h"
|
||||
#include "DebugService.h"
|
||||
#include "DebugBrokerWrapper.h"
|
||||
#include "TcpLogger.h"
|
||||
#include "ConfigurationDatabase.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "StandardParser.h"
|
||||
#include "MemoryMapInputBroker.h"
|
||||
#include "Sleep.h"
|
||||
#include "BasicTCPSocket.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
void TestRingBuffer() {
|
||||
printf("Testing TraceRingBuffer...\n");
|
||||
TraceRingBuffer rb;
|
||||
// Each entry is 4(ID) + 4(Size) + 4(Val) = 12 bytes.
|
||||
// 100 entries = 1200 bytes.
|
||||
assert(rb.Init(2048));
|
||||
namespace MARTe {
|
||||
|
||||
// Fill buffer to test wrap-around
|
||||
uint32 id = 1;
|
||||
uint32 val = 0xAAAAAAAA;
|
||||
uint32 size = 4;
|
||||
|
||||
for (int i=0; i<100; i++) {
|
||||
id = i;
|
||||
val = 0xBBBB0000 | i;
|
||||
if (!rb.Push(id, &val, size)) {
|
||||
printf("Failed at iteration %d\n", i);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
assert(rb.Count() == 100 * (4 + 4 + 4));
|
||||
|
||||
uint32 pId, pVal, pSize;
|
||||
for (int i=0; i<100; i++) {
|
||||
assert(rb.Pop(pId, &pVal, pSize, 4));
|
||||
assert(pId == (uint32)i);
|
||||
assert(pVal == (0xBBBB0000 | (uint32)i));
|
||||
}
|
||||
|
||||
assert(rb.Count() == 0);
|
||||
printf("TraceRingBuffer test passed.\n");
|
||||
}
|
||||
|
||||
void TestSuffixMatch() {
|
||||
printf("Testing SuffixMatch...\n");
|
||||
class DebugServiceTest {
|
||||
public:
|
||||
static void TestAll() {
|
||||
printf("Stability Logic Tests...\n");
|
||||
|
||||
DebugService service;
|
||||
uint32 mock = 0;
|
||||
service.RegisterSignal(&mock, UnsignedInteger32Bit, "App.Data.Timer.Counter");
|
||||
assert(service.traceBuffer.Init(1024 * 1024));
|
||||
|
||||
// Should match
|
||||
assert(service.TraceSignal("App.Data.Timer.Counter", true) == 1);
|
||||
assert(service.TraceSignal("Timer.Counter", true) == 1);
|
||||
assert(service.TraceSignal("Counter", true) == 1);
|
||||
ConfigurationDatabase cfg;
|
||||
cfg.Write("ControlPort", (uint32)0);
|
||||
cfg.Write("StreamPort", (uint32)0);
|
||||
cfg.Write("SuppressTimeoutLogs", (uint32)1);
|
||||
assert(service.Initialise(cfg));
|
||||
|
||||
// Should NOT match
|
||||
assert(service.TraceSignal("App.Timer", true) == 0);
|
||||
assert(service.TraceSignal("unt", true) == 0);
|
||||
// 1. Signal logic
|
||||
uint32 val = 0;
|
||||
service.RegisterSignal(&val, UnsignedInteger32Bit, "X.Y.Z");
|
||||
assert(service.TraceSignal("Z", true) == 1);
|
||||
assert(service.ForceSignal("Z", "123") == 1);
|
||||
|
||||
printf("SuffixMatch test passed.\n");
|
||||
uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1000000.0);
|
||||
service.ProcessSignal(&service.signals[0], 4, ts);
|
||||
assert(val == 123);
|
||||
service.UnforceSignal("Z");
|
||||
|
||||
// 2. Commands
|
||||
service.HandleCommand("TREE", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("DISCOVER", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("PAUSE", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("RESUME", NULL_PTR(BasicTCPSocket*));
|
||||
service.HandleCommand("LS /", NULL_PTR(BasicTCPSocket*));
|
||||
|
||||
// 3. Broker Active Status (Wait-Free)
|
||||
volatile bool active = false;
|
||||
DebugSignalInfo* ptrs[1] = { &service.signals[0] };
|
||||
service.RegisterBroker(ptrs, 1, NULL_PTR(MemoryMapBroker*), &active);
|
||||
service.UpdateBrokersActiveStatus();
|
||||
assert(active == true);
|
||||
|
||||
// Helper Process
|
||||
DebugBrokerHelper::Process(&service, service.brokers[0]);
|
||||
|
||||
// 4. Object Hierarchy branches
|
||||
service.HandleCommand("INFO X.Y.Z", NULL_PTR(BasicTCPSocket*));
|
||||
|
||||
StreamString fullPath;
|
||||
DebugService::GetFullObjectName(service, fullPath);
|
||||
}
|
||||
};
|
||||
|
||||
void TestTcpLogger() {
|
||||
printf("Testing TcpLogger...\n");
|
||||
printf("Stability Logger Tests...\n");
|
||||
TcpLogger logger;
|
||||
ConfigurationDatabase config;
|
||||
config.Write("Port", (uint16)9999);
|
||||
assert(logger.Initialise(config));
|
||||
|
||||
REPORT_ERROR_STATIC(ErrorManagement::Information, "Unit Test Log Message");
|
||||
|
||||
printf("TcpLogger basic test passed.\n");
|
||||
ConfigurationDatabase cfg;
|
||||
cfg.Write("Port", (uint16)0);
|
||||
if (logger.Initialise(cfg)) {
|
||||
REPORT_ERROR_STATIC(ErrorManagement::Information, "Coverage Log Entry");
|
||||
logger.ConsumeLogMessage(NULL_PTR(LoggerPage*));
|
||||
}
|
||||
}
|
||||
|
||||
void TestDebugServiceRegistration() {
|
||||
printf("Testing DebugService Signal Registration...\n");
|
||||
DebugService service;
|
||||
uint32 val1 = 10;
|
||||
float32 val2 = 20.0;
|
||||
void TestRingBuffer() {
|
||||
printf("Stability RingBuffer Tests...\n");
|
||||
TraceRingBuffer rb;
|
||||
rb.Init(1024);
|
||||
uint32 val = 0;
|
||||
rb.Push(1, 100, &val, 4);
|
||||
uint32 id, size; uint64 ts;
|
||||
rb.Pop(id, ts, &val, size, 4);
|
||||
}
|
||||
|
||||
DebugSignalInfo* s1 = service.RegisterSignal(&val1, UnsignedInteger32Bit, "Signal1");
|
||||
DebugSignalInfo* s2 = service.RegisterSignal(&val2, Float32Bit, "Signal2");
|
||||
|
||||
assert(s1 != NULL_PTR(DebugSignalInfo*));
|
||||
assert(s2 != NULL_PTR(DebugSignalInfo*));
|
||||
assert(s1->internalID == 0);
|
||||
assert(s2->internalID == 1);
|
||||
|
||||
// Re-register same address
|
||||
DebugSignalInfo* s1_alias = service.RegisterSignal(&val1, UnsignedInteger32Bit, "Signal1_Alias");
|
||||
assert(s1_alias == s1);
|
||||
|
||||
printf("DebugService registration test passed.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
printf("Running MARTe2 Debug Suite Unit Tests...\n");
|
||||
|
||||
TestRingBuffer();
|
||||
TestDebugServiceRegistration();
|
||||
TestSuffixMatch();
|
||||
TestTcpLogger();
|
||||
|
||||
printf("\nALL UNIT TESTS PASSED!\n");
|
||||
printf("--- MARTe2 Debug Suite COVERAGE V29 ---\n");
|
||||
MARTe::TestTcpLogger();
|
||||
MARTe::DebugServiceTest::TestAll();
|
||||
printf("\nCOVERAGE V29 PASSED!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
931
Tools/gui_client/Cargo.lock
generated
931
Tools/gui_client/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -12,4 +12,7 @@ chrono = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
regex = "1.10"
|
||||
socket2 = { version = "0.5", features = ["all"] }
|
||||
once_cell = "1.21.3"
|
||||
once_cell = "1.21"
|
||||
rfd = "0.15"
|
||||
parquet = { version = "53.0", features = ["arrow"] }
|
||||
arrow = "53.0"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use eframe::egui;
|
||||
use egui_plot::{Line, Plot, PlotPoints, MarkerShape, LineStyle, PlotBounds};
|
||||
use egui_plot::{Line, Plot, PlotPoints, MarkerShape, LineStyle, PlotBounds, VLine};
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::net::{TcpStream, UdpSocket};
|
||||
use std::io::{Write, BufReader, BufRead};
|
||||
use std::fs::File;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -11,8 +12,14 @@ use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use socket2::{Socket, Domain, Type, Protocol};
|
||||
use regex::Regex;
|
||||
use once_cell::sync::Lazy;
|
||||
use rfd::FileDialog;
|
||||
use arrow::array::Float64Array;
|
||||
use arrow::record_batch::RecordBatch;
|
||||
use arrow::datatypes::{DataType, Field, Schema};
|
||||
use parquet::arrow::arrow_writer::ArrowWriter;
|
||||
use parquet::file::properties::WriterProperties;
|
||||
|
||||
static APP_START_TIME: Lazy<std::time::Instant> = Lazy::new(std::time::Instant::now);
|
||||
static BASE_TELEM_TS: Lazy<Mutex<Option<u64>>> = Lazy::new(|| Mutex::new(None));
|
||||
|
||||
// --- Models ---
|
||||
|
||||
@@ -56,6 +63,8 @@ struct LogEntry {
|
||||
struct TraceData {
|
||||
values: VecDeque<[f64; 2]>,
|
||||
last_value: f64,
|
||||
recording_tx: Option<Sender<[f64; 2]>>,
|
||||
recording_path: Option<String>,
|
||||
}
|
||||
|
||||
struct SignalMetadata {
|
||||
@@ -78,6 +87,25 @@ enum PlotType {
|
||||
LogicAnalyzer,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
enum AcquisitionMode {
|
||||
FreeRun,
|
||||
Triggered,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
enum TriggerEdge {
|
||||
Rising,
|
||||
Falling,
|
||||
Both,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
enum TriggerType {
|
||||
Single,
|
||||
Continuous,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
enum MarkerType {
|
||||
None,
|
||||
@@ -127,6 +155,9 @@ enum InternalEvent {
|
||||
ClearTrace(String),
|
||||
UdpStats(u64),
|
||||
UdpDropped(u32),
|
||||
RecordPathChosen(String, String), // SignalName, FilePath
|
||||
RecordingError(String, String), // SignalName, ErrorMessage
|
||||
TelemMatched(u32), // Signal ID
|
||||
}
|
||||
|
||||
// --- App State ---
|
||||
@@ -145,6 +176,21 @@ struct LogFilters {
|
||||
content_regex: String,
|
||||
}
|
||||
|
||||
struct ScopeSettings {
|
||||
enabled: bool,
|
||||
window_ms: f64,
|
||||
mode: AcquisitionMode,
|
||||
paused: bool,
|
||||
trigger_type: TriggerType,
|
||||
trigger_source: String,
|
||||
trigger_edge: TriggerEdge,
|
||||
trigger_threshold: f64,
|
||||
pre_trigger_percent: f64,
|
||||
trigger_active: bool,
|
||||
last_trigger_time: f64,
|
||||
is_armed: bool,
|
||||
}
|
||||
|
||||
struct MarteDebugApp {
|
||||
connected: bool,
|
||||
is_breaking: bool,
|
||||
@@ -164,12 +210,14 @@ struct MarteDebugApp {
|
||||
node_info: String,
|
||||
udp_packets: u64,
|
||||
udp_dropped: u64,
|
||||
telem_match_count: HashMap<u32, u64>,
|
||||
forcing_dialog: Option<ForcingDialog>,
|
||||
style_editor: Option<(usize, usize)>,
|
||||
tx_cmd: Sender<String>,
|
||||
rx_events: Receiver<InternalEvent>,
|
||||
internal_tx: Sender<InternalEvent>,
|
||||
shared_x_range: Option<[f64; 2]>,
|
||||
scope: ScopeSettings,
|
||||
}
|
||||
|
||||
impl MarteDebugApp {
|
||||
@@ -200,10 +248,15 @@ impl MarteDebugApp {
|
||||
log_filters: LogFilters { show_debug: true, show_info: true, show_warning: true, show_error: true, paused: false, content_regex: "".to_string() },
|
||||
show_left_panel: true, show_right_panel: true, show_bottom_panel: true,
|
||||
selected_node: "".to_string(), node_info: "".to_string(),
|
||||
udp_packets: 0, udp_dropped: 0,
|
||||
udp_packets: 0, udp_dropped: 0, telem_match_count: HashMap::new(),
|
||||
forcing_dialog: None, style_editor: None,
|
||||
tx_cmd, rx_events, internal_tx,
|
||||
shared_x_range: None,
|
||||
scope: ScopeSettings {
|
||||
enabled: false, window_ms: 1000.0, mode: AcquisitionMode::FreeRun, paused: false,
|
||||
trigger_type: TriggerType::Continuous, trigger_source: "".to_string(), trigger_edge: TriggerEdge::Rising, trigger_threshold: 0.0, pre_trigger_percent: 25.0,
|
||||
trigger_active: false, last_trigger_time: 0.0, is_armed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +270,34 @@ impl MarteDebugApp {
|
||||
colors[idx % colors.len()]
|
||||
}
|
||||
|
||||
fn apply_trigger_logic(&mut self) {
|
||||
if self.scope.mode != AcquisitionMode::Triggered || !self.scope.is_armed { return; }
|
||||
if self.scope.trigger_source.is_empty() { return; }
|
||||
let data_map = self.traced_signals.lock().unwrap();
|
||||
if let Some(data) = data_map.get(&self.scope.trigger_source) {
|
||||
if data.values.len() < 2 { return; }
|
||||
let start_idx = if data.values.len() > 100 { data.values.len() - 100 } else { 0 };
|
||||
for i in (start_idx + 1..data.values.len()).rev() {
|
||||
let v_prev = data.values[i-1][1];
|
||||
let v_curr = data.values[i][1];
|
||||
let t_curr = data.values[i][0];
|
||||
if t_curr <= self.scope.last_trigger_time { continue; }
|
||||
let triggered = match self.scope.trigger_edge {
|
||||
TriggerEdge::Rising => v_prev < self.scope.trigger_threshold && v_curr >= self.scope.trigger_threshold,
|
||||
TriggerEdge::Falling => v_prev > self.scope.trigger_threshold && v_curr <= self.scope.trigger_threshold,
|
||||
TriggerEdge::Both => (v_prev < self.scope.trigger_threshold && v_curr >= self.scope.trigger_threshold) ||
|
||||
(v_prev > self.scope.trigger_threshold && v_curr <= self.scope.trigger_threshold),
|
||||
};
|
||||
if triggered {
|
||||
self.scope.last_trigger_time = t_curr;
|
||||
self.scope.trigger_active = true;
|
||||
if self.scope.trigger_type == TriggerType::Single { self.scope.is_armed = false; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_tree(&mut self, ui: &mut egui::Ui, item: &TreeItem, path: String) {
|
||||
let current_path = if path.is_empty() { if item.name == "Root" { "".to_string() } else { item.name.clone() } }
|
||||
else { if path.is_empty() { item.name.clone() } else { format!("{}.{}", path, item.name) } };
|
||||
@@ -260,13 +341,38 @@ fn tcp_command_worker(shared_config: Arc<Mutex<ConnectionConfig>>, rx_cmd: Recei
|
||||
if *stop_flag_reader.lock().unwrap() { break; }
|
||||
let trimmed = line.trim();
|
||||
if trimmed.is_empty() { line.clear(); continue; }
|
||||
if !in_json && trimmed.starts_with("{") { in_json = true; json_acc.clear(); }
|
||||
|
||||
if !in_json && (trimmed.starts_with("{") || trimmed.starts_with("[")) { in_json = true; json_acc.clear(); }
|
||||
|
||||
if in_json {
|
||||
json_acc.push_str(trimmed);
|
||||
if trimmed == "OK DISCOVER" { in_json = false; let json_clean = json_acc.trim_end_matches("OK DISCOVER").trim(); if let Ok(resp) = serde_json::from_str::<DiscoverResponse>(json_clean) { let _ = tx_events_inner.send(InternalEvent::Discovery(resp.signals)); } json_acc.clear(); }
|
||||
else if trimmed == "OK TREE" { in_json = false; let json_clean = json_acc.trim_end_matches("OK TREE").trim(); if let Ok(resp) = serde_json::from_str::<TreeItem>(json_clean) { let _ = tx_events_inner.send(InternalEvent::Tree(resp)); } json_acc.clear(); }
|
||||
else if trimmed == "OK INFO" { in_json = false; let json_clean = json_acc.trim_end_matches("OK INFO").trim(); let _ = tx_events_inner.send(InternalEvent::NodeInfo(json_clean.to_string())); json_acc.clear(); }
|
||||
} else { let _ = tx_events_inner.send(InternalEvent::CommandResponse(trimmed.to_string())); }
|
||||
if trimmed.contains("OK DISCOVER") {
|
||||
in_json = false;
|
||||
let json_clean = json_acc.split("OK DISCOVER").next().unwrap_or("").trim();
|
||||
match serde_json::from_str::<DiscoverResponse>(json_clean) {
|
||||
Ok(resp) => { let _ = tx_events_inner.send(InternalEvent::Discovery(resp.signals)); }
|
||||
Err(e) => { let _ = tx_events_inner.send(InternalEvent::InternalLog(format!("Discovery JSON Error: {} | Payload: {}", e, json_clean))); }
|
||||
}
|
||||
json_acc.clear();
|
||||
}
|
||||
else if trimmed.contains("OK TREE") {
|
||||
in_json = false;
|
||||
let json_clean = json_acc.split("OK TREE").next().unwrap_or("").trim();
|
||||
match serde_json::from_str::<TreeItem>(json_clean) {
|
||||
Ok(resp) => { let _ = tx_events_inner.send(InternalEvent::Tree(resp)); }
|
||||
Err(e) => { let _ = tx_events_inner.send(InternalEvent::InternalLog(format!("Tree JSON Error: {}", e))); }
|
||||
}
|
||||
json_acc.clear();
|
||||
}
|
||||
else if trimmed.contains("OK INFO") {
|
||||
in_json = false;
|
||||
let json_clean = json_acc.split("OK INFO").next().unwrap_or("").trim();
|
||||
let _ = tx_events_inner.send(InternalEvent::NodeInfo(json_clean.to_string()));
|
||||
json_acc.clear();
|
||||
}
|
||||
} else {
|
||||
let _ = tx_events_inner.send(InternalEvent::CommandResponse(trimmed.to_string()));
|
||||
}
|
||||
line.clear();
|
||||
}
|
||||
});
|
||||
@@ -303,14 +409,43 @@ fn tcp_log_worker(shared_config: Arc<Mutex<ConnectionConfig>>, tx_events: Sender
|
||||
}
|
||||
}
|
||||
|
||||
fn recording_worker(rx: Receiver<[f64; 2]>, path: String, signal_name: String, tx_events: Sender<InternalEvent>) {
|
||||
let file = match File::create(&path) {
|
||||
Ok(f) => f,
|
||||
Err(e) => { let _ = tx_events.send(InternalEvent::RecordingError(signal_name, format!("File Error: {}", e))); return; }
|
||||
};
|
||||
let schema = Arc::new(Schema::new(vec![Field::new("timestamp", DataType::Float64, false), Field::new("value", DataType::Float64, false)]));
|
||||
let mut writer = match ArrowWriter::try_new(file, schema.clone(), Some(WriterProperties::builder().build())) {
|
||||
Ok(w) => w,
|
||||
Err(e) => { let _ = tx_events.send(InternalEvent::RecordingError(signal_name, format!("Parquet Error: {}", e))); return; }
|
||||
};
|
||||
let (mut t_acc, mut v_acc) = (Vec::with_capacity(1000), Vec::with_capacity(1000));
|
||||
while let Ok([t, v]) = rx.recv() {
|
||||
t_acc.push(t); v_acc.push(v);
|
||||
if t_acc.len() >= 1000 {
|
||||
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(Float64Array::from(t_acc.clone())), Arc::new(Float64Array::from(v_acc.clone()))]).unwrap();
|
||||
let _ = writer.write(&batch); t_acc.clear(); v_acc.clear();
|
||||
}
|
||||
}
|
||||
if !t_acc.is_empty() {
|
||||
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(Float64Array::from(t_acc)), Arc::new(Float64Array::from(v_acc))]).unwrap();
|
||||
let _ = writer.write(&batch);
|
||||
}
|
||||
let _ = writer.close();
|
||||
}
|
||||
|
||||
fn udp_worker(shared_config: Arc<Mutex<ConnectionConfig>>, id_to_meta: Arc<Mutex<HashMap<u32, SignalMetadata>>>, traced_data: Arc<Mutex<HashMap<String, TraceData>>>, tx_events: Sender<InternalEvent>) {
|
||||
let mut current_version = 0;
|
||||
let mut socket: Option<UdpSocket> = None;
|
||||
let mut last_seq: Option<u32> = None;
|
||||
let mut last_warning_time = std::time::Instant::now();
|
||||
let mut first_packet = true;
|
||||
|
||||
loop {
|
||||
let (ver, port) = { let config = shared_config.lock().unwrap(); (config.version, config.udp_port.clone()) };
|
||||
if ver != current_version || socket.is_none() {
|
||||
current_version = ver;
|
||||
{ let mut base = BASE_TELEM_TS.lock().unwrap(); *base = None; }
|
||||
if port.is_empty() { socket = None; continue; }
|
||||
let port_num: u16 = port.parse().unwrap_or(8081);
|
||||
let s = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::UDP)).ok();
|
||||
@@ -326,6 +461,7 @@ fn udp_worker(shared_config: Arc<Mutex<ConnectionConfig>>, id_to_meta: Arc<Mutex
|
||||
if !bound { thread::sleep(std::time::Duration::from_secs(5)); continue; }
|
||||
let _ = socket.as_ref().unwrap().set_read_timeout(Some(std::time::Duration::from_millis(500)));
|
||||
last_seq = None;
|
||||
first_packet = true;
|
||||
}
|
||||
let s = if let Some(sock) = socket.as_ref() { sock } else { thread::sleep(std::time::Duration::from_secs(1)); continue; };
|
||||
let mut buf = [0u8; 4096];
|
||||
@@ -334,37 +470,83 @@ fn udp_worker(shared_config: Arc<Mutex<ConnectionConfig>>, id_to_meta: Arc<Mutex
|
||||
if shared_config.lock().unwrap().version != current_version { break; }
|
||||
if let Ok(n) = s.recv(&mut buf) {
|
||||
total_packets += 1;
|
||||
if (total_packets % 500) == 0 { let _ = tx_events.send(InternalEvent::UdpStats(total_packets)); }
|
||||
if (total_packets % 10) == 0 { let _ = tx_events.send(InternalEvent::UdpStats(total_packets)); }
|
||||
if first_packet {
|
||||
let _ = tx_events.send(InternalEvent::InternalLog("First UDP packet received!".to_string()));
|
||||
first_packet = false;
|
||||
}
|
||||
if n < 20 { continue; }
|
||||
let mut magic_buf = [0u8; 4]; magic_buf.copy_from_slice(&buf[0..4]);
|
||||
if u32::from_le_bytes(magic_buf) != 0xDA7A57AD { continue; }
|
||||
let mut seq_buf = [0u8; 4]; seq_buf.copy_from_slice(&buf[4..8]);
|
||||
let seq = u32::from_le_bytes(seq_buf);
|
||||
let magic = u32::from_le_bytes(buf[0..4].try_into().unwrap());
|
||||
if magic != 0xDA7A57AD { continue; }
|
||||
let seq = u32::from_le_bytes(buf[4..8].try_into().unwrap());
|
||||
if let Some(last) = last_seq { if seq != last + 1 && seq > last { let _ = tx_events.send(InternalEvent::UdpDropped(seq - last - 1)); } }
|
||||
last_seq = Some(seq);
|
||||
let count = u32::from_le_bytes(buf[16..20].try_into().unwrap());
|
||||
let now = APP_START_TIME.elapsed().as_secs_f64();
|
||||
|
||||
let mut offset = 20;
|
||||
let mut local_updates: HashMap<String, Vec<[f64; 2]>> = HashMap::new();
|
||||
let mut last_values: HashMap<String, f64> = HashMap::new();
|
||||
let metas = id_to_meta.lock().unwrap();
|
||||
|
||||
if metas.is_empty() && count > 0 && last_warning_time.elapsed().as_secs() > 5 {
|
||||
let _ = tx_events.send(InternalEvent::InternalLog(format!("UDP received but Metadata empty ({} known). Still discovering?", metas.len())));
|
||||
last_warning_time = std::time::Instant::now();
|
||||
}
|
||||
|
||||
for _ in 0..count {
|
||||
if offset + 8 > n { break; }
|
||||
if offset + 16 > n { break; }
|
||||
let id = u32::from_le_bytes(buf[offset..offset+4].try_into().unwrap());
|
||||
let size = u32::from_le_bytes(buf[offset+4..offset+8].try_into().unwrap());
|
||||
offset += 8;
|
||||
let ts_raw = u64::from_le_bytes(buf[offset+4..offset+12].try_into().unwrap());
|
||||
let size = u32::from_le_bytes(buf[offset+12..offset+16].try_into().unwrap());
|
||||
offset += 16;
|
||||
|
||||
if offset + size as usize > n { break; }
|
||||
let data_slice = &buf[offset..offset + size as usize];
|
||||
|
||||
let mut base_ts_guard = BASE_TELEM_TS.lock().unwrap();
|
||||
|
||||
if let Some(base) = *base_ts_guard {
|
||||
let diff = if ts_raw > base { ts_raw - base } else { base - ts_raw };
|
||||
if diff > 100_000_000 {
|
||||
*base_ts_guard = Some(ts_raw);
|
||||
let _ = tx_events.send(InternalEvent::InternalLog("Clock reset detected. Syncing base.".to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
if base_ts_guard.is_none() { *base_ts_guard = Some(ts_raw); }
|
||||
|
||||
let base = base_ts_guard.unwrap();
|
||||
let ts_s = if ts_raw >= base {
|
||||
(ts_raw - base) as f64 / 1000000.0
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
drop(base_ts_guard);
|
||||
|
||||
if let Some(meta) = metas.get(&id) {
|
||||
let t = meta.sig_type.as_str();
|
||||
let _ = tx_events.send(InternalEvent::TelemMatched(id));
|
||||
let t = meta.sig_type.to_lowercase();
|
||||
let val = match size {
|
||||
1 => { if t.contains('u') { data_slice[0] as f64 } else { (data_slice[0] as i8) as f64 } },
|
||||
2 => { let b = data_slice[0..2].try_into().unwrap(); if t.contains('u') { u16::from_le_bytes(b) as f64 } else { i16::from_le_bytes(b) as f64 } },
|
||||
4 => { let b = data_slice[0..4].try_into().unwrap(); if t.contains("float") { f32::from_le_bytes(b) as f64 } else if t.contains('u') { u32::from_le_bytes(b) as f64 } else { i32::from_le_bytes(b) as f64 } },
|
||||
8 => { let b = data_slice[0..8].try_into().unwrap(); if t.contains("float") { f64::from_le_bytes(b) } else if t.contains('u') { u64::from_le_bytes(b) as f64 } else { i64::from_le_bytes(b) as f64 } },
|
||||
4 => {
|
||||
let b = data_slice[0..4].try_into().unwrap();
|
||||
if t.contains("float") || (t.contains("32") && (t.contains('f') || t.contains("real"))) { f32::from_le_bytes(b) as f64 }
|
||||
else if t.contains('u') { u32::from_le_bytes(b) as f64 }
|
||||
else { i32::from_le_bytes(b) as f64 }
|
||||
},
|
||||
8 => {
|
||||
let b = data_slice[0..8].try_into().unwrap();
|
||||
if t.contains("float") || t.contains("double") || (t.contains("64") && (t.contains('f') || t.contains("real"))) { f64::from_le_bytes(b) }
|
||||
else if t.contains('u') { u64::from_le_bytes(b) as f64 }
|
||||
else { i64::from_le_bytes(b) as f64 }
|
||||
},
|
||||
_ => 0.0,
|
||||
};
|
||||
for name in &meta.names { local_updates.entry(name.clone()).or_default().push([now, val]); last_values.insert(name.clone(), val); }
|
||||
for name in &meta.names {
|
||||
local_updates.entry(name.clone()).or_default().push([ts_s, val]);
|
||||
last_values.insert(name.clone(), val);
|
||||
}
|
||||
}
|
||||
offset += size as usize;
|
||||
}
|
||||
@@ -373,9 +555,12 @@ fn udp_worker(shared_config: Arc<Mutex<ConnectionConfig>>, id_to_meta: Arc<Mutex
|
||||
let mut data_map = traced_data.lock().unwrap();
|
||||
for (name, new_points) in local_updates {
|
||||
if let Some(entry) = data_map.get_mut(&name) {
|
||||
for point in new_points { entry.values.push_back(point); }
|
||||
for point in new_points {
|
||||
entry.values.push_back(point);
|
||||
if let Some(tx) = &entry.recording_tx { let _ = tx.send(point); }
|
||||
}
|
||||
if let Some(lv) = last_values.get(&name) { entry.last_value = *lv; }
|
||||
while entry.values.len() > 10000 { entry.values.pop_front(); }
|
||||
while entry.values.len() > 100000 { entry.values.pop_front(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,10 +574,22 @@ impl eframe::App for MarteDebugApp {
|
||||
while let Ok(event) = self.rx_events.try_recv() {
|
||||
match event {
|
||||
InternalEvent::Log(log) => { if !self.log_filters.paused { self.logs.push_back(log); if self.logs.len() > 2000 { self.logs.pop_front(); } } }
|
||||
InternalEvent::Discovery(signals) => { let mut metas = self.id_to_meta.lock().unwrap(); metas.clear(); for s in &signals { let meta = metas.entry(s.id).or_insert_with(|| SignalMetadata { names: Vec::new(), sig_type: s.sig_type.clone() }); if !meta.names.contains(&s.name) { meta.names.push(s.name.clone()); } } }
|
||||
InternalEvent::Discovery(signals) => {
|
||||
let mut metas = self.id_to_meta.lock().unwrap();
|
||||
metas.clear();
|
||||
for s in &signals {
|
||||
let meta = metas.entry(s.id).or_insert_with(|| SignalMetadata { names: Vec::new(), sig_type: s.sig_type.clone() });
|
||||
if !meta.names.contains(&s.name) { meta.names.push(s.name.clone()); }
|
||||
}
|
||||
self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "GUI_INFO".to_string(), message: format!("Discovery complete: {} signals mapped", signals.len()) });
|
||||
}
|
||||
InternalEvent::Tree(tree) => { self.app_tree = Some(tree); }
|
||||
InternalEvent::NodeInfo(info) => { self.node_info = info; }
|
||||
InternalEvent::TraceRequested(name) => { let mut data_map = self.traced_signals.lock().unwrap(); data_map.entry(name).or_insert_with(|| TraceData { values: VecDeque::with_capacity(10000), last_value: 0.0 }); }
|
||||
InternalEvent::TraceRequested(name) => {
|
||||
let mut data_map = self.traced_signals.lock().unwrap();
|
||||
data_map.entry(name.clone()).or_insert_with(|| TraceData { values: VecDeque::with_capacity(10000), last_value: 0.0, recording_tx: None, recording_path: None });
|
||||
self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "GUI_INFO".to_string(), message: format!("Trace requested for: {}", name) });
|
||||
}
|
||||
InternalEvent::ClearTrace(name) => { let mut data_map = self.traced_signals.lock().unwrap(); data_map.remove(&name); for plot in &mut self.plots { plot.signals.retain(|s| s.source_name != name); } }
|
||||
InternalEvent::UdpStats(count) => { self.udp_packets = count; }
|
||||
InternalEvent::UdpDropped(dropped) => { self.udp_dropped += dropped as u64; }
|
||||
@@ -400,8 +597,24 @@ impl eframe::App for MarteDebugApp {
|
||||
InternalEvent::Disconnected => { self.connected = false; }
|
||||
InternalEvent::InternalLog(msg) => { self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "GUI_ERROR".to_string(), message: msg }); }
|
||||
InternalEvent::CommandResponse(resp) => { self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "CMD_RESP".to_string(), message: resp }); }
|
||||
InternalEvent::TelemMatched(id) => { *self.telem_match_count.entry(id).or_insert(0) += 1; }
|
||||
InternalEvent::RecordPathChosen(name, path) => {
|
||||
let mut data_map = self.traced_signals.lock().unwrap();
|
||||
if let Some(entry) = data_map.get_mut(&name) {
|
||||
let (tx, rx) = unbounded();
|
||||
entry.recording_tx = Some(tx);
|
||||
entry.recording_path = Some(path.clone());
|
||||
let tx_err = self.internal_tx.clone();
|
||||
thread::spawn(move || { recording_worker(rx, path, name, tx_err); });
|
||||
}
|
||||
}
|
||||
InternalEvent::RecordingError(name, err) => {
|
||||
self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "REC_ERROR".to_string(), message: format!("{}: {}", name, err) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if self.scope.enabled { self.apply_trigger_logic(); }
|
||||
|
||||
if let Some(dragged_name) = ctx.data_mut(|d| d.get_temp::<String>(egui::Id::new("drag_signal"))) {
|
||||
egui::Area::new(egui::Id::new("drag_ghost")).fixed_pos(ctx.input(|i| i.pointer.hover_pos().unwrap_or(egui::Pos2::ZERO))).order(egui::Order::Tooltip).show(ctx, |ui| { ui.group(|ui| { ui.label(format!("📈 {}", dragged_name)); }); });
|
||||
@@ -438,22 +651,40 @@ impl eframe::App for MarteDebugApp {
|
||||
ui.separator();
|
||||
if ui.button("➕ Plot").clicked() { self.plots.push(PlotInstance { id: format!("Plot {}", self.plots.len()+1), plot_type: PlotType::Normal, signals: Vec::new(), auto_bounds: true }); }
|
||||
ui.separator();
|
||||
let (btn_text, btn_color) = if self.is_breaking { ("▶ Resume", egui::Color32::GREEN) } else { ("⏸ Pause", egui::Color32::YELLOW) };
|
||||
let (btn_text, btn_color) = if self.is_breaking { ("▶ Resume App", egui::Color32::GREEN) } else { ("⏸ Pause App", egui::Color32::YELLOW) };
|
||||
if ui.button(egui::RichText::new(btn_text).color(btn_color)).clicked() { self.is_breaking = !self.is_breaking; let _ = self.tx_cmd.send(if self.is_breaking { "PAUSE".to_string() } else { "RESUME".to_string() }); }
|
||||
ui.separator();
|
||||
ui.menu_button("🔌 Connection", |ui| {
|
||||
ui.checkbox(&mut self.scope.enabled, "🔭 Scope");
|
||||
if self.scope.enabled {
|
||||
egui::ComboBox::from_id_salt("window_size").selected_text(format!("{}ms", self.scope.window_ms)).show_ui(ui, |ui| { for ms in [10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0] { ui.selectable_value(&mut self.scope.window_ms, ms, format!("{}ms", ms)); } });
|
||||
ui.selectable_value(&mut self.scope.mode, AcquisitionMode::FreeRun, "Free");
|
||||
ui.selectable_value(&mut self.scope.mode, AcquisitionMode::Triggered, "Trig");
|
||||
if self.scope.mode == AcquisitionMode::FreeRun { if ui.button(if self.scope.paused { "▶ Resume" } else { "⏸ Pause" }).clicked() { self.scope.paused = !self.scope.paused; } }
|
||||
else {
|
||||
if ui.button(if self.scope.is_armed { "🔴 Armed" } else { "⚪ Single" }).clicked() { self.scope.is_armed = true; self.scope.trigger_active = false; }
|
||||
ui.menu_button("⚙ Trig", |ui| {
|
||||
egui::Grid::new("trig").num_columns(2).show(ui, |ui| {
|
||||
ui.label("Source:"); ui.text_edit_singleline(&mut self.scope.trigger_source); ui.end_row();
|
||||
ui.label("Edge:"); egui::ComboBox::from_id_salt("edge").selected_text(format!("{:?}", self.scope.trigger_edge)).show_ui(ui, |ui| { ui.selectable_value(&mut self.scope.trigger_edge, TriggerEdge::Rising, "Rising"); ui.selectable_value(&mut self.scope.trigger_edge, TriggerEdge::Falling, "Falling"); ui.selectable_value(&mut self.scope.trigger_edge, TriggerEdge::Both, "Both"); }); ui.end_row();
|
||||
ui.label("Thresh:"); ui.add(egui::DragValue::new(&mut self.scope.trigger_threshold).speed(0.1)); ui.end_row();
|
||||
ui.label("Pre %:"); ui.add(egui::Slider::new(&mut self.scope.pre_trigger_percent, 0.0..=100.0)); ui.end_row();
|
||||
ui.label("Type:"); ui.selectable_value(&mut self.scope.trigger_type, TriggerType::Single, "Single"); ui.selectable_value(&mut self.scope.trigger_type, TriggerType::Continuous, "Cont"); ui.end_row();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
ui.menu_button("🔌 Conn", |ui| {
|
||||
egui::Grid::new("conn_grid").num_columns(2).show(ui, |ui| {
|
||||
ui.label("IP:"); ui.text_edit_singleline(&mut self.config.ip); ui.end_row();
|
||||
ui.label("Control:"); ui.text_edit_singleline(&mut self.config.tcp_port); ui.end_row();
|
||||
ui.label("Telemetry:"); ui.text_edit_singleline(&mut self.config.udp_port); ui.end_row();
|
||||
ui.label("Logs:"); ui.text_edit_singleline(&mut self.config.log_port); ui.end_row();
|
||||
});
|
||||
ui.separator();
|
||||
if ui.button("🔄 Apply & Reconnect").clicked() { self.config.version += 1; *self.shared_config.lock().unwrap() = self.config.clone(); ui.close_menu(); }
|
||||
if ui.button("❌ Disconnect").clicked() { self.config.version += 1; let mut cfg = self.config.clone(); cfg.ip = "".to_string(); *self.shared_config.lock().unwrap() = cfg; ui.close_menu(); }
|
||||
if ui.button("🔄 Apply").clicked() { self.config.version += 1; *self.shared_config.lock().unwrap() = self.config.clone(); ui.close_menu(); }
|
||||
if ui.button("📡 Re-Discover").clicked() { let _ = self.tx_cmd.send("DISCOVER".to_string()); ui.close_menu(); }
|
||||
if ui.button("❌ Off").clicked() { self.config.version += 1; let mut cfg = self.config.clone(); cfg.ip = "".to_string(); *self.shared_config.lock().unwrap() = cfg; ui.close_menu(); }
|
||||
});
|
||||
let status_color = if self.connected { egui::Color32::GREEN } else { egui::Color32::RED };
|
||||
ui.label(egui::RichText::new(if self.connected { "● Online" } else { "○ Offline" }).color(status_color));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { ui.label(format!("UDP: OK[{}] DROP[{}]", self.udp_packets, self.udp_dropped)); });
|
||||
});
|
||||
});
|
||||
@@ -467,14 +698,45 @@ impl eframe::App for MarteDebugApp {
|
||||
names.sort();
|
||||
egui::ScrollArea::vertical().id_salt("traced_scroll").show(ui, |ui| {
|
||||
for key in names {
|
||||
let last_val = { self.traced_signals.lock().unwrap().get(&key).map(|d| d.last_value).unwrap_or(0.0) };
|
||||
let mut data_map = self.traced_signals.lock().unwrap();
|
||||
if let Some(entry) = data_map.get_mut(&key) {
|
||||
let last_val = entry.last_value;
|
||||
let is_recording = entry.recording_tx.is_some();
|
||||
ui.horizontal(|ui| {
|
||||
let response = ui.add(egui::Label::new(format!("{}: {:.2}", key, last_val)).sense(egui::Sense::drag()));
|
||||
if is_recording { ui.label(egui::RichText::new("●").color(egui::Color32::RED)); }
|
||||
let response = ui.add(egui::Label::new(format!("{}: {:.2}", key, last_val)).sense(egui::Sense::drag().union(egui::Sense::click())));
|
||||
if response.drag_started() { ctx.data_mut(|d| d.insert_temp(egui::Id::new("drag_signal"), key.clone())); }
|
||||
if ui.button("❌").clicked() { let _ = self.tx_cmd.send(format!("TRACE {} 0", key)); let _ = self.internal_tx.send(InternalEvent::ClearTrace(key)); }
|
||||
});
|
||||
response.context_menu(|ui| {
|
||||
if !is_recording {
|
||||
if ui.button("⏺ Record to Parquet").clicked() {
|
||||
let tx = self.internal_tx.clone();
|
||||
let name_clone = key.clone();
|
||||
thread::spawn(move || {
|
||||
if let Some(path) = FileDialog::new().add_filter("Parquet", &["parquet"]).save_file() {
|
||||
let _ = tx.send(InternalEvent::RecordPathChosen(name_clone, path.to_string_lossy().to_string()));
|
||||
}
|
||||
});
|
||||
ui.close_menu();
|
||||
}
|
||||
} else {
|
||||
if ui.button("⏹ Stop").clicked() { entry.recording_tx = None; ui.close_menu(); }
|
||||
}
|
||||
});
|
||||
if ui.button("❌").clicked() { let _ = self.tx_cmd.send(format!("TRACE {} 0", key)); let _ = self.internal_tx.send(InternalEvent::ClearTrace(key.clone())); }
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.heading("Telemetry Stats");
|
||||
let mut ids: Vec<_> = self.telem_match_count.keys().cloned().collect();
|
||||
ids.sort();
|
||||
if ids.is_empty() { ui.label("No IDs matched yet."); }
|
||||
for id in ids {
|
||||
if let Some(count) = self.telem_match_count.get(&id) {
|
||||
ui.label(format!("ID {}: {} samples", id, count));
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
ui.heading("Forced Signals");
|
||||
for (path, val) in &self.forced_signals { ui.horizontal(|ui| { ui.label(format!("{}: {}", path, val)); if ui.button("❌").clicked() { let _ = self.tx_cmd.send(format!("UNFORCE {}", path)); } }); }
|
||||
@@ -483,23 +745,21 @@ impl eframe::App for MarteDebugApp {
|
||||
|
||||
if self.show_bottom_panel {
|
||||
egui::TopBottomPanel::bottom("log_panel").resizable(true).default_height(150.0).show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.heading("System Logs"); ui.separator();
|
||||
ui.checkbox(&mut self.log_filters.show_debug, "Debug"); ui.checkbox(&mut self.log_filters.show_info, "Info"); ui.checkbox(&mut self.log_filters.show_warning, "Warn"); ui.checkbox(&mut self.log_filters.show_error, "Error");
|
||||
ui.separator();
|
||||
ui.label("Filter:"); ui.text_edit_singleline(&mut self.log_filters.content_regex);
|
||||
ui.separator();
|
||||
ui.toggle_value(&mut self.log_filters.paused, "⏸ Pause");
|
||||
if ui.button("🗑 Clear").clicked() { self.logs.clear(); }
|
||||
});
|
||||
ui.horizontal(|ui| { ui.heading("Logs"); ui.separator(); ui.checkbox(&mut self.log_filters.show_debug, "Debug"); ui.checkbox(&mut self.log_filters.show_info, "Info"); ui.checkbox(&mut self.log_filters.show_warning, "Warn"); ui.checkbox(&mut self.log_filters.show_error, "Error"); ui.separator(); ui.label("Filter:"); ui.text_edit_singleline(&mut self.log_filters.content_regex); if ui.button("🗑 Clear").clicked() { self.logs.clear(); } });
|
||||
ui.separator();
|
||||
let regex = if !self.log_filters.content_regex.is_empty() { Regex::new(&self.log_filters.content_regex).ok() } else { None };
|
||||
egui::ScrollArea::vertical().stick_to_bottom(true).auto_shrink([false, false]).show(ui, |ui| {
|
||||
for log in &self.logs {
|
||||
let show = match log.level.as_str() { "Debug" => self.log_filters.show_debug, "Information" => self.log_filters.show_info, "Warning" => self.log_filters.show_warning, "FatalError" | "OSError" | "ParametersError" => self.log_filters.show_error, _ => true };
|
||||
let show = match log.level.as_str() {
|
||||
"Debug" => self.log_filters.show_debug,
|
||||
"Information" | "GUI_INFO" | "GUI_WARN" | "CMD_RESP" => self.log_filters.show_info,
|
||||
"Warning" => self.log_filters.show_warning,
|
||||
"FatalError" | "OSError" | "ParametersError" | "GUI_ERROR" | "REC_ERROR" => self.log_filters.show_error,
|
||||
_ => true
|
||||
};
|
||||
if !show { continue; }
|
||||
if let Some(re) = ®ex { if !re.is_match(&log.message) && !re.is_match(&log.level) { continue; } }
|
||||
let color = match log.level.as_str() { "FatalError" | "OSError" | "ParametersError" => egui::Color32::from_rgb(255, 100, 100), "Warning" => egui::Color32::from_rgb(255, 255, 100), "Information" => egui::Color32::from_rgb(100, 255, 100), "Debug" => egui::Color32::from_rgb(100, 100, 255), "GUI_ERROR" => egui::Color32::from_rgb(255, 50, 255), "CMD_RESP" => egui::Color32::from_rgb(255, 255, 255), _ => egui::Color32::WHITE };
|
||||
let color = match log.level.as_str() { "FatalError" | "OSError" | "ParametersError" | "GUI_ERROR" | "REC_ERROR" => egui::Color32::from_rgb(255, 100, 100), "Warning" | "GUI_WARN" => egui::Color32::from_rgb(255, 255, 100), "Information" | "GUI_INFO" => egui::Color32::from_rgb(100, 255, 100), "Debug" => egui::Color32::from_rgb(100, 100, 255), "CMD_RESP" => egui::Color32::from_rgb(255, 255, 255), _ => egui::Color32::WHITE };
|
||||
ui.horizontal_wrapped(|ui| { ui.label(egui::RichText::new(&log.time).color(egui::Color32::GRAY).monospace()); ui.label(egui::RichText::new(format!("[{}]", log.level)).color(color).strong()); ui.add(egui::Label::new(&log.message).wrap()); });
|
||||
}
|
||||
});
|
||||
@@ -516,49 +776,75 @@ impl eframe::App for MarteDebugApp {
|
||||
ui.group(|ui| {
|
||||
ui.horizontal(|ui| { ui.label(egui::RichText::new(&plot_inst.id).strong()); ui.selectable_value(&mut plot_inst.plot_type, PlotType::Normal, "Series"); ui.selectable_value(&mut plot_inst.plot_type, PlotType::LogicAnalyzer, "Logic"); if ui.button("🗑").clicked() { to_remove = Some(p_idx); } });
|
||||
let mut plot = Plot::new(&plot_inst.id).height(plot_height - 40.0).show_axes([true, true]);
|
||||
|
||||
plot = plot.x_axis_formatter(|mark, _range| {
|
||||
let val = mark.value;
|
||||
let hours = (val / 3600.0) as u32;
|
||||
let mins = ((val % 3600.0) / 60.0) as u32;
|
||||
let secs = val % 60.0;
|
||||
format!("{:02}:{:02}:{:05.2}", hours, mins, secs)
|
||||
});
|
||||
|
||||
let data_map = self.traced_signals.lock().unwrap();
|
||||
let mut latest_t = 0.0;
|
||||
for sig_cfg in &plot_inst.signals {
|
||||
if let Some(data) = data_map.get(&sig_cfg.source_name) {
|
||||
if let Some(last) = data.values.back() { if last[0] > latest_t { latest_t = last[0]; } }
|
||||
}
|
||||
}
|
||||
|
||||
if self.scope.enabled {
|
||||
let window_s = self.scope.window_ms / 1000.0;
|
||||
let center_t = if self.scope.mode == AcquisitionMode::Triggered { if self.scope.trigger_active { self.scope.last_trigger_time } else { latest_t } } else { latest_t };
|
||||
let x_min = center_t - (self.scope.pre_trigger_percent / 100.0) * window_s;
|
||||
plot = plot.include_x(x_min).include_x(x_min + window_s);
|
||||
if !self.scope.paused { plot = plot.auto_bounds(egui::Vec2b::new(true, true)); }
|
||||
} else {
|
||||
if let Some(range) = self.shared_x_range { if !plot_inst.auto_bounds { plot = plot.include_x(range[0]).include_x(range[1]); } }
|
||||
if plot_inst.auto_bounds { plot = plot.auto_bounds(egui::Vec2b::new(true, true)); }
|
||||
}
|
||||
|
||||
let plot_resp = plot.show(ui, |plot_ui| {
|
||||
if !plot_inst.auto_bounds { if let Some(range) = self.shared_x_range { let bounds = plot_ui.plot_bounds(); plot_ui.set_plot_bounds(PlotBounds::from_min_max([range[0], bounds.min()[1]], [range[1], bounds.max()[1]])); } }
|
||||
let data_map = self.traced_signals.lock().unwrap();
|
||||
if !self.scope.enabled && !plot_inst.auto_bounds { if let Some(range) = self.shared_x_range { let bounds = plot_ui.plot_bounds(); plot_ui.set_plot_bounds(PlotBounds::from_min_max([range[0], bounds.min()[1]], [range[1], bounds.max()[1]])); } }
|
||||
if self.scope.enabled && self.scope.mode == AcquisitionMode::Triggered && self.scope.trigger_active { plot_ui.vline(VLine::new(self.scope.last_trigger_time).color(egui::Color32::YELLOW).style(LineStyle::Dashed { length: 5.0 })); }
|
||||
|
||||
for (s_idx, sig_cfg) in plot_inst.signals.iter().enumerate() {
|
||||
if let Some(data) = data_map.get(&sig_cfg.source_name) {
|
||||
let mut points = Vec::new();
|
||||
for [t, v] in &data.values {
|
||||
let points_iter = data.values.iter().rev().take(5000).rev().map(|[t, v]| {
|
||||
let mut final_v = *v * sig_cfg.gain + sig_cfg.offset;
|
||||
if plot_inst.plot_type == PlotType::LogicAnalyzer { final_v = (s_idx as f64 * 1.5) + (if final_v > 0.5 { 1.0 } else { 0.0 }); }
|
||||
points.push([*t, final_v]);
|
||||
}
|
||||
plot_ui.line(Line::new(PlotPoints::from(points)).name(&sig_cfg.label).color(sig_cfg.color));
|
||||
[*t, final_v]
|
||||
});
|
||||
plot_ui.line(Line::new(PlotPoints::from_iter(points_iter)).name(&sig_cfg.label).color(sig_cfg.color));
|
||||
}
|
||||
}
|
||||
if p_idx == 0 || current_range.is_none() { let b = plot_ui.plot_bounds(); current_range = Some([b.min()[0], b.max()[0]]); }
|
||||
});
|
||||
drop(data_map);
|
||||
|
||||
if plot_resp.response.hovered() && ctx.input(|i| i.pointer.any_released()) {
|
||||
if let Some(dropped) = ctx.data_mut(|d| d.get_temp::<String>(egui::Id::new("drag_signal"))) {
|
||||
let color = Self::next_color(plot_inst.signals.len());
|
||||
plot_inst.signals.push(SignalPlotConfig { source_name: dropped.clone(), label: dropped.clone(), unit: "".to_string(), color, line_style: LineStyle::Solid, marker_type: MarkerType::None, gain: 1.0, offset: 0.0 });
|
||||
self.logs.push_back(LogEntry { time: Local::now().format("%H:%M:%S").to_string(), level: "GUI".to_string(), message: format!("Dropped {} into plot", dropped) });
|
||||
ctx.data_mut(|d| d.remove_temp::<String>(egui::Id::new("drag_signal")));
|
||||
}
|
||||
}
|
||||
if plot_resp.response.dragged() || ctx.input(|i| i.pointer.any_click() || i.smooth_scroll_delta.y != 0.0) { if plot_resp.response.hovered() { plot_inst.auto_bounds = false; let b = plot_resp.transform.bounds(); self.shared_x_range = Some([b.min()[0], b.max()[0]]); } }
|
||||
if plot_resp.response.dragged() || ctx.input(|i| i.smooth_scroll_delta.y != 0.0) { if plot_resp.response.hovered() { plot_inst.auto_bounds = false; let b = plot_resp.transform.bounds(); self.shared_x_range = Some([b.min()[0], b.max()[0]]); } }
|
||||
plot_resp.response.context_menu(|ui| {
|
||||
if ui.button("🔍 Fit View").clicked() { plot_inst.auto_bounds = true; self.shared_x_range = None; ui.close_menu(); }
|
||||
ui.separator();
|
||||
let mut sig_to_remove = None;
|
||||
for (s_idx, sig) in plot_inst.signals.iter().enumerate() {
|
||||
ui.horizontal(|ui| { ui.label(&sig.label); if ui.button("🎨").clicked() { self.style_editor = Some((p_idx, s_idx)); ui.close_menu(); } if ui.button("❌").clicked() { sig_to_remove = Some(s_idx); ui.close_menu(); } });
|
||||
ui.horizontal(|ui| { ui.label(&sig.label); if ui.button("🎨 Style").clicked() { self.style_editor = Some((p_idx, s_idx)); ui.close_menu(); } if ui.button("❌ Remove").clicked() { sig_to_remove = Some(s_idx); ui.close_menu(); } });
|
||||
}
|
||||
if let Some(idx) = sig_to_remove { plot_inst.signals.remove(idx); }
|
||||
});
|
||||
});
|
||||
}
|
||||
if let Some(idx) = to_remove { self.plots.remove(idx); }
|
||||
if let Some(range) = current_range { if self.shared_x_range.is_none() { self.shared_x_range = Some(range); } }
|
||||
if !self.scope.enabled { if let Some(range) = current_range { if self.shared_x_range.is_none() { self.shared_x_range = Some(range); } } }
|
||||
} else { ui.centered_and_justified(|ui| { ui.label("Add a plot panel to begin analysis"); }); }
|
||||
});
|
||||
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(16));
|
||||
}
|
||||
}
|
||||
|
||||
431
Tools/pipeline_validator/Cargo.lock
generated
Normal file
431
Tools/pipeline_validator/Cargo.lock
generated
Normal file
@@ -0,0 +1,431 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.182"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "pipeline_validator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"socket2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.60.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||
10
Tools/pipeline_validator/Cargo.toml
Normal file
10
Tools/pipeline_validator/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "pipeline_validator"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
socket2 = "0.5"
|
||||
chrono = "0.4"
|
||||
135
Tools/pipeline_validator/src/main.rs
Normal file
135
Tools/pipeline_validator/src/main.rs
Normal file
@@ -0,0 +1,135 @@
|
||||
use std::io::{Read, Write};
|
||||
use std::net::{TcpStream, UdpSocket};
|
||||
use std::time::{Duration, Instant};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Signal {
|
||||
name: String,
|
||||
id: u32,
|
||||
#[serde(rename = "type")]
|
||||
sig_type: String,
|
||||
ready: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct DiscoverResponse {
|
||||
#[serde(rename = "Signals")]
|
||||
signals: Vec<Signal>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("--- MARTe2 Debug Pipeline Validator ---");
|
||||
|
||||
// 1. Connect to TCP Control Port
|
||||
let mut stream = match TcpStream::connect("127.0.0.1:8080") {
|
||||
Ok(s) => {
|
||||
println!("[TCP] Connected to DebugService on 8080");
|
||||
s
|
||||
}
|
||||
Err(e) => {
|
||||
println!("[TCP] FAILED to connect: {}", e);
|
||||
println!("Check if 'run_debug_app.sh' is running.");
|
||||
return;
|
||||
}
|
||||
};
|
||||
stream.set_read_timeout(Some(Duration::from_secs(2))).unwrap();
|
||||
|
||||
// 2. DISCOVER signals
|
||||
println!("[TCP] Sending DISCOVER...");
|
||||
stream.write_all(b"DISCOVER\n").unwrap();
|
||||
|
||||
let mut buf = [0u8; 8192];
|
||||
let n = stream.read(&mut buf).unwrap();
|
||||
let resp = String::from_utf8_lossy(&buf[..n]);
|
||||
|
||||
// Split JSON from OK DISCOVER terminator
|
||||
let json_part = resp.split("OK DISCOVER").next().unwrap_or("").trim();
|
||||
let discovery: DiscoverResponse = match serde_json::from_str(json_part) {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
println!("[TCP] Discovery Parse Error: {}", e);
|
||||
println!("Raw Response: {}", resp);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
println!("[TCP] Found {} signals.", discovery.signals.len());
|
||||
let mut counter_id = None;
|
||||
for s in &discovery.signals {
|
||||
println!("[TCP] Signal: {} (ID={}, Ready={})", s.name, s.id, s.ready);
|
||||
if s.name.contains("Timer.Counter") {
|
||||
println!("[TCP] Target found: {} (ID={})", s.name, s.id);
|
||||
counter_id = Some(s.id);
|
||||
|
||||
// 3. Enable TRACE
|
||||
println!("[TCP] Enabling TRACE for {}...", s.name);
|
||||
stream.write_all(format!("TRACE {} 1\n", s.name).as_bytes()).unwrap();
|
||||
let mut t_buf = [0u8; 1024];
|
||||
let tn = stream.read(&mut t_buf).unwrap();
|
||||
println!("[TCP] TRACE Response: {}", String::from_utf8_lossy(&t_buf[..tn]).trim());
|
||||
}
|
||||
}
|
||||
|
||||
if counter_id.is_none() {
|
||||
println!("[TCP] ERROR: Counter signal not found in discovery.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. Listen for UDP Telemetry
|
||||
let socket = UdpSocket::bind("0.0.0.0:8081").expect("Could not bind UDP socket");
|
||||
socket.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
|
||||
println!("[UDP] Listening for telemetry on 8081...");
|
||||
|
||||
let mut samples_received = 0;
|
||||
let mut last_val: Option<u32> = None;
|
||||
let mut last_ts: Option<u64> = None;
|
||||
let start_wait = Instant::now();
|
||||
|
||||
while samples_received < 20 && start_wait.elapsed().as_secs() < 10 {
|
||||
let mut u_buf = [0u8; 4096];
|
||||
if let Ok(n) = socket.recv(&mut u_buf) {
|
||||
if n < 20 { continue; }
|
||||
|
||||
// Validate Header
|
||||
let magic = u32::from_le_bytes(u_buf[0..4].try_into().unwrap());
|
||||
if magic != 0xDA7A57AD { continue; }
|
||||
|
||||
let count = u32::from_le_bytes(u_buf[16..20].try_into().unwrap());
|
||||
let mut offset = 20;
|
||||
|
||||
for _ in 0..count {
|
||||
if offset + 16 > n { break; }
|
||||
let id = u32::from_le_bytes(u_buf[offset..offset+4].try_into().unwrap());
|
||||
let ts = u64::from_le_bytes(u_buf[offset+4..offset+12].try_into().unwrap());
|
||||
let size = u32::from_le_bytes(u_buf[offset+12..offset+16].try_into().unwrap());
|
||||
offset += 16;
|
||||
|
||||
if offset + size as usize > n { break; }
|
||||
|
||||
if id == counter_id.unwrap() && size == 4 {
|
||||
let val = u32::from_le_bytes(u_buf[offset..offset+4].try_into().unwrap());
|
||||
println!("[UDP] Match! ID={} TS={} VAL={}", id, ts, val);
|
||||
|
||||
if let Some(lt) = last_ts {
|
||||
if ts <= lt { println!("[UDP] WARNING: Non-monotonic timestamp!"); }
|
||||
}
|
||||
if let Some(lv) = last_val {
|
||||
if val == lv { println!("[UDP] WARNING: Stale value detected."); }
|
||||
}
|
||||
|
||||
last_ts = Some(ts);
|
||||
last_val = Some(val);
|
||||
samples_received += 1;
|
||||
}
|
||||
offset += size as usize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if samples_received >= 20 {
|
||||
println!("\n[RESULT] SUCCESS: Telemetry pipeline is fully functional!");
|
||||
} else {
|
||||
println!("\n[RESULT] FAILURE: Received only {} samples.", samples_received);
|
||||
}
|
||||
}
|
||||
334
app_output.log
334
app_output.log
@@ -17,17 +17,6 @@ Filename = "Test/Configurations/debug_
|
||||
[Information - Loader.cpp:74]: SchedulerGranularity is 10000
|
||||
[Debug - Loader.cpp:189]: Purging ObjectRegistryDatabase with 0 objects
|
||||
[Debug - Loader.cpp:192]: Purge ObjectRegistryDatabase. Number of objects left: 0
|
||||
[Information - LinuxTimer.cpp:117]: SleepNature was not set. Using Default.
|
||||
[Information - LinuxTimer.cpp:127]: Phase was not configured, using default 0
|
||||
[Warning - LinuxTimer.cpp:164]: ExecutionMode not specified using: IndependentThread
|
||||
[Warning - LinuxTimer.cpp:185]: CPUMask not specified using: 255
|
||||
[Warning - LinuxTimer.cpp:191]: StackSize not specified using: 262144
|
||||
[Information - LinuxTimer.cpp:236]: No timer provider specified. Falling back to HighResolutionTimeProvider
|
||||
[Information - HighResolutionTimeProvider.cpp:163]: Sleep nature was not specified, falling back to default (Sleep::NoMore mode)
|
||||
[Information - HighResolutionTimeProvider.cpp:61]: Inner initialization succeeded
|
||||
[Information - LinuxTimer.cpp:267]: Backward compatibility parameters injection unnecessary
|
||||
[Information - RealTimeThread.cpp:190]: No CPUs defined for the RealTimeThread Thread1
|
||||
[Information - RealTimeThread.cpp:193]: No StackSize defined for the RealTimeThread Thread1
|
||||
[DebugService] TCP Server listening on port 8080
|
||||
[DebugService] UDP Streamer socket opened
|
||||
[ParametersError - StringHelper.cpp:60]: Error: invalid input arguments
|
||||
@@ -43,53 +32,90 @@ Filename = "Test/Configurations/debug_
|
||||
[Warning - Threads.cpp:173]: Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Information] SleepNature was not set. Using Default.
|
||||
[Information] Phase was not configured, using default 0
|
||||
[Warning] ExecutionMode not specified using: IndependentThread
|
||||
[Warning] CPUMask not specified using: 255
|
||||
[Warning] StackSize not specified using: 262144
|
||||
[Information] No timer provider specified. Falling back to HighResolutionTimeProvider
|
||||
[Information] Sleep nature was not specified, falling back to default (Sleep::NoMore mode)
|
||||
[Information] Inner initialization succeeded
|
||||
[Information] Backward compatibility parameters injection unnecessary
|
||||
[Information] SleepNature was not set. Using Default.
|
||||
[Information] Phase was not configured, using default 0
|
||||
[Warning] ExecutionMode not specified using: IndependentThread
|
||||
[Warning] CPUMask not specified using: 255
|
||||
[Warning] StackSize not specified using: 262144
|
||||
[Information] No timer provider specified. Falling back to HighResolutionTimeProvider
|
||||
[Information] Sleep nature was not specified, falling back to default (Sleep::NoMore mode)
|
||||
[Information] Inner initialization succeeded
|
||||
[Information] Backward compatibility parameters injection unnecessary
|
||||
[Information] No CPUs defined for the RealTimeThread Thread1
|
||||
[Information] No StackSize defined for the RealTimeThread Thread1
|
||||
[Information] No CPUs defined for the RealTimeThread Thread2
|
||||
[Information] No StackSize defined for the RealTimeThread Thread2
|
||||
[Information] LoaderPostInit not set
|
||||
[Debug] Finished updating the signal database
|
||||
[Information] Going to rtAppBuilder.ConfigureAfterInitialisation()
|
||||
[Information] Going to InitialiseSignalsDatabase
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Information] Going to FlattenSignalsDatabases
|
||||
[Information] Caching introspection signals
|
||||
[Information] Flattening functions input signals
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Information] Flattening functions output signals
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Information] Flattening data sources signals
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Debug] Updating the signal database
|
||||
[Debug] Finished updating the signal database
|
||||
[Information] Going to VerifyDataSourcesSignals
|
||||
[Debug] Updating the signal database
|
||||
[Information] Verifying signals for Timer
|
||||
[Debug] Finished updating the signal database
|
||||
[Information] Going to ResolveStates
|
||||
[Information] Resolving state State1
|
||||
[Information] Resolving thread container Threads
|
||||
[Information] Resolving thread State1.Thread1
|
||||
[Information] Resolving GAM1
|
||||
[Information] Resolving thread State1.Thread2
|
||||
[Information] Resolving GAM2
|
||||
[Information] Going to ResolveDataSources
|
||||
[Information] Verifying signals for Logger
|
||||
[Information] Resolving for function GAM1 [idx: 0]
|
||||
[Information] Resolving 2 signals
|
||||
[Information] Resolving 2 signals
|
||||
[Information] Resolving for function GAM2 [idx: 1]
|
||||
[Information] Resolving 2 signals
|
||||
[Information] Resolving 2 signals
|
||||
[DebugBrokerBuilder] Built MemoryMapSynchronisedInputBroker
|
||||
[DebugBrokerBuilder] Built MemoryMapInputBroker
|
||||
[Information] Going to VerifyDataSourcesSignals
|
||||
[Information] Verifying signals for Timer
|
||||
[Information] Verifying signals for TimerSlow
|
||||
[Information] Verifying signals for Logger
|
||||
[Information] Verifying signals for DDB
|
||||
[Information] Verifying signals for DAMS
|
||||
[Information] Going to VerifyConsumersAndProducers
|
||||
[Information] Started application in state State1
|
||||
[Information] Application starting
|
||||
[Information] Verifying consumers and producers for Timer
|
||||
[Information] Verifying consumers and producers for TimerSlow
|
||||
[Information] Verifying consumers and producers for Logger
|
||||
[Information] Verifying consumers and producers for DDB
|
||||
[Information] Verifying consumers and producers for DAMS
|
||||
[Information] Going to CleanCaches
|
||||
[Debug] Purging dataSourcesIndexesCache. Number of children:3
|
||||
[Debug] Purging functionsIndexesCache. Number of children:1
|
||||
[Debug] Purging dataSourcesSignalIndexCache. Number of children:3
|
||||
[Information] Creating broker MemoryMapSynchronisedInputBroker for GAM2 and signal Counter(0)
|
||||
[DebugBrokerBuilder] Built MemoryMapSynchronisedInputBroker
|
||||
[Debug] Purging dataSourcesIndexesCache. Number of children:4
|
||||
[Debug] Purging functionsIndexesCache. Number of children:2
|
||||
[Debug] Purging dataSourcesSignalIndexCache. Number of children:4
|
||||
[Debug] Purging dataSourcesFunctionIndexesCache. Number of children:1
|
||||
[Debug] Purging functionsMemoryIndexesCache. Number of children:2
|
||||
[Debug] Purging functionsMemoryIndexesCache. Number of children:1
|
||||
[Debug] Purged functionsMemoryIndexesCache. Number of children:0
|
||||
[Debug] Purged cachedIntrospections. Number of children:0
|
||||
[Information] Going to rtAppBuilder.PostConfigureDataSources()
|
||||
@@ -102,6 +128,11 @@ Filename = "Test/Configurations/debug_
|
||||
[Information] Creating broker MemoryMapInputBroker for GAM1 and signal Time(1)
|
||||
[Information] Getting input brokers for Timer
|
||||
[Information] Getting output brokers for Timer
|
||||
[DebugBrokerBuilder] Built MemoryMapInputBroker
|
||||
[DebugBrokerBuilder] Built MemoryMapOutputBroker
|
||||
[Information] Creating broker MemoryMapInputBroker for GAM2 and signal Time(1)
|
||||
[Information] Getting input brokers for TimerSlow
|
||||
[Information] Getting output brokers for TimerSlow
|
||||
[Information] Getting input brokers for Logger
|
||||
[Information] Getting output brokers for Logger
|
||||
[Information] Getting input brokers for DDB
|
||||
@@ -111,40 +142,253 @@ Filename = "Test/Configurations/debug_
|
||||
[Information] Going to FindStatefulDataSources
|
||||
[Information] Going to configure scheduler
|
||||
[Information] Preparing state State1
|
||||
[Information] Frequency found = 1.000000
|
||||
[Information] Frequency found = 1.000000
|
||||
[Information] The timer will be set using a frequency of 1.000000 Hz
|
||||
[Information] Frequency found = 1000.000000
|
||||
[Information] Frequency found = 1000.000000
|
||||
[Information] The timer will be set using a frequency of 1000.000000 Hz
|
||||
[ParametersError] Error: invalid input arguments
|
||||
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Warning] Failed to change the thread priority (likely due to insufficient permissions)
|
||||
[Information] LinuxTimer::Prepared = true
|
||||
[Information] Frequency found = 10.000000
|
||||
[Information] Frequency found = 10.000000
|
||||
[Information] The timer will be set using a frequency of 10.000000 Hz
|
||||
[ParametersError] Error: invalid input arguments
|
||||
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Warning] Failed to change the thread priority (likely due to insufficient permissions)
|
||||
[Information] LinuxTimer::Prepared = true
|
||||
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Warning] Failed to change the thread priority (likely due to insufficient permissions)
|
||||
[Warning] Requested a thread priority that is higher than the one supported by the selected policy - clipping to the maximum value supported by the policy.
|
||||
[Warning] Failed to change the thread priority (likely due to insufficient permissions)
|
||||
[Information] Started application in state State1
|
||||
[Information] Application starting
|
||||
[Information] Counter [0:0]:1
|
||||
[Information] Time [0:0]:0
|
||||
[Information] Counter [0:0]:2
|
||||
[Information] Time [0:0]:200000
|
||||
[Information] Counter [0:0]:3
|
||||
[Information] Time [0:0]:300000
|
||||
[Information] Counter [0:0]:4
|
||||
[Information] Time [0:0]:400000
|
||||
[DebugService] Discover called. Instance: 0x7fd54d967010
|
||||
[DebugService] Found existing broker: GAM1.InputBroker.MemoryMapSynchronisedInputBroker (MemoryMapSynchronisedInputBroker)
|
||||
[DebugService] Found existing broker: GAM1.InputBroker.MemoryMapInputBroker (MemoryMapInputBroker)
|
||||
[DebugService] Found existing broker: GAM2.InputBroker.MemoryMapSynchronisedInputBroker (MemoryMapSynchronisedInputBroker)
|
||||
[DebugService] Found existing broker: GAM2.InputBroker.MemoryMapInputBroker (MemoryMapInputBroker)
|
||||
[DebugService] Found existing broker: (null) (MemoryMapOutputBroker)
|
||||
[DebugService] Registry Scan: Current Signals=19, Brokers=0
|
||||
[Debug] Tracing state for App.Data.Timer.Counter (ID: 0, Mem: (nil)) set to 1
|
||||
[Debug] WARNING: Signal App.Data.Timer.Counter is NOT associated with any active broker!
|
||||
[Information] Counter [0:0]:5
|
||||
[Information] Time [0:0]:500000
|
||||
[Information] Counter [0:0]:6
|
||||
[Information] Time [0:0]:600000
|
||||
[Information] Counter [0:0]:7
|
||||
[Information] Time [0:0]:700000
|
||||
[Information] Counter [0:0]:8
|
||||
[Information] Time [0:0]:800000
|
||||
[Information] Counter [0:0]:9
|
||||
[Information] Time [0:0]:900000
|
||||
[Information] Counter [0:0]:10
|
||||
[Information] Time [0:0]:1000000
|
||||
[Information] Counter [0:0]:11
|
||||
[Information] Time [0:0]:1100000
|
||||
[Information] Counter [0:0]:12
|
||||
[Information] Time [0:0]:1200000
|
||||
[Information] Counter [0:0]:13
|
||||
[Information] Time [0:0]:1300000
|
||||
[Information] Counter [0:0]:14
|
||||
[Information] Time [0:0]:1400000
|
||||
[Information] Counter [0:0]:15
|
||||
[Information] Time [0:0]:1500000
|
||||
[Information] Counter [0:0]:16
|
||||
[Information] Time [0:0]:1600000
|
||||
[Information] Counter [0:0]:17
|
||||
[Information] Time [0:0]:1700000
|
||||
[Information] Counter [0:0]:18
|
||||
[Information] Time [0:0]:1800000
|
||||
[Information] Counter [0:0]:19
|
||||
[Information] Time [0:0]:1900000
|
||||
[Information] Counter [0:0]:20
|
||||
[Information] Time [0:0]:2000000
|
||||
[Information] Counter [0:0]:21
|
||||
[Information] Time [0:0]:2100000
|
||||
[Information] Counter [0:0]:22
|
||||
[Information] Time [0:0]:2200000
|
||||
[Information] Counter [0:0]:23
|
||||
[Information] Time [0:0]:2300000
|
||||
[Information] Counter [0:0]:24
|
||||
[Information] Time [0:0]:2400000
|
||||
[Information] Counter [0:0]:25
|
||||
[Information] Time [0:0]:2500000
|
||||
[Information] Counter [0:0]:26
|
||||
[Information] Time [0:0]:2600000
|
||||
[Information] Counter [0:0]:27
|
||||
[Information] Time [0:0]:2700000
|
||||
[Information] Counter [0:0]:28
|
||||
[Information] Time [0:0]:2800000
|
||||
[Information] Counter [0:0]:29
|
||||
[Information] Time [0:0]:2900000
|
||||
[Information] Counter [0:0]:30
|
||||
[Information] Time [0:0]:3000000
|
||||
[Information] Counter [0:0]:31
|
||||
[Information] Time [0:0]:3100000
|
||||
[Information] Counter [0:0]:32
|
||||
[Information] Time [0:0]:3200000
|
||||
[Information] Counter [0:0]:33
|
||||
[Information] Time [0:0]:3300000
|
||||
[Information] Counter [0:0]:34
|
||||
[Information] Time [0:0]:3400000
|
||||
[Information] Counter [0:0]:35
|
||||
[Information] Time [0:0]:3500000
|
||||
[Information] Counter [0:0]:36
|
||||
[Information] Time [0:0]:3600000
|
||||
[Information] Counter [0:0]:37
|
||||
[Information] Time [0:0]:3700000
|
||||
[Information] Counter [0:0]:38
|
||||
[Information] Time [0:0]:3800000
|
||||
[Information] Counter [0:0]:39
|
||||
[Information] Time [0:0]:3900000
|
||||
[Information] Counter [0:0]:40
|
||||
[Information] Time [0:0]:4000000
|
||||
[Information] Counter [0:0]:41
|
||||
[Information] Time [0:0]:4100000
|
||||
[Information] Counter [0:0]:42
|
||||
[Information] Time [0:0]:4200000
|
||||
[Information] Counter [0:0]:43
|
||||
[Information] Time [0:0]:4300000
|
||||
[Information] Counter [0:0]:44
|
||||
[Information] Time [0:0]:4400000
|
||||
[Information] Counter [0:0]:45
|
||||
[Information] Time [0:0]:4500000
|
||||
[Information] Counter [0:0]:46
|
||||
[Information] Time [0:0]:4600000
|
||||
[Information] Counter [0:0]:47
|
||||
[Information] Time [0:0]:4700000
|
||||
[Information] Counter [0:0]:48
|
||||
[Information] Time [0:0]:4800000
|
||||
[Information] Counter [0:0]:49
|
||||
[Information] Time [0:0]:4900000
|
||||
[Information] Counter [0:0]:50
|
||||
[Information] Time [0:0]:5000000
|
||||
[Information] Counter [0:0]:51
|
||||
[Information] Time [0:0]:5100000
|
||||
[Information] Counter [0:0]:52
|
||||
[Information] Time [0:0]:5200000
|
||||
[Information] Counter [0:0]:53
|
||||
[Information] Time [0:0]:5300000
|
||||
[Information] Counter [0:0]:54
|
||||
[Information] Time [0:0]:5400000
|
||||
[Information] Counter [0:0]:55
|
||||
[Information] Time [0:0]:5500000
|
||||
[Information] Counter [0:0]:56
|
||||
[Information] Time [0:0]:5600000
|
||||
[Information] Counter [0:0]:57
|
||||
[Information] Time [0:0]:5700000
|
||||
[Information] Counter [0:0]:58
|
||||
[Information] Time [0:0]:5800000
|
||||
[Information] Counter [0:0]:59
|
||||
[Information] Time [0:0]:5900000
|
||||
[Information] Counter [0:0]:60
|
||||
[Information] Time [0:0]:6000000
|
||||
[Information] Counter [0:0]:61
|
||||
[Information] Time [0:0]:6100000
|
||||
[Information] Counter [0:0]:62
|
||||
[Information] Time [0:0]:6200000
|
||||
[Information] Counter [0:0]:63
|
||||
[Information] Time [0:0]:6300000
|
||||
[Information] Counter [0:0]:64
|
||||
[Information] Time [0:0]:6400000
|
||||
[Information] Counter [0:0]:65
|
||||
[Information] Time [0:0]:6500000
|
||||
[Information] Counter [0:0]:66
|
||||
[Information] Time [0:0]:6600000
|
||||
[Information] Counter [0:0]:67
|
||||
[Information] Time [0:0]:6700000
|
||||
[Information] Counter [0:0]:68
|
||||
[Information] Time [0:0]:6800000
|
||||
[Information] Counter [0:0]:69
|
||||
[Information] Time [0:0]:6900000
|
||||
[Information] Counter [0:0]:70
|
||||
[Information] Time [0:0]:7000000
|
||||
[Information] Counter [0:0]:71
|
||||
[Information] Time [0:0]:7100000
|
||||
[Information] Counter [0:0]:72
|
||||
[Information] Time [0:0]:7200000
|
||||
[Information] Counter [0:0]:73
|
||||
[Information] Time [0:0]:7300000
|
||||
[Information] Counter [0:0]:74
|
||||
[Information] Time [0:0]:7400000
|
||||
[Information] Counter [0:0]:75
|
||||
[Information] Time [0:0]:7500000
|
||||
[Information] Counter [0:0]:76
|
||||
[Information] Time [0:0]:7600000
|
||||
[Information] Counter [0:0]:77
|
||||
[Information] Time [0:0]:7700000
|
||||
[Information] Counter [0:0]:78
|
||||
[Information] Time [0:0]:7800000
|
||||
[Information] Counter [0:0]:79
|
||||
[Information] Time [0:0]:7900000
|
||||
[Information] Counter [0:0]:80
|
||||
[Information] Time [0:0]:8000000
|
||||
[Information] Counter [0:0]:81
|
||||
[Information] Time [0:0]:8100000
|
||||
[Information] Counter [0:0]:82
|
||||
[Information] Time [0:0]:8200000
|
||||
[Information] Counter [0:0]:83
|
||||
[Information] Time [0:0]:8300000
|
||||
[Information] Counter [0:0]:84
|
||||
[Information] Time [0:0]:8400000
|
||||
[Information] Counter [0:0]:85
|
||||
[Information] Time [0:0]:8500000
|
||||
[Information] Counter [0:0]:86
|
||||
[Information] Time [0:0]:8600000
|
||||
[Information] Counter [0:0]:87
|
||||
[Information] Time [0:0]:8700000
|
||||
[Information] Counter [0:0]:88
|
||||
[Information] Time [0:0]:8800000
|
||||
[Information] Counter [0:0]:89
|
||||
[Information] Time [0:0]:8900000
|
||||
[Information] Counter [0:0]:90
|
||||
[Information] Time [0:0]:9000000
|
||||
[Information] Counter [0:0]:91
|
||||
[Information] Time [0:0]:9100000
|
||||
[Information] Counter [0:0]:92
|
||||
[Information] Time [0:0]:9200000
|
||||
[Information] Counter [0:0]:93
|
||||
[Information] Time [0:0]:9300000
|
||||
[Information] Counter [0:0]:94
|
||||
[Information] Time [0:0]:9400000
|
||||
[Information] Counter [0:0]:95
|
||||
[Information] Time [0:0]:9500000
|
||||
[Information] Counter [0:0]:96
|
||||
[Information] Time [0:0]:9600000
|
||||
[Information] Counter [0:0]:97
|
||||
[Information] Time [0:0]:9700000
|
||||
[Information] Counter [0:0]:98
|
||||
[Information] Time [0:0]:9800000
|
||||
[Information] Counter [0:0]:99
|
||||
[Information] Time [0:0]:9900000
|
||||
[Information] Counter [0:0]:100
|
||||
[Information] Time [0:0]:10000000
|
||||
[Information] Counter [0:0]:101
|
||||
[Information] Time [0:0]:10100000
|
||||
[Information] Counter [0:0]:102
|
||||
[Information] Time [0:0]:10200000
|
||||
[Information] Counter [0:0]:103
|
||||
[Information] Time [0:0]:10300000
|
||||
[Information] Counter [0:0]:104
|
||||
[Information] Time [0:0]:10400000
|
||||
[Information] Counter [0:0]:105
|
||||
[Information] Time [0:0]:10500000
|
||||
[Information] Counter [0:0]:106
|
||||
[Information] Time [0:0]:10600000
|
||||
[Information] Counter [0:0]:107
|
||||
[Information] Time [0:0]:10700000
|
||||
[Information] Counter [0:0]:108
|
||||
[Information] Time [0:0]:10800000
|
||||
[Information] Counter [0:0]:109
|
||||
[Information] Time [0:0]:10900000
|
||||
[Information] Counter [0:0]:110
|
||||
[Information] Time [0:0]:11000000
|
||||
[Information] Time [0:0]:12000000
|
||||
[Information] Time [0:0]:13000000
|
||||
[Information] Time [0:0]:14000000
|
||||
[Information] Time [0:0]:15000000
|
||||
[Information] Time [0:0]:16000000
|
||||
[Information] Time [0:0]:17000000
|
||||
[Information] Time [0:0]:18000000
|
||||
[Information] Time [0:0]:19000000
|
||||
[Information] Time [0:0]:20000000
|
||||
[Information] Time [0:0]:21000000
|
||||
[Information] Time [0:0]:22000000
|
||||
[Information] Time [0:0]:23000000
|
||||
[Information] Time [0:0]:24000000
|
||||
[Information] Time [0:0]:25000000
|
||||
[Information] Time [0:0]:26000000
|
||||
[Information] Time [0:0]:27000000
|
||||
[Information] Time [0:0]:28000000
|
||||
./run_debug_app.sh: line 40: 325075 Killed "$MARTE_EX" -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
|
||||
|
||||
30
run_coverage.sh
Executable file
30
run_coverage.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Load environment
|
||||
. ./env.sh
|
||||
|
||||
# Clean build directory
|
||||
rm -rf Build_Coverage
|
||||
|
||||
# Build with coverage
|
||||
mkdir -p Build_Coverage
|
||||
cd Build_Coverage
|
||||
cmake .. -DENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug
|
||||
make -j$(nproc)
|
||||
|
||||
# Reset coverage data
|
||||
lcov --directory . --zerocounters
|
||||
|
||||
# Run unit tests
|
||||
./Test/UnitTests/UnitTests
|
||||
|
||||
# Capture coverage data
|
||||
lcov --directory . --capture --output-file coverage.info --ignore-errors inconsistent
|
||||
|
||||
# Filter out system and MARTe2 internal headers
|
||||
lcov --remove coverage.info '/usr/*' '*/dependency/*' '*/Test/*' --output-file coverage_filtered.info --ignore-errors inconsistent
|
||||
|
||||
# Generate report
|
||||
genhtml coverage_filtered.info --output-directory out --ignore-errors inconsistent
|
||||
|
||||
# Display summary
|
||||
lcov --list coverage_filtered.info --ignore-errors inconsistent
|
||||
@@ -26,7 +26,7 @@ for dir in $ALL_COMPONENT_DIRS; do
|
||||
done
|
||||
|
||||
# Ensure our build dir and core dir are included
|
||||
export LD_LIBRARY_PATH="$(pwd)/Build:${MARTe2_DIR}/Build/${TARGET}/Core:${LD_LIBRARY_PATH}"
|
||||
export LD_LIBRARY_PATH="$(pwd)/Build:${LD_LIBRARY_PATH}"
|
||||
|
||||
# 3. Cleanup
|
||||
echo "Cleaning up lingering processes..."
|
||||
@@ -36,5 +36,5 @@ sleep 1
|
||||
# 4. Launch Application
|
||||
echo "Launching standard MARTeApp.ex with debug_test.cfg..."
|
||||
# PRELOAD ensures our DebugService class is available to the registry early
|
||||
export LD_PRELOAD="${DEBUG_LIB}"
|
||||
export LD_PRELOAD="$(pwd)/Build/libmarte_dev.so"
|
||||
"$MARTE_EX" -f Test/Configurations/debug_test.cfg -l RealTimeLoader -s State1
|
||||
|
||||
Reference in New Issue
Block a user